cartodb-4.42/db/migrate/20161125174333_create_snapshots.rb

34 lines
876 B
Ruby
Raw Normal View History

2024-04-06 13:25:13 +08:00
require 'carto/db/migration_helper'
include Carto::Db::MigrationHelper
migration(
Proc.new do
create_table :snapshots 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 :state, 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 :snapshots do
add_index [:visualization_id, :user_id]
end
end,
Proc.new do
drop_table :snapshots
end
)