Full mariadb-dump (schema + data) from the live develop instance,
post-NFP-18 migration. Includes test data new devs can immediately
poke at instead of staring at an empty dashboard.
Contents:
- 36 tables (full schema)
- 2 users (admin@finetune.ai/admin123, testuser@example.com/test123)
- 5 datasets, 1 job (Support Bot v1, completed), 1 model
- 1 user_billing row, 5 user_settings rows
- 8 email_templates, 3 ACL roles, all migrations table state
Sanitization applied at the end of the dump (POST-LOAD block):
- user.user_pass set to NULL (legacy AES-encrypted passwords;
post-NFP-18 auth uses user_password_hash only)
- user_settings values for keys matching token/key/secret/password/api
set to empty string (devs add their own HF token, etc.)
- user_password_hash for both default users reset to freshly-generated
argon2id hashes that verify against the documented plaintexts
bootstrap-db.sh adds NFP_USE_SNAPSHOT=1 to load this instead of the
clean 3-file path. Both routes arrive at the same credentials.
Verified end-to-end:
- dump loads on a fresh DB (exit 0)
- both default credentials authenticate via password_verify
- all data rows preserved
- no credential-shaped strings in non-comment lines
84 lines
3.1 KiB
Bash
Executable File
84 lines
3.1 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
# Bootstrap the Neuronetz Finetuning Platform database from a fresh container.
|
|
# Run AFTER `docker compose up -d` has started and mariadb is healthy.
|
|
#
|
|
# Usage:
|
|
# ./bootstrap-db.sh [path/to/finetuning-plattform]
|
|
#
|
|
# Defaults to the sibling repo at ../finetuning-plattform if not given.
|
|
#
|
|
# Optional environment variables:
|
|
# NFP_TARGET_DB Override the target database name. Useful for testing
|
|
# the bootstrap against a sandbox DB without wiping the
|
|
# platform's live data. Default: MARIADB_DATABASE from
|
|
# local/.env (i.e. neuronetz_finetune).
|
|
#
|
|
# NFP_USE_SNAPSHOT=1 Load db/dev-snapshot.sql (Stephan's working state with
|
|
# test data — 5 datasets, 1 job, 1 model, etc.) instead
|
|
# of the clean 3-file path. Default: 0 (clean install).
|
|
# Secrets are pre-scrubbed; both default credentials
|
|
# still authenticate (admin/admin123, test/test123).
|
|
|
|
set -euo pipefail
|
|
|
|
DELTA_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
|
PLATFORM_DIR="${1:-$DELTA_DIR/../finetuning-plattform}"
|
|
|
|
if [[ ! -f "$PLATFORM_DIR/local/.env" ]]; then
|
|
echo "ERROR: Could not find $PLATFORM_DIR/local/.env"
|
|
echo " Pass the platform repo path as the first argument."
|
|
echo " e.g. $0 ~/PhpstormProjects/finetuning-plattform"
|
|
exit 1
|
|
fi
|
|
|
|
# shellcheck disable=SC1091
|
|
set -a; . "$PLATFORM_DIR/local/.env"; set +a
|
|
|
|
TARGET_DB="${NFP_TARGET_DB:-$MARIADB_DATABASE}"
|
|
USE_SNAPSHOT="${NFP_USE_SNAPSHOT:-0}"
|
|
|
|
CONTAINER="neuro-finetuning-platform-mariadb-1"
|
|
|
|
if ! docker ps --format '{{.Names}}' | grep -q "^${CONTAINER}$"; then
|
|
echo "ERROR: ${CONTAINER} is not running. Run 'docker compose up -d' in $PLATFORM_DIR/local first."
|
|
exit 2
|
|
fi
|
|
|
|
run_sql() {
|
|
local file=$1
|
|
docker exec -i "$CONTAINER" mariadb -u "$MARIADB_USER" -p"$MARIADB_PASSWORD" "$TARGET_DB" < "$file"
|
|
}
|
|
|
|
echo "Waiting for MariaDB to accept connections (target: ${TARGET_DB})..."
|
|
for i in {1..30}; do
|
|
if docker exec "$CONTAINER" mariadb -u "$MARIADB_USER" -p"$MARIADB_PASSWORD" -e "SELECT 1" "$TARGET_DB" >/dev/null 2>&1; then
|
|
break
|
|
fi
|
|
sleep 1
|
|
done
|
|
|
|
if [[ "$USE_SNAPSHOT" == "1" ]]; then
|
|
echo "[snapshot] Loading dev-snapshot.sql (Stephan's working state)..."
|
|
run_sql "$DELTA_DIR/db/dev-snapshot.sql"
|
|
else
|
|
echo "[1/3] Loading schema (01-schema.sql)..."
|
|
run_sql "$DELTA_DIR/db/01-schema.sql"
|
|
echo "[2/3] Loading seed data (02-seed.sql)..."
|
|
run_sql "$DELTA_DIR/db/02-seed.sql"
|
|
echo "[3/3] Loading default users (03-default-users.sql)..."
|
|
run_sql "$DELTA_DIR/db/03-default-users.sql"
|
|
fi
|
|
|
|
echo
|
|
if [[ "$USE_SNAPSHOT" == "1" ]]; then
|
|
echo "✓ Database '${TARGET_DB}' bootstrapped from dev snapshot."
|
|
echo " Includes Stephan's test data: 5 datasets, 1 job (Support Bot v1), 1 model."
|
|
else
|
|
echo "✓ Database '${TARGET_DB}' bootstrapped from clean install."
|
|
fi
|
|
echo
|
|
echo " admin@finetune.ai / admin123 (superuser)"
|
|
echo " testuser@example.com / test123 (user)"
|
|
echo
|
|
echo "Open: http://local.finetune.neuronetz.ai/auth/login"
|