Commit d34e8781 authored by Lin Jen-Shin's avatar Lin Jen-Shin

Remove old project_id index and make sure mysql work

parent 5eb4a472
...@@ -6,18 +6,28 @@ class AddUniqueConstraintToCiVariables < ActiveRecord::Migration ...@@ -6,18 +6,28 @@ class AddUniqueConstraintToCiVariables < ActiveRecord::Migration
disable_ddl_transaction! disable_ddl_transaction!
def up def up
unless index_exists?(:ci_variables, columns) unless this_index_exists?
add_concurrent_index(:ci_variables, columns, unique: true) add_concurrent_index(:ci_variables, columns, name: index_name, unique: true)
end end
end end
def down def down
if index_exists?(:ci_variables, columns) && Gitlab::Database.postgresql? if this_index_exists? && Gitlab::Database.postgresql?
remove_concurrent_index(:ci_variables, columns) remove_concurrent_index(:ci_variables, columns, name: index_name)
end end
end end
private
def this_index_exists?
index_exists?(:ci_variables, name: index_name)
end
def columns def columns
@columns ||= [:project_id, :key, :environment_scope] @columns ||= [:project_id, :key, :environment_scope]
end end
def index_name
'index_ci_variables_on_project_id_and_key_and_environment_scope'
end
end end
class RemoveCiVariablesProjectIdIndex < ActiveRecord::Migration
include Gitlab::Database::MigrationHelpers
DOWNTIME = false
disable_ddl_transaction!
def up
if index_exists?(:ci_variables, :project_id)
remove_concurrent_index(:ci_variables, :project_id)
end
end
def down
unless index_exists?(:ci_variables, :project_id)
add_concurrent_index(:ci_variables, :project_id)
end
end
end
...@@ -11,7 +11,7 @@ ...@@ -11,7 +11,7 @@
# #
# It's strongly recommended that you check this file into your version control system. # It's strongly recommended that you check this file into your version control system.
ActiveRecord::Schema.define(version: 20170622135728) do ActiveRecord::Schema.define(version: 20170623080805) do
# These are extensions that must be enabled in order to support this database # These are extensions that must be enabled in order to support this database
enable_extension "plpgsql" enable_extension "plpgsql"
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment