If you upgrade Gitlab to version 17.6 and higher and get error:
Tasks: TOP => db:migrate
(See full trace by running task with --trace)
Running db:migrate rake task
main: == [advisory_lock_connection] object_id: 52520, pg_backend_pid: 443
main: == 20241016072342 AddNotNullConstraintToPackagesDependenciesProjectId: migrating
main: -- current_schema(nil)
main: -> 0.0007s
main: -- transaction_open?(nil)
main: -> 0.0000s
main: -- execute("SET statement_timeout TO 0")
main: -> 0.0002s
main: -- execute("ALTER TABLE packages_dependencies VALIDATE CONSTRAINT check_83faf1f5e7;")
main: -- execute("RESET statement_timeout")
main: -> 0.0002s
main: == [advisory_lock_connection] object_id: 52520, pg_backend_pid: 443
STDERR:
---- End output of "bash" ----
Ran "bash" returned 1
Than the main problem in the table packages_dependencies that contains rows with null
value in column ‘project_id’
select * from packages_dependencies where project_id is null;
You should find the project from where this packages ( try to look in the table ‘packages_dependency_links’)
Update the projects ID in the packages_dependencies
update packages_dependencies set project_id=1412 where project_id is null;
or
update packages_dependencies set project_id=1412 where id=33 ;
Use ‘gitlab-psql’ command for Postgresql connection