Failed to open the referenced table 'sizes' [Failed SQL: (1824)]

Рейтинг: 0Ответов: 0Опубликовано: 26.06.2023

Подскажите, пожалуйста, в чем причина ошибки? Механизмы таблиц идентичны.

<changeSet id="create_table_product" author="store_author">
        <preConditions onFail="MARK_RAN">
            <not>
                <tableExists tableName="product"/>
            </not>
        </preConditions>
        <createTable tableName="product">
            <column autoIncrement="true" name="id" type="bigint">
                <constraints primaryKey="true" nullable="false"/>
            </column>
            <column name="name" type="text">
                <constraints nullable="false"/>
            </column>
            <column name="price" type="integer">
                <constraints nullable="false"/>
            </column>
            ...
             </createTable>
             <addForeignKeyConstraint baseColumnNames="id"
                baseTableName="product"
                constraintName="fk_product_id"
                referencedColumnNames="size_id"
                referencedTableName="sizes"/>
</changeSet>

<changeSet id="create_sizes_product" author="store_author">
        <preConditions onFail="MARK_RAN">
            <not>
                <tableExists tableName="sizes"/>
            </not>
        </preConditions>
        <createTable tableName="sizes">
            <column autoIncrement="true" name="size_id" type="bigint">
                <constraints primaryKey="true" nullable="false"/>
            </column>
            <column name="size" type="varchar(30)">
                <constraints nullable="false"/>
            </column>
        </createTable>
</changeSet>
Failed to open the referenced table 'sizes' [Failed SQL: (1824)
ALTER TABLE to_cart.product ADD CONSTRAINT fk_product_id FOREIGN KEY (id) REFERENCES to_cart.sizes (size_id)]

Ответы

Ответов пока нет.