mirror of
https://github.com/simple-login/app.git
synced 2025-02-21 22:32:56 +08:00
improve script
This commit is contained in:
parent
009e1edced
commit
0a1f545c12
3 changed files with 12 additions and 13 deletions
|
@ -42,16 +42,8 @@ brew install gnupg
|
|||
|
||||
## Run tests
|
||||
|
||||
Running test requires a Postgres database. You can run one with docker:
|
||||
|
||||
```bash
|
||||
docker run -e POSTGRES_PASSWORD=test -e POSTGRES_USER=test -e POSTGRES_DB=test -p 15432:5432 postgres:13
|
||||
```
|
||||
|
||||
then run all tests
|
||||
|
||||
```bash
|
||||
pytest
|
||||
sh scripts/run-test.sh
|
||||
```
|
||||
|
||||
## Run the code locally
|
||||
|
@ -93,7 +85,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
|
||||
sh new_migration.sh
|
||||
sh scripts/new-migration.sh
|
||||
```
|
||||
|
||||
Make sure to review the migration script before committing it.
|
||||
|
|
|
@ -1,16 +1,16 @@
|
|||
# Generate a new migration script using Docker
|
||||
# To run it:
|
||||
# sh new_migration.sh
|
||||
# sh scripts/new-migration.sh
|
||||
|
||||
# create a postgres database for SimpleLogin
|
||||
docker rm -f sl-db
|
||||
docker run -p 25432:5432 --name sl-db -e POSTGRES_PASSWORD=postgres -e POSTGRES_DB=sl -d postgres:13
|
||||
|
||||
# run run `flask db upgrade` to upgrade the DB to the latest stage and
|
||||
env DB_URI=postgresql://postgres:postgres@127.0.0.1:25432/sl flask db upgrade
|
||||
env DB_URI=postgresql://postgres:postgres@127.0.0.1:25432/sl poetry run flask db upgrade
|
||||
|
||||
# finally `flask db migrate` to generate the migration script.
|
||||
env DB_URI=postgresql://postgres:postgres@127.0.0.1:25432/sl flask db migrate
|
||||
env DB_URI=postgresql://postgres:postgres@127.0.0.1:25432/sl poetry run flask db migrate
|
||||
|
||||
# remove the db
|
||||
docker rm -f sl-db
|
7
scripts/run-test.sh
Normal file
7
scripts/run-test.sh
Normal file
|
@ -0,0 +1,7 @@
|
|||
# Run tests
|
||||
|
||||
docker run -d --name sl-test-db -e POSTGRES_PASSWORD=test -e POSTGRES_USER=test -e POSTGRES_DB=test -p 15432:5432 postgres:13
|
||||
|
||||
poetry run pytest
|
||||
|
||||
docker rm -f sl-test-db
|
Loading…
Reference in a new issue