cartodb-4.29/db/migrate/20160808114841_create_states.rb
2020-06-15 10:58:47 +08:00

22 lines
649 B
Ruby

Sequel.migration do
up do
create_table :states do
Uuid :id, primary_key: true, default: Sequel.lit('uuid_generate_v4()')
DateTime :created_at, default: Sequel::CURRENT_TIMESTAMP
DateTime :updated_at, default: Sequel::CURRENT_TIMESTAMP
String :json, null: false, type: 'json', default: '{}'
foreign_key :user_id, :users, type: :uuid, null: false, on_delete: :cascade
foreign_key :visualization_id, :visualizations, type: :uuid, null: false, on_delete: :cascade
end
alter_table :states do
add_index [:visualization_id, :user_id]
end
end
down do
drop_table :states
end
end