Populate new flow_classification and flow_classification_rule tables with existing data
#CTCTOWALTZ-2286
</column>
<column name="code"
type="${external-id.type}">
- <constraints nullable="true"/>
+ <constraints nullable="false"/>
</column>
<column name="color"
type="${name.type}">
- <constraints nullable="true"/>
+ <constraints nullable="false"/>
</column>
<column name="position"
type="${int.type}"
</createTable>
</changeSet>
+ <changeSet id="20210726-5554-3"
+ author="woodjes">
+ <comment>5554: Create fk from flow_classification_rule to flow_classification</comment>
+ <addForeignKeyConstraint baseColumnNames="flow_classification_id"
+ baseTableName="flow_classification_rule"
+ constraintName="flow_classification_rule_classification_id_fkey"
+ onDelete="CASCADE"
+ referencedColumnNames="id"
+ referencedTableName="flow_classification"/>
+ </changeSet>
+
+ <changeSet id="20210727-5554-4"
+ author="woodjes">
+ <comment>5554: Insert authority ratings from enum_value into flow_classification</comment>
+ <sql>
+ INSERT INTO flow_classification (name, description, code, color, position, is_custom)
+ SELECT display_name, description, [key], icon_color, position, 0
+ FROM enum_value
+ WHERE type = 'AuthoritativenessRating'
+ </sql>
+ </changeSet>
+
+ <changeSet id="20210727-5554-5"
+ author="woodjes">
+ <comment>5554: Copy authoritative_source info into flow_classification_rule</comment>
+ <sql>
+ INSERT INTO flow_classification_rule ( parent_kind,
+ parent_id,
+ application_id,
+ data_type_id,
+ flow_classification_id,
+ description,
+ external_id,
+ last_updated_at,
+ last_updated_by,
+ provenance)
+ SELECT auth.parent_kind,
+ auth.parent_id,
+ auth.application_id,
+ dt.id,
+ fc.id,
+ auth.description,
+ auth.external_id,
+ auth.last_updated_at,
+ auth.last_updated_by,
+ provenance
+ FROM authoritative_source auth
+ INNER JOIN data_type dt on auth.data_type = dt.code
+ INNER JOIN flow_classification fc on auth.rating = fc.code
+ </sql>
+ </changeSet>
+
<!-- <changeSet id="20210722-5545-2"-->
<!-- author="woodjes">-->
<!-- <update tableName="settings">-->
