change transactional primary key to custom ID for better portability

This commit is contained in:
Min Zeya Phyo
2017-06-03 19:12:35 +06:30
parent 9dddd2fc78
commit 394d2ed938
16 changed files with 52 additions and 31 deletions

View File

@@ -119,6 +119,7 @@ GEM
nokogiri (1.7.2)
mini_portile2 (~> 2.1.0)
pdf-core (0.7.0)
pg (0.20.0)
prawn (2.2.2)
pdf-core (~> 0.7.0)
ttfunk (~> 1.5)
@@ -252,6 +253,7 @@ DEPENDENCIES
kaminari!
listen (~> 3.0.5)
mysql2 (>= 0.3.18, < 0.5)
pg
prawn
prawn-table
puma (~> 3.0)

View File

@@ -13,9 +13,6 @@ module SXRestaurants
# -- all .rb files in that directory are automatically loaded.
config.active_record.time_zone_aware_types = [:datetime, :time]
config.active_job.queue_adapter = :sidekiq
# config.generators do |g|
# g.orm :active_record, primary_key_type: :uuid
# end
end
end

View File

@@ -1,6 +1,7 @@
class CreateCustomers < ActiveRecord::Migration[5.0]
def change
create_table :customers do |t|
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
t.string :name, :null => false
t.string :company
t.string :contact_no

View File

@@ -1,10 +1,11 @@
class CreateOrders < ActiveRecord::Migration[5.0]
def change
create_table :orders do |t|
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
t.datetime :date, :null => false
t.string :source, :null => false, :default => "emenu"
t.string :order_type, :null => false, :default => "dine-in"
t.references :customer, foreign_key: true
t.string :customer_id, foreign_key: true, :limit => 16
t.integer :item_count, :null => false, :default => 0
t.integer :quantity_count, :null => false, :default => 0
t.string :status, :null => false, :default => "new"

View File

@@ -1,7 +1,8 @@
class CreateOrderItems < ActiveRecord::Migration[5.0]
def change
create_table :order_items do |t|
t.references :order, foreign_key: true, :null => false
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
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
t.string :item_code, :null => false

View File

@@ -1,6 +1,8 @@
class CreateCashierLoginLogs < ActiveRecord::Migration[5.0]
def change
create_table :cashier_login_logs do |t|
create_table :cashier_login_logs, :id => false, :primary_key => :cashier_login_log_id do |t|
t.string :cashier_login_log_id, :limit => 16, :null => false, :index => true, :unique => true #custom primary key - to ensure consistence for cloud syncing
t.references :cashier_terminal, foreign_key: true
t.references :employee, foreign_key: true
t.datetime :login_at, :null => false

View File

@@ -1,13 +1,15 @@
class CreateSales < ActiveRecord::Migration[5.0]
def change
create_table :sales do |t|
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
t.integer :cashier_id, :index => true
t.string :cashier_name
t.string :requested_by, :null => false
t.datetime :requested_at, :null => false
t.string :receipt_no, :null => false
t.datetime :receipt_date, :null => false
t.references :customer, foreign_key: true
t.string :customer_id, foreign_key: true, :limit => 16
t.string :payment_status, :null => false, :default => "outstanding"
t.string :sale_status, :null => false, :default => "new"
t.decimal :total_amount, :precision => 10, :scale => 2, :null => false, :default => 0.00

View File

@@ -1,7 +1,8 @@
class CreateSaleItems < ActiveRecord::Migration[5.0]
def change
create_table :sale_items do |t|
t.references :sale, foreign_key: true
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
t.string :sale_id, foreign_key: true, :limit => 16
t.string :product_code, :null => false
t.string :product_name, :null => false
t.string :remark

View File

@@ -1,7 +1,9 @@
class CreateSaleTaxes < ActiveRecord::Migration[5.0]
def change
create_table :sale_taxes do |t|
t.references :sale, foreign_key: true
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
t.string :sale_id, foreign_key: true, :limit => 16
t.string :tax_name, :null => false
t.decimal :tax_rate, :precision => 10, :scale => 2, :null => false, :default => 0.00
t.decimal :tax_payable_amount, :precision => 10, :scale => 2, :null => false, :default => 0.00

View File

@@ -1,13 +1,15 @@
class CreateSalePayments < ActiveRecord::Migration[5.0]
def change
create_table :sale_payments do |t|
t.references :sale, foreign_key: true
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
t.string :sale_id, foreign_key: true, :limit => 16
t.string :payment_method, :null => false, :default => "cash"
t.decimal :payment_amount, :precision => 10, :scale => 2, :null => false, :default => 0.00
t.decimal :outstanding_amount, :precision => 10, :scale => 2, :null => false, :default => 0.00
t.string :payment_reference
t.string :payment_status, :null => false, :default => "new"
t.timestamps
end
end

View File

@@ -1,8 +1,10 @@
class CreateSaleOrders < ActiveRecord::Migration[5.0]
def change
create_table :sale_orders do |t|
t.references :sale, foreign_key: true
t.references :order, foreign_key: true
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
t.string :sale, foreign_key: true,:limit => 16
t.string :order, foreign_key: true, :limit => 16
t.timestamps
end

View File

@@ -1,7 +1,9 @@
class CreateSaleAudits < ActiveRecord::Migration[5.0]
def change
create_table :sale_audits do |t|
t.references :sale, foreign_key: true
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
t.string :sale_id, foreign_key: true, :limit => 16
t.string :action, :null => false
t.datetime :action_at, :null => false
t.string :action_by, :null => false

View File

@@ -1,6 +1,8 @@
class CreateBookings < ActiveRecord::Migration[5.0]
def change
create_table :bookings do |t|
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
t.references :dining_facility, foreign_key: true
t.string :type, :null => false, :default => "Table"
t.datetime :checkin_at, :null => false
@@ -10,7 +12,8 @@ class CreateBookings < ActiveRecord::Migration[5.0]
t.datetime :reserved_at
t.string :reserved_by
t.string :booking_status, :null => false, :default => "new"
t.references :sale, foreign_key: true
t.string :sale_id, foreign_key: true, :limit => 16
t.string :customer_id, foreign_key: true, :limit => 16
t.timestamps
end

View File

@@ -1,9 +1,10 @@
class CreateAssignedOrderItems < ActiveRecord::Migration[5.0]
def change
create_table :assigned_order_items do |t|
create_table :assigned_order_items, :id => false, :primary_key => :assigned_order_item_id do |t|
t.string :assigned_order_item_id, :limit => 16, :null => false, :index => true, :unique => true #custom primary key - to ensure consistence for cloud syncing
t.string :item_code, :null => false, :index => true
t.references :order_queue_station, foreign_key: true
t.references :order, foreign_key: true
t.string :order_id, foreign_key: true, :limit => 16
t.boolean :print_status
t.boolean :delivery_status

View File

@@ -1,8 +1,10 @@
class CreateBookingOrders < ActiveRecord::Migration[5.0]
def change
create_table :booking_orders do |t|
t.references :booking, foreign_key: true
t.references :order, foreign_key: true
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
t.timestamps
end

Binary file not shown.