-
Notifications
You must be signed in to change notification settings - Fork 42
Migrations DSL
Evan Prothro edited this page Nov 19, 2015
·
12 revisions
The create_table method allow do pass a hash of options for:
- Clustering Order (clustering_order): A string such as 'a_decimal DESC'
- Compact Storage (compact_storage): Boolean, true or false
- Wait before GC (gc_grace_seconds): Default: 864000 [10 days]
- Others: See CQL Table Properties
Cassandra Migration will attempt to pass through the properties to the CREATE TABLE command.
Examples:
class WithClusteringOrderMigration < CassandraMigrations::Migration
def up
create_table :collection_lists, options: {
clustering_order: 'a_decimal DESC',
compact_storage: true,
gc_grace_seconds: 43200
} do |t|
t.uuid :id, :primary_key => true
t.decimal :a_decimal
end
end
end
The using_keyspace method in a migration allows to execute that migration in the context of a specific keyspace:
class WithAlternateKeyspaceMigration < CassandraMigrations::Migration
def up
using_keyspace('alternative') do
create_table :collection_lists, options: {compact_storage: true} do |t|
t.uuid :id, :primary_key => true
t.decimal :a_decimal
end
end
end
end
If using multiple keyspaces, read about Using Multiple Keyspaces.