Sha256: 8b172249d6d20abb4be113ff72ccb45729ec523f19ffbe37cff055fdd650cb4b

Contents?: true

Size: 1.41 KB

Versions: 1

Compression:

Stored size: 1.41 KB

Contents

# frozen_string_literals: true

require "jobshop/helpers/migration.rb"

# TODO: Inherit employees/contacts from common people table
# TODO: This table only exists because roles still link to it. remove this once
# TODO: roles are migrated to their respective parent.
class CreatePeople < ActiveRecord::Migration[5.2]
  include Jobshop::Helpers::Migration

  def change # rubocop:disable Metrics/MethodLength
    create_table_with_auditing :jobshop_people, primary_key: %i[
      organization_id person_id
    ] do |t|
      t.citext :email, null: false
      t.string :forename
      t.string :surname
      t.timestamps
    end

    add_index :jobshop_people, %i[ organization_id email ], unique: true
    fk_organization :jobshop_people

    create_table :jobshop_users, id: false do |t|
      t.uuid :organization_id, null: false
      t.uuid :user_id, null: false, default: "gen_random_uuid()"
      t.index %i[ organization_id user_id ], unique: true,
        name: :idx_jobshop_users_pkey

      # Database authenticatable
      t.citext :email, null: false, default: ""
      t.string :encrypted_password, null: false, default: ""
      t.index %i[ organization_id email ], unique: true

      t.string :email_authentication_token, index: { unique: true }
      t.datetime :email_authentication_token_sent_at, :datetime
      t.timestamps
    end

    idx_table_name_pkey :jobshop_users
    fk_organization :jobshop_users
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
jobshop-0.0.167 db/migrate/20171216021554_create_people.rb