diff --git a/CHANGELOG b/CHANGELOG index 2d09a608f1201c89460a16f9d95a0c9a08d2758d..c7afe8928d716471f401cc719d34379767b55d77 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -3,6 +3,7 @@ v 7.5.0 - Add time zone configuration on gitlab.yml (Sullivan Senechal) - Fix LDAP authentication for Git HTTP access - Fix LDAP config lookup for provider 'ldap' + - Drop all sequences during Postgres database restore - Project title links to project homepage (Ben Bodenmiller) - Add Atlassian Bamboo CI service (Drew Blessing) - Mentioned @user will receive email even if he is not participating in issue or commit diff --git a/lib/backup/database.rb b/lib/backup/database.rb index d12d30a91103ad4dde9c49e9d28352a6432b19bd..ea659e3b605fd81cb72fecb9395ff7b2f91efc64 100644 --- a/lib/backup/database.rb +++ b/lib/backup/database.rb @@ -34,6 +34,7 @@ module Backup # Drop all tables because PostgreSQL DB dumps do not contain DROP TABLE # statements like MySQL. Rake::Task["gitlab:db:drop_all_tables"].invoke + Rake::Task["gitlab:db:drop_all_postgres_sequences"].invoke pg_env system('psql', config['database'], '-f', db_file_name) end diff --git a/lib/tasks/gitlab/db/drop_all_postgres_sequences.rake b/lib/tasks/gitlab/db/drop_all_postgres_sequences.rake new file mode 100644 index 0000000000000000000000000000000000000000..e9cf0a9b5e862cc16d1b886ecac14ff424d8807c --- /dev/null +++ b/lib/tasks/gitlab/db/drop_all_postgres_sequences.rake @@ -0,0 +1,10 @@ +namespace :gitlab do + namespace :db do + task drop_all_postgres_sequences: :environment do + connection = ActiveRecord::Base.connection + connection.execute("SELECT c.relname FROM pg_class c WHERE c.relkind = 'S';").each do |sequence| + connection.execute("DROP SEQUENCE #{sequence['relname']}") + end + end + end +end