mirror of
https://github.com/zkldi/Tachi.git
synced 2026-09-29 02:18:09 +03:00
33 lines
1.2 KiB
Plaintext
33 lines
1.2 KiB
Plaintext
POSTGRES_URL := "postgresql://tachi:tachi@tachi-postgres"
|
|
DEFAULT_DB := "tachi_dev"
|
|
|
|
# Open a psql shell against the local dev Postgres instance.
|
|
db POSTGRES_DB=DEFAULT_DB:
|
|
psql "{{POSTGRES_URL}}/{{POSTGRES_DB}}"
|
|
|
|
# Drop and recreate the database so migrations can be re-applied from scratch.
|
|
db-reset POSTGRES_DB=DEFAULT_DB:
|
|
#!/bin/bash
|
|
|
|
export POSTGRES_URL="{{POSTGRES_URL}}/{{POSTGRES_DB}}"
|
|
tachidb database drop
|
|
tachidb database create
|
|
tachidb migrate run
|
|
|
|
just db-load-seeds "{{POSTGRES_DB}}"
|
|
|
|
# Show the status of all applied (and failed) migrations.
|
|
db-migrate-status POSTGRES_DB=DEFAULT_DB:
|
|
psql "{{POSTGRES_URL}}/{{POSTGRES_DB}}" -c \
|
|
"SELECT version, description, success, installed_on, execution_time || 'µs' AS execution_time \
|
|
FROM \"_migration\" \
|
|
ORDER BY version"
|
|
|
|
# Load the seeds into the database.
|
|
db-load-seeds POSTGRES_DB=DEFAULT_DB:
|
|
cd typescript/server && POSTGRES_URL="{{POSTGRES_URL}}/{{POSTGRES_DB}}" \
|
|
bun run src/scripts/load-seeds-pg.ts
|
|
|
|
# Reset templatedb from migrations, then dump schema and indexes for local debugging.
|
|
db-schema: (db-reset "templatedb")
|
|
pg_dump "{{POSTGRES_URL}}/templatedb" --schema-only --no-owner --no-acl -f db/schema.sql |