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

Merge branch 'pb-update-check-migrations-for-decomposed' into 'master'

Update db:check-migrations for decomposed CI

See merge request gitlab-org/gitlab!75557
parents 312d144a 4ba07c95
......@@ -346,8 +346,8 @@ rspec fast_spec_helper minimal:
db:rollback:
extends: .db-job-base
script:
- scripts/db_migrate VERSION=20181228175414
- scripts/db_migrate SKIP_SCHEMA_VERSION_CHECK=true
- scripts/db_tasks db:migrate VERSION=20181228175414
- scripts/db_tasks db:migrate SKIP_SCHEMA_VERSION_CHECK=true
db:migrate:reset:
extends: .db-job-base
......@@ -372,15 +372,13 @@ db:migrate-from-previous-major-version:
- git checkout -f $CI_COMMIT_SHA
- SETUP_DB=false USE_BUNDLE_INSTALL=true bash scripts/prepare_build.sh
script:
- run_timed_command "scripts/db_migrate"
- run_timed_command "scripts/db_tasks db:migrate"
db:migrate-from-previous-major-version-decomposed:
extends:
- db:migrate-from-previous-major-version
- .decomposed-database
- .rails:rules:decomposed-databases
variables:
GITLAB_MIGRATE_MAIN_ONLY: "true"
.db:check-schema-base:
extends:
......@@ -388,7 +386,7 @@ db:migrate-from-previous-major-version-decomposed:
variables:
TAG_TO_CHECKOUT: "v14.4.0"
script:
- run_timed_command "scripts/db_migrate"
- run_timed_command "scripts/db_tasks db:migrate"
- scripts/schema_changed.sh
- scripts/validate_migration_timestamps
......@@ -411,6 +409,12 @@ db:check-migrations:
- scripts/validate_migration_schema
allow_failure: true
db:check-migrations-decomposed:
extends:
- db:check-migrations
- .decomposed-database
- .rails:rules:decomposed-databases
db:gitlabcom-database-testing:
extends: .rails:rules:db:gitlabcom-database-testing
stage: test
......
#!/bin/bash
root_path="$(cd "$(dirname "$0")/.." || exit ; pwd -P)"
task=$1
if [[ -d "${root_path}/ee/" || "${GITLAB_MIGRATE_MAIN_ONLY}" == "true" ]]; then
task="db:migrate:main"
else
task="db:migrate"
shift
if [[ -d "${root_path}/ee/" || "${DECOMPOSED_DB}" == "true" ]]; then
task="${task}:main"
fi
eval "bundle exec rake ${task} ${*}"
......@@ -30,7 +30,8 @@ class MigrationSchemaValidator
committed_migrations.reverse_each do |filename|
version = find_migration_version(filename)
run("bin/rails db:migrate:down VERSION=#{version}")
run("scripts/db_tasks db:migrate:down VERSION=#{version}")
run("scripts/db_tasks db:schema:dump")
end
git_command = "git diff #{diff_target} -- #{FILENAME}"
......@@ -40,7 +41,8 @@ class MigrationSchemaValidator
end
def validate_schema_on_migrate!
run('bin/rails db:migrate')
run("scripts/db_tasks db:migrate")
run("scripts/db_tasks db:schema:dump")
git_command = "git diff -- #{FILENAME}"
base_message = "the committed #{FILENAME} does not match the one generated by running added migrations"
......
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