tabletop-companion/db/migrate/20240629080930_create_templ...

19 lines
616 B
Ruby

# frozen_string_literal: true
class CreateTemplates < ActiveRecord::Migration[7.1]
def change
create_table :templates do |t|
t.belongs_to :game_system, null: false, foreign_key: true
t.string :name, null: false
t.jsonb :content, null: false, default: {}
t.string :klass, null: false
t.timestamps
end
add_check_constraint :templates, "length(name) <= 200", name: "chk_template_name_max_length"
add_check_constraint :templates, "length(klass) <= 200", name: "chk_template_klass_max_length"
add_index :templates, [ :name, :game_system_id ], unique: true
end
end