From 583c97709c6551b030a68da34617ab4cba25135d Mon Sep 17 00:00:00 2001 From: James Jefferies Date: Thu, 19 Dec 2024 14:28:49 +0000 Subject: [PATCH 1/2] Add some helper scripts --- .gitignore | 4 ++++ db/structure.sql | 15 +-------------- heroku_db_to_file.sh | 2 ++ heroku_file_to_db.sh | 3 +++ move-and-reset.sh | 16 ++++++++++++++++ reset.sh | 4 ++++ 6 files changed, 30 insertions(+), 14 deletions(-) create mode 100755 heroku_db_to_file.sh create mode 100755 heroku_file_to_db.sh create mode 100755 move-and-reset.sh create mode 100755 reset.sh diff --git a/.gitignore b/.gitignore index 92fc332..eb26151 100644 --- a/.gitignore +++ b/.gitignore @@ -8,6 +8,10 @@ /lib/tweet/tokens.rb .DS_Store + +data +latest.dump + # Ignore bundler config. /.bundle diff --git a/db/structure.sql b/db/structure.sql index 76f4dd3..f81d941 100644 --- a/db/structure.sql +++ b/db/structure.sql @@ -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); @@ -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: - -- diff --git a/heroku_db_to_file.sh b/heroku_db_to_file.sh new file mode 100755 index 0000000..f0d9473 --- /dev/null +++ b/heroku_db_to_file.sh @@ -0,0 +1,2 @@ +heroku pg:backups:capture +heroku pg:backups:download diff --git a/heroku_file_to_db.sh b/heroku_file_to_db.sh new file mode 100755 index 0000000..bbb9be9 --- /dev/null +++ b/heroku_file_to_db.sh @@ -0,0 +1,3 @@ +pg_restore --verbose --clean --no-acl --no-owner -h localhost -d written_answers latest.dump +rake db:migrate + diff --git a/move-and-reset.sh b/move-and-reset.sh new file mode 100755 index 0000000..1530337 --- /dev/null +++ b/move-and-reset.sh @@ -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 diff --git a/reset.sh b/reset.sh new file mode 100755 index 0000000..20a0f70 --- /dev/null +++ b/reset.sh @@ -0,0 +1,4 @@ +rake db:drop +rake db:create +./heroku_file_to_db.sh + From a942de9787fb049e5defee96f7d394176a4ffdf1 Mon Sep 17 00:00:00 2001 From: James Jefferies Date: Thu, 19 Dec 2024 14:33:42 +0000 Subject: [PATCH 2/2] Update to use postgres 17 on GH action --- .github/workflows/rspec.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/rspec.yml b/.github/workflows/rspec.yml index 03dbdd9..c97d9c4 100644 --- a/.github/workflows/rspec.yml +++ b/.github/workflows/rspec.yml @@ -18,7 +18,7 @@ jobs: runs-on: ubuntu-latest services: postgres: - image: postgres:15 + image: postgres:17 env: POSTGRES_PASSWORD: postgres ports: ['5432:5432']