Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
gitlab-ce
Commits
e00e67db
Commit
e00e67db
authored
Oct 28, 2014
by
Jacob Vosmaer
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Drop all Postgres sequences during backup restore
parent
01441f54
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
11 additions
and
0 deletions
+11
-0
lib/backup/database.rb
lib/backup/database.rb
+1
-0
lib/tasks/gitlab/db/drop_all_postgres_sequences.rake
lib/tasks/gitlab/db/drop_all_postgres_sequences.rake
+10
-0
No files found.
lib/backup/database.rb
View file @
e00e67db
...
...
@@ -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
...
...
lib/tasks/gitlab/db/drop_all_postgres_sequences.rake
0 → 100644
View file @
e00e67db
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
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment