-
Notifications
You must be signed in to change notification settings - Fork 48
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Avoid Cassandra db exception during migration #35
Comments
Hi,
I don’t have any experience with spring data Cassandra so keep that in mind when reading my answer 🙂
Personally I would not try to ignore this exception as it is the symptom of another problem. In my opinion you should not mix the frameworks used for schema creation but go for one of them exclusively. Otherwise you will always depend on your spring container doing things in the right order, meaning first spring data does it’s schema thing and then cassandra migration. The idea of cassandra migration is that you manage your whole schema lifecycle in it. So, if you go for this approach you should create your tables with it in the first place instead of relying on tables that are created by something else. Otherwise you end up with shared responsibilities which is almost never a good idea.
Given that spring data cassandra cannot update a schema without dropping it, according to what I have read, I would go for the approach to have create table statements in cassandra migration as well.
Hope this helps, otherwise I am there for questions.
Cheers
Patrick
… Am 29.03.2019 um 06:59 schrieb Gautam Kumar ***@***.***>:
How Avoid Cassandra db exception during migration?
for eg:
@table(value = "Student ")
@DaTa
public class Student {
private String id;
private String name;
}
in my application using spring-data-cassandra, so when i will start application, spring will create table during server start-up.
now i want to add age column in Student table
@table(value = "Student ")
@DaTa
public class Student {
private String id;
private String name;
private Integer age;
}
when i will start application, spring will not create table during server start-up. because student table is already exist.
so here i using cassandra migration and have written cql script file with ALTER TABLE student add age int;
so it is working fine for existing db.
if i'm using same cql script file for new fresh db then giving error like
Caused by: com.datastax.driver.core.exceptions.InvalidQueryException: Invalid column name tags because it conflicts with an existing column
Caused by: org.cognitor.cassandra.migration.MigrationException: Error during migration of script 7_test.cql while executing 'ALTER TABLE endpointspec add tags map<text,text>;'
at org.cognitor.cassandra.migration.Database.execute(Database.java:187) ~[cassandra-migration-2.2.0.jar:?]
at java.util.ArrayList.forEach(ArrayList.java:1257) ~[?:1.8.0_181]
at org.cognitor.cassandra.migration.MigrationTask.migrate(MigrationTask.java:52) ~[cassandra-migration-2.2.0.jar:?]
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0_181]
this error is coming because spring is already added the age column in student table because it is a fresh new db and student table doesn't exist.
so is there any way to skip this type of error?
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub, or mute the thread.
|
refer : #25 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
How Avoid Cassandra db exception during migration?
for eg:
@table(value = "Student ")
@DaTa
public class Student {
private String id;
private String name;
}
in my application using spring-data-cassandra, so when i will start application, spring will create table during server start-up.
now i want to add age column in Student table
@table(value = "Student ")
@DaTa
public class Student {
private String id;
private String name;
private Integer age;
}
when i will start application, spring will not create table during server start-up. because student table is already exist.
so here i using cassandra migration and have written cql script file with ALTER TABLE student add age int;
so it is working fine for existing db.
if i'm using same cql script file for new fresh db then giving error like
Caused by: com.datastax.driver.core.exceptions.InvalidQueryException: Invalid column name age because it conflicts with an existing column
Caused by: org.cognitor.cassandra.migration.MigrationException: Error during migration of script 1_test.cql while executing 'ALTER TABLE student add age int;'
at org.cognitor.cassandra.migration.Database.execute(Database.java:187) ~[cassandra-migration-2.2.0.jar:?]
at java.util.ArrayList.forEach(ArrayList.java:1257) ~[?:1.8.0_181]
at org.cognitor.cassandra.migration.MigrationTask.migrate(MigrationTask.java:52) ~[cassandra-migration-2.2.0.jar:?]
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0_181]
this error is coming because spring is already added the age column in student table because it is a fresh new db and student table doesn't exist.
so is there any way to skip this type of errors?
The text was updated successfully, but these errors were encountered: