Skip to content
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

Open
pura1029 opened this issue Mar 29, 2019 · 2 comments
Open

Avoid Cassandra db exception during migration #35

pura1029 opened this issue Mar 29, 2019 · 2 comments

Comments

@pura1029
Copy link

pura1029 commented Mar 29, 2019

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?

@patka
Copy link
Owner

patka commented Mar 29, 2019 via email

@kumargautam-vmware
Copy link

kumargautam-vmware commented May 13, 2019

refer : #25

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants