Files
ubicloud/migrate/20230517_authorization.rb
Enes Cakir 02c8a89c29 Switch TimestampMigrator from IntegerMigrator
IntegerMigrator doesn't allow duplicate migrations (1_foo, 1_bar).
Requires manual renaming for simultaneous migrations.

Here's comparison in detail:
https://sequel.jeremyevans.net/rdoc/files/doc/migration_rdoc.html#label-Two+separate+migrators

The TimestampMigrator will be used if any filename in the migrations
directory has a version greater than 20000101.

IntegerMigrator keeps version information at scheme_info table with an
integer. But TimestampMigrator keeps version information at
scheme_migrations tables with all filenames.

It's not backward compatible. You need to reset your database or create
and fill scheme_migrations table manually, then drop scheme_info table.
2023-07-05 11:15:03 -07:00

40 lines
1.3 KiB
Ruby

# frozen_string_literal: true
Sequel.migration do
change do
create_table :project do
column :id, :uuid, primary_key: true, default: Sequel.lit("gen_random_uuid()")
column :name, :text, collate: '"C"', null: false, unique: true
end
create_table :access_tag do
column :id, :uuid, primary_key: true, default: Sequel.lit("gen_random_uuid()")
foreign_key :project_id, :project, type: :uuid, null: false
column :hyper_tag_id, :uuid, null: true
column :hyper_tag_table, :text, collate: '"C"', null: false
column :name, :text, collate: '"C"', null: false
index [:project_id, :hyper_tag_id], unique: true
index [:project_id, :name], unique: true
end
create_table :applied_tag do
foreign_key :access_tag_id, :access_tag, type: :uuid, null: false
column :tagged_id, :uuid, null: false
column :tagged_table, :text, collate: '"C"', null: false
index [:access_tag_id, :tagged_id], unique: true
index :tagged_id
end
create_table :access_policy do
column :id, :uuid, primary_key: true, default: Sequel.lit("gen_random_uuid()")
foreign_key :project_id, :project, type: :uuid, null: false
column :name, :text, collate: '"C"', null: false
column :body, :jsonb, null: false
index [:project_id, :name], unique: true
end
end
end