Permalink
Browse files

Added a generator to create the amazon_products database migration

  • Loading branch information...
1 parent 64207a6 commit 1e678ef4b46e9012346e0c0921d012fe54e7d42c David Eisinger committed Jul 3, 2008
View
13 README
@@ -6,15 +6,10 @@ existing model.
== Setup
This code does not require changing any current database tables. It only requires
-adding one migration for a single new table used to cache responses from Amazon:
-
- ActiveRecord::Base.connection.create_table :amazon_products do |t|
- t.column :asin, :string
- t.column :xml, :text
- t.column :created_at, :datetime, :null => false
- t.column :amazonable_id, :integer, :default => 0, :null => false
- t.column :amazonable_type, :string, :limit => 15, :default => "", :null => false
- end
+adding one migration for a single new table used to cache responses from Amazon.
+Run the following to create the migration:
+
+ script/generate acts_as_amazon_product_migration
== Using acts_as_amazon_product
@@ -0,0 +1,11 @@
+class ActsAsAmazonProductMigrationGenerator < Rails::Generator::Base
+ def manifest
+ record do |m|
+ m.migration_template 'migration.rb', 'db/migrate'
+ end
+ end
+
+ def file_name
+ "acts_as_amazon_product_migration"
+ end
+end
@@ -0,0 +1,16 @@
+class ActsAsAmazonProductMigration < ActiveRecord::Migration
+ def self.up
+ create_table :amazon_products do |t|
+ t.string :asin
+ t.text :xml
+ t.integer :amazonable_id, :default => 0, :null => false
+ t.string :amazonable_type, :limit => 15, :default => "", :null => false
+
+ t.timestamps
+ end
+ end
+
+ def self.down
+ drop_table :amazon_products
+ end
+end

0 comments on commit 1e678ef

Please sign in to comment.