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