1
0
Fork 0
This repository has been archived on 2023-03-28. You can view files and clone it, but cannot push or open issues or pull requests.
lpr-partynest/db/migrate/20190930215223_create_org_u...

33 lines
827 B
Ruby

# frozen_string_literal: true
class CreateOrgUnits < ActiveRecord::Migration[6.0]
include Partynest::Migration
def change
create_table :org_units do |t|
t.timestamps null: false
t.string :short_name, null: false, index: { unique: true }
t.string :name, null: false, index: { unique: true }
t.references :kind,
null: false,
index: true,
foreign_key: { to_table: :org_unit_kinds }
t.references :parent,
null: true,
index: true,
foreign_key: { to_table: :org_units }
end
add_constraint :org_units, :short_name, <<~SQL
is_good_small_text(short_name)
SQL
add_constraint :org_units, :name, <<~SQL
is_good_small_text(name)
SQL
end
end