Migration 20170301195939_rename_ci_commits_to_ci_pipelines.rb fails due to missing index
Trying to upgrade with apt-get install gitlab-ce from version 9.3.0 to 9.3.6.
The following error occures when trying to rename one of the CI tables
Recipe: gitlab::database_migrations
* bash[migrate gitlab-rails database] action run
[execute] rake aborted!
StandardError: An error has occurred, this and all later migrations canceled:
PG::UndefinedTable: ERROR: relation "ci_commits_pkey" does not exist
: ALTER INDEX "ci_commits_pkey" RENAME TO "ci_pipelines_pkey"/opt/gitlab/embedded/service/gitlab-rails/db/migrate/20170301195939_rename_ci_commits_to_ci_pipelines.rb:8: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::UndefinedTable: ERROR: relation "ci_commits_pkey" does not exist
: ALTER INDEX "ci_commits_pkey" RENAME TO "ci_pipelines_pkey"
/opt/gitlab/embedded/service/gitlab-rails/db/migrate/20170301195939_rename_ci_commits_to_ci_pipelines.rb:8: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>'
PG::UndefinedTable: ERROR: relation "ci_commits_pkey" does not exist
/opt/gitlab/embedded/service/gitlab-rails/db/migrate/20170301195939_rename_ci_commits_to_ci_pipelines.rb:8: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>'
Tasks: TOP => db:migrate
(See full trace by running task with --trace)
== 20170301195939 RenameCiCommitsToCiPipelines: migrating =====================
-- rename_table("ci_commits", "ci_pipelines")
================================================================================
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-script20170714-7381-1atjgcw" ----
STDOUT: rake aborted!
StandardError: An error has occurred, this and all later migrations canceled:
PG::UndefinedTable: ERROR: relation "ci_commits_pkey" does not exist
: ALTER INDEX "ci_commits_pkey" RENAME TO "ci_pipelines_pkey"/opt/gitlab/embedded/service/gitlab-rails/db/migrate/20170301195939_rename_ci_commits_to_ci_pipelines.rb:8: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::UndefinedTable: ERROR: relation "ci_commits_pkey" does not exist
: ALTER INDEX "ci_commits_pkey" RENAME TO "ci_pipelines_pkey"
/opt/gitlab/embedded/service/gitlab-rails/db/migrate/20170301195939_rename_ci_commits_to_ci_pipelines.rb:8: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>'
PG::UndefinedTable: ERROR: relation "ci_commits_pkey" does not exist
/opt/gitlab/embedded/service/gitlab-rails/db/migrate/20170301195939_rename_ci_commits_to_ci_pipelines.rb:8: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>'
Tasks: TOP => db:migrate
(See full trace by running task with --trace)
== 20170301195939 RenameCiCommitsToCiPipelines: migrating =====================
-- rename_table("ci_commits", "ci_pipelines")
STDERR:
---- End output of "bash" "/tmp/chef-script20170714-7381-1atjgcw" ----
Ran "bash" "/tmp/chef-script20170714-7381-1atjgcw" returned 1
Resource Declaration:
---------------------
# In /opt/gitlab/embedded/cookbooks/cache/cookbooks/gitlab/recipes/database_migrations.rb
51: bash "migrate gitlab-rails database" do
52: code <<-EOH
53: set -e
54: log_file="#{node['gitlab']['gitlab-rails']['log_directory']}/gitlab-rails-db-migrate-$(date +%Y-%m-%d-%H-%M-%S).log"
55: umask 077
56: /opt/gitlab/bin/gitlab-rake gitlab:db:configure 2>& 1 | tee ${log_file}
57: STATUS=${PIPESTATUS[0]}
58: echo $STATUS > #{db_migrate_status_file}
59: exit $STATUS
60: EOH
61: environment env_variables unless env_variables.empty?
62: notifies :run, 'execute[enable pg_trgm extension]', :before if omnibus_helper.service_enabled?('postgresql')
63: notifies :run, "execute[clear the gitlab-rails cache]", :immediately
64: dependent_services.each do |svc|
65: notifies :restart, svc, :immediately
66: end
67: not_if "(test -f #{db_migrate_status_file}) && (cat #{db_migrate_status_file} | grep -Fx 0)"
68: only_if { node['gitlab']['gitlab-rails']['auto_migrate'] }
69: end
Compiled Resource:
------------------
# Declared in /opt/gitlab/embedded/cookbooks/cache/cookbooks/gitlab/recipes/database_migrations.rb:51:in `from_file'
bash("migrate gitlab-rails database") do
action [:run]
updated true
retries 0
retry_delay 2
default_guard_interpreter :default
command "migrate gitlab-rails database"
backup 5
returns 0
code " set -e\n log_file=\"/var/log/gitlab/gitlab-rails/gitlab-rails-db-migrate-$(date +%Y-%m-%d-%H-%M-%S).log\"\n umask 077\n /opt/gitlab/bin/gitlab-rake gitlab:db:configure 2>& 1 | tee ${log_file}\n STATUS=${PIPESTATUS[0]}\n echo $STATUS > /var/opt/gitlab/gitlab-rails/upgrade-status/db-migrate-873248b1f0d3a7a5535771a3a1635803-b9a169c\n exit $STATUS\n"
interpreter "bash"
declared_type :bash
cookbook_name "gitlab"
recipe_name "database_migrations"
not_if "(test -f /var/opt/gitlab/gitlab-rails/upgrade-status/db-migrate-873248b1f0d3a7a5535771a3a1635803-b9a169c) && (cat /var/opt/gitlab/gitlab-rails/upgrade-status/db-migrate-873248b1f0d3a7a5535771a3a1635803-b9a169c | grep -Fx 0)"
only_if { #code block }
end
Platform:
---------
x86_64-linux