Sha256: a86f51b883ae7c63d85956c4e29fdbbef6c9fd1962308568f97498afc6ecab0f

Contents?: true

Size: 1.67 KB

Versions: 1

Compression:

Stored size: 1.67 KB

Contents

require "jobshop/helpers/migration.rb"

class CreateRoles < ActiveRecord::Migration[5.1]
  include Jobshop::Helpers::Migration

  def change
    create_table :jobshop_roles, id: false do |t|
      t.uuid :organization_id, null: false
      t.uuid :role_id, null: false, default: "gen_random_uuid()"
      t.index [ :organization_id, :role_id ], unique: true,
        name: :idx_jobshop_roles_pkey

      t.citext :name
      t.index [ :organization_id, :name ], unique: true

      t.timestamps
    end

    idx_table_name_pkey "jobshop_roles"
    fk_organization_id "jobshop_roles"

    create_table :jobshop_role_assignments, id: false do |t|
      t.uuid :organization_id, null: false
      t.uuid :user_id, null: false
      t.uuid :role_id, null: false

      t.index [ :organization_id, :user_id, :role_id ], unique: true,
        name: :jobshop_role_assignment_user_roles_ckey
      t.index [ :organization_id, :role_id, :user_id ], unique: true,
        name: :jobshop_role_assignment_role_users_ckey

      t.timestamps
    end

    fk_organization_id "jobshop_role_assignments"
    foreign_key "jobshop_role_assignments", "jobshop_roles",
      [ "organization_id", "role_id" ]
    foreign_key "jobshop_role_assignments", "jobshop_users",
      [ "organization_id", "user_id" ]

    create_table :jobshop_abilities, id: :uuid, default: "gen_random_uuid()" do |t|
      t.uuid :organization_id, null: false
      t.uuid :resource_id
      t.string :resource_class, null: false
      t.integer :action
      t.index [ :organization_id, :resource_class, :action, :resource_id ],
        unique: true, name: :idx_jobshop_abilities_secondary_key
    end

    fk_organization_id "jobshop_abilities"
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
jobshop-0.0.157 db/migrate/20171216023018_create_roles.rb