Skip to content

Commit

Permalink
Namespace indexes when copying databases in some cases
Browse files Browse the repository at this point in the history
If copying from a database without a global index namespace (e.g.
MySQL) to a database with a global index namespace (e.g. PostgreSQL),
the previous copying could break if you had indexes with the same
name in both tables.  To work around this, prepend the table name
to the index name when copying.

Note that if the index name exactly matches Sequel's default name,
it will not do any additional namespacing.
  • Loading branch information
jeremyevans committed May 31, 2012
1 parent 452cb31 commit 7f2f6e0
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion bin/sequel
Expand Up @@ -162,10 +162,12 @@ begin
start_time = Time.now
TO_DB = connect_proc[db2]
same_db = DB.database_type==TO_DB.database_type
index_opts = {:same_db=>same_db}
index_opts[:index_names] = :namespace if !DB.global_index_namespace? && TO_DB.global_index_namespace?

puts "Databases connections successful"
schema_migration = eval(DB.dump_schema_migration(:indexes=>false, :same_db=>same_db))
index_migration = eval(DB.dump_indexes_migration(:same_db=>same_db))
index_migration = eval(DB.dump_indexes_migration(index_opts))
fk_migration = eval(DB.dump_foreign_key_migration(:same_db=>same_db))
puts "Migrations dumped successfully"

Expand Down

0 comments on commit 7f2f6e0

Please sign in to comment.