mirror of
https://github.com/ebean-orm/ebean.git
synced 2026-11-14 06:45:21 +00:00
121 lines
11 KiB
XML
121 lines
11 KiB
XML
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
|
|
<migration xmlns="http://ebean-orm.github.io/xml/ns/dbmigration">
|
|
<changeSet type="apply">
|
|
<addColumn tableName="migtest_ckey_detail">
|
|
<column name="one_key" type="integer"/>
|
|
<column name="two_key" type="varchar(127)"/>
|
|
</addColumn>
|
|
<alterForeignKey name="fk_migtest_ckey_detail_parent" columnNames="one_key,two_key" refColumnNames="one_key,two_key" refTableName="migtest_ckey_parent" indexName="ix_migtest_ckey_detail_parent" tableName="migtest_ckey_detail"/>
|
|
<addColumn tableName="migtest_ckey_parent">
|
|
<column name="assoc_id" type="integer" references="migtest_ckey_assoc.id" foreignKeyName="fk_migtest_ckey_parent_assoc_id" foreignKeyIndex="ix_migtest_ckey_parent_assoc_id"/>
|
|
</addColumn>
|
|
<alterColumn columnName="one_id" tableName="migtest_fk_cascade" references="migtest_fk_cascade_one.id" foreignKeyName="fk_migtest_fk_cascade_one_id" foreignKeyIndex="ix_migtest_fk_cascade_one_id" foreignKeyOnDelete="RESTRICT" foreignKeyOnUpdate="RESTRICT" dropForeignKey="fk_migtest_fk_cascade_one_id" dropForeignKeyIndex="ix_migtest_fk_cascade_one_id"/>
|
|
<alterColumn columnName="one_id" tableName="migtest_fk_none" references="migtest_fk_one.id" foreignKeyName="fk_migtest_fk_none_one_id" foreignKeyIndex="ix_migtest_fk_none_one_id" foreignKeyOnDelete="RESTRICT" foreignKeyOnUpdate="RESTRICT"/>
|
|
<alterColumn columnName="one_id" tableName="migtest_fk_none_via_join" references="migtest_fk_one.id" foreignKeyName="fk_migtest_fk_none_via_join_one_id" foreignKeyIndex="ix_migtest_fk_none_via_join_one_id"/>
|
|
<alterColumn columnName="one_id" tableName="migtest_fk_set_null" references="migtest_fk_one.id" foreignKeyName="fk_migtest_fk_set_null_one_id" foreignKeyIndex="ix_migtest_fk_set_null_one_id" foreignKeyOnDelete="RESTRICT" foreignKeyOnUpdate="RESTRICT" dropForeignKey="fk_migtest_fk_set_null_one_id" dropForeignKeyIndex="ix_migtest_fk_set_null_one_id"/>
|
|
<alterColumn columnName="status" tableName="migtest_e_basic" currentType="varchar(1)" defaultValue="'A'" notnull="true" currentNotnull="false" checkConstraint="check ( status in ('N','A','I','?'))" checkConstraintName="ck_migtest_e_basic_status"/>
|
|
<alterColumn columnName="status2" tableName="migtest_e_basic" type="varchar(127)" currentType="varchar(1)" defaultValue="DROP DEFAULT" notnull="false" currentNotnull="true" dropCheckConstraint="ck_migtest_e_basic_status2"/>
|
|
<alterColumn columnName="description" tableName="migtest_e_basic" unique="uq_migtest_e_basic_description">
|
|
<before platforms="db2">
|
|
<ddl>-- db2 does not support parial null indices :( - so we have to clean</ddl>
|
|
<ddl>update ${table} set status = 'N' where id = 1</ddl>
|
|
</before>
|
|
<before>
|
|
<ddl>-- rename all collisions</ddl>
|
|
</before>
|
|
</alterColumn>
|
|
<alterColumn columnName="user_id" tableName="migtest_e_basic" currentType="integer" notnull="false" currentNotnull="true" references="migtest_e_user.id" foreignKeyName="fk_migtest_e_basic_user_id" foreignKeyIndex="ix_migtest_e_basic_user_id">
|
|
<before>
|
|
<ddl>insert into migtest_e_user (id) select distinct user_id from migtest_e_basic</ddl>
|
|
</before>
|
|
</alterColumn>
|
|
<addColumn tableName="migtest_e_basic">
|
|
<column name="new_string_field" type="varchar" defaultValue="'foo''bar'" notnull="true"/>
|
|
<column name="new_boolean_field" type="boolean" defaultValue="true" notnull="true">
|
|
<after>
|
|
<ddl>update ${table} set ${column} = old_boolean</ddl>
|
|
</after>
|
|
</column>
|
|
<column name="new_boolean_field2" type="boolean" defaultValue="true" notnull="true"/>
|
|
<column name="progress" type="integer" defaultValue="0" notnull="true" checkConstraint="check ( progress in (0,1,2))" checkConstraintName="ck_migtest_e_basic_progress"/>
|
|
<column name="new_integer" type="integer" defaultValue="42" notnull="true"/>
|
|
</addColumn>
|
|
<addUniqueConstraint constraintName="uq_migtest_e_basic_indextest2" tableName="migtest_e_basic" columnNames="DROP CONSTRAINT" nullableColumns="indextest2"/>
|
|
<addUniqueConstraint constraintName="uq_migtest_e_basic_indextest6" tableName="migtest_e_basic" columnNames="DROP CONSTRAINT" nullableColumns="indextest6"/>
|
|
<addUniqueConstraint constraintName="uq_migtest_e_basic_status_indextest1" tableName="migtest_e_basic" columnNames="status,indextest1" oneToOne="false" nullableColumns="indextest1"/>
|
|
<addUniqueConstraint constraintName="uq_migtest_e_basic_name" tableName="migtest_e_basic" columnNames="name" oneToOne="false" nullableColumns="name"/>
|
|
<addUniqueConstraint constraintName="uq_migtest_e_basic_indextest4" tableName="migtest_e_basic" columnNames="indextest4" oneToOne="false" nullableColumns="indextest4"/>
|
|
<addUniqueConstraint constraintName="uq_migtest_e_basic_indextest5" tableName="migtest_e_basic" columnNames="indextest5" oneToOne="false" nullableColumns="indextest5"/>
|
|
<alterColumn columnName="test_status" tableName="migtest_e_enum" dropCheckConstraint="ck_migtest_e_enum_test_status"/>
|
|
<addHistoryTable baseTable="migtest_e_history"/>
|
|
<alterColumn columnName="test_string" tableName="migtest_e_history" type="bigint" currentType="varchar" currentNotnull="false" comment="Column altered to long now">
|
|
<before platforms="postgres">
|
|
<ddl>alter table ${table} alter column ${column} TYPE bigint USING (${column}::integer)</ddl>
|
|
</before>
|
|
</alterColumn>
|
|
<addTableComment name="migtest_e_history" comment="We have history now"/>
|
|
<alterColumn columnName="test_string" tableName="migtest_e_history2" withHistory="true" currentType="varchar" defaultValue="'unknown'" notnull="true" currentNotnull="false">
|
|
<before platforms="mariadb">
|
|
<ddl>SET @@system_versioning_alter_history = 1</ddl>
|
|
<ddl>update ${table} set ${column} = 'unknown' where ${column} is null</ddl>
|
|
</before>
|
|
<before>
|
|
<ddl>update ${table} set ${column} = 'unknown' where ${column} is null</ddl>
|
|
</before>
|
|
</alterColumn>
|
|
<addColumn tableName="migtest_e_history2" withHistory="true">
|
|
<column name="test_string2" type="varchar" historyExclude="true"/>
|
|
<column name="test_string3" type="varchar" defaultValue="'unknown'" notnull="true"/>
|
|
<column name="new_column" type="varchar(20)"/>
|
|
</addColumn>
|
|
<alterColumn columnName="test_string" tableName="migtest_e_history3" withHistory="true" historyExclude="true"/>
|
|
<alterColumn columnName="test_number" tableName="migtest_e_history4" withHistory="true" type="bigint" currentType="integer" currentNotnull="false"/>
|
|
<addColumn tableName="migtest_e_history5" withHistory="true">
|
|
<column name="test_boolean" type="boolean" defaultValue="false" notnull="true"/>
|
|
</addColumn>
|
|
<alterColumn columnName="test_number1" tableName="migtest_e_history6" withHistory="true" currentType="integer" defaultValue="42" notnull="true" currentNotnull="false"/>
|
|
<alterColumn columnName="test_number2" tableName="migtest_e_history6" withHistory="true" currentType="integer" notnull="false" currentNotnull="true"/>
|
|
<addColumn tableName="migtest_e_softdelete">
|
|
<column name="deleted" type="boolean" defaultValue="false" notnull="true"/>
|
|
</addColumn>
|
|
<createTable name="migtest_e_user" pkName="pk_migtest_e_user">
|
|
<column name="id" type="integer" primaryKey="true"/>
|
|
</createTable>
|
|
<createTable name="migtest_mtm_c_migtest_mtm_m" pkName="pk_migtest_mtm_c_migtest_mtm_m">
|
|
<column name="migtest_mtm_c_id" type="integer" notnull="true" primaryKey="true"/>
|
|
<column name="migtest_mtm_m_id" type="bigint" notnull="true" primaryKey="true"/>
|
|
<foreignKey name="fk_migtest_mtm_c_migtest_mtm_m_migtest_mtm_c" columnNames="migtest_mtm_c_id" refColumnNames="id" refTableName="migtest_mtm_c" indexName="ix_migtest_mtm_c_migtest_mtm_m_migtest_mtm_c"/>
|
|
<foreignKey name="fk_migtest_mtm_c_migtest_mtm_m_migtest_mtm_m" columnNames="migtest_mtm_m_id" refColumnNames="id" refTableName="migtest_mtm_m" indexName="ix_migtest_mtm_c_migtest_mtm_m_migtest_mtm_m"/>
|
|
</createTable>
|
|
<createTable name="migtest_mtm_m_migtest_mtm_c" pkName="pk_migtest_mtm_m_migtest_mtm_c">
|
|
<column name="migtest_mtm_m_id" type="bigint" notnull="true" primaryKey="true"/>
|
|
<column name="migtest_mtm_c_id" type="integer" notnull="true" primaryKey="true"/>
|
|
<foreignKey name="fk_migtest_mtm_m_migtest_mtm_c_migtest_mtm_m" columnNames="migtest_mtm_m_id" refColumnNames="id" refTableName="migtest_mtm_m" indexName="ix_migtest_mtm_m_migtest_mtm_c_migtest_mtm_m"/>
|
|
<foreignKey name="fk_migtest_mtm_m_migtest_mtm_c_migtest_mtm_c" columnNames="migtest_mtm_c_id" refColumnNames="id" refTableName="migtest_mtm_c" indexName="ix_migtest_mtm_m_migtest_mtm_c_migtest_mtm_c"/>
|
|
</createTable>
|
|
<createTable name="migtest_mtm_m_phone_numbers" pkName="pk_migtest_mtm_m_phone_numbers">
|
|
<column name="migtest_mtm_m_id" type="bigint" notnull="true" references="migtest_mtm_m.id" foreignKeyName="fk_migtest_mtm_m_phone_numbers_migtest_mtm_m_id" foreignKeyIndex="ix_migtest_mtm_m_phone_numbers_migtest_mtm_m_id"/>
|
|
<column name="value" type="varchar" notnull="true"/>
|
|
</createTable>
|
|
<addColumn tableName="migtest_oto_child">
|
|
<column name="master_id" type="bigint" uniqueOneToOne="uq_migtest_oto_child_master_id" references="migtest_oto_master.id" foreignKeyName="fk_migtest_oto_child_master_id"/>
|
|
</addColumn>
|
|
<createIndex indexName="ix_migtest_e_basic_indextest3" tableName="migtest_e_basic" columns="indextest3"/>
|
|
<createIndex indexName="ix_migtest_e_basic_indextest6" tableName="migtest_e_basic" columns="indextest6"/>
|
|
<createIndex indexName="ix_migtest_oto_child_name" tableName="migtest_oto_child" columns="name" platforms="POSTGRES"/>
|
|
<dropIndex indexName="ix_migtest_e_basic_indextest1" tableName="migtest_e_basic"/>
|
|
<dropIndex indexName="ix_migtest_e_basic_indextest5" tableName="migtest_e_basic"/>
|
|
<dropIndex indexName="idxd_migtest_0" tableName="migtest_oto_child" platforms="POSTGRES"/>
|
|
<dropIndex indexName="ix_migtest_oto_child_lowername_id" tableName="migtest_oto_child" concurrent="true" platforms="POSTGRES"/>
|
|
<dropIndex indexName="ix_migtest_oto_child_lowername" tableName="migtest_oto_child" platforms="POSTGRES"/>
|
|
</changeSet>
|
|
<changeSet type="pendingDrops">
|
|
<dropColumn columnName="description_file" tableName="migtest_e_basic"/>
|
|
<dropColumn columnName="old_boolean" tableName="migtest_e_basic"/>
|
|
<dropColumn columnName="old_boolean2" tableName="migtest_e_basic"/>
|
|
<dropColumn columnName="eref_id" tableName="migtest_e_basic"/>
|
|
<dropColumn columnName="obsolete_string1" tableName="migtest_e_history2" withHistory="true"/>
|
|
<dropColumn columnName="obsolete_string2" tableName="migtest_e_history2" withHistory="true"/>
|
|
<dropTable name="migtest_e_ref" sequenceCol="id"/>
|
|
</changeSet>
|
|
</migration> |