Commit 62ac46f9 by ivan Lan

Add catalog to model genereator & Add index of type & Add annotate for index

parent e12ea483
......@@ -17,6 +17,8 @@ class CreateShotengaiProductsAndOrders < ActiveRecord::Migration[5.1]
t.timestamps
end
add_index :shotengai_products, :type
create_table :shotengai_series do |t|
t.decimal :original_price, precision: 9, scale: 2
t.decimal :price, precision: 9, scale: 2
......@@ -31,6 +33,8 @@ class CreateShotengaiProductsAndOrders < ActiveRecord::Migration[5.1]
t.timestamps
end
add_index :shotengai_series, :type
create_table :shotengai_orders do |t|
t.integer :seq
t.string :address
......@@ -52,6 +56,7 @@ class CreateShotengaiProductsAndOrders < ActiveRecord::Migration[5.1]
t.timestamps
end
add_index :shotengai_orders, :type
add_index :shotengai_orders, [:buyer_id, :buyer_type]
create_table :shotengai_snapshots do |t|
......@@ -72,5 +77,6 @@ class CreateShotengaiProductsAndOrders < ActiveRecord::Migration[5.1]
t.timestamps
end
add_index :shotengai_snapshots, :type
end
end
\ No newline at end of file
......@@ -7,7 +7,10 @@ class CreateShotengaiCatalogs < ActiveRecord::Migration[5.1]
# STI
t.string :type
t.references :super_catalog, index: true
t.timestamps
end
add_index :shotengai_catalogs, :type
end
end
......@@ -20,11 +20,14 @@ module Shotengai
desc: "Product class name"
class_option :order, type: :string, default: 'Order',
desc: "Order class name"
class_option :catalog, type: :string, default: 'Catalog',
desc: "Catalog class name"
def copy_models
@product_name, @order_name = options.values_at(:product, :order)
@product_name, @order_name, @catalog_name = options.values_at(:product, :order, :catalog)
template 'product.rb', "app/models/#{@product_name.underscore}.rb"
template 'order.rb', "app/models/#{@order_name.underscore}.rb"
template 'catalog.rb', "app/models/#{@catalog_name.underscore}.rb"
end
end
end
......
class <%= @controller_prefix%><%= @klass_name.pluralize %>Controller < Shotengai:Customer::ProductsController
class <%= @controller_prefix%><%= @klass_name.pluralize %>Controller < Shotengai::Controller::Customer::ProductsController
self.resource = '<%= @klass_name %>'
end
class <%= @catalog_name %> < Shotengai::Catalog
end
class <%= @order_name %> < Shotengai::Order
can_buy '<%= @product_name %>'
end
class <%= @product_name %> < Shotengai::Product
end
......@@ -18,6 +18,12 @@ module Shotengai
# buyer_type :string(255)
# created_at :datetime not null
# updated_at :datetime not null
#
# Indexes
#
# index_shotengai_orders_on_buyer_id_and_buyer_type (buyer_id,buyer_type)
# index_shotengai_orders_on_type (type)
#
class Cart < ::ActiveRecord::Base
self.table_name = 'shotengai_orders'
......
......@@ -12,6 +12,11 @@ module Shotengai
# created_at :datetime not null
# updated_at :datetime not null
#
# Indexes
#
# index_shotengai_catalogs_on_super_catalog_id (super_catalog_id)
# index_shotengai_catalogs_on_type (type)
#
class Catalog < ActiveRecord::Base
self.table_name = 'shotengai_catalogs'
......
......@@ -21,6 +21,12 @@ module Shotengai
# buyer_type :string(255)
# created_at :datetime not null
# updated_at :datetime not null
#
# Indexes
#
# index_shotengai_orders_on_buyer_id_and_buyer_type (buyer_id,buyer_type)
# index_shotengai_orders_on_type (type)
#
class Order < ActiveRecord::Base
self.table_name = 'shotengai_orders'
......
......@@ -17,6 +17,11 @@ module Shotengai
# meta :json
# created_at :datetime not null
# updated_at :datetime not null
#
# Indexes
#
# index_shotengai_products_on_type (type)
#
class Shotengai::Product < ActiveRecord::Base
require 'acts-as-taggable-on'
......
......@@ -13,6 +13,12 @@ module Shotengai
# shotengai_products_id :integer
# created_at :datetime not null
# updated_at :datetime not null
#
# Indexes
#
# index_shotengai_series_on_shotengai_products_id (shotengai_products_id)
# index_shotengai_series_on_type (type)
#
class Series < ActiveRecord::Base
self.table_name = 'shotengai_series'
......
......@@ -17,6 +17,13 @@ module Shotengai
# shotengai_orders_id :integer
# created_at :datetime not null
# updated_at :datetime not null
#
# Indexes
#
# index_shotengai_snapshots_on_shotengai_orders_id (shotengai_orders_id)
# index_shotengai_snapshots_on_shotengai_series_id (shotengai_series_id)
# index_shotengai_snapshots_on_type (type)
#
class Snapshot < ActiveRecord::Base
self.table_name = 'shotengai_snapshots'
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment