Sha256: 0c89e96607ba9dff1de57263d0fae07a3c5ec8d5adfc0c21e07ee34be14747d8

Contents?: true

Size: 1.65 KB

Versions: 1

Compression:

Stored size: 1.65 KB

Contents

require "jobshop/helpers/migration.rb"

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

  def change
    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 [ :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 [ :organization_id, :company_id ]

      t.string :number
      t.index [ :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 [ :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 [ :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.157 db/migrate/20171216022605_create_orders.rb