Sha256: f94ba67d402b927b9d84950470385cb7870f6e7c3dbd9ee5e43607ae9a5e6fa6

Contents?: true

Size: 1.71 KB

Versions: 1

Compression:

Stored size: 1.71 KB

Contents

# frozen_string_literals: true

require "jobshop/helpers/migration.rb"

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

  def change # rubocop:disable Metrics/MethodLength
    create_table :jobshop_orders, id: false do |t|
      t.uuid :organization_id, null: false
      t.uuid :order_id, null: false, default: "gen_random_uuid()"
      t.index %i[ organization_id order_id ], unique: true,
        name: "idx_jobshop_orders_pkey"

      t.uuid :created_by_id, null: false

      t.uuid :company_id, null: false
      t.index %i[ organization_id company_id ]

      t.string :number
      t.index %i[ organization_id number ], unique: true

      t.timestamps
    end

    idx_table_name_pkey "jobshop_orders"
    fk_organization_id "jobshop_orders"
    fk_created_by_id "jobshop_orders"
    foreign_key "jobshop_orders", "jobshop_companies",
      [ "organization_id", "company_id" ]

    create_table :jobshop_order_lines, id: false do |t|
      t.uuid :organization_id, null: false
      t.uuid :order_id, null: false
      t.uuid :order_line_id, null: false, default: "gen_random_uuid()"
      t.index %i[ organization_id order_id order_line_id ], unique: true,
        name: "idx_jobshop_order_lines_pkey"

      t.uuid :created_by_id, null: false

      t.uuid :product_id, null: false
      t.index %i[ organization_id product_id ]

      t.timestamps
    end

    idx_table_name_pkey "jobshop_order_lines"
    fk_organization_id "jobshop_order_lines"
    fk_created_by_id "jobshop_order_lines"
    foreign_key "jobshop_order_lines", "jobshop_orders",
      [ "organization_id", "order_id" ]
    foreign_key "jobshop_order_lines", "jobshop_products",
      [ "organization_id", "product_id" ]
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
jobshop-0.0.163 db/migrate/20171216022605_create_orders.rb