The Depot Application

The Depot Application

18 Active Record: The Basics 16 Active Support

17 Migration

ruby -rubygems /home/rubys/git/rails/bin/rails new migration
      create  
      create  README
      create  Rakefile
      create  config.ru
      create  .gitignore
      create  Gemfile
      create  app
      create  app/helpers/application_helper.rb
      create  app/views/layouts/application.html.erb
      create  app/controllers/application_controller.rb
      create  app/mailers
      create  app/models
      create  config
      create  config/routes.rb
      create  config/application.rb
      create  config/environment.rb
      create  config/environments
      create  config/environments/development.rb
      create  config/environments/test.rb
      create  config/environments/production.rb
      create  config/initializers
      create  config/initializers/mime_types.rb
      create  config/initializers/inflections.rb
      create  config/initializers/session_store.rb
      create  config/initializers/backtrace_silencers.rb
      create  config/initializers/secret_token.rb
      create  config/locales
      create  config/locales/en.yml
      create  config/boot.rb
      create  config/database.yml
      create  db
      create  db/seeds.rb
      create  doc
      create  doc/README_FOR_APP
      create  lib
      create  lib/tasks
      create  lib/tasks/.gitkeep
      create  log
      create  log/server.log
      create  log/production.log
      create  log/development.log
      create  log/test.log
      create  public
      create  public/500.html
      create  public/robots.txt
      create  public/favicon.ico
      create  public/422.html
      create  public/404.html
      create  public/index.html
      create  public/images
      create  public/images/rails.png
      create  public/stylesheets
      create  public/stylesheets/.gitkeep
      create  public/javascripts
      create  public/javascripts/prototype.js
      create  public/javascripts/dragdrop.js
      create  public/javascripts/rails.js
      create  public/javascripts/effects.js
      create  public/javascripts/controls.js
      create  public/javascripts/application.js
      create  script
      create  script/rails
      create  test
      create  test/performance/browsing_test.rb
      create  test/test_helper.rb
      create  test/fixtures
      create  test/unit
      create  test/functional
      create  test/integration
      create  tmp
      create  tmp/sessions
      create  tmp/sockets
      create  tmp/cache
      create  tmp/pids
      create  vendor/plugins
      create  vendor/plugins/.gitkeep
