diff options
author | Josh Susser <josh@hasmanythrough.com> | 2010-03-15 00:53:57 -0700 |
---|---|---|
committer | Josh Susser <josh@hasmanythrough.com> | 2010-12-01 10:46:29 -0800 |
commit | c283cdd63cafdb04784cfcc5094da41c9268c20c (patch) | |
tree | b4368e9028e267d586eeebecf2dd7e6707e612b7 /activerecord/lib/active_record/connection_adapters | |
parent | 7148b933c4865a5140187d7ed792fd6df9b860a4 (diff) | |
download | rails-c283cdd63cafdb04784cfcc5094da41c9268c20c.tar.gz rails-c283cdd63cafdb04784cfcc5094da41c9268c20c.tar.bz2 rails-c283cdd63cafdb04784cfcc5094da41c9268c20c.zip |
Add migrated_at column to schema_migrations table.
Diffstat (limited to 'activerecord/lib/active_record/connection_adapters')
-rw-r--r-- | activerecord/lib/active_record/connection_adapters/abstract/schema_statements.rb | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/activerecord/lib/active_record/connection_adapters/abstract/schema_statements.rb b/activerecord/lib/active_record/connection_adapters/abstract/schema_statements.rb index 4e770c37da..730b1c7425 100644 --- a/activerecord/lib/active_record/connection_adapters/abstract/schema_statements.rb +++ b/activerecord/lib/active_record/connection_adapters/abstract/schema_statements.rb @@ -422,9 +422,17 @@ module ActiveRecord def initialize_schema_migrations_table sm_table = ActiveRecord::Migrator.schema_migrations_table_name - unless table_exists?(sm_table) + if table_exists?(sm_table) + cols = columns(sm_table).collect { |col| col.name } + unless cols.include?("migrated_at") + add_column sm_table, :migrated_at, :datetime + update "UPDATE #{quote_table_name(sm_table)} SET migrated_at = '#{quoted_date(Time.now)}' WHERE migrated_at IS NULL" + change_column sm_table, :migrated_at, :datetime, :null => false + end + else create_table(sm_table, :id => false) do |schema_migrations_table| schema_migrations_table.column :version, :string, :null => false + schema_migrations_table.column :migrated_at, :datetime, :null => false end add_index sm_table, :version, :unique => true, :name => "#{Base.table_name_prefix}unique_schema_migrations#{Base.table_name_suffix}" |