diff options
author | Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com> | 2014-11-12 13:20:01 +0200 |
---|---|---|
committer | Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com> | 2014-11-12 13:20:01 +0200 |
commit | 9a96a8270ba0377b3d634efa0f2c41afdc871156 (patch) | |
tree | 5cbcdbc44f2cd4b1eaf0a64ea705f75e58ff24ce /lib | |
parent | 940ed58e768af5580f65159c4040541f29663d4a (diff) | |
parent | 31d9864ad4e13f8ad09dde8eb7876174cfad2df5 (diff) | |
download | gitlab-ce-9a96a8270ba0377b3d634efa0f2c41afdc871156.tar.gz |
Merge branch 'master' of dev.gitlab.org:gitlab/gitlabhq
Diffstat (limited to 'lib')
-rw-r--r-- | lib/backup/database.rb | 1 | ||||
-rw-r--r-- | lib/tasks/gitlab/db/drop_all_postgres_sequences.rake | 10 |
2 files changed, 11 insertions, 0 deletions
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 |