-
Notifications
You must be signed in to change notification settings - Fork 196
Expand file tree
/
Copy pathjustfile
More file actions
66 lines (49 loc) · 2.38 KB
/
Copy pathjustfile
File metadata and controls
66 lines (49 loc) · 2.38 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
default:
just --list --unsorted
db-host := env_var_or_default('DB_HOST', "localhost")
db-port := env_var_or_default('DB_PORT', "5432")
db-user := env_var_or_default('DB_USER', "postgres")
db-password := env_var_or_default('DB_PASSWORD', "admin")
db-name := env_var_or_default('DB_NAME', "tac_operation_lifecycle")
export DATABASE_URL := "postgres://" + db-user + ":" + db-password + "@" + db-host + ":" + db-port + "/" + db-name
export RUST_LOG := env_var_or_default('RUST_LOG', "info")
export RUST_BACKTRACE := env_var_or_default('RUST_BACKTRACE', "0")
docker-name := env_var_or_default('DOCKER_NAME', "tac-operation-lifecycle-postgres-dev")
test-db-port := env_var_or_default('TEST_DB_PORT', "9433")
start-postgres:
# we run it in --rm mode, so all data will be deleted after stopping
docker run -p {{db-port}}:5432 --name {{docker-name}} -e POSTGRES_PASSWORD={{db-password}} -e POSTGRES_USER={{db-user}} --rm -d postgres -N 500
sleep 3
# wait for postgres to start, but only if db_name is not empty
$SHELL -c '[[ -z "{{db-name}}" ]] || docker exec -it {{docker-name}} psql -U postgres -c "create database {{db-name}};"'
stop-postgres:
docker kill {{docker-name}}
test *args:
cargo test {{args}} -- --include-ignored
test-with-db *args:
-just db-port="{{test-db-port}}" db-name="" docker-name="{{docker-name}}-test" start-postgres
just db-port="{{test-db-port}}" db-name="" test {{args}}
stop-test-postgres:
just docker-name="{{docker-name}}-test" stop-postgres
run:
TAC_OPERATION_LIFECYCLE__DATABASE__CONNECT__URL={{DATABASE_URL}} \
TAC_OPERATION_LIFECYCLE__CONFIG=tac-operation-lifecycle-server/config/spb.toml \
cargo run --bin tac-operation-lifecycle-server
generate-entities:
sea-orm-cli generate entity --lib -o tac-operation-lifecycle-entity/src
new-migration name:
sea-orm-cli migrate generate -d tac-operation-lifecycle-migration {{name}}
migrate-up:
sea-orm-cli migrate -d tac-operation-lifecycle-migration up
migrate-down:
sea-orm-cli migrate -d tac-operation-lifecycle-migration down
flush-database:
sea-orm-cli migrate -d tac-operation-lifecycle-migration reset
format:
cargo sort --workspace
cargo fmt --all -- --config imports_granularity=Crate
check:
cargo check
cargo clippy --all --all-targets --all-features -- -D warnings
check-envs:
cargo run --bin env-docs-generation