aboutsummaryrefslogtreecommitdiffstats
path: root/lib/generators
diff options
context:
space:
mode:
Diffstat (limited to 'lib/generators')
-rw-r--r--lib/generators/acts_as_xapian/USAGE1
-rw-r--r--lib/generators/acts_as_xapian/acts_as_xapian_generator.rb10
-rw-r--r--lib/generators/acts_as_xapian/templates/migration.rb14
3 files changed, 25 insertions, 0 deletions
diff --git a/lib/generators/acts_as_xapian/USAGE b/lib/generators/acts_as_xapian/USAGE
new file mode 100644
index 000000000..2d027c46f
--- /dev/null
+++ b/lib/generators/acts_as_xapian/USAGE
@@ -0,0 +1 @@
+./script/generate acts_as_xapian
diff --git a/lib/generators/acts_as_xapian/acts_as_xapian_generator.rb b/lib/generators/acts_as_xapian/acts_as_xapian_generator.rb
new file mode 100644
index 000000000..434c02cb5
--- /dev/null
+++ b/lib/generators/acts_as_xapian/acts_as_xapian_generator.rb
@@ -0,0 +1,10 @@
+require 'rails/generators/active_record/migration'
+
+class ActsAsXapianGenerator < Rails::Generators::Base
+ include Rails::Generators::Migration
+ extend ActiveRecord::Generators::Migration
+ source_root File.expand_path("../templates", __FILE__)
+ def create_migration_file
+ migration_template "migration.rb", "db/migrate/add_acts_as_xapian_jobs.rb"
+ end
+end
diff --git a/lib/generators/acts_as_xapian/templates/migration.rb b/lib/generators/acts_as_xapian/templates/migration.rb
new file mode 100644
index 000000000..84a9dd766
--- /dev/null
+++ b/lib/generators/acts_as_xapian/templates/migration.rb
@@ -0,0 +1,14 @@
+class CreateActsAsXapian < ActiveRecord::Migration
+ def self.up
+ create_table :acts_as_xapian_jobs do |t|
+ t.column :model, :string, :null => false
+ t.column :model_id, :integer, :null => false
+ t.column :action, :string, :null => false
+ end
+ add_index :acts_as_xapian_jobs, [:model, :model_id], :unique => true
+ end
+ def self.down
+ drop_table :acts_as_xapian_jobs
+ end
+end
+