Skip to content
Browse files

Make migration generator work with Rails 3

  • Loading branch information...
1 parent 08dc20b commit c69d728c3af1d6fdd9ace8d7cedd5801bff769fa @lifo lifo committed Jun 3, 2010
View
7 generators/tolk_migration/tolk_migration_generator.rb
@@ -1,7 +0,0 @@
-class TolkMigrationGenerator < Rails::Generator::Base
- def manifest
- record do |m|
- m.migration_template "migrate/create_tolk_tables.rb", "db/migrate", :migration_file_name => "create_tolk_tables"
- end
- end
-end
View
0 ...n/templates/migrate/create_tolk_tables.rb → ...n/templates/migrate/create_tolk_tables.rb
File renamed without changes.
View
19 lib/generators/tolk_migration/tolk_migration_generator.rb
@@ -0,0 +1,19 @@
+class TolkMigrationGenerator < Rails::Generators::Base
+ include Rails::Generators::Migration
+
+ source_root File.expand_path("../templates", __FILE__)
+
+ def create_migration_file
+ migration_template "migrate/create_tolk_tables.rb", "db/migrate/create_tolk_tables.rb"
+ end
+
+ # Implement the required interface for Rails::Generators::Migration.
+ def self.next_migration_number(dirname) #:nodoc:
+ next_migration_number = current_migration_number(dirname) + 1
+ if ActiveRecord::Base.timestamped_migrations
+ [Time.now.utc.strftime("%Y%m%d%H%M%S"), "%.14d" % next_migration_number].max
+ else
+ "%.3d" % next_migration_number
+ end
+ end
+end

0 comments on commit c69d728

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