Sha256: fce3f443572e6596618294288229262f76385ec7a82f6a6f6f60661194b4ee98

Contents?: true

Size: 1.33 KB

Versions: 1

Compression:

Stored size: 1.33 KB

Contents

# frozen_string_literals: true

require "jobshop/helpers/migration.rb"

class CreateThings < ActiveRecord::Migration[5.2]
  include Jobshop::Helpers::Migration

  def change
    create_table :jobshop_things, id: false do |t|
      t.uuid :organization_id, null: false
      t.uuid :thing_id, null: false, default: "gen_random_uuid()"
      t.index %i[ organization_id thing_id ],
        name: :idx_jobshop_things_pkey, unique: true

      t.uuid :collection_id, null: false
      t.citext :name
      t.index %i[ organization_id collection_id name ], unique: true,
        name: :idx_jobshop_organization_id_collection_id_name

      t.jsonb :custom_fields, null: false, default: "{}"
      t.index :custom_fields, using: :gin

      t.timestamps
    end

    idx_table_name_pkey :jobshop_things
    fk_organization :jobshop_things

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

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

      t.jsonb :schema, null: false, default: "{}"

      t.timestamps
    end

    idx_table_name_pkey :jobshop_collections
    fk_organization :jobshop_collections
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
jobshop-0.0.167 db/migrate/20171216035357_create_things.rb