18 lines
565 B
Ruby
18 lines
565 B
Ruby
|
# frozen_string_literal: true
|
||
|
|
||
|
class CreateTables < ActiveRecord::Migration[7.1]
|
||
|
def change
|
||
|
create_table :tables do |t|
|
||
|
t.string :name, null: false
|
||
|
t.string :slug, index: { unique: true }, null: false
|
||
|
t.references :owner, foreign_key: { to_table: :users }
|
||
|
t.belongs_to :game_system, null: false, foreign_key: true
|
||
|
|
||
|
t.timestamps
|
||
|
end
|
||
|
|
||
|
add_check_constraint :tables, "length(name) <= 100", name: "chk_table_name_max_length"
|
||
|
add_check_constraint :tables, "length(slug) <= 100", name: "chk_table_slug_max_length"
|
||
|
end
|
||
|
end
|