Commit f7194365 authored by Dmitriy Zaporozhets's avatar Dmitriy Zaporozhets

Refactor migrations in a way it can work with MySQL properly

Signed-off-by: default avatarDmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>
parent 9b912362
......@@ -11,7 +11,7 @@
#
# It's strongly recommended that you check this file into your version control system.
ActiveRecord::Schema.define(version: 20180810155213) do
ActiveRecord::Schema.define(version: 20180807153545) do
# These are extensions that must be enabled in order to support this database
enable_extension "plpgsql"
......
......@@ -22,6 +22,8 @@ class CreatePackagesPackageFiles < ActiveRecord::Migration
t.text :file, null: false
end
add_concurrent_index :packages_package_files, [:package_id, :file_name]
add_concurrent_foreign_key :packages_package_files, :packages_packages,
column: :package_id,
on_delete: :cascade
......@@ -32,6 +34,10 @@ class CreatePackagesPackageFiles < ActiveRecord::Migration
remove_foreign_key :packages_package_files, column: :package_id
end
if index_exists?(:packages_package_files, [:package_id, :file_name])
remove_concurrent_index :packages_package_files, [:package_id, :file_name]
end
if table_exists?(:packages_package_files)
drop_table :packages_package_files
end
......
......@@ -18,6 +18,8 @@ class CreatePackagesMavenMetadata < ActiveRecord::Migration
t.string :path, limit: 512, null: false
end
add_concurrent_index :packages_maven_metadata, [:package_id, :path]
add_concurrent_foreign_key :packages_maven_metadata, :packages_packages,
column: :package_id,
on_delete: :cascade
......@@ -28,6 +30,10 @@ class CreatePackagesMavenMetadata < ActiveRecord::Migration
remove_foreign_key :packages_maven_metadata, column: :package_id
end
if index_exists?(:packages_maven_metadata, [:package_id, :path])
remove_concurrent_index :packages_maven_metadata, [:package_id, :path]
end
if table_exists?(:packages_maven_metadata)
drop_table :packages_maven_metadata
end
......
class AddMoreIndicesToPackages < ActiveRecord::Migration
include Gitlab::Database::MigrationHelpers
DOWNTIME = false
disable_ddl_transaction!
def up
add_concurrent_index :packages_package_files, [:package_id, :file_name]
add_concurrent_index :packages_maven_metadata, [:package_id, :path]
end
def down
remove_concurrent_index :packages_package_files, [:package_id, :file_name]
remove_concurrent_index :packages_maven_metadata, [:package_id, :path]
end
end
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