Skip to content

Commit

Permalink
Merge pull request #30 from ukparliament/add-things-to-help-get-db-du…
Browse files Browse the repository at this point in the history
…mps-etc

Add some helper scripts
  • Loading branch information
jamesjefferies authored Dec 19, 2024
2 parents 1743107 + a942de9 commit a3354e2
Show file tree
Hide file tree
Showing 7 changed files with 31 additions and 15 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/rspec.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ jobs:
runs-on: ubuntu-latest
services:
postgres:
image: postgres:15
image: postgres:17
env:
POSTGRES_PASSWORD: postgres
ports: ['5432:5432']
Expand Down
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@
/lib/tweet/tokens.rb
.DS_Store


data
latest.dump

# Ignore bundler config.
/.bundle

Expand Down
15 changes: 1 addition & 14 deletions db/structure.sql
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
SET statement_timeout = 0;
SET lock_timeout = 0;
SET idle_in_transaction_session_timeout = 0;
SET transaction_timeout = 0;
SET client_encoding = 'UTF8';
SET standard_conforming_strings = on;
SELECT pg_catalog.set_config('search_path', '', false);
Expand All @@ -9,20 +10,6 @@ SET xmloption = content;
SET client_min_messages = warning;
SET row_security = off;

--
-- Name: heroku_ext; Type: SCHEMA; Schema: -; Owner: -
--

CREATE SCHEMA heroku_ext;


--
-- Name: public; Type: SCHEMA; Schema: -; Owner: -
--

-- *not* creating schema, since initdb creates it


--
-- Name: pg_stat_statements; Type: EXTENSION; Schema: -; Owner: -
--
Expand Down
2 changes: 2 additions & 0 deletions heroku_db_to_file.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
heroku pg:backups:capture
heroku pg:backups:download
3 changes: 3 additions & 0 deletions heroku_file_to_db.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
pg_restore --verbose --clean --no-acl --no-owner -h localhost -d written_answers latest.dump
rake db:migrate

16 changes: 16 additions & 0 deletions move-and-reset.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
echo "Remove link latest.dump"
rm latest.dump

echo "Download latest"
heroku pg:backups:capture
heroku pg:backups:download

echo "Rename latest"
now=`date +"%d-%m-%Y"`
mv latest.dump data/$now.latest.dump

echo "Link latest file"
ln -sf data/$now.latest.dump latest.dump

echo "reset"
./reset.sh
4 changes: 4 additions & 0 deletions reset.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
rake db:drop
rake db:create
./heroku_file_to_db.sh

0 comments on commit a3354e2

Please sign in to comment.