tabletop-companion/db/migrate/20240607091417_create_stats.rb

22 lines
680 B
Ruby

# frozen_string_literal: true
class CreateStats < ActiveRecord::Migration[7.1]
def change
create_table :stats do |t|
t.string :name, null: false
t.string :slug, null: false
t.belongs_to :character_sheet_section, null: false, foreign_key: true
t.integer :value, null: false, default: 0
t.string :roll_command
t.timestamps
end
add_check_constraint :stats, "length(name) <= 100", name: "chk_stat_name_max_length"
add_check_constraint :stats, "length(slug) <= 100", name: "chk_stat_slug_max_length"
add_index :stats, :slug, unique: true
add_index :stats, [ :name, :character_sheet_section_id ], unique: true
end
end