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.
2019-09-30 22:20:45 +00:00
|
|
|
# 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
|
|
|
|
|
2019-09-30 22:32:04 +00:00
|
|
|
t.string :short_name, null: false, index: { unique: true }
|
|
|
|
t.string :name, null: false, index: { unique: true }
|
2019-09-30 22:20:45 +00:00
|
|
|
|
|
|
|
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
|
|
|
|
|
2019-09-30 22:32:04 +00:00
|
|
|
add_constraint :org_units, :short_name, <<~SQL
|
|
|
|
is_good_small_text(short_name)
|
|
|
|
SQL
|
|
|
|
|
2019-09-30 22:20:45 +00:00
|
|
|
add_constraint :org_units, :name, <<~SQL
|
|
|
|
is_good_small_text(name)
|
|
|
|
SQL
|
|
|
|
end
|
|
|
|
end
|