Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
A
Admin
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
osuny
Admin
Commits
4653baeb
Unverified
Commit
4653baeb
authored
3 years ago
by
Sébastien Gaya
Browse files
Options
Downloads
Patches
Plain Diff
staging db task
parent
e3f4d569
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
lib/tasks/app.rake
+20
-0
20 additions, 0 deletions
lib/tasks/app.rake
with
20 additions
and
0 deletions
lib/tasks/app.rake
+
20
−
0
View file @
4653baeb
...
...
@@ -20,6 +20,26 @@ namespace :app do
namespace
:db
do
desc
'Get database from Scalingo'
task
:staging
do
Bundler
.
with_unbundled_env
do
# Get a new backup archive from Scalingo
# PG Addon ID from `scalingo addons` CLI command.
sh
"scalingo --app
#{
ENV
[
'OSUNY_STAGING_APP_NAME'
]
}
backups-create --addon
#{
ENV
[
'OSUNY_STAGING_PG_ADDON_ID'
]
}
"
sh
"scalingo --app
#{
ENV
[
'OSUNY_STAGING_APP_NAME'
]
}
backups-download --addon
#{
ENV
[
'OSUNY_STAGING_PG_ADDON_ID'
]
}
--output db/scalingo-dump.tar.gz"
sh
'rm -f db/latest.dump'
# Remove an old backup file if it exists
sh
'tar zxvf db/scalingo-dump.tar.gz -C db/'
# Extract the new backup archive
sh
'rm db/scalingo-dump.tar.gz'
# Remove the backup archive
sh
'mv db/*.pgsql db/latest.dump'
# Rename the backup file
sh
'DISABLE_DATABASE_ENVIRONMENT_CHECK=1 bundle exec rails db:drop'
sh
'bundle exec rails db:create'
begin
sh
'pg_restore --verbose --clean --no-acl --no-owner -h localhost -U postgres -d osuny_development db/latest.dump'
rescue
'There were some warnings or errors while restoring'
end
sh
'rails db:migrate'
sh
'rails db:seed'
end
end
end
end
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment