rename habit_users_assigns table to habit_assign and change it structure (move column status(renamed to acquired) and create_date from habits table + new id primary column) + changed habit_id to habit_assign_id in habit_status table and removed redundant columns
<dropTable tableName="habit_dictionary"/>
</changeSet>
+ <changeSet id="6" author="Kravchenko">
+ <dropColumn tableName="habits" columnName="status"/>
+ <dropColumn tableName="habits" columnName="create_date"/>
+
+ <addColumn tableName="habits_users_assign">
+ <column name="status" type="boolean" defaultValueBoolean="true">
+ <constraints nullable="false"/>
+ </column>
+
+ <column name="create_date" type="timestamp with time zone" defaultValueComputed="CURRENT_TIMESTAMP">
+ <constraints nullable="false"/>
+ </column>
+ </addColumn>
+ </changeSet>
+
+ <changeSet id="7" author="Kravchenko">
+ <addColumn tableName="habits_users_assign">
+ <column name="id" type="bigint" autoIncrement="true">
+ <constraints primaryKey="true" nullable="false"/>
+ </column>
+ </addColumn>
+ </changeSet>
+
+ <changeSet id="8" author="Kravchenko">
+ <renameColumn tableName="habits_users_assign" oldColumnName="users_id" newColumnName="user_id"/>
+ </changeSet>
+
+ <changeSet id="9" author="Kravchenko">
+ <addForeignKeyConstraint baseColumnNames="user_id" baseTableName="habits_users_assign"
+ constraintName="fk_user_id" deferrable="false" initiallyDeferred="false"
+ onDelete="RESTRICT" onUpdate="RESTRICT" referencedColumnNames="id"
+ referencedTableName="users"/>
+ </changeSet>
+
+ <changeSet id="10" author="Kravchenko">
+ <dropForeignKeyConstraint baseTableName="habits_users_assign" constraintName="fk_users_id"/>
+ </changeSet>
+
+ <changeSet id="11" author="Kravchenko">
+ <renameTable oldTableName="habits_users_assign" newTableName="habits_users_acquired"/>
+ </changeSet>
+
+ <changeSet id="12" author="Kravchenko">
+ <renameTable oldTableName="habits_users_acquired" newTableName="habit_assign"/>
+ </changeSet>
+
+ <changeSet id="13" author="Kravchenko">
+ <renameColumn tableName="habit_assign" oldColumnName="status" newColumnName="acquired"/>
+
+ <dropForeignKeyConstraint baseTableName="habit_status" constraintName="fk_habit_id"/>
+ <dropForeignKeyConstraint baseTableName="habit_status" constraintName="fk_user_id"/>
+
+ <dropColumn tableName="habit_status" columnName="user_id"/>
+ <dropColumn tableName="habit_status" columnName="create_date"/>
+
+ <renameColumn tableName="habit_status" oldColumnName="habit_id"
+ newColumnName="habit_assign_id"/>
+
+ <addForeignKeyConstraint baseColumnNames="habit_assign_id" baseTableName="habit_status"
+ constraintName="fk_habit_assign_id" deferrable="false" initiallyDeferred="false"
+ onDelete="RESTRICT" onUpdate="RESTRICT" referencedColumnNames="id"
+ referencedTableName="habit_assign"/>
+ </changeSet>
</databaseChangeLog>
\ No newline at end of file
