-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
release 202006-1 | Merge pull request #52 from gomicorp/develop
* 기능: Brand 와 OrderInfo 가 너무 멀어서 매개테이블 추가 * 기능: Brand 와 ProductOption 이 너무 멀어서 매개테이블 추가
- Loading branch information
Showing
17 changed files
with
153 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
class OrderInfoBrand < ApplicationRecord | ||
belongs_to :order_info, class_name: 'OrderInfo' | ||
belongs_to :brand, class_name: 'Brand' | ||
|
||
validates_uniqueness_of :order_info_id, scope: :brand_id | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
class ProductOptionBrand < ApplicationRecord | ||
belongs_to :product_option, class_name: 'ProductOption' | ||
belongs_to :brand, class_name: 'Brand' | ||
|
||
validates_uniqueness_of :product_option_id, scope: :brand_id | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
class SetProductOptionBrands < ActiveRecord::Migration[6.0] | ||
def up | ||
ApplicationRecord.country_context_with 'global' do | ||
ProductOption.all.each do |option| | ||
option.bridges.each do |bridge| | ||
bridge.brands.each do |brand| | ||
ProductOptionBrand.create(product_option: option, brand: brand) | ||
end | ||
end | ||
end | ||
end | ||
end | ||
|
||
def down | ||
raise ActiveRecord::IrreversibleMigration if Rails.production? | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
class SetOrderInfoBrands < ActiveRecord::Migration[6.0] | ||
def up | ||
ApplicationRecord.country_context_with 'global' do | ||
OrderInfo.all.each do |order_info| | ||
order_info.product_options.each do |option| | ||
option.bridges.each do |bridge| | ||
bridge.brands.each do |brand| | ||
OrderInfoBrand.create(order_info: order_info, brand: brand) | ||
end | ||
end | ||
end | ||
|
||
# 정상적인 로직으로 데이터를 채워줄 수 없는 레거시 데이터에 대한 대응 | ||
order_info.items.each do |item| | ||
item.barcodes.each do |barcode| | ||
OrderInfoBrand.create(order_info: order_info, brand: barcode.product.brand) | ||
end | ||
end | ||
end | ||
end | ||
end | ||
|
||
def down | ||
# raise ActiveRecord::IrreversibleMigration if Rails.production? | ||
end | ||
end |
5 changes: 5 additions & 0 deletions
5
db/migrate/order_info/20200610022109_add_unique_to_cart_id_for_order_info.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
class AddUniqueToCartIdForOrderInfo < ActiveRecord::Migration[6.0] | ||
def change | ||
add_index :order_infos, :cart_id, unique: true | ||
end | ||
end |
10 changes: 10 additions & 0 deletions
10
db/migrate/order_info_brand/20200604095218_create_order_info_brands.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
class CreateOrderInfoBrands < ActiveRecord::Migration[6.0] | ||
def change | ||
create_table :order_info_brands do |t| | ||
t.references :order_info, null: false, foreign_key: true | ||
t.references :brand, null: false, foreign_key: true | ||
|
||
t.timestamps | ||
end | ||
end | ||
end |
10 changes: 10 additions & 0 deletions
10
db/migrate/product_option_brand/20200603031809_create_product_option_brands.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
class CreateProductOptionBrands < ActiveRecord::Migration[6.0] | ||
def change | ||
create_table :product_option_brands do |t| | ||
t.references :product_option, null: false, foreign_key: true | ||
t.references :brand, null: false, foreign_key: true | ||
|
||
t.timestamps | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
# Read about fixtures at https://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html | ||
|
||
# This model initially had no columns defined. If you add columns to the | ||
# model remove the '{}' from the fixture names and add the columns immediately | ||
# below each fixture, per the syntax in the comments below | ||
# | ||
one: {} | ||
# column: value | ||
# | ||
two: {} | ||
# column: value |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
# Read about fixtures at https://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html | ||
|
||
# This model initially had no columns defined. If you add columns to the | ||
# model remove the '{}' from the fixture names and add the columns immediately | ||
# below each fixture, per the syntax in the comments below | ||
# | ||
one: {} | ||
# column: value | ||
# | ||
two: {} | ||
# column: value |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
require 'test_helper' | ||
|
||
class OrderInfoBrandTest < ActiveSupport::TestCase | ||
# test "the truth" do | ||
# assert true | ||
# end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
require 'test_helper' | ||
|
||
class ProductOptionBrandTest < ActiveSupport::TestCase | ||
# test "the truth" do | ||
# assert true | ||
# end | ||
end |