patka / cassandra-migration

Schema migration library for Cassandra
MIT License
152 stars 47 forks source link

CREATE TABLE IF NOT EXISTS not working #79

Closed SaoYan closed 1 year ago

SaoYan commented 1 year ago

Hi there, I.m using the spring starter and have 2 scripts. The first one is to create a table and the second one is alter it.

00002_createTable.cql (we already have a 00001 version script which is altering another table)

CREATE TABLE IF NOT EXISTS table_name
(
    field1       text,
    field2      text,

    PRIMARY KEY ((field1), field2)
);

00003_addExpireTimestamp.cql

alter table "table_name" add expire_timestamp timestamp;

When running the service, I got error saying

Caused by: org.cognitor.cassandra.migration.MigrationException: Error during migration of script 00003_addExpireTimestamp.cql while executing 'alter table cass_content_of_interests add expire_timestamp timestamp;'

... ...

Caused by: com.datastax.oss.driver.api.core.servererrors.InvalidQueryException: Table 'namespace.table_name' doesn't exist

Looks like the create table scrip is not executed somehow. Am I missing something here?

patka commented 1 year ago

Hello, there should be a table in your namespace that is called "schema_migration". That should provide you some hints if script 2 was successfully executed. If that is not mentioned there, then it seems that this script would be run against a different namespace. In that case it would be helpful if you could provide the code you use to run the application. Cheers

SaoYan commented 1 year ago

oh nvm it's our fault, we are reusing some version number due to some incorrectly handled merge conflict lol

sorry for this..