simple-login/scripts/new-migration.sh

22 lines
693 B
Bash
Raw Permalink Normal View History

2020-05-07 15:59:21 +00:00
# Generate a new migration script using Docker
# To run it:
2021-08-20 10:00:45 +00:00
# sh scripts/new-migration.sh
2020-05-07 15:59:21 +00:00
2022-05-12 11:42:53 +00:00
container_name=sl-db-new-migration
2020-05-07 15:59:21 +00:00
# create a postgres database for SimpleLogin
2022-05-12 11:42:53 +00:00
docker rm -f ${container_name}
docker run -p 25432:5432 --name ${container_name} -e POSTGRES_PASSWORD=postgres -e POSTGRES_DB=sl -d postgres:13
2020-05-07 15:59:21 +00:00
# sleep a little bit for the db to be ready
sleep 3
2020-05-07 15:59:21 +00:00
# upgrade the DB to the latest stage and
env DB_URI=postgresql://postgres:postgres@127.0.0.1:25432/sl poetry run alembic upgrade head
# generate the migration script.
2022-05-12 16:42:16 +00:00
env DB_URI=postgresql://postgres:postgres@127.0.0.1:25432/sl poetry run alembic revision --autogenerate $@
2020-05-07 15:59:21 +00:00
# remove the db
2022-05-12 11:42:53 +00:00
docker rm -f ${container_name}