2009-01-29 01:57:51 +01:00
|
|
|
class RefactorOrderLogic < ActiveRecord::Migration
|
|
|
|
def self.up
|
|
|
|
# TODO: Combine migrations since foodsoft3-development into one file
|
|
|
|
# and try to build a migration path from old data.
|
2009-02-02 16:35:43 +01:00
|
|
|
|
2009-02-03 21:14:48 +01:00
|
|
|
# # == Ordergroups
|
|
|
|
# add_column :groups, :deleted_at, :datetime # acts_as_paranoid
|
|
|
|
# remove_column :groups, :actual_size # Useless, desposits are better stored within a transaction.note
|
|
|
|
# # move contact-infos from users to ordergroups
|
|
|
|
# add_column :groups, :contact_person, :string
|
|
|
|
# add_column :groups, :contact_phone, :string
|
|
|
|
# add_column :groups, :contact_address, :string
|
|
|
|
# Ordergroup.all.each do |ordergroup|
|
|
|
|
# contact = ordergroup.users.first
|
|
|
|
# if contact
|
|
|
|
# ordergroup.update_attributes :contact_person => contact.name,
|
|
|
|
# :contact_phone => contact.phone, :contact_address => contact.address
|
|
|
|
# end
|
|
|
|
# end
|
|
|
|
# remove_column :users, :address
|
2009-02-02 16:35:43 +01:00
|
|
|
#
|
|
|
|
# # == Article
|
2009-01-29 21:28:22 +01:00
|
|
|
# rename_column :articles, :net_price, :price
|
|
|
|
# remove_column :articles, :gross_price
|
|
|
|
#
|
2009-02-02 16:35:43 +01:00
|
|
|
# # == Order
|
2009-01-29 21:28:22 +01:00
|
|
|
# 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
|
|
|
|
#
|
2009-02-02 16:35:43 +01:00
|
|
|
# # == Invoice
|
2009-01-29 21:28:22 +01:00
|
|
|
# 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
|
|
|
|
#
|
2009-02-02 16:35:43 +01:00
|
|
|
# # == Comment
|
2009-01-29 21:28:22 +01:00
|
|
|
# drop_table :comments
|
|
|
|
# create_table :order_comments do |t|
|
|
|
|
# t.references :order
|
|
|
|
# t.references :user
|
|
|
|
# t.text :text
|
|
|
|
# t.datetime :created_at
|
|
|
|
# end
|
|
|
|
#
|
2009-02-02 16:35:43 +01:00
|
|
|
# # == ArticlePrice
|
2009-01-29 21:28:22 +01:00
|
|
|
# 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
|
|
|
|
#
|
2009-02-02 16:35:43 +01:00
|
|
|
# # == GroupOrder
|
|
|
|
# change_column :group_orders, :updated_by_user_id, :integer, :default => nil, :null => true
|
2009-02-03 21:14:48 +01:00
|
|
|
|
|
|
|
# == GroupOrderArticle
|
|
|
|
# The order result in ordergroup is now saved!
|
|
|
|
add_column :group_order_articles, :quantity_result, :integer, :default => nil
|
|
|
|
add_column :group_order_articles, :tolerance_result, :integer, :default => nil
|
2009-01-29 01:57:51 +01:00
|
|
|
end
|
|
|
|
|
|
|
|
def self.down
|
|
|
|
end
|
|
|
|
end
|