Skip to content

Commit 9ecae74

Browse files
committed
rails generator to create the migration
1 parent 18212a0 commit 9ecae74

File tree

2 files changed

+31
-0
lines changed

2 files changed

+31
-0
lines changed
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
require 'rails/generators'
2+
require 'rails/generators/migration'
3+
require 'active_record'
4+
5+
module QC
6+
class InstallGenerator < Rails::Generators::Base
7+
include Rails::Generators::Migration
8+
9+
namespace "queue_classic:install"
10+
self.source_paths << File.join(File.dirname(__FILE__), 'templates')
11+
desc 'Generates (but does not run) a migration to add a queue_classic table.'
12+
13+
def self.next_migration_number(dirname)
14+
next_migration_number = current_migration_number(dirname) + 1
15+
ActiveRecord::Migration.next_migration_number(next_migration_number)
16+
end
17+
18+
def create_migration_file
19+
migration_template 'add_queue_classic.rb', 'db/migrate/add_queue_classic.rb'
20+
end
21+
end
22+
end
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
class AddQueueClassic < ActiveRecord::Migration
2+
def self.up
3+
QC::Setup.create
4+
end
5+
6+
def self.down
7+
QC::Setup.drop
8+
end
9+
end

0 commit comments

Comments
 (0)