Files
HealthLog/prisma/migrations/0002_roles_and_settings/migration.sql
T
Marc-André Bombeck 38309932f3 Initial release v1.0.0
HealthLog — personal health-tracking PWA with weight, blood pressure,
pulse, mood tracking, medication compliance, Withings integration,
doctor report PDF export, and Dracula-themed UI.
2026-03-10 20:14:33 +01:00

26 lines
1.0 KiB
SQL

-- AlterTable: Add role and date_of_birth to users
ALTER TABLE "users" ADD COLUMN "role" TEXT NOT NULL DEFAULT 'USER';
ALTER TABLE "users" ADD COLUMN "date_of_birth" TIMESTAMP(3);
-- AlterTable: Remove BP target columns from users
ALTER TABLE "users" DROP COLUMN IF EXISTS "bp_sys_target_low";
ALTER TABLE "users" DROP COLUMN IF EXISTS "bp_sys_target_high";
ALTER TABLE "users" DROP COLUMN IF EXISTS "bp_dia_target_low";
ALTER TABLE "users" DROP COLUMN IF EXISTS "bp_dia_target_high";
-- CreateTable: app_settings (singleton)
CREATE TABLE "app_settings" (
"id" TEXT NOT NULL DEFAULT 'singleton',
"registration_enabled" BOOLEAN NOT NULL DEFAULT true,
CONSTRAINT "app_settings_pkey" PRIMARY KEY ("id")
);
-- Insert default settings row
INSERT INTO "app_settings" ("id", "registration_enabled") VALUES ('singleton', true)
ON CONFLICT ("id") DO NOTHING;
-- Set existing users as ADMIN (first user gets admin role)
UPDATE "users" SET "role" = 'ADMIN'
WHERE "id" = (SELECT "id" FROM "users" ORDER BY "created_at" ASC LIMIT 1);