2020-05-07 23:59:21 +08:00
|
|
|
# Generate a new migration script using Docker
|
|
|
|
# To run it:
|
2021-08-20 18:00:45 +08:00
|
|
|
# sh scripts/new-migration.sh
|
2020-05-07 23:59:21 +08:00
|
|
|
|
|
|
|
# create a postgres database for SimpleLogin
|
|
|
|
docker rm -f sl-db
|
2021-08-15 23:41:16 +08:00
|
|
|
docker run -p 25432:5432 --name sl-db -e POSTGRES_PASSWORD=postgres -e POSTGRES_DB=sl -d postgres:13
|
2020-05-07 23:59:21 +08:00
|
|
|
|
2021-10-14 21:42:19 +08:00
|
|
|
# sleep a little bit for the db to be ready
|
|
|
|
sleep 3
|
2020-05-07 23:59:21 +08:00
|
|
|
|
2021-10-14 21:42:19 +08: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.
|
|
|
|
env DB_URI=postgresql://postgres:postgres@127.0.0.1:25432/sl poetry run alembic revision --autogenerate
|
2020-05-07 23:59:21 +08:00
|
|
|
|
|
|
|
# remove the db
|
2022-02-04 05:11:42 +08:00
|
|
|
docker rm -f sl-db
|