From 0a497c9f67648009ef6a080b5c83c6b7080188df Mon Sep 17 00:00:00 2001 From: Son NK <> Date: Thu, 7 May 2020 17:59:21 +0200 Subject: [PATCH] put migration generation into a script --- README.md | 13 +------------ new_migration.sh | 16 ++++++++++++++++ 2 files changed, 17 insertions(+), 12 deletions(-) create mode 100644 new_migration.sh diff --git a/README.md b/README.md index 509c0685..af6d761e 100644 --- a/README.md +++ b/README.md @@ -1160,18 +1160,7 @@ Whenever the model changes, a new migration has to be created. If you have Docker installed, you can create the migration by the following script: ```bash -# create a postgres database for SimpleLogin -docker rm -f sl-db -docker run -p 5432:5432 --name sl-db -e POSTGRES_PASSWORD=postgres -e POSTGRES_DB=sl -d postgres - -# run run `flask db upgrade` to upgrade the DB to the latest stage and -env DB_URI=postgresql://postgres:postgres@127.0.0.1:5432/sl flask db upgrade - -# finally `flask db migrate` to generate the migration script. -env DB_URI=postgresql://postgres:postgres@127.0.0.1:5432/sl flask db migrate - -# remove the db -docker rm -f sl-db +sh new_migration.sh ``` Make sure to review the migration script before committing it. diff --git a/new_migration.sh b/new_migration.sh new file mode 100644 index 00000000..6c786097 --- /dev/null +++ b/new_migration.sh @@ -0,0 +1,16 @@ +# Generate a new migration script using Docker +# To run it: +# sh new_migration.sh + +# create a postgres database for SimpleLogin +docker rm -f sl-db +docker run -p 5432:5432 --name sl-db -e POSTGRES_PASSWORD=postgres -e POSTGRES_DB=sl -d postgres + +# run run `flask db upgrade` to upgrade the DB to the latest stage and +env DB_URI=postgresql://postgres:postgres@127.0.0.1:5432/sl flask db upgrade + +# finally `flask db migrate` to generate the migration script. +env DB_URI=postgresql://postgres:postgres@127.0.0.1:5432/sl flask db migrate + +# remove the db +docker rm -f sl-db \ No newline at end of file