bundle install
Using rake (0.8.7) 
Using abstract (1.0.0) 
Using activesupport (3.0.1.pre) from source at /home/rubys/git/rails 
Using builder (2.1.2) 
Using i18n (0.4.1) 
Using activemodel (3.0.1.pre) from source at /home/rubys/git/rails 
Using erubis (2.6.6) 
Using rack (1.2.1) 
Using rack-mount (0.6.13) 
Using rack-test (0.5.4) 
Using tzinfo (0.3.23) 
Using actionpack (3.0.1.pre) from source at /home/rubys/git/rails 
Using mime-types (1.16) 
Using polyglot (0.3.1) 
Using treetop (1.4.8) 
Using mail (2.2.5) 
Using actionmailer (3.0.1.pre) from source at /home/rubys/git/rails 
Using arel (1.0.1) from source at /home/rubys/git/arel 
Using activerecord (3.0.1.pre) from source at /home/rubys/git/rails 
Using activeresource (3.0.1.pre) from source at /home/rubys/git/rails 
Using bundler (1.0.0) 
Using thor (0.14.0) 
Using railties (3.0.1.pre) from source at /home/rubys/git/rails 
Using rails (3.0.1.pre) from source at /home/rubys/git/rails 
Using sqlite3-ruby (1.3.1) 
Your bundle is complete! Use `bundle show [gemname]` to see where a bundled gem is installed.
*[32m
Your bundle was installed to `/home/rubys/.rvm/gems/ruby-1.8.7-p302`*[0m
edit config/routes.rb
Migration::Application.routes.draw do
  # ...
 
  # This is a legacy wild controller route that's not recommended for RESTful applications.
  # Note: This route will make all actions in every controller accessible via GET requests.
   match ':controller(/:action(/:id(.:format)))'
end
cp -rpv /home/rubys/git/awdwr/plugins/* vendor/plugins/
`/home/rubys/git/awdwr/plugins/MANIFEST' -> `vendor/plugins/MANIFEST'
`/home/rubys/git/awdwr/plugins/acts_as_list' -> `vendor/plugins/acts_as_list'
`/home/rubys/git/awdwr/plugins/acts_as_list/lib' -> `vendor/plugins/acts_as_list/lib'
`/home/rubys/git/awdwr/plugins/acts_as_list/lib/active_record' -> `vendor/plugins/acts_as_list/lib/active_record'
`/home/rubys/git/awdwr/plugins/acts_as_list/lib/active_record/acts' -> `vendor/plugins/acts_as_list/lib/active_record/acts'
`/home/rubys/git/awdwr/plugins/acts_as_list/lib/active_record/acts/list.rb' -> `vendor/plugins/acts_as_list/lib/active_record/acts/list.rb'
`/home/rubys/git/awdwr/plugins/acts_as_list/init.rb' -> `vendor/plugins/acts_as_list/init.rb'
`/home/rubys/git/awdwr/plugins/acts_as_list/test' -> `vendor/plugins/acts_as_list/test'
`/home/rubys/git/awdwr/plugins/acts_as_list/test/list_test.rb' -> `vendor/plugins/acts_as_list/test/list_test.rb'
`/home/rubys/git/awdwr/plugins/acts_as_list/README' -> `vendor/plugins/acts_as_list/README'
`/home/rubys/git/awdwr/plugins/acts_as_tree' -> `vendor/plugins/acts_as_tree'
`/home/rubys/git/awdwr/plugins/acts_as_tree/lib' -> `vendor/plugins/acts_as_tree/lib'
`/home/rubys/git/awdwr/plugins/acts_as_tree/lib/active_record' -> `vendor/plugins/acts_as_tree/lib/active_record'
`/home/rubys/git/awdwr/plugins/acts_as_tree/lib/active_record/acts' -> `vendor/plugins/acts_as_tree/lib/active_record/acts'
`/home/rubys/git/awdwr/plugins/acts_as_tree/lib/active_record/acts/tree.rb' -> `vendor/plugins/acts_as_tree/lib/active_record/acts/tree.rb'
`/home/rubys/git/awdwr/plugins/acts_as_tree/init.rb' -> `vendor/plugins/acts_as_tree/init.rb'
`/home/rubys/git/awdwr/plugins/acts_as_tree/Rakefile' -> `vendor/plugins/acts_as_tree/Rakefile'
`/home/rubys/git/awdwr/plugins/acts_as_tree/test' -> `vendor/plugins/acts_as_tree/test'
`/home/rubys/git/awdwr/plugins/acts_as_tree/test/fixtures' -> `vendor/plugins/acts_as_tree/test/fixtures'
`/home/rubys/git/awdwr/plugins/acts_as_tree/test/fixtures/mixin.rb' -> `vendor/plugins/acts_as_tree/test/fixtures/mixin.rb'
`/home/rubys/git/awdwr/plugins/acts_as_tree/test/fixtures/mixins.yml' -> `vendor/plugins/acts_as_tree/test/fixtures/mixins.yml'
`/home/rubys/git/awdwr/plugins/acts_as_tree/test/database.yml' -> `vendor/plugins/acts_as_tree/test/database.yml'
`/home/rubys/git/awdwr/plugins/acts_as_tree/test/acts_as_tree_test.rb' -> `vendor/plugins/acts_as_tree/test/acts_as_tree_test.rb'
`/home/rubys/git/awdwr/plugins/acts_as_tree/test/abstract_unit.rb' -> `vendor/plugins/acts_as_tree/test/abstract_unit.rb'
`/home/rubys/git/awdwr/plugins/acts_as_tree/test/schema.rb' -> `vendor/plugins/acts_as_tree/test/schema.rb'
`/home/rubys/git/awdwr/plugins/acts_as_tree/README' -> `vendor/plugins/acts_as_tree/README'
`/home/rubys/git/awdwr/plugins/annotate_models' -> `vendor/plugins/annotate_models'
`/home/rubys/git/awdwr/plugins/annotate_models/lib' -> `vendor/plugins/annotate_models/lib'
`/home/rubys/git/awdwr/plugins/annotate_models/lib/annotate_models.rb' -> `vendor/plugins/annotate_models/lib/annotate_models.rb'
`/home/rubys/git/awdwr/plugins/annotate_models/ChangeLog' -> `vendor/plugins/annotate_models/ChangeLog'
`/home/rubys/git/awdwr/plugins/annotate_models/README' -> `vendor/plugins/annotate_models/README'
`/home/rubys/git/awdwr/plugins/annotate_models/tasks' -> `vendor/plugins/annotate_models/tasks'
`/home/rubys/git/awdwr/plugins/annotate_models/tasks/annotate_models_tasks.rake' -> `vendor/plugins/annotate_models/tasks/annotate_models_tasks.rake'
`/home/rubys/git/awdwr/plugins/country_select' -> `vendor/plugins/country_select'
`/home/rubys/git/awdwr/plugins/country_select/lib' -> `vendor/plugins/country_select/lib'
`/home/rubys/git/awdwr/plugins/country_select/lib/country_select.rb' -> `vendor/plugins/country_select/lib/country_select.rb'
`/home/rubys/git/awdwr/plugins/country_select/init.rb' -> `vendor/plugins/country_select/init.rb'
`/home/rubys/git/awdwr/plugins/country_select/install.rb' -> `vendor/plugins/country_select/install.rb'
`/home/rubys/git/awdwr/plugins/country_select/MIT-LICENSE' -> `vendor/plugins/country_select/MIT-LICENSE'
`/home/rubys/git/awdwr/plugins/country_select/uninstall.rb' -> `vendor/plugins/country_select/uninstall.rb'
`/home/rubys/git/awdwr/plugins/country_select/README' -> `vendor/plugins/country_select/README'

Restart the server.

cp -v -r ../depot/db/* db/
`../depot/db/development.sqlite3' -> `db/development.sqlite3'
`../depot/db/migrate' -> `db/migrate'
`../depot/db/migrate/20100301000005_create_orders.rb' -> `db/migrate/20100301000005_create_orders.rb'
`../depot/db/migrate/20100301000003_add_test_data.rb' -> `db/migrate/20100301000003_add_test_data.rb'
`../depot/db/migrate/20100301000004_add_sessions_table.rb' -> `db/migrate/20100301000004_add_sessions_table.rb'
`../depot/db/migrate/20100301000001_create_products.rb' -> `db/migrate/20100301000001_create_products.rb'
`../depot/db/migrate/20100301000006_create_line_items.rb' -> `db/migrate/20100301000006_create_line_items.rb'
`../depot/db/migrate/20100301000007_create_users.rb' -> `db/migrate/20100301000007_create_users.rb'
`../depot/db/migrate/20100301000002_add_price_to_product.rb' -> `db/migrate/20100301000002_add_price_to_product.rb'
`../depot/db/schema.rb' -> `db/schema.rb'
`../depot/db/seeds.rb' -> `db/seeds.rb'
`../depot/db/test.sqlite3' -> `db/test.sqlite3'
cp -v -r ../depot/app/models/* app/models/
`../depot/app/models/cart.rb' -> `app/models/cart.rb'
`../depot/app/models/cart_item.rb' -> `app/models/cart_item.rb'
`../depot/app/models/line_item.rb' -> `app/models/line_item.rb'
`../depot/app/models/order.rb' -> `app/models/order.rb'
`../depot/app/models/product.rb' -> `app/models/product.rb'
`../depot/app/models/user.rb' -> `app/models/user.rb'
rails generate model discount
      invoke  active_record
      create    db/migrate/20100906011427_create_discounts.rb
      create    app/models/discount.rb
      invoke    test_unit
      create      test/unit/discount_test.rb
      create      test/fixtures/discounts.yml
rails generate migration add_status_to_user status:string
      invoke  active_record
      create    db/migrate/20100906011429_add_status_to_user.rb
rake db:migrate
mv 20100906011427_create_discounts.rb 20100301000008_create_discounts.rb
mv 20100906011429_add_status_to_user.rb 20100301000009_add_status_to_user.rb
DEPRECATION WARNING: Rake tasks in /home/rubys/git/awdwr/work/migration/vendor/plugins/annotate_models/tasks/annotate_models_tasks.rake are deprecated. Use lib/tasks instead. (called from /home/rubys/git/awdwr/work/migration/Rakefile:7)
(in /home/rubys/git/awdwr/work/migration)
==  CreateDiscounts: migrating ================================================
-- create_table(:discounts)
   -> 0.0016s
==  CreateDiscounts: migrated (0.0018s) =======================================
 
==  AddStatusToUser: migrating ================================================
-- add_column(:users, :status, :string)
   -> 0.0011s
==  AddStatusToUser: migrated (0.0012s) =======================================
 
cp -v /home/rubys/git/awdwr/data/migrate/020* db/migrate
`/home/rubys/git/awdwr/data/migrate/020_add_email_to_orders.rb' -> `db/migrate/020_add_email_to_orders.rb'
rake db:migrate
mv 020_add_email_to_orders.rb 20100301000010_add_email_to_orders.rb
DEPRECATION WARNING: Rake tasks in /home/rubys/git/awdwr/work/migration/vendor/plugins/annotate_models/tasks/annotate_models_tasks.rake are deprecated. Use lib/tasks instead. (called from /home/rubys/git/awdwr/work/migration/Rakefile:7)
(in /home/rubys/git/awdwr/work/migration)
==  AddEmailToOrders: migrating ===============================================
-- add_column(:orders, :e_mail, :string)
   -> 0.0011s
==  AddEmailToOrders: migrated (0.0012s) ======================================
 
rake annotate_models
DEPRECATION WARNING: Rake tasks in /home/rubys/git/awdwr/work/migration/vendor/plugins/annotate_models/tasks/annotate_models_tasks.rake are deprecated. Use lib/tasks instead. (called from /home/rubys/git/awdwr/work/migration/Rakefile:7)
(in /home/rubys/git/awdwr/work/migration)
Skipping Cart
Skipping CartItem
Annotating User
Annotating Discount
Annotating Product
Annotating LineItem
Annotating Order
cat app/models/line_item.rb
# == Schema Information
# Schema version: 20100301000010
#
# Table name: line_items
#
#  id          :integer         not null, primary key
#  product_id  :integer         not null
#  order_id    :integer         not null
#  quantity    :integer         not null
#  total_price :decimal(8, 2)   not null
#  created_at  :datetime        
#  updated_at  :datetime        
#
 
#START:belongs_to
class LineItem < ActiveRecord::Base
  belongs_to :order
  belongs_to :product
#END:belongs_to
 
  def self.from_cart_item(cart_item)
    li = self.new
    li.product     = cart_item.product
    li.quantity    = cart_item.quantity
    li.total_price = cart_item.price
    li
  end
 
#START:belongs_to
end
#END:belongs_to
cp -v /home/rubys/git/awdwr/data/migrate/021* db/migrate
`/home/rubys/git/awdwr/data/migrate/021_add_placed_at_to_orders.rb' -> `db/migrate/021_add_placed_at_to_orders.rb'
rake db:migrate
mv 021_add_placed_at_to_orders.rb 20100301000011_add_placed_at_to_orders.rb
DEPRECATION WARNING: Rake tasks in /home/rubys/git/awdwr/work/migration/vendor/plugins/annotate_models/tasks/annotate_models_tasks.rake are deprecated. Use lib/tasks instead. (called from /home/rubys/git/awdwr/work/migration/Rakefile:7)
(in /home/rubys/git/awdwr/work/migration)
==  AddPlacedAtToOrders: migrating ============================================
-- add_column(:orders, :placed_at, :datetime, {:default=>Sun Sep 05 21:14:39 -0400 2010})
   -> 0.0073s
==  AddPlacedAtToOrders: migrated (0.0074s) ===================================
 
rake annotate_models
DEPRECATION WARNING: Rake tasks in /home/rubys/git/awdwr/work/migration/vendor/plugins/annotate_models/tasks/annotate_models_tasks.rake are deprecated. Use lib/tasks instead. (called from /home/rubys/git/awdwr/work/migration/Rakefile:7)
(in /home/rubys/git/awdwr/work/migration)
Skipping Cart
Skipping CartItem
Annotating User
Annotating Discount
Annotating Product
Annotating LineItem
Annotating Order
cat app/models/line_item.rb
# == Schema Information
# Schema version: 20100301000011
#
# Table name: line_items
#
#  id          :integer         not null, primary key
#  product_id  :integer         not null
#  order_id    :integer         not null
#  quantity    :integer         not null
#  total_price :decimal(8, 2)   not null
#  created_at  :datetime        
#  updated_at  :datetime        
#
 
#START:belongs_to
class LineItem < ActiveRecord::Base
  belongs_to :order
  belongs_to :product
#END:belongs_to
 
  def self.from_cart_item(cart_item)
    li = self.new
    li.product     = cart_item.product
    li.quantity    = cart_item.quantity
    li.total_price = cart_item.price
    li
  end
 
#START:belongs_to
end
#END:belongs_to
cp -v /home/rubys/git/awdwr/data/migrate/022* db/migrate
`/home/rubys/git/awdwr/data/migrate/022_add_columns_to_orders.rb' -> `db/migrate/022_add_columns_to_orders.rb'
rake db:migrate
mv 022_add_columns_to_orders.rb 20100301000012_add_columns_to_orders.rb
DEPRECATION WARNING: Rake tasks in /home/rubys/git/awdwr/work/migration/vendor/plugins/annotate_models/tasks/annotate_models_tasks.rake are deprecated. Use lib/tasks instead. (called from /home/rubys/git/awdwr/work/migration/Rakefile:7)
(in /home/rubys/git/awdwr/work/migration)
==  AddColumnsToOrders: migrating =============================================
-- add_column(:orders, :attn, :string, {:limit=>100})
   -> 0.0011s
-- add_column(:orders, :order_type, :integer)
   -> 0.0006s
-- add_column(:orders, :ship_class, :string, {:default=>"priority", :null=>false})
   -> 0.0007s
-- add_column(:orders, :amount, :decimal, {:precision=>8, :scale=>2})
   -> 0.0007s
-- add_column(:orders, :state, :string, {:limit=>2})
   -> 0.0006s
==  AddColumnsToOrders: migrated (0.0042s) ====================================
 
rake annotate_models
DEPRECATION WARNING: Rake tasks in /home/rubys/git/awdwr/work/migration/vendor/plugins/annotate_models/tasks/annotate_models_tasks.rake are deprecated. Use lib/tasks instead. (called from /home/rubys/git/awdwr/work/migration/Rakefile:7)
(in /home/rubys/git/awdwr/work/migration)
Skipping Cart
Skipping CartItem
Annotating User
Annotating Discount
Annotating Product
Annotating LineItem
Annotating Order
cat app/models/line_item.rb
# == Schema Information
# Schema version: 20100301000012
#
# Table name: line_items
#
#  id          :integer         not null, primary key
#  product_id  :integer         not null
#  order_id    :integer         not null
#  quantity    :integer         not null
#  total_price :decimal(8, 2)   not null
#  created_at  :datetime        
#  updated_at  :datetime        
#
 
#START:belongs_to
class LineItem < ActiveRecord::Base
  belongs_to :order
  belongs_to :product
#END:belongs_to
 
  def self.from_cart_item(cart_item)
    li = self.new
    li.product     = cart_item.product
    li.quantity    = cart_item.quantity
    li.total_price = cart_item.price
    li
  end
 
#START:belongs_to
end
#END:belongs_to
cp -v /home/rubys/git/awdwr/data/migrate/023* db/migrate
`/home/rubys/git/awdwr/data/migrate/023_rename_email_column.rb' -> `db/migrate/023_rename_email_column.rb'
rake db:migrate
mv 023_rename_email_column.rb 20100301000013_rename_email_column.rb
DEPRECATION WARNING: Rake tasks in /home/rubys/git/awdwr/work/migration/vendor/plugins/annotate_models/tasks/annotate_models_tasks.rake are deprecated. Use lib/tasks instead. (called from /home/rubys/git/awdwr/work/migration/Rakefile:7)
(in /home/rubys/git/awdwr/work/migration)
==  RenameEmailColumn: migrating ==============================================
-- rename_column(:orders, :e_mail, :customer_email)
   -> 0.0239s
==  RenameEmailColumn: migrated (0.0240s) =====================================
 
rake annotate_models
DEPRECATION WARNING: Rake tasks in /home/rubys/git/awdwr/work/migration/vendor/plugins/annotate_models/tasks/annotate_models_tasks.rake are deprecated. Use lib/tasks instead. (called from /home/rubys/git/awdwr/work/migration/Rakefile:7)
(in /home/rubys/git/awdwr/work/migration)
Skipping Cart
Skipping CartItem
Annotating User
Annotating Discount
Annotating Product
Annotating LineItem
Annotating Order
cat app/models/line_item.rb
# == Schema Information
# Schema version: 20100301000013
#
# Table name: line_items
#
#  id          :integer         not null, primary key
#  product_id  :integer         not null
#  order_id    :integer         not null
#  quantity    :integer         not null
#  total_price :decimal(8, 2)   not null
#  created_at  :datetime        
#  updated_at  :datetime        
#
 
#START:belongs_to
class LineItem < ActiveRecord::Base
  belongs_to :order
  belongs_to :product
#END:belongs_to
 
  def self.from_cart_item(cart_item)
    li = self.new
    li.product     = cart_item.product
    li.quantity    = cart_item.quantity
    li.total_price = cart_item.price
    li
  end
 
#START:belongs_to
end
#END:belongs_to
cp -v /home/rubys/git/awdwr/data/migrate/024* db/migrate
`/home/rubys/git/awdwr/data/migrate/024_change_order_type_to_string.rb' -> `db/migrate/024_change_order_type_to_string.rb'
rake db:migrate
mv 024_change_order_type_to_string.rb 20100301000014_change_order_type_to_string.rb
DEPRECATION WARNING: Rake tasks in /home/rubys/git/awdwr/work/migration/vendor/plugins/annotate_models/tasks/annotate_models_tasks.rake are deprecated. Use lib/tasks instead. (called from /home/rubys/git/awdwr/work/migration/Rakefile:7)
(in /home/rubys/git/awdwr/work/migration)
==  ChangeOrderTypeToString: migrating ========================================
-- change_column(:orders, :order_type, :string)
   -> 0.0233s
==  ChangeOrderTypeToString: migrated (0.0234s) ===============================
 
rake annotate_models
DEPRECATION WARNING: Rake tasks in /home/rubys/git/awdwr/work/migration/vendor/plugins/annotate_models/tasks/annotate_models_tasks.rake are deprecated. Use lib/tasks instead. (called from /home/rubys/git/awdwr/work/migration/Rakefile:7)
(in /home/rubys/git/awdwr/work/migration)
Skipping Cart
Skipping CartItem
Annotating User
Annotating Discount
Annotating Product
Annotating LineItem
Annotating Order
cat app/models/line_item.rb
# == Schema Information
# Schema version: 20100301000014
#
# Table name: line_items
#
#  id          :integer         not null, primary key
#  product_id  :integer         not null
#  order_id    :integer         not null
#  quantity    :integer         not null
#  total_price :decimal(8, 2)   not null
#  created_at  :datetime        
#  updated_at  :datetime        
#
 
#START:belongs_to
class LineItem < ActiveRecord::Base
  belongs_to :order
  belongs_to :product
#END:belongs_to
 
  def self.from_cart_item(cart_item)
    li = self.new
    li.product     = cart_item.product
    li.quantity    = cart_item.quantity
    li.total_price = cart_item.price
    li
  end
 
#START:belongs_to
end
#END:belongs_to
cp -v /home/rubys/git/awdwr/data/migrate/025* db/migrate
`/home/rubys/git/awdwr/data/migrate/025_create_order_histories.rb' -> `db/migrate/025_create_order_histories.rb'
rake db:migrate
mv 025_create_order_histories.rb 20100301000015_create_order_histories.rb
DEPRECATION WARNING: Rake tasks in /home/rubys/git/awdwr/work/migration/vendor/plugins/annotate_models/tasks/annotate_models_tasks.rake are deprecated. Use lib/tasks instead. (called from /home/rubys/git/awdwr/work/migration/Rakefile:7)
(in /home/rubys/git/awdwr/work/migration)
==  CreateOrderHistories: migrating ===========================================
-- create_table(:order_histories)
   -> 0.0020s
==  CreateOrderHistories: migrated (0.0022s) ==================================
 
rake annotate_models
DEPRECATION WARNING: Rake tasks in /home/rubys/git/awdwr/work/migration/vendor/plugins/annotate_models/tasks/annotate_models_tasks.rake are deprecated. Use lib/tasks instead. (called from /home/rubys/git/awdwr/work/migration/Rakefile:7)
(in /home/rubys/git/awdwr/work/migration)
Skipping Cart
Skipping CartItem
Annotating User
Annotating Discount
Annotating Product
Annotating LineItem
Annotating Order
cat app/models/line_item.rb
# == Schema Information
# Schema version: 20100301000015
#
# Table name: line_items
#
#  id          :integer         not null, primary key
#  product_id  :integer         not null
#  order_id    :integer         not null
#  quantity    :integer         not null
#  total_price :decimal(8, 2)   not null
#  created_at  :datetime        
#  updated_at  :datetime        
#
 
#START:belongs_to
class LineItem < ActiveRecord::Base
  belongs_to :order
  belongs_to :product
#END:belongs_to
 
  def self.from_cart_item(cart_item)
    li = self.new
    li.product     = cart_item.product
    li.quantity    = cart_item.quantity
    li.total_price = cart_item.price
    li
  end
 
#START:belongs_to
end
#END:belongs_to
cp -v /home/rubys/git/awdwr/data/migrate/026* db/migrate
`/home/rubys/git/awdwr/data/migrate/026_create_table_tickets.rb' -> `db/migrate/026_create_table_tickets.rb'
rake db:migrate
mv 026_create_table_tickets.rb 20100301000016_create_table_tickets.rb
DEPRECATION WARNING: Rake tasks in /home/rubys/git/awdwr/work/migration/vendor/plugins/annotate_models/tasks/annotate_models_tasks.rake are deprecated. Use lib/tasks instead. (called from /home/rubys/git/awdwr/work/migration/Rakefile:7)
rake aborted!
An error has occurred, this and all later migrations canceled:

    
SQLite3::SQLException: near "auto_increment": syntax error: CREATE TABLE "tickets" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "description" text, "text" text, "created_at" datetime, "updated_at" datetime) auto_increment = 10000

    
(See full trace by running task with --trace)
(in /home/rubys/git/awdwr/work/migration)
==  CreateTableTickets: migrating =============================================
-- create_table(:tickets, {:options=>"auto_increment = 10000"})
rm db/migrate/20100301000016_create_table_tickets.rb
rake annotate_models
DEPRECATION WARNING: Rake tasks in /home/rubys/git/awdwr/work/migration/vendor/plugins/annotate_models/tasks/annotate_models_tasks.rake are deprecated. Use lib/tasks instead. (called from /home/rubys/git/awdwr/work/migration/Rakefile:7)
(in /home/rubys/git/awdwr/work/migration)
Skipping Cart
Skipping CartItem
Annotating User
Annotating Discount
Annotating Product
Annotating LineItem
Annotating Order
cat app/models/line_item.rb
# == Schema Information
# Schema version: 20100301000015
#
# Table name: line_items
#
#  id          :integer         not null, primary key
#  product_id  :integer         not null
#  order_id    :integer         not null
#  quantity    :integer         not null
#  total_price :decimal(8, 2)   not null
#  created_at  :datetime        
#  updated_at  :datetime        
#
 
#START:belongs_to
class LineItem < ActiveRecord::Base
  belongs_to :order
  belongs_to :product
#END:belongs_to
 
  def self.from_cart_item(cart_item)
    li = self.new
    li.product     = cart_item.product
    li.quantity    = cart_item.quantity
    li.total_price = cart_item.price
    li
  end
 
#START:belongs_to
end
#END:belongs_to
cp -v /home/rubys/git/awdwr/data/migrate/027* db/migrate
`/home/rubys/git/awdwr/data/migrate/027_rename_order_histories.rb' -> `db/migrate/027_rename_order_histories.rb'
rake db:migrate
mv 027_rename_order_histories.rb 20100301000016_rename_order_histories.rb
DEPRECATION WARNING: Rake tasks in /home/rubys/git/awdwr/work/migration/vendor/plugins/annotate_models/tasks/annotate_models_tasks.rake are deprecated. Use lib/tasks instead. (called from /home/rubys/git/awdwr/work/migration/Rakefile:7)
(in /home/rubys/git/awdwr/work/migration)
==  RenameOrderHistories: migrating ===========================================
-- rename_table(:order_histories, :order_notes)
   -> 0.0012s
==  RenameOrderHistories: migrated (0.0013s) ==================================
 
rake annotate_models
DEPRECATION WARNING: Rake tasks in /home/rubys/git/awdwr/work/migration/vendor/plugins/annotate_models/tasks/annotate_models_tasks.rake are deprecated. Use lib/tasks instead. (called from /home/rubys/git/awdwr/work/migration/Rakefile:7)
(in /home/rubys/git/awdwr/work/migration)
Skipping Cart
Skipping CartItem
Annotating User
Annotating Discount
Annotating Product
Annotating LineItem
Annotating Order
cat app/models/line_item.rb
# == Schema Information
# Schema version: 20100301000016
#
# Table name: line_items
#
#  id          :integer         not null, primary key
#  product_id  :integer         not null
#  order_id    :integer         not null
#  quantity    :integer         not null
#  total_price :decimal(8, 2)   not null
#  created_at  :datetime        
#  updated_at  :datetime        
#
 
#START:belongs_to
class LineItem < ActiveRecord::Base
  belongs_to :order
  belongs_to :product
#END:belongs_to
 
  def self.from_cart_item(cart_item)
    li = self.new
    li.product     = cart_item.product
    li.quantity    = cart_item.quantity
    li.total_price = cart_item.price
    li
  end
 
#START:belongs_to
end
#END:belongs_to
cp -v /home/rubys/git/awdwr/data/migrate/028* db/migrate
`/home/rubys/git/awdwr/data/migrate/028_create_order_histories2.rb' -> `db/migrate/028_create_order_histories2.rb'
rake db:migrate
mv 028_create_order_histories2.rb 20100301000017_create_order_histories2.rb
DEPRECATION WARNING: Rake tasks in /home/rubys/git/awdwr/work/migration/vendor/plugins/annotate_models/tasks/annotate_models_tasks.rake are deprecated. Use lib/tasks instead. (called from /home/rubys/git/awdwr/work/migration/Rakefile:7)
(in /home/rubys/git/awdwr/work/migration)
==  CreateOrderHistories2: migrating ==========================================
-- create_table(:order_histories)
   -> 0.0018s
==  CreateOrderHistories2: migrated (0.0612s) =================================
 
rake annotate_models
DEPRECATION WARNING: Rake tasks in /home/rubys/git/awdwr/work/migration/vendor/plugins/annotate_models/tasks/annotate_models_tasks.rake are deprecated. Use lib/tasks instead. (called from /home/rubys/git/awdwr/work/migration/Rakefile:7)
(in /home/rubys/git/awdwr/work/migration)
Skipping Cart
Skipping CartItem
Annotating User
Annotating Discount
Annotating Product
Annotating LineItem
Annotating Order
cat app/models/line_item.rb
# == Schema Information
# Schema version: 20100301000017
#
# Table name: line_items
#
#  id          :integer         not null, primary key
#  product_id  :integer         not null
#  order_id    :integer         not null
#  quantity    :integer         not null
#  total_price :decimal(8, 2)   not null
#  created_at  :datetime        
#  updated_at  :datetime        
#
 
#START:belongs_to
class LineItem < ActiveRecord::Base
  belongs_to :order
  belongs_to :product
#END:belongs_to
 
  def self.from_cart_item(cart_item)
    li = self.new
    li.product     = cart_item.product
    li.quantity    = cart_item.quantity
    li.total_price = cart_item.price
    li
  end
 
#START:belongs_to
end
#END:belongs_to
cp -v /home/rubys/git/awdwr/data/migrate/029* db/migrate
`/home/rubys/git/awdwr/data/migrate/029_add_customer_name_index_to_orders.rb' -> `db/migrate/029_add_customer_name_index_to_orders.rb'
rake db:migrate
mv 029_add_customer_name_index_to_orders.rb 20100301000018_add_customer_name_index_to_orders.rb
DEPRECATION WARNING: Rake tasks in /home/rubys/git/awdwr/work/migration/vendor/plugins/annotate_models/tasks/annotate_models_tasks.rake are deprecated. Use lib/tasks instead. (called from /home/rubys/git/awdwr/work/migration/Rakefile:7)
(in /home/rubys/git/awdwr/work/migration)
==  AddCustomerNameIndexToOrders: migrating ===================================
-- add_index(:orders, :name)
   -> 0.0012s
==  AddCustomerNameIndexToOrders: migrated (0.0013s) ==========================
 
rake annotate_models
DEPRECATION WARNING: Rake tasks in /home/rubys/git/awdwr/work/migration/vendor/plugins/annotate_models/tasks/annotate_models_tasks.rake are deprecated. Use lib/tasks instead. (called from /home/rubys/git/awdwr/work/migration/Rakefile:7)
(in /home/rubys/git/awdwr/work/migration)
Skipping Cart
Skipping CartItem
Annotating User
Annotating Discount
Annotating Product
Annotating LineItem
Annotating Order
cat app/models/line_item.rb
# == Schema Information
# Schema version: 20100301000018
#
# Table name: line_items
#
#  id          :integer         not null, primary key
#  product_id  :integer         not null
#  order_id    :integer         not null
#  quantity    :integer         not null
#  total_price :decimal(8, 2)   not null
#  created_at  :datetime        
#  updated_at  :datetime        
#
 
#START:belongs_to
class LineItem < ActiveRecord::Base
  belongs_to :order
  belongs_to :product
#END:belongs_to
 
  def self.from_cart_item(cart_item)
    li = self.new
    li.product     = cart_item.product
    li.quantity    = cart_item.quantity
    li.total_price = cart_item.price
    li
  end
 
#START:belongs_to
end
#END:belongs_to
cp -v /home/rubys/git/awdwr/data/migrate/030* db/migrate
`/home/rubys/git/awdwr/data/migrate/030_create_author_book.rb' -> `db/migrate/030_create_author_book.rb'
rake db:migrate
mv 030_create_author_book.rb 20100301000019_create_author_book.rb
DEPRECATION WARNING: Rake tasks in /home/rubys/git/awdwr/work/migration/vendor/plugins/annotate_models/tasks/annotate_models_tasks.rake are deprecated. Use lib/tasks instead. (called from /home/rubys/git/awdwr/work/migration/Rakefile:7)
(in /home/rubys/git/awdwr/work/migration)
==  CreateAuthorBook: migrating ===============================================
-- create_table(:authors_books, {:id=>false})
   -> 0.0014s
==  CreateAuthorBook: migrated (0.0015s) ======================================
 
rake annotate_models
DEPRECATION WARNING: Rake tasks in /home/rubys/git/awdwr/work/migration/vendor/plugins/annotate_models/tasks/annotate_models_tasks.rake are deprecated. Use lib/tasks instead. (called from /home/rubys/git/awdwr/work/migration/Rakefile:7)
(in /home/rubys/git/awdwr/work/migration)
Skipping Cart
Skipping CartItem
Annotating User
Annotating Discount
Annotating Product
Annotating LineItem
Annotating Order
cat app/models/line_item.rb
# == Schema Information
# Schema version: 20100301000019
#
# Table name: line_items
#
#  id          :integer         not null, primary key
#  product_id  :integer         not null
#  order_id    :integer         not null
#  quantity    :integer         not null
#  total_price :decimal(8, 2)   not null
#  created_at  :datetime        
#  updated_at  :datetime        
#
 
#START:belongs_to
class LineItem < ActiveRecord::Base
  belongs_to :order
  belongs_to :product
#END:belongs_to
 
  def self.from_cart_item(cart_item)
    li = self.new
    li.product     = cart_item.product
    li.quantity    = cart_item.quantity
    li.total_price = cart_item.price
    li
  end
 
#START:belongs_to
end
#END:belongs_to
cp -v /home/rubys/git/awdwr/data/migrate/031* db/migrate
`/home/rubys/git/awdwr/data/migrate/031_create_table_tickets.rb' -> `db/migrate/031_create_table_tickets.rb'
rake db:migrate
mv 031_create_table_tickets.rb 20100301000020_create_table_tickets.rb
DEPRECATION WARNING: Rake tasks in /home/rubys/git/awdwr/work/migration/vendor/plugins/annotate_models/tasks/annotate_models_tasks.rake are deprecated. Use lib/tasks instead. (called from /home/rubys/git/awdwr/work/migration/Rakefile:7)
(in /home/rubys/git/awdwr/work/migration)
==  CreateTableTickets: migrating =============================================
-- create_table(:tickets, {:primary_key=>:number})
   -> 0.0015s
==  CreateTableTickets: migrated (0.0016s) ====================================
 
rake annotate_models
DEPRECATION WARNING: Rake tasks in /home/rubys/git/awdwr/work/migration/vendor/plugins/annotate_models/tasks/annotate_models_tasks.rake are deprecated. Use lib/tasks instead. (called from /home/rubys/git/awdwr/work/migration/Rakefile:7)
(in /home/rubys/git/awdwr/work/migration)
Skipping Cart
Skipping CartItem
Annotating User
Annotating Discount
Annotating Product
Annotating LineItem
Annotating Order
cat app/models/line_item.rb
# == Schema Information
# Schema version: 20100301000020
#
# Table name: line_items
#
#  id          :integer         not null, primary key
#  product_id  :integer         not null
#  order_id    :integer         not null
#  quantity    :integer         not null
#  total_price :decimal(8, 2)   not null
#  created_at  :datetime        
#  updated_at  :datetime        
#
 
#START:belongs_to
class LineItem < ActiveRecord::Base
  belongs_to :order
  belongs_to :product
#END:belongs_to
 
  def self.from_cart_item(cart_item)
    li = self.new
    li.product     = cart_item.product
    li.quantity    = cart_item.quantity
    li.total_price = cart_item.price
    li
  end
 
#START:belongs_to
end
#END:belongs_to
cp -v /home/rubys/git/awdwr/data/migrate/032* db/migrate
`/home/rubys/git/awdwr/data/migrate/032_test_discounts.rb' -> `db/migrate/032_test_discounts.rb'
rake db:migrate
mv 032_test_discounts.rb 20100301000021_test_discounts.rb
DEPRECATION WARNING: Rake tasks in /home/rubys/git/awdwr/work/migration/vendor/plugins/annotate_models/tasks/annotate_models_tasks.rake are deprecated. Use lib/tasks instead. (called from /home/rubys/git/awdwr/work/migration/Rakefile:7)
rake aborted!
An error has occurred, this and all later migrations canceled:

    
uninitialized constant TestDiscounts::Sku

    
(See full trace by running task with --trace)
(in /home/rubys/git/awdwr/work/migration)
==  TestDiscounts: migrating ==================================================
==  TestDiscounts: reverting ==================================================
==  TestDiscounts: reverted (0.0323s) =========================================
 
rm db/migrate/20100301000021_test_discounts.rb
rake annotate_models
DEPRECATION WARNING: Rake tasks in /home/rubys/git/awdwr/work/migration/vendor/plugins/annotate_models/tasks/annotate_models_tasks.rake are deprecated. Use lib/tasks instead. (called from /home/rubys/git/awdwr/work/migration/Rakefile:7)
(in /home/rubys/git/awdwr/work/migration)
Skipping Cart
Skipping CartItem
Annotating User
Annotating Discount
Annotating Product
Annotating LineItem
Annotating Order
cat app/models/line_item.rb
# == Schema Information
# Schema version: 20100301000020
#
# Table name: line_items
#
#  id          :integer         not null, primary key
#  product_id  :integer         not null
#  order_id    :integer         not null
#  quantity    :integer         not null
#  total_price :decimal(8, 2)   not null
#  created_at  :datetime        
#  updated_at  :datetime        
#
 
#START:belongs_to
class LineItem < ActiveRecord::Base
  belongs_to :order
  belongs_to :product
#END:belongs_to
 
  def self.from_cart_item(cart_item)
    li = self.new
    li.product     = cart_item.product
    li.quantity    = cart_item.quantity
    li.total_price = cart_item.price
    li
  end
 
#START:belongs_to
end
#END:belongs_to
mkdir db/migrate/dev_data
cp /home/rubys/git/awdwr/data/migrate/users.yml db/migrate/dev_data
rake db:migrate
DEPRECATION WARNING: Rake tasks in /home/rubys/git/awdwr/work/migration/vendor/plugins/annotate_models/tasks/annotate_models_tasks.rake are deprecated. Use lib/tasks instead. (called from /home/rubys/git/awdwr/work/migration/Rakefile:7)
(in /home/rubys/git/awdwr/work/migration)
rake annotate_models
DEPRECATION WARNING: Rake tasks in /home/rubys/git/awdwr/work/migration/vendor/plugins/annotate_models/tasks/annotate_models_tasks.rake are deprecated. Use lib/tasks instead. (called from /home/rubys/git/awdwr/work/migration/Rakefile:7)
(in /home/rubys/git/awdwr/work/migration)
Skipping Cart
Skipping CartItem
Annotating User
Annotating Discount
Annotating Product
Annotating LineItem
Annotating Order
cat app/models/line_item.rb
# == Schema Information
# Schema version: 20100301000020
#
# Table name: line_items
#
#  id          :integer         not null, primary key
#  product_id  :integer         not null
#  order_id    :integer         not null
#  quantity    :integer         not null
#  total_price :decimal(8, 2)   not null
#  created_at  :datetime        
#  updated_at  :datetime        
#
 
#START:belongs_to
class LineItem < ActiveRecord::Base
  belongs_to :order
  belongs_to :product
#END:belongs_to
 
  def self.from_cart_item(cart_item)
    li = self.new
    li.product     = cart_item.product
    li.quantity    = cart_item.quantity
    li.total_price = cart_item.price
    li
  end
 
#START:belongs_to
end
#END:belongs_to
cp -v /home/rubys/git/awdwr/data/migrate/034* db/migrate
`/home/rubys/git/awdwr/data/migrate/034_load_user_data.rb' -> `db/migrate/034_load_user_data.rb'
rake db:migrate
mv 034_load_user_data.rb 20100301000021_load_user_data.rb
DEPRECATION WARNING: Rake tasks in /home/rubys/git/awdwr/work/migration/vendor/plugins/annotate_models/tasks/annotate_models_tasks.rake are deprecated. Use lib/tasks instead. (called from /home/rubys/git/awdwr/work/migration/Rakefile:7)
(in /home/rubys/git/awdwr/work/migration)
==  LoadUserData: migrating ===================================================
==  LoadUserData: reverting ===================================================
==  LoadUserData: reverted (0.0362s) ==========================================
 
==  LoadUserData: migrated (0.0460s) ==========================================
 
rake annotate_models
DEPRECATION WARNING: Rake tasks in /home/rubys/git/awdwr/work/migration/vendor/plugins/annotate_models/tasks/annotate_models_tasks.rake are deprecated. Use lib/tasks instead. (called from /home/rubys/git/awdwr/work/migration/Rakefile:7)
(in /home/rubys/git/awdwr/work/migration)
Skipping Cart
Skipping CartItem
Annotating User
Annotating Discount
Annotating Product
Annotating LineItem
Annotating Order
cat app/models/line_item.rb
# == Schema Information
# Schema version: 20100301000021
#
# Table name: line_items
#
#  id          :integer         not null, primary key
#  product_id  :integer         not null
#  order_id    :integer         not null
#  quantity    :integer         not null
#  total_price :decimal(8, 2)   not null
#  created_at  :datetime        
#  updated_at  :datetime        
#
 
#START:belongs_to
class LineItem < ActiveRecord::Base
  belongs_to :order
  belongs_to :product
#END:belongs_to
 
  def self.from_cart_item(cart_item)
    li = self.new
    li.product     = cart_item.product
    li.quantity    = cart_item.quantity
    li.total_price = cart_item.price
    li
  end
 
#START:belongs_to
end
#END:belongs_to
cp -v /home/rubys/git/awdwr/data/migrate/035* db/migrate
`/home/rubys/git/awdwr/data/migrate/035_change_price_to_integer.rb' -> `db/migrate/035_change_price_to_integer.rb'
rake db:migrate
mv 035_change_price_to_integer.rb 20100301000022_change_price_to_integer.rb
DEPRECATION WARNING: Rake tasks in /home/rubys/git/awdwr/work/migration/vendor/plugins/annotate_models/tasks/annotate_models_tasks.rake are deprecated. Use lib/tasks instead. (called from /home/rubys/git/awdwr/work/migration/Rakefile:7)
(in /home/rubys/git/awdwr/work/migration)
==  ChangePriceToInteger: migrating ===========================================
-- change_column(:line_items, :total_price, :integer)
   -> 0.0166s
==  ChangePriceToInteger: migrated (0.0564s) ==================================
 
rake annotate_models
DEPRECATION WARNING: Rake tasks in /home/rubys/git/awdwr/work/migration/vendor/plugins/annotate_models/tasks/annotate_models_tasks.rake are deprecated. Use lib/tasks instead. (called from /home/rubys/git/awdwr/work/migration/Rakefile:7)
(in /home/rubys/git/awdwr/work/migration)
Skipping Cart
Skipping CartItem
Annotating User
Annotating Discount
Annotating Product
Annotating LineItem
Annotating Order
cat app/models/line_item.rb
# == Schema Information
# Schema version: 20100301000022
#
# Table name: line_items
#
#  id          :integer         not null, primary key
#  product_id  :integer         not null
#  order_id    :integer         not null
#  quantity    :integer         not null
#  total_price :integer         not null
#  created_at  :datetime        
#  updated_at  :datetime        
#
 
#START:belongs_to
class LineItem < ActiveRecord::Base
  belongs_to :order
  belongs_to :product
#END:belongs_to
 
  def self.from_cart_item(cart_item)
    li = self.new
    li.product     = cart_item.product
    li.quantity    = cart_item.quantity
    li.total_price = cart_item.price
    li
  end
 
#START:belongs_to
end
#END:belongs_to
cp -v /home/rubys/git/awdwr/data/migrate/036* db/migrate
`/home/rubys/git/awdwr/data/migrate/036_total_price_to_unit.rb' -> `db/migrate/036_total_price_to_unit.rb'
rake db:migrate
mv 036_total_price_to_unit.rb 20100301000023_total_price_to_unit.rb
DEPRECATION WARNING: Rake tasks in /home/rubys/git/awdwr/work/migration/vendor/plugins/annotate_models/tasks/annotate_models_tasks.rake are deprecated. Use lib/tasks instead. (called from /home/rubys/git/awdwr/work/migration/Rakefile:7)
(in /home/rubys/git/awdwr/work/migration)
==  TotalPriceToUnit: migrating ===============================================
-- add_column(:line_items, :unit_price, :decimal, {:precision=>8, :scale=>2})
   -> 0.0011s
==  TotalPriceToUnit: migrated (0.0405s) ======================================
 
rake annotate_models
DEPRECATION WARNING: Rake tasks in /home/rubys/git/awdwr/work/migration/vendor/plugins/annotate_models/tasks/annotate_models_tasks.rake are deprecated. Use lib/tasks instead. (called from /home/rubys/git/awdwr/work/migration/Rakefile:7)
(in /home/rubys/git/awdwr/work/migration)
Skipping Cart
Skipping CartItem
Annotating User
Annotating Discount
Annotating Product
Annotating LineItem
Annotating Order
cat app/models/line_item.rb
# == Schema Information
# Schema version: 20100301000023
#
# Table name: line_items
#
#  id          :integer         not null, primary key
#  product_id  :integer         not null
#  order_id    :integer         not null
#  quantity    :integer         not null
#  total_price :integer         not null
#  created_at  :datetime        
#  updated_at  :datetime        
#  unit_price  :decimal(8, 2)   
#
 
#START:belongs_to
class LineItem < ActiveRecord::Base
  belongs_to :order
  belongs_to :product
#END:belongs_to
 
  def self.from_cart_item(cart_item)
    li = self.new
    li.product     = cart_item.product
    li.quantity    = cart_item.quantity
    li.total_price = cart_item.price
    li
  end
 
#START:belongs_to
end
#END:belongs_to
cp -v /home/rubys/git/awdwr/data/migrate/037* db/migrate
`/home/rubys/git/awdwr/data/migrate/037_add_foreign_key.rb' -> `db/migrate/037_add_foreign_key.rb'
cp -v /home/rubys/git/awdwr/data/migrate/migration_helpers.rb lib
`/home/rubys/git/awdwr/data/migrate/migration_helpers.rb' -> `lib/migration_helpers.rb'
rake db:migrate
mv 037_add_foreign_key.rb 20100301000024_add_foreign_key.rb
DEPRECATION WARNING: Rake tasks in /home/rubys/git/awdwr/work/migration/vendor/plugins/annotate_models/tasks/annotate_models_tasks.rake are deprecated. Use lib/tasks instead. (called from /home/rubys/git/awdwr/work/migration/Rakefile:7)
(in /home/rubys/git/awdwr/work/migration)
==  AddForeignKey: migrating ==================================================
-- execute("\n      CREATE TRIGGER fk_line_items_products_insert\n      BEFORE INSERT ON line_items\n      FOR EACH ROW BEGIN\n        SELECT \n\t  RAISE(ABORT, \"constraint violation: fk_line_items_products\")\n\tWHERE \n\t  (SELECT id FROM products WHERE id = NEW.product_id) IS NULL;\n      END;\n    ")
   -> 0.0010s
-- execute("\n      CREATE TRIGGER fk_line_items_products_update\n      BEFORE UPDATE ON line_items\n      FOR EACH ROW BEGIN\n        SELECT \n\t  RAISE(ABORT, \"constraint violation: fk_line_items_products\")\n\tWHERE \n\t  (SELECT id FROM products WHERE id = NEW.product_id) IS NULL;\n      END;\n    ")
   -> 0.0004s
-- execute("\n      CREATE TRIGGER fk_line_items_products_delete\n      BEFORE DELETE ON products\n      FOR EACH ROW BEGIN\n        SELECT \n\t  RAISE(ABORT, \"constraint violation: fk_line_items_products\")\n\tWHERE \n\t  (SELECT id FROM line_items WHERE product_id = OLD.id) IS NOT NULL;\n      END;\n    ")
   -> 0.0006s
-- execute("\n      CREATE TRIGGER fk_line_items_orders_insert\n      BEFORE INSERT ON line_items\n      FOR EACH ROW BEGIN\n        SELECT \n\t  RAISE(ABORT, \"constraint violation: fk_line_items_orders\")\n\tWHERE \n\t  (SELECT id FROM orders WHERE id = NEW.order_id) IS NULL;\n      END;\n    ")
   -> 0.0003s
-- execute("\n      CREATE TRIGGER fk_line_items_orders_update\n      BEFORE UPDATE ON line_items\n      FOR EACH ROW BEGIN\n        SELECT \n\t  RAISE(ABORT, \"constraint violation: fk_line_items_orders\")\n\tWHERE \n\t  (SELECT id FROM orders WHERE id = NEW.order_id) IS NULL;\n      END;\n    ")
   -> 0.0004s
-- execute("\n      CREATE TRIGGER fk_line_items_orders_delete\n      BEFORE DELETE ON orders\n      FOR EACH ROW BEGIN\n        SELECT \n\t  RAISE(ABORT, \"constraint violation: fk_line_items_orders\")\n\tWHERE \n\t  (SELECT id FROM line_items WHERE order_id = OLD.id) IS NOT NULL;\n      END;\n    ")
   -> 0.0004s
==  AddForeignKey: migrated (0.0074s) =========================================
 
rake annotate_models
DEPRECATION WARNING: Rake tasks in /home/rubys/git/awdwr/work/migration/vendor/plugins/annotate_models/tasks/annotate_models_tasks.rake are deprecated. Use lib/tasks instead. (called from /home/rubys/git/awdwr/work/migration/Rakefile:7)
(in /home/rubys/git/awdwr/work/migration)
Skipping Cart
Skipping CartItem
Annotating User
Annotating Discount
Annotating Product
Annotating LineItem
Annotating Order
cat app/models/line_item.rb
# == Schema Information
# Schema version: 20100301000024
#
# Table name: line_items
#
#  id          :integer         not null, primary key
#  product_id  :integer         not null
#  order_id    :integer         not null
#  quantity    :integer         not null
#  total_price :integer         not null
#  created_at  :datetime        
#  updated_at  :datetime        
#  unit_price  :decimal(8, 2)   
#
 
#START:belongs_to
class LineItem < ActiveRecord::Base
  belongs_to :order
  belongs_to :product
#END:belongs_to
 
  def self.from_cart_item(cart_item)
    li = self.new
    li.product     = cart_item.product
    li.quantity    = cart_item.quantity
    li.total_price = cart_item.price
    li
  end
 
#START:belongs_to
end
#END:belongs_to

18 Active Record: The Basics 16 Active Support