1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00

Add some attribute readers to migration module.

This commit is contained in:
José Valim 2009-07-13 20:42:25 +02:00
parent b9f4ea7198
commit 25647f7021
4 changed files with 8 additions and 3 deletions

View file

@ -1,4 +1,4 @@
class <%= @migration_class_name %> < ActiveRecord::Migration class <%= migration_class_name %> < ActiveRecord::Migration
def self.up<% attributes.each do |attribute| %> def self.up<% attributes.each do |attribute| %>
<%= migration_action %>_column :<%= table_name %>, :<%= attribute.name %><% if migration_action == 'add' %>, :<%= attribute.type %><% end -%> <%= migration_action %>_column :<%= table_name %>, :<%= attribute.name %><% if migration_action == 'add' %>, :<%= attribute.type %><% end -%>
<%- end %> <%- end %>

View file

@ -1,4 +1,4 @@
class <%= @migration_class_name %> < ActiveRecord::Migration class <%= migration_class_name %> < ActiveRecord::Migration
def self.up def self.up
create_table :<%= table_name %> do |t| create_table :<%= table_name %> do |t|
<% for attribute in attributes -%> <% for attribute in attributes -%>

View file

@ -1,4 +1,4 @@
class <%= @migration_class_name %> < ActiveRecord::Migration class <%= migration_class_name %> < ActiveRecord::Migration
def self.up def self.up
create_table :<%= session_table_name %> do |t| create_table :<%= session_table_name %> do |t|
t.string :session_id, :null => false t.string :session_id, :null => false

View file

@ -5,6 +5,11 @@ module Rails
# just by implementing the next migration number method. # just by implementing the next migration number method.
# #
module Migration 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 # Creates a migration template at the given destination. The difference
# to the default template method is that the migration number is appended # to the default template method is that the migration number is appended