Skip to content

Commit

Permalink
renaming generator to singular
Browse files Browse the repository at this point in the history
  • Loading branch information
cainlevy committed Dec 28, 2007
1 parent a8e1e64 commit 6bb1501
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 0 deletions.
1 change: 1 addition & 0 deletions generators/freemium_migration/USAGE
@@ -0,0 +1 @@
./script/generate freemium_migrations
13 changes: 13 additions & 0 deletions generators/freemium_migration/freemium_migrations_generator.rb
@@ -0,0 +1,13 @@
class FreemiumMigrationsGenerator < Rails::Generator::NamedBase
def initialize(runtime_args, runtime_options = {})
runtime_args.insert(0, 'migrations')
super
end

def manifest
record do |m|
m.class_collisions "Subscription", "SubscriptionPlan"
m.migration_template "migration.erb", "db/migrate", :migration_file_name => "create_subscription_and_plan"
end
end
end
28 changes: 28 additions & 0 deletions generators/freemium_migration/templates/migration.erb
@@ -0,0 +1,28 @@
class <%= migration_name %> < ActiveRecord::Migration
def self.up
create_table :subscription_plans, :force => true do |t|
t.column :name, :string, :null => false
t.column :rate_cents, :integer, :null => false
t.column :yearly, :boolean, :null => false
end

create_table :subscriptions, :force => true do |t|
t.column :subscribable_id, :integer, :null => false
t.column :subscribable_type, :string, :null => false
t.column :subscription_plan_id, :integer, :null => false
t.column :paid_through, :date, :null => false
t.column :expire_on, :date, :null => true
t.column :billing_key, :string, :null => true
t.column :last_transaction_at, :datetime, :null => true
end

add_index :subscriptions, :account_id
add_index :subscriptions, :account_type
add_index :subscriptions, :paid_through
end

def self.down
drop_table :subscription_plans
drop_table :subscriptions
end
end

0 comments on commit 6bb1501

Please sign in to comment.