1

Using the following changeset in liquibase to create a table with a foreign key is possible and works.

<changeSet author="cibn" context="initialSchema" id="initialSchema-edited-1.0.4">
    <createTable tableName="prices">
        <column name="articleId" type="String">
            <constraints nullable="false" foreignKeyName="fk_articles_articleId" references="articles(articleId)"/>
        </column>
...
</changeSet>

However, the addForeignKeyConstraint change after creation of the initial schema is not supported.

https://www.liquibase.org/documentation/changes/add_foreign_key_constraint.html

Why? and could this be changed?

user637338
  • 2,565
  • 1
  • 25
  • 26

1 Answers1

0

I believe that's because ADD CONSTRAINT is not supported by SQLite for ALTER TABLE feature, and that's exactly what Liquibase does during addForeignKeyConstraint change.

Here's the documentation SQL Features That SQLite Does Not Implement

Only the RENAME TABLE, ADD COLUMN, and RENAME COLUMN variants of the ALTER TABLE command are supported. Other kinds of ALTER TABLE operations such as DROP COLUMN, ALTER COLUMN, ADD CONSTRAINT, and so forth are omitted.

htshame
  • 6,599
  • 5
  • 36
  • 56