updated migration code

This commit is contained in:
Yan
2017-06-05 15:06:34 +06:30
parent b332d6a525
commit f004db9b19
16 changed files with 33 additions and 33 deletions

View File

@@ -1,7 +1,7 @@
class CreateCustomers < ActiveRecord::Migration[5.0]
def change
create_table :customers, :id => false, :primary_key => :customer_id do |t|
t.string :customer_id, :limit => 16, :null => false, :index => true, :unique => true #custom foreign_key to prevent conflict during sync
create_table :customers, :id => false do |t|
t.string :customer_id, :limit => 16, :primary_key => true #custom foreign_key to prevent conflict during sync
t.string :name, :null => false
t.string :company
t.string :contact_no

View File

@@ -1,7 +1,7 @@
class CreateOrders < ActiveRecord::Migration[5.0]
def change
create_table :orders, :id => false, :primary_key => :order_id do |t|
t.string :order_id, :limit => 16, :null => false, :index => true, :unique => true #custom foreign_key to prevent conflict during sync
create_table :orders, :id => false do |t|
t.string :order_id, :limit => 16, :primary_key => true #custom foreign_key to prevent conflict during sync
t.datetime :date, :null => false
t.string :source, :null => false, :default => "emenu"
t.string :order_type, :null => false, :default => "dine-in"

View File

@@ -1,7 +1,7 @@
class CreateOrderItems < ActiveRecord::Migration[5.0]
def change
create_table :order_items, :id => false, :primary_key => :order_items_id do |t|
t.string :order_items_id, :limit => 16, :null => false, :index => true, :unique => true #custom primary key - to ensure consistence for cloud syncing
create_table :order_items, :id => false do |t|
t.string :order_items_id, :limit => 16, :primary_key => true #custom primary key - to ensure consistence for cloud syncing
t.string :order_id, foreign_key: true, :null => false, :limit => 16
t.string :order_item_status, :null => false, :default => "new"
t.string :item_order_by #person who order this

View File

@@ -1,7 +1,7 @@
class CreateSales < ActiveRecord::Migration[5.0]
def change
create_table :sales, :id => false, :primary_key => :sale_id do |t|
t.string :sale_id, :limit => 16, :null => false, :index => true, :unique => true #custom primary key - to ensure consistence for cloud syncing
create_table :sales, :id => false do |t|
t.string :sale_id, :limit => 16, :primary_key => true #custom primary key - to ensure consistence for cloud syncing
t.integer :cashier_id, :index => true
t.string :cashier_name

View File

@@ -1,7 +1,7 @@
class CreateSaleItems < ActiveRecord::Migration[5.0]
def change
create_table :sale_items, :id => false, :primary_key => :sale_item_id do |t|
t.string :sale_item_id, :limit => 16, :null => false, :index => true, :unique => true #custom primary key - to ensure consistence for cloud syncing
create_table :sale_items, :id => false do |t|
t.string :sale_item_id, :limit => 16, :primary_key => true#custom primary key - to ensure consistence for cloud syncing
t.string :sale_id, foreign_key: true, :limit => 16
t.string :product_code, :null => false
t.string :product_name, :null => false

View File

@@ -1,7 +1,7 @@
class CreateSaleTaxes < ActiveRecord::Migration[5.0]
def change
create_table :sale_taxes, :id => false, :primary_key => :sale_tax_id do |t|
t.string :sale_tax_id, :limit => 16, :null => false, :index => true, :unique => true #custom primary key - to ensure consistence for cloud syncing
create_table :sale_taxes, :id => false do |t|
t.string :sale_tax_id, :limit => 16, :primary_key => true #custom primary key - to ensure consistence for cloud syncing
t.string :sale_id, foreign_key: true, :limit => 16
t.string :tax_name, :null => false

View File

@@ -1,7 +1,7 @@
class CreateSalePayments < ActiveRecord::Migration[5.0]
def change
create_table :sale_payments, :id => false, :primary_key => :sale_payment_id do |t|
t.string :sale_payment_id, :limit => 16, :null => false, :index => true, :unique => true #custom primary key - to ensure consistence for cloud syncing
create_table :sale_payments, :id => false do |t|
t.string :sale_payment_id, :limit => 16, :primary_key => true #custom primary key - to ensure consistence for cloud syncing
t.string :sale_id, foreign_key: true, :limit => 16
t.string :payment_method, :null => false, :default => "cash"

View File

@@ -1,10 +1,10 @@
class CreateSaleOrders < ActiveRecord::Migration[5.0]
def change
create_table :sale_orders, :id => false, :primary_key => :sale_order_id do |t|
t.string :sale_order_id, :limit => 16, :null => false, :index => true, :unique => true #custom primary key - to ensure consistence for cloud syncing
create_table :sale_orders, :id => false do |t|
t.primary_key :sale_order_id #custom primary key - to ensure consistence for cloud syncing
t.string :sale, foreign_key: true,:limit => 16
t.string :order, foreign_key: true, :limit => 16
t.string :sale_id, foreign_key: true,:limit => 16
t.string :order_id, foreign_key: true, :limit => 16
t.timestamps
end

View File

@@ -1,7 +1,7 @@
class CreateSaleAudits < ActiveRecord::Migration[5.0]
def change
create_table :sale_audits, :id => false, :primary_key => :sale_audit_id do |t|
t.string :sale_audit_id, :limit => 16, :null => false, :index => true, :unique => true #custom primary key - to ensure consistence for cloud syncing
create_table :sale_audits, :id => false do |t|
t.string :sale_audit_id, :limit => 16, :primary_key => true #custom primary key - to ensure consistence for cloud syncing
t.string :sale_id, foreign_key: true, :limit => 16
t.string :action, :null => false

View File

@@ -1,7 +1,7 @@
class CreateBookings < ActiveRecord::Migration[5.0]
def change
create_table :bookings, :id => false, :primary_key => :booking_id do |t|
t.string :booking_id, :limit => 16, :null => false, :index => true, :unique => true #custom primary key - to ensure consistence for cloud syncing
create_table :bookings, :id => false do |t|
t.string :booking_id, :limit => 16, :primary_key => true #custom primary key - to ensure consistence for cloud syncing
t.references :dining_facility, foreign_key: true
t.string :type, :null => false, :default => "Table"

View File

@@ -1,10 +1,10 @@
class CreateBookingOrders < ActiveRecord::Migration[5.0]
def change
create_table :booking_orders, :id => false, :primary_key => :booking_order_id do |t|
t.string :booking_order_id, :limit => 16, :null => false, :index => true, :unique => true #custom primary key - to ensure consistence for cloud syncing
t.string :booking, foreign_key: true, :limit => 16
t.string :order, foreign_key: true, :limit => 16
create_table :booking_orders, :id => false do |t|
#t.string :booking_order_id, :limit => 16, :null => false, :index => true, :unique => true #custom primary key - to ensure consistence for cloud syncing
t.primary_key :booking_order_id
t.string :booking_id, foreign_key: true, :limit => 16
t.string :order_id, foreign_key: true, :limit => 16
t.timestamps
end