diff options
author | Valery Sizov <valery@gitlab.com> | 2014-11-12 11:15:10 +0000 |
---|---|---|
committer | Valery Sizov <valery@gitlab.com> | 2014-11-12 11:15:10 +0000 |
commit | 31d9864ad4e13f8ad09dde8eb7876174cfad2df5 (patch) | |
tree | 944564aabc35977b9771933ced239d46ddece10b | |
parent | c58edd7c708c39a6e7c60bd96c7f97ced370f304 (diff) | |
parent | 1a7e3476351979d37cd5fa2b7b5800717487d758 (diff) | |
download | gitlab-ce-31d9864ad4e13f8ad09dde8eb7876174cfad2df5.tar.gz |
Merge branch 'backup_restore_drop_sequences' into 'master'
Drop all Postgres sequences during backup restore
See merge request !1226
-rw-r--r-- | CHANGELOG | 1 | ||||
-rw-r--r-- | lib/backup/database.rb | 1 | ||||
-rw-r--r-- | lib/tasks/gitlab/db/drop_all_postgres_sequences.rake | 10 |
3 files changed, 12 insertions, 0 deletions
diff --git a/CHANGELOG b/CHANGELOG index 2d09a608f12..c7afe8928d7 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 d12d30a9110..ea659e3b605 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 00000000000..e9cf0a9b5e8 --- /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 |