mirror of
https://github.com/zkldi/Tachi.git
synced 2026-10-02 11:58:12 +03:00
49 lines
1.8 KiB
Plaintext
49 lines
1.8 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
|
|
|
|
# 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"
|
|
|
|
# Create (or recreate) the bot test template database with all migrations applied.
|
|
# Workers clone from this template rather than re-running migrations each time.
|
|
bot-db-test-template-reset:
|
|
#!/bin/bash
|
|
export POSTGRES_URL="{{POSTGRES_URL}}/tachi_bot_test_template"
|
|
tachidb database drop || true
|
|
tachidb database create
|
|
tachidb migrate run
|
|
|
|
# Create (or recreate) the server test template database with all migrations applied.
|
|
# Workers clone from this template rather than re-running migrations each time.
|
|
server-db-test-template-reset:
|
|
#!/bin/bash
|
|
export POSTGRES_URL="{{POSTGRES_URL}}/tachi_server_test_template"
|
|
tachidb database drop || true
|
|
tachidb database create
|
|
tachidb migrate run
|
|
|
|
# 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 |