diaspora/db/migrate/20110926120220_fix_indexes_to_serivces.rb
Andreas Schneider df86bc5799 db: Fixed the migration of the database.
The limit down to 127 is needed cause of a long time bug in mysql. The
error message looks like this when creating an index.

Mysql2::Error: Specified key was too long; max key length is 1000 bytes

So with utf8 (3 bytes for one char) you exceed this with two
varchar(255).

See http://bugs.mysql.com/bug.php?id=4541 guru meditation

Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2011-09-26 13:05:00 +02:00

14 lines
460 B
Ruby

class FixIndexesToSerivces < ActiveRecord::Migration
# This alters the tables to avoid a mysql bug
# See http://bugs.joindiaspora.com/issues/835
def self.up
remove_index :services, :column => [:type, :uid]
change_column(:services, :type, :string, :limit => 127)
change_column(:services, :uid, :string, :limit => 127)
add_index :services, [:type, :uid]
end
def self.down
remove_index :services, :column => [:type, :uid]
end
end