aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib/active_record/schema_migration.rb
diff options
context:
space:
mode:
authorJeremy Kemper <jeremy@bitsweat.net>2012-12-09 15:52:28 -0700
committerJeremy Kemper <jeremy@bitsweat.net>2012-12-09 15:57:34 -0700
commitcff747d304f008c103a7ba92440400a9a0848bee (patch)
tree88e4ac162d9a90db715abecbbfbfe155c7756d6f /activerecord/lib/active_record/schema_migration.rb
parent3c2c1a46064684a1becc8ae7b6b7fe6eebf9651a (diff)
downloadrails-cff747d304f008c103a7ba92440400a9a0848bee.tar.gz
rails-cff747d304f008c103a7ba92440400a9a0848bee.tar.bz2
rails-cff747d304f008c103a7ba92440400a9a0848bee.zip
Move to the schema-migrations-metadata branch.
Pending work on graceful app upgrades. Revert "Merge pull request #8439 from joshsusser/fixes" This reverts commit ce8ac39338f86388e70356b3a470b3ea443802ae, reversing changes made to b0e7b6f67c984d4b1502e801781ed75fad681633. Revert "Merge pull request #8431 from joshsusser/schemadump" This reverts commit 036d3e1c2b65c4b8cbd23de2e20ad67b9b756182, reversing changes made to 0c692f4d121792117b6a71e5ed590a31c3b9d12e. Revert "Merge branch 'joshsusser-master' into merge" This reverts commit 0c692f4d121792117b6a71e5ed590a31c3b9d12e, reversing changes made to 2e299fca715b083a60222a85e48f9d3b8dd8ce93. Conflicts: activerecord/CHANGELOG.md activerecord/lib/active_record/connection_adapters/abstract/schema_statements.rb activerecord/test/cases/schema_dumper_test.rb
Diffstat (limited to 'activerecord/lib/active_record/schema_migration.rb')
-rw-r--r--activerecord/lib/active_record/schema_migration.rb39
1 files changed, 3 insertions, 36 deletions
diff --git a/activerecord/lib/active_record/schema_migration.rb b/activerecord/lib/active_record/schema_migration.rb
index 6c3cd5b6ba..9830abe7d8 100644
--- a/activerecord/lib/active_record/schema_migration.rb
+++ b/activerecord/lib/active_record/schema_migration.rb
@@ -14,38 +14,17 @@ module ActiveRecord
end
def self.create_table
- if connection.table_exists?(table_name)
- cols = connection.columns(table_name).collect { |col| col.name }
- unless cols.include?("migrated_at")
- connection.add_column(table_name, "migrated_at", :datetime)
- q_table_name = connection.quote_table_name(table_name)
- q_timestamp = connection.quoted_date(Time.now)
- connection.update("UPDATE #{q_table_name} SET migrated_at = '#{q_timestamp}' WHERE migrated_at IS NULL")
- connection.change_column(table_name, "migrated_at", :datetime, :null => false)
- end
- unless cols.include?("fingerprint")
- connection.add_column(table_name, "fingerprint", :string, :limit => 32)
- end
- unless cols.include?("name")
- connection.add_column(table_name, "name", :string)
- end
- else
+ unless connection.table_exists?(table_name)
connection.create_table(table_name, :id => false) do |t|
t.column :version, :string, :null => false
- t.column :migrated_at, :datetime, :null => false
- t.column :fingerprint, :string, :limit => 32
- t.column :name, :string
end
- connection.add_index(table_name, "version", :unique => true, :name => index_name)
+ connection.add_index table_name, :version, :unique => true, :name => index_name
end
- reset_column_information
end
def self.drop_table
if connection.table_exists?(table_name)
- if connection.index_exists?(table_name, "version", :unique => true, :name => index_name)
- connection.remove_index(table_name, :name => index_name)
- end
+ connection.remove_index table_name, :name => index_name
connection.drop_table(table_name)
end
end
@@ -53,17 +32,5 @@ module ActiveRecord
def version
super.to_i
end
-
- # Construct ruby source to include in schema.rb dump for this migration.
- # Pass a string of spaces as +indent+ to allow calling code to control how deeply indented the line is.
- # The generated line includes the migration version, fingerprint, and name. Either fingerprint or name
- # can be an empty string.
- #
- # Example output:
- #
- # migration 20121129235959, "ee4be703f9e6e2fc0f4baddebe6eb8f7", "add_magic_power_to_unicorns"
- def schema_line(indent)
- %Q(#{indent}migration %s, "%s", "%s") % [version, fingerprint, name]
- end
end
end