# See http://doc.gitlab.com/ce/development/migration_style_guide.html# for more information on how to write migrations for GitLab.classRemoveUniqNameIndexFromNamespace<ActiveRecord::MigrationincludeGitlab::Database::MigrationHelpersdisable_ddl_transaction!DOWNTIME=falsedefupconstraint_name='namespaces_name_key'transactiondoifindex_exists?(:namespaces,:name)remove_index(:namespaces,:name)end# In some bizarre cases PostgreSQL might have a separate unique constraint# that we'll need to drop.ifconstraint_exists?(constraint_name)&&Gitlab::Database.postgresql?execute("ALTER TABLE namespaces DROP CONSTRAINT IF EXISTS #{constraint_name};")endendenddefdownunlessindex_exists?(:namespaces,:name)add_concurrent_index(:namespaces,:name,unique: true)endenddefconstraint_exists?(name)indexes(:namespaces).map(&:name).include?(name)endend