Skip to content
Browse files

Add Rails 2.3-compatible generator

  • Loading branch information...
1 parent 286a1b7 commit e94af9ca123cd813f9e3c8fb8f86667970d55659 Ariel Salomon committed Sep 1, 2011
View
53 generators/templates/vanity_migration.rb
@@ -0,0 +1,53 @@
+class VanityMigration < ActiveRecord::Migration
+ def self.up
+ create_table :vanity_metrics do |t|
+ t.string :metric_id
+ t.datetime :updated_at
+ end
+ add_index :vanity_metrics, [:metric_id]
+
+ create_table :vanity_metric_values do |t|
+ t.integer :vanity_metric_id
+ t.integer :index
+ t.integer :value
+ t.string :date
+ end
+ add_index :vanity_metric_values, [:vanity_metric_id]
+
+ create_table :vanity_experiments do |t|
+ t.string :experiment_id
+ t.integer :outcome
+ t.datetime :created_at
+ t.datetime :completed_at
+ end
+ add_index :vanity_experiments, [:experiment_id]
+
+ create_table :vanity_conversions do |t|
+ t.integer :vanity_experiment_id
+ t.integer :alternative
+ t.integer :conversions
+ end
+ add_index :vanity_conversions, [:vanity_experiment_id, :alternative], :name => "by_experiment_id_and_alternative"
+
+ create_table :vanity_participants do |t|
+ t.string :experiment_id
+ t.string :identity
+ t.integer :shown
+ t.integer :seen
+ t.integer :converted
+ end
+ add_index :vanity_participants, [:experiment_id]
+ add_index :vanity_participants, [:experiment_id, :identity], :name => "by_experiment_id_and_identity"
+ add_index :vanity_participants, [:experiment_id, :shown], :name => "by_experiment_id_and_shown"
+ add_index :vanity_participants, [:experiment_id, :seen], :name => "by_experiment_id_and_seen"
+ add_index :vanity_participants, [:experiment_id, :converted], :name => "by_experiment_id_and_converted"
+ end
+
+ def self.down
+ drop_table :vanity_metrics
+ drop_table :vanity_metric_values
+ drop_table :vanity_experiments
+ drop_table :vanity_conversions
+ drop_table :vanity_participants
+ end
+end
View
8 generators/vanity_generator.rb
@@ -0,0 +1,8 @@
+class VanityGenerator < Rails::Generator::Base
+ def manifest
+ record do |m|
+ m.migration_template 'vanity_migration.rb', 'db/migrate',
+ :migration_file_name => "vanity_migration"
+ end
+ end
+end
View
8 lib/generators/templates/vanity_migration.rb
@@ -45,9 +45,9 @@ def self.up
def self.down
drop_table :vanity_metrics
- drop_table :vanity_metric_values
- drop_table :vanity_experiments
- drop_table :vanity_conversions
- drop_table :vanity_participants
+ drop_table :vanity_metric_values
+ drop_table :vanity_experiments
+ drop_table :vanity_conversions
+ drop_table :vanity_participants
end
end
View
2 vanity.gemspec
@@ -11,7 +11,7 @@ Gem::Specification.new do |spec|
spec.description = "Mirror, mirror on the wall ..."
spec.post_install_message = "To get started run vanity --help"
- spec.files = Dir["{bin,lib,vendor,test}/**/*", "CHANGELOG", "MIT-LICENSE", "README.rdoc", "Rakefile", "Gemfile", "*.gemspec"]
+ spec.files = Dir["{bin,generators,lib,vendor,test}/**/*", "CHANGELOG", "MIT-LICENSE", "README.rdoc", "Rakefile", "Gemfile", "*.gemspec"]
spec.executable = "vanity"
spec.extra_rdoc_files = "README.rdoc", "CHANGELOG"

0 comments on commit e94af9c

Please sign in to comment.
Something went wrong with that request. Please try again.