Merge remote branch 'gladiac/835-fixed-mysql-migration'

This commit is contained in:
Raphael 2011-02-03 11:30:14 -08:00
commit 8c9aa2242b
5 changed files with 49 additions and 8 deletions

View file

@ -105,8 +105,8 @@ class CreateSchema < ActiveRecord::Migration
create_table :profiles do |t|
t.string :diaspora_handle
t.string :first_name
t.string :last_name
t.string :first_name, :limit => 127
t.string :last_name, :limit => 127
t.string :image_url
t.string :image_url_small
t.string :image_url_medium

View file

@ -95,8 +95,8 @@ class CreateImportTables < ActiveRecord::Migration
add_index :mongo_invitations, :sender_mongo_id
create_table :mongo_notifications do |t|
t.string :mongo_id
t.string :target_type
t.string :target_mongo_id
t.string :target_type, :limit => 127
t.string :target_mongo_id, :limit => 127
t.string :recipient_mongo_id
t.string :actor_mongo_id
t.string :action
@ -114,8 +114,8 @@ class CreateImportTables < ActiveRecord::Migration
create_table :mongo_profiles do |t|
t.string :diaspora_handle
t.string :first_name
t.string :last_name
t.string :first_name, :limit => 127
t.string :last_name, :limit => 127
t.string :image_url
t.string :image_url_small
t.string :image_url_medium
@ -134,8 +134,8 @@ class CreateImportTables < ActiveRecord::Migration
create_table :mongo_requests do |t|
t.string :mongo_id
t.string :sender_mongo_id
t.string :recipient_mongo_id
t.string :sender_mongo_id, :limit => 127
t.string :recipient_mongo_id, :limit => 127
t.string :aspect_mongo_id
t.timestamps
end

View file

@ -0,0 +1,37 @@
class AlterStringColumns < ActiveRecord::Migration
# This alters the tables to avoid a mysql bug
# See http://bugs.joindiaspora.com/issues/835
def self.up
remove_index :profiles, :column => [:first_name, :searchable]
remove_index :profiles, :column => [:last_name, :searchable]
remove_index :profiles, :column => [:first_name, :last_name, :searchable]
change_column(:profiles, :first_name, :string, :limit => 127)
change_column(:profiles, :last_name, :string, :limit => 127)
add_index :profiles, [:first_name, :searchable]
add_index :profiles, [:last_name, :searchable]
add_index :profiles, [:first_name, :last_name, :searchable]
remove_index :mongo_notifications, :column => [:target_type, :target_mongo_id]
change_column(:mongo_notifications, :target_type, :string, :limit => 127)
change_column(:mongo_notifications, :target_mongo_id, :string, :limit => 127)
add_index :mongo_notifications, [:target_type, :target_mongo_id]
remove_index :mongo_profiles, :column => [:first_name, :searchable]
remove_index :mongo_profiles, :column => [:last_name, :searchable]
remove_index :mongo_profiles, :column => [:first_name, :last_name, :searchable]
change_column(:mongo_profiles, :first_name, :string, :limit => 127)
change_column(:mongo_profiles, :last_name, :string, :limit => 127)
add_index :mongo_profiles, [:first_name, :searchable]
add_index :mongo_profiles, [:last_name, :searchable]
add_index :mongo_profiles, [:first_name, :last_name, :searchable]
remove_index :mongo_requests, :column => :sender_mongo_id
remove_index :mongo_requests, :column => :recipient_mongo_id
remove_index :mongo_requests, :column => [:sender_mongo_id, :recipient_mongo_id]
change_column(:mongo_requests, :sender_mongo_id, :string, :limit => 127)
change_column(:mongo_requests, :recipient_mongo_id, :string, :limit => 127)
add_index :mongo_requests, :sender_mongo_id
add_index :mongo_requests, :recipient_mongo_id
add_index :mongo_requests, [:sender_mongo_id, :recipient_mongo_id], :unique => true
end
end

View file

@ -1,5 +1,7 @@
class AddUniqueIndexOnInvitationServiceAndInvitationIdentifierToUsers < ActiveRecord::Migration
def self.up
change_column(:users, :invitation_service, :string, :limit => 127)
change_column(:users, :invitation_identifier, :string, :limit => 127)
add_index(:users, [:invitation_service, :invitation_identifier], :unique => true)
end

View file

@ -20,11 +20,13 @@ class MakeFieldsNotNull < ActiveRecord::Migration
end
def self.up
remove_index(:profiles, :person_id)
non_nullable_fields.each_pair do |table, columns|
columns.each do |column|
change_column_null(table, column, false)
end
end
add_index :profiles, :person_id
end
def self.down