Merge branch 'test-db-rollback' into 'master'
Add a test which would rollback db and migrate again Closes #29106 See merge request !9908
This commit is contained in:
commit
9226ce9e30
11 changed files with 28 additions and 9 deletions
|
@ -224,6 +224,14 @@ rake db:migrate:reset:
|
|||
script:
|
||||
- bundle exec rake db:migrate:reset
|
||||
|
||||
rake db:rollback:
|
||||
stage: test
|
||||
<<: *use-db
|
||||
<<: *dedicated-runner
|
||||
script:
|
||||
- bundle exec rake db:rollback STEP=120
|
||||
- bundle exec rake db:migrate
|
||||
|
||||
rake db:seed_fu:
|
||||
stage: test
|
||||
<<: *use-db
|
||||
|
|
|
@ -12,8 +12,8 @@ class AddGroupIdToLabels < ActiveRecord::Migration
|
|||
end
|
||||
|
||||
def down
|
||||
remove_foreign_key :labels, column: :group_id
|
||||
remove_index :labels, :group_id if index_exists? :labels, :group_id
|
||||
remove_foreign_key :labels, :namespaces, column: :group_id
|
||||
remove_column :labels, :group_id
|
||||
end
|
||||
end
|
||||
|
|
|
@ -32,8 +32,8 @@ class AddPipelineIdToMergeRequestMetrics < ActiveRecord::Migration
|
|||
end
|
||||
|
||||
def down
|
||||
remove_foreign_key :merge_request_metrics, column: :pipeline_id
|
||||
remove_index :merge_request_metrics, :pipeline_id if index_exists? :merge_request_metrics, :pipeline_id
|
||||
remove_foreign_key :merge_request_metrics, :ci_commits, column: :pipeline_id
|
||||
remove_column :merge_request_metrics, :pipeline_id
|
||||
end
|
||||
end
|
||||
|
|
|
@ -9,6 +9,7 @@ class AddProjectIdToSubscriptions < ActiveRecord::Migration
|
|||
end
|
||||
|
||||
def down
|
||||
remove_foreign_key :subscriptions, column: :project_id
|
||||
remove_column :subscriptions, :project_id
|
||||
end
|
||||
end
|
||||
|
|
|
@ -16,8 +16,9 @@ class MigrateProjectStatistics < ActiveRecord::Migration
|
|||
remove_column :projects, :commit_count
|
||||
end
|
||||
|
||||
# rubocop: disable Migration/AddColumn
|
||||
def down
|
||||
add_column_with_default :projects, :repository_size, :float, default: 0.0
|
||||
add_column_with_default :projects, :commit_count, :integer, default: 0
|
||||
add_column :projects, :repository_size, :float, default: 0.0
|
||||
add_column :projects, :commit_count, :integer, default: 0
|
||||
end
|
||||
end
|
||||
|
|
|
@ -12,7 +12,7 @@ class CreateEnvironmentNameUniqueIndex < ActiveRecord::Migration
|
|||
end
|
||||
|
||||
def down
|
||||
remove_index :environments, [:project_id, :name], unique: true
|
||||
add_concurrent_index :environments, [:project_id, :name]
|
||||
remove_index :environments, [:project_id, :name]
|
||||
add_concurrent_index :environments, [:project_id, :name], unique: true
|
||||
end
|
||||
end
|
||||
|
|
|
@ -14,6 +14,6 @@ class AddUniqueIndexForEnvironmentSlug < ActiveRecord::Migration
|
|||
end
|
||||
|
||||
def down
|
||||
remove_index :environments, [:project_id, :slug], unique: true if index_exists? :environments, [:project_id, :slug]
|
||||
remove_index :environments, [:project_id, :slug] if index_exists? :environments, [:project_id, :slug]
|
||||
end
|
||||
end
|
||||
|
|
|
@ -17,6 +17,6 @@ class AddLowerPathIndexToRoutes < ActiveRecord::Migration
|
|||
def down
|
||||
return unless Gitlab::Database.postgresql?
|
||||
|
||||
remove_index :routes, name: :index_on_routes_lower_path
|
||||
remove_index :routes, name: :index_on_routes_lower_path if index_exists?(:routes, name: :index_on_routes_lower_path)
|
||||
end
|
||||
end
|
||||
|
|
|
@ -49,6 +49,9 @@ class AddForeignKeysToTimelogs < ActiveRecord::Migration
|
|||
Timelog.where('issue_id IS NOT NULL').update_all("trackable_id = issue_id, trackable_type = 'Issue'")
|
||||
Timelog.where('merge_request_id IS NOT NULL').update_all("trackable_id = merge_request_id, trackable_type = 'MergeRequest'")
|
||||
|
||||
remove_foreign_key :timelogs, name: 'fk_timelogs_issues_issue_id'
|
||||
remove_foreign_key :timelogs, name: 'fk_timelogs_merge_requests_merge_request_id'
|
||||
|
||||
remove_columns :timelogs, :issue_id, :merge_request_id
|
||||
end
|
||||
end
|
||||
|
|
|
@ -8,4 +8,9 @@ class AddIndexToProjectAuthorizations < ActiveRecord::Migration
|
|||
def up
|
||||
add_concurrent_index(:project_authorizations, :project_id)
|
||||
end
|
||||
|
||||
def down
|
||||
remove_index(:project_authorizations, :project_id) if
|
||||
Gitlab::Database.postgresql?
|
||||
end
|
||||
end
|
||||
|
|
|
@ -18,6 +18,7 @@ class RemoveTrackableColumnsFromTimelogs < ActiveRecord::Migration
|
|||
# disable_ddl_transaction!
|
||||
|
||||
def change
|
||||
remove_columns :timelogs, :trackable_id, :trackable_type
|
||||
remove_column :timelogs, :trackable_id, :integer
|
||||
remove_column :timelogs, :trackable_type, :string
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue