Nexova / scripts /init-db.sh
Nexova
fix: init-db via sh+sqlite3 cli, exact prisma schema sql
512af3e
raw
history blame contribute delete
610 Bytes
#!/bin/sh
set -e
DIR="$(pwd)/data"
DB="$DIR/nexova.db"
mkdir -p "$DIR"
if [ ! -f "$DB" ] || [ ! -s "$DB" ]; then
rm -f "$DB"
sqlite3 "$DB" <<'SQL'
CREATE TABLE IF NOT EXISTS "notes" (
"id" TEXT NOT NULL PRIMARY KEY,
"title" TEXT NOT NULL,
"content" TEXT NOT NULL DEFAULT '',
"color" TEXT NOT NULL DEFAULT '#fef08a',
"pinned" BOOLEAN NOT NULL DEFAULT false,
"created_at" DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
"updated_at" DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP
);
SQL
echo "[init] db created ($(wc -c < "$DB") bytes)"
else
echo "[init] db exists ($(wc -c < "$DB") bytes)"
fi