Commit 6b9608e1 authored by Grzegorz Bizon's avatar Grzegorz Bizon

Fix build stages reference migration

parent 4b0b2f15
...@@ -7,15 +7,11 @@ class AddStageIdToCiBuilds < ActiveRecord::Migration ...@@ -7,15 +7,11 @@ class AddStageIdToCiBuilds < ActiveRecord::Migration
def up def up
add_column :ci_builds, :stage_id, :integer add_column :ci_builds, :stage_id, :integer
add_concurrent_foreign_key :ci_builds, :ci_stages, column: :stage_id, on_delete: :cascade add_concurrent_foreign_key :ci_builds, :ci_stages, column: :stage_id, on_delete: :cascade
add_concurrent_index :ci_builds, :stage_id
end end
def down def down
remove_foreign_key :ci_builds, column: :stage_id remove_foreign_key :ci_builds, column: :stage_id
remove_concurrent_index :ci_builds, :stage_id
remove_column :ci_builds, :stage_id, :integer remove_column :ci_builds, :stage_id, :integer
end end
end end
class RemoveStageIdIndexFromBuilds < ActiveRecord::Migration
include Gitlab::Database::MigrationHelpers
DOWNTIME = false
disable_ddl_transaction!
def up
if index_exists?(:ci_builds, :stage_id)
remove_concurrent_index(:ci_builds, :stage_id)
end
end
def down
# noop
end
end
...@@ -3,6 +3,8 @@ class MigrateBuildStageReference < ActiveRecord::Migration ...@@ -3,6 +3,8 @@ class MigrateBuildStageReference < ActiveRecord::Migration
DOWNTIME = false DOWNTIME = false
disable_ddl_transaction!
def up def up
disable_statement_timeout disable_statement_timeout
......
class AddStageIdIndexToBuilds < ActiveRecord::Migration
include Gitlab::Database::MigrationHelpers
DOWNTIME = false
disable_ddl_transaction!
def up
unless index_exists?(:ci_builds, :stage_id)
add_concurrent_index(:ci_builds, :stage_id)
end
end
def down
if index_exists?(:ci_builds, :stage_id)
remove_concurrent_index(:ci_builds, :stage_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: 20170614115405) do ActiveRecord::Schema.define(version: 20170621102400) 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