Skip to content

Commit c2c67a9

Browse files
committed
AddAdd latest DB migration script for tests
1 parent df20135 commit c2c67a9

3 files changed

Lines changed: 31 additions & 0 deletions

File tree

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,3 +39,5 @@ Thumbs.db
3939
# dotCover
4040
*.dotCover
4141
/Publish
42+
/Scripts/migrate.log
43+
/Scripts/restore.log

Scripts/MigrateEmptyDB.sh

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
#!/bin/bash
2+
3+
set -e
4+
15
docker stop migrateempty
26
docker run -d --rm --name migrateempty -p 5432:5432 reloni/todo-postgres:latest
37

Scripts/MigrateLastDB.sh

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
#!/bin/bash
2+
3+
set -e
4+
5+
docker stop migratelast
6+
docker run -d --rm --name migratelast -p 5432:5432 reloni/todo-postgres:latest
7+
8+
export POSTGRES_USER=postgres
9+
export POSTGRES_PASSWORD=postgres
10+
export POSTGRES_HOST=localhost
11+
export POSTGRES_PORT=5432
12+
export POSTGRES_DB=postgres
13+
export MIGRATE_LOG=$PWD/migrate.log
14+
export SECRETS_BUCKET_REGION=us-east-1
15+
export BACKUPS_BUCKET_NAME=task-manager-backups
16+
export BACKUP_RESTORE_LOG=$PWD/restore.log
17+
18+
sleep 7
19+
20+
aws s3 --region ${SECRETS_BUCKET_REGION} cp s3://${BACKUPS_BUCKET_NAME}/latest.psql.gz ./latest.psql.gz
21+
#restore backup
22+
gunzip -c ./latest.psql.gz | psql --dbname=postgresql://${POSTGRES_USER}:${POSTGRES_PASSWORD}@${POSTGRES_HOST}:${POSTGRES_PORT}/${POSTGRES_DB} >> ${BACKUP_RESTORE_LOG} 2>&1 && \
23+
rm ./latest.psql.gz
24+
25+
sh MigrateDB.sh

0 commit comments

Comments
 (0)