aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib
diff options
context:
space:
mode:
authorRyuta Kamizono <kamipo@gmail.com>2016-01-31 03:19:07 +0900
committerRyuta Kamizono <kamipo@gmail.com>2016-01-31 03:26:57 +0900
commitff16a39922cc3379426724a4bed2122087807b9d (patch)
tree4ee83d96410df341bace6bc0ee7265dad854aace /activerecord/lib
parenta398cd0bcbd39998f1b0313e6fe3f04bf491b3db (diff)
downloadrails-ff16a39922cc3379426724a4bed2122087807b9d.tar.gz
rails-ff16a39922cc3379426724a4bed2122087807b9d.tar.bz2
rails-ff16a39922cc3379426724a4bed2122087807b9d.zip
Make to primary key instead of an unique index for internal tables
Diffstat (limited to 'activerecord/lib')
-rw-r--r--activerecord/lib/active_record/internal_metadata.rb10
-rw-r--r--activerecord/lib/active_record/schema_migration.rb9
2 files changed, 4 insertions, 15 deletions
diff --git a/activerecord/lib/active_record/internal_metadata.rb b/activerecord/lib/active_record/internal_metadata.rb
index 10fee4dca2..641b137851 100644
--- a/activerecord/lib/active_record/internal_metadata.rb
+++ b/activerecord/lib/active_record/internal_metadata.rb
@@ -18,10 +18,6 @@ module ActiveRecord
"#{table_name_prefix}#{ActiveRecord::Base.internal_metadata_table_name}#{table_name_suffix}"
end
- def index_name
- "#{table_name_prefix}unique_#{ActiveRecord::Base.internal_metadata_table_name}#{table_name_suffix}"
- end
-
def []=(key, value)
first_or_initialize(key: key).update_attributes!(value: value)
end
@@ -38,10 +34,8 @@ module ActiveRecord
def create_table
unless table_exists?
connection.create_table(table_name, id: false) do |t|
- t.column :key, :string, null: false, limit: KEY_LIMIT
- t.column :value, :string
- t.index :key, unique: true, name: index_name
-
+ t.string :key, primary_key: true, limit: KEY_LIMIT
+ t.string :value
t.timestamps
end
end
diff --git a/activerecord/lib/active_record/schema_migration.rb b/activerecord/lib/active_record/schema_migration.rb
index 8f0ab2b55b..a5b693c349 100644
--- a/activerecord/lib/active_record/schema_migration.rb
+++ b/activerecord/lib/active_record/schema_migration.rb
@@ -16,22 +16,17 @@ module ActiveRecord
"#{table_name_prefix}#{ActiveRecord::Base.schema_migrations_table_name}#{table_name_suffix}"
end
- def index_name
- "#{table_name_prefix}unique_#{ActiveRecord::Base.schema_migrations_table_name}#{table_name_suffix}"
- end
-
def table_exists?
ActiveSupport::Deprecation.silence { connection.table_exists?(table_name) }
end
def create_table(limit=nil)
unless table_exists?
- version_options = {null: false}
+ version_options = { primary_key: true }
version_options[:limit] = limit if limit
connection.create_table(table_name, id: false) do |t|
- t.column :version, :string, version_options
- t.index :version, unique: true, name: index_name
+ t.string :version, version_options
end
end
end