Initial travel knowledge graph release
This commit is contained in:
31
docker/postgres-init/01-restore-snapshot.sh
Executable file
31
docker/postgres-init/01-restore-snapshot.sh
Executable file
@@ -0,0 +1,31 @@
|
||||
#!/usr/bin/env bash
|
||||
set -euo pipefail
|
||||
|
||||
SNAPSHOT=/snapshots/kg_admin_new2.dump
|
||||
|
||||
if [ -f "$SNAPSHOT" ]; then
|
||||
echo "Restoring PostgreSQL snapshot: $SNAPSHOT"
|
||||
pg_restore \
|
||||
-U "$POSTGRES_USER" \
|
||||
-d "$POSTGRES_DB" \
|
||||
--clean \
|
||||
--if-exists \
|
||||
--no-owner \
|
||||
--no-privileges \
|
||||
"$SNAPSHOT"
|
||||
else
|
||||
echo "Snapshot not found: $SNAPSHOT"
|
||||
fi
|
||||
|
||||
psql -v ON_ERROR_STOP=1 -U "$POSTGRES_USER" -d "$POSTGRES_DB" <<'SQL'
|
||||
UPDATE kg_admin_new2.users
|
||||
SET hashed_password = '$2b$12$7qSbaju/y1tlCnwpEo1wG.i601QAU9itXMFNSmkke1ycJ8RoIPfom',
|
||||
status = 'active'
|
||||
WHERE username = 'admin@example.com';
|
||||
|
||||
INSERT INTO kg_admin_new2.user_roles (user_id, role_key)
|
||||
SELECT id, 'admin'
|
||||
FROM kg_admin_new2.users
|
||||
WHERE username = 'admin@example.com'
|
||||
ON CONFLICT DO NOTHING;
|
||||
SQL
|
||||
Reference in New Issue
Block a user