So I created a table named tv_campaigns in liquibase as follows.
<changeSet id=" add tv campaigns table" author="abc">
        <createTable tableName="tv_campaigns">
            <column name="campaign_id" type="int" autoIncrement="false">
                <constraints primaryKey="true"
                             foreignKeyName="fk_linear_tv_campaign_id"
                             references="campaigns(id)"
                             nullable="false"/>
            </column>
        </createTable>
    </changeSet>
Here the primary and foreign key is the same (campaign_id) and the table just have one column. Later I realized I need an auto-increment column in this table and proceeded to add this changeset:
<changeSet id="add auto increment column" author="abc">
        <addColumn tableName="tv_campaigns">
            <column name="id" type="int" autoIncrement="true">
                <constraints unique="true"
                             nullable="false"/>
            </column>
        </addColumn>
    </changeSet>
On running this changeset I get the following error: "Cannot add a non-primary key identity column". Tried adding 'id' as a primary key by dropping the older primary key (campaign_id) and that too throws an error about foreign key relation not properly defined (as the original primary key also references  another table's key).
Is there a way to do it nicely or to do it?
 
     
    