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

22 lines
680 B
Ruby
Raw Normal View History

2024-06-07 14:38:10 +00:00
# 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
2024-06-07 15:53:32 +00:00
t.integer :value, null: false, default: 0
2024-06-07 14:38:10 +00:00
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