forked from smartcat-labs/cassandra-migration-tool-java
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathAddBookGenreFieldMigration.java
More file actions
34 lines (25 loc) · 968 Bytes
/
Copy pathAddBookGenreFieldMigration.java
File metadata and controls
34 lines (25 loc) · 968 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
package io.smartcat.migration.migrations.schema;
import com.datastax.driver.core.SimpleStatement;
import io.smartcat.migration.exceptions.MigrationException;
import io.smartcat.migration.SchemaMigration;
/**
* Example of schema migration which adds new column to existing table.
*/
public class AddBookGenreFieldMigration extends SchemaMigration {
public AddBookGenreFieldMigration(final int version) {
super(version);
}
@Override
public String getDescription() {
return "Alters books tables by adding genre column";
}
@Override
public void execute() throws MigrationException {
try {
final String alterBooksAddGenreCQL = "ALTER TABLE books ADD genre text;";
executeWithSchemaAgreement(new SimpleStatement(alterBooksAddGenreCQL));
} catch (final Exception e) {
throw new MigrationException("Failed to execute AddBookGenreField migration", e);
}
}
}