From: Tom Hughes Date: Thu, 9 Apr 2009 15:09:38 +0000 (+0000) Subject: Fix primary key creation for ACL table. X-Git-Tag: live~7577^2~28 X-Git-Url: https://git.openstreetmap.org/rails.git/commitdiff_plain/2e1414b229266eb2e263abf0ae94bd94a588b7ba Fix primary key creation for ACL table. --- diff --git a/db/migrate/018_create_acls.rb b/db/migrate/018_create_acls.rb index 3606bd670..c9fd1f3e7 100644 --- a/db/migrate/018_create_acls.rb +++ b/db/migrate/018_create_acls.rb @@ -1,17 +1,15 @@ class CreateAcls < ActiveRecord::Migration def self.up create_table "acls", myisam_table do |t| - t.column "id", :integer, :null => false - t.column "address", :integer, :null => false - t.column "netmask", :integer, :null => false - t.column "k", :string, :null => false + t.column "id", :integer_pk, :null => false + t.column "address", :integer, :null => false + t.column "netmask", :integer, :null => false + t.column "k", :string, :null => false t.column "v", :string end - add_primary_key "acls", ["id"] add_index "acls", ["k"], :name => "acls_k_idx" - change_column "acls", "id", :integer, :null => false, :options => "AUTO_INCREMENT" change_column "acls", "address", :integer, :null => false, :unsigned => true change_column "acls", "netmask", :integer, :null => false, :unsigned => true end diff --git a/lib/migrate.rb b/lib/migrate.rb index 3b1e46fb8..bb8ffa6e8 100644 --- a/lib/migrate.rb +++ b/lib/migrate.rb @@ -46,6 +46,7 @@ module ActiveRecord types = old_native_database_types types[:bigint] = { :name => "bigint", :limit => 20 } types[:double] = { :name => "double" } + types[:integer_pk] = { :name => "integer DEFAULT NULL auto_increment PRIMARY KEY" } types[:bigint_pk] = { :name => "bigint(20) DEFAULT NULL auto_increment PRIMARY KEY" } types[:bigint_pk_64] = { :name => "bigint(64) DEFAULT NULL auto_increment PRIMARY KEY" } types[:bigint_auto_64] = { :name => "bigint(64) DEFAULT NULL auto_increment" } @@ -106,6 +107,7 @@ module ActiveRecord def native_database_types types = old_native_database_types types[:double] = { :name => "double precision" } + types[:integer_pk] = { :name => "serial PRIMARY KEY" } types[:bigint_pk] = { :name => "bigserial PRIMARY KEY" } types[:bigint_pk_64] = { :name => "bigserial PRIMARY KEY" } types[:bigint_auto_64] = { :name => "bigint" } #fixme: need autoincrement?