Order refactoring part two: Balancing workflow was adapted to the new order schema. Article modification is still missing.

This commit is contained in:
Benjamin Meichsner 2009-01-29 21:28:22 +01:00
parent 9eb2125f15
commit 190a777278
53 changed files with 568 additions and 603 deletions

View file

@ -5,7 +5,7 @@ class ActsAsParanoid < ActiveRecord::Migration
end
def self.down
remove_column :suppliers, :deleted_at, :datetime
remove_column :articles, :deleted_at, :datetime
remove_column :suppliers, :deleted_at
remove_column :articles, :deleted_at
end
end

View file

@ -3,64 +3,67 @@ class RefactorOrderLogic < ActiveRecord::Migration
# TODO: Combine migrations since foodsoft3-development into one file
# and try to build a migration path from old data.
# articles
rename_column :articles, :net_price, :price
remove_column :articles, :gross_price
# # articles
# rename_column :articles, :net_price, :price
# remove_column :articles, :gross_price
#
# # orders
# drop_table :orders
# drop_table :group_order_results
# drop_table :order_article_results
# drop_table :group_order_article_results
# GroupOrder.delete_all; OrderArticle.delete_all; GroupOrderArticle.delete_all; GroupOrderArticleQuantity.delete_all
#
# create_table :orders do |t|
# t.references :supplier
# t.text :note
# t.datetime :starts
# t.datetime :ends
# t.string :state, :default => "open" # Statemachine ... open -> finished -> closed
# t.integer :lock_version, :default => 0, :null => false
# t.integer :updated_by_user_id
# end
#
# # invoices
# add_column :invoices, :order_id, :integer
# add_column :invoices, :deposit, :decimal, :precision => 8, :scale => 2, :default => 0.0, :null => false
# add_column :invoices, :deposit_credit, :decimal, :precision => 8, :scale => 2, :default => 0.0, :null => false
#
# # comments
# drop_table :comments
# create_table :order_comments do |t|
# t.references :order
# t.references :user
# t.text :text
# t.datetime :created_at
# end
#
# # article_prices
# create_table :article_prices do |t|
# t.references :article
# t.decimal :price, :precision => 8, :scale => 2, :default => 0.0, :null => false
# t.decimal :tax, :precision => 8, :scale => 2, :default => 0.0, :null => false
# t.decimal :deposit, :precision => 8, :scale => 2, :default => 0.0, :null => false
# t.integer :unit_quantity
# t.datetime :created_at
# end
# # Create price history for every Article
# Article.all.each do |a|
# a.article_prices.create :price => a.price, :tax => a.tax,
# :deposit => a.deposit, :unit_quantity => a.unit_quantity
# end
# # Every Article has now a Category. Fix it if neccessary.
# Article.all(:conditions => { :article_category_id => nil }).each do |article|
# article.update_attribute(:article_category, ArticleCategory.first)
# end
# # order-articles
# add_column :order_articles, :article_price_id, :integer
#
# # ordergroups
# add_column :groups, :deleted_at, :datetime
# orders
drop_table :orders
drop_table :group_order_results
drop_table :order_article_results
drop_table :group_order_article_results
GroupOrder.delete_all; OrderArticle.delete_all; GroupOrderArticle.delete_all; GroupOrderArticleQuantity.delete_all
create_table :orders do |t|
t.references :supplier
t.text :note
t.datetime :starts
t.datetime :ends
t.string :state, :default => "open" # Statemachine ... open -> finished -> closed
t.integer :lock_version, :default => 0, :null => false
t.integer :updated_by_user_id
end
# invoices
add_column :invoices, :order_id, :integer
add_column :invoices, :deposit, :decimal, :precision => 8, :scale => 2, :default => 0.0, :null => false
add_column :invoices, :deposit_credit, :decimal, :precision => 8, :scale => 2, :default => 0.0, :null => false
# comments
drop_table :comments
create_table :order_comments do |t|
t.references :order
t.references :user
t.text :text
t.datetime :created_at
end
# article_prices
create_table :article_prices do |t|
t.references :article
t.decimal :price, :precision => 8, :scale => 2, :default => 0.0, :null => false
t.decimal :tax, :precision => 8, :scale => 2, :default => 0.0, :null => false
t.decimal :deposit, :precision => 8, :scale => 2, :default => 0.0, :null => false
t.integer :unit_quantity
t.datetime :created_at
end
# Create price history for every Article
Article.all.each do |a|
a.article_prices.create :price => a.price, :tax => a.tax,
:deposit => a.deposit, :unit_quantity => a.unit_quantity
end
# Every Article has now a Category. Fix it if neccessary.
Article.all(:conditions => { :article_category_id => nil }).each do |article|
article.update_attribute(:article_category, ArticleCategory.first)
end
# order-articles
add_column :order_articles, :article_price_id, :integer
# ordergroups
add_column :groups, :deleted_at, :datetime
# GroupOrders
change_column :group_orders, :updated_by_user_id, :integer, :default => nil, :null => true
end
def self.down