From 25647f70215e38635d16038e71f47730f2717021 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Valim?= Date: Mon, 13 Jul 2009 20:42:25 +0200 Subject: [PATCH] Add some attribute readers to migration module. --- .../active_record/migration/templates/migration.rb | 2 +- .../generators/active_record/model/templates/migration.rb | 2 +- .../active_record/session_migration/templates/migration.rb | 2 +- railties/lib/generators/migration.rb | 5 +++++ 4 files changed, 8 insertions(+), 3 deletions(-) diff --git a/railties/lib/generators/active_record/migration/templates/migration.rb b/railties/lib/generators/active_record/migration/templates/migration.rb index 2851f7cb42..bbb7c53d86 100644 --- a/railties/lib/generators/active_record/migration/templates/migration.rb +++ b/railties/lib/generators/active_record/migration/templates/migration.rb @@ -1,4 +1,4 @@ -class <%= @migration_class_name %> < ActiveRecord::Migration +class <%= migration_class_name %> < ActiveRecord::Migration def self.up<% attributes.each do |attribute| %> <%= migration_action %>_column :<%= table_name %>, :<%= attribute.name %><% if migration_action == 'add' %>, :<%= attribute.type %><% end -%> <%- end %> diff --git a/railties/lib/generators/active_record/model/templates/migration.rb b/railties/lib/generators/active_record/model/templates/migration.rb index 542e9db2fc..1f68487304 100644 --- a/railties/lib/generators/active_record/model/templates/migration.rb +++ b/railties/lib/generators/active_record/model/templates/migration.rb @@ -1,4 +1,4 @@ -class <%= @migration_class_name %> < ActiveRecord::Migration +class <%= migration_class_name %> < ActiveRecord::Migration def self.up create_table :<%= table_name %> do |t| <% for attribute in attributes -%> diff --git a/railties/lib/generators/active_record/session_migration/templates/migration.rb b/railties/lib/generators/active_record/session_migration/templates/migration.rb index 19811d9455..919822af7b 100644 --- a/railties/lib/generators/active_record/session_migration/templates/migration.rb +++ b/railties/lib/generators/active_record/session_migration/templates/migration.rb @@ -1,4 +1,4 @@ -class <%= @migration_class_name %> < ActiveRecord::Migration +class <%= migration_class_name %> < ActiveRecord::Migration def self.up create_table :<%= session_table_name %> do |t| t.string :session_id, :null => false diff --git a/railties/lib/generators/migration.rb b/railties/lib/generators/migration.rb index 2eb7c0a964..5596cc274c 100644 --- a/railties/lib/generators/migration.rb +++ b/railties/lib/generators/migration.rb @@ -5,6 +5,11 @@ module Rails # just by implementing the next migration number method. # module Migration + def self.included(base) #:nodoc: + base.send :attr_reader, :migration_number, + :migration_file_name, + :migration_class_name + end # Creates a migration template at the given destination. The difference # to the default template method is that the migration number is appended