Hi,
I met a problem when upgrade Gitlab to 9.5,
when it doing [migrate gitlab-rails database]
withe the error after runing gitlab-ctl reconfigure
:
================================================================================
Error executing action `run` on resource 'bash[migrate gitlab-rails database]'
================================================================================
Mixlib::ShellOut::ShellCommandFailed
------------------------------------
Expected process to exit with [0], but received '1'
---- Begin output of "bash" "/tmp/chef-script20170905-17962-1vfwbht" ----
STDOUT: rake aborted!
StandardError: An error has occurred, this and all later migrations canceled:
PG::DatatypeMismatch: ERROR: argument of AND must be type boolean, not type smallint
LINE 3: ...id AND (status='failed' OR status='canceled') AND allow_fail...
^
: UPDATE ci_commits SET status=(CASE
WHEN (SELECT COUNT(*) FROM ci_builds WHERE ci_builds.commit_id=ci_commits.id)=0 THEN 'skipped'
WHEN (SELECT COUNT(*) FROM ci_builds WHERE ci_builds.commit_id=ci_commits.id)=(SELECT COUNT(*) FROM ci_builds WHERE ci_builds.commit_id=ci_commits.id AND status='success')+(SELECT COUNT(*) FROM ci_builds WHERE ci_builds.commit_id=ci_commits.id AND (status='failed' OR status='canceled') AND allow_failure) THEN 'success'
WHEN (SELECT COUNT(*) FROM ci_builds WHERE ci_builds.commit_id=ci_commits.id)=(SELECT COUNT(*) FROM ci_builds WHERE ci_builds.commit_id=ci_commits.id AND status='pending') THEN 'pending'
WHEN (SELECT COUNT(*) FROM ci_builds WHERE ci_builds.commit_id=ci_commits.id)=(SELECT COUNT(*) FROM ci_builds WHERE ci_builds.commit_id=ci_commits.id AND status='canceled') THEN 'canceled'
WHEN (SELECT COUNT(*) FROM ci_builds WHERE ci_builds.commit_id=ci_commits.id AND status='running')+(SELECT COUNT(*) FROM ci_builds WHERE ci_builds.commit_id=ci_commits.id AND status='pending')>0 THEN 'running'
ELSE 'failed'
END), ref=(SELECT ref FROM ci_builds WHERE ci_builds.commit_id=ci_commits.id ORDER BY id DESC LIMIT 1), tag=(SELECT tag FROM ci_builds WHERE ci_builds.commit_id=ci_commits.id ORDER BY id DESC LIMIT 1) WHERE status IS NULL
/opt/gitlab/embedded/service/gitlab-rails/db/migrate/20160412173417_update_ci_commit.rb:6:in `change'
/opt/gitlab/embedded/service/gitlab-rails/lib/tasks/gitlab/db.rake:50:in `block (3 levels) in <top (required)>'
/opt/gitlab/embedded/bin/bundle:22:in `load'
/opt/gitlab/embedded/bin/bundle:22:in `<main>'
ActiveRecord::StatementInvalid: PG::DatatypeMismatch: ERROR: argument of AND must be type boolean, not type smallint
LINE 3: ...id AND (status='failed' OR status='canceled') AND allow_fail...
^
I wonder what is allow_failure
in this SQL and how can I pass this migration.
Solution:
# sudo -u gitlab-psql /opt/gitlab/embedded/bin/pg_dump -h /var/opt/gitlab/postgresql -s -d gitlabhq_production
gitlabhq_production=# alter table ci_builds alter column allow_failure drop default;
gitlabhq_production=# alter table ci_builds alter column allow_failure type bool using case WHEN allow_failure=0 THEN FALSE ELSE TRUE END;;
gitlabhq_production=# alter table ci_builds alter column allow_failure set default false;