Task 25: Multiple dashboards — dashboards table + migration, /d/[slug] route, root redirect, dashboard tabs in nav with create/rename/delete/ set-default. Task 26: Editable dashboard — react-grid-layout drag/resize editor, widget picker modal with per-widget configurator auto-generated from default config, save/reset server actions with Zod validation. Completion visibility: server-side per-user setting (hours) replaces localStorage timer; queries filter completed items by updatedAt cutoff; Settings page dropdown persists preference via server action. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
29 lines
1008 B
SQL
29 lines
1008 B
SQL
CREATE TABLE "dashboards" (
|
|
"id" uuid PRIMARY KEY DEFAULT gen_random_uuid() NOT NULL,
|
|
"user_id" uuid NOT NULL REFERENCES "users"("id") ON DELETE CASCADE,
|
|
"name" text NOT NULL,
|
|
"slug" text NOT NULL,
|
|
"is_default" boolean NOT NULL DEFAULT false,
|
|
"position" integer NOT NULL DEFAULT 0,
|
|
"layout" jsonb NOT NULL DEFAULT '{"version":1,"widgets":[]}',
|
|
"created_at" timestamp with time zone NOT NULL DEFAULT now(),
|
|
"updated_at" timestamp with time zone NOT NULL DEFAULT now()
|
|
);
|
|
|
|
CREATE UNIQUE INDEX "dashboards_user_slug_uq" ON "dashboards" ("user_id", "slug");
|
|
|
|
-- Migrate each existing user's default_dashboard_layout into a "Home" dashboard.
|
|
-- Idempotent: ON CONFLICT DO NOTHING.
|
|
INSERT INTO "dashboards" ("user_id", "name", "slug", "is_default", "position", "layout")
|
|
SELECT
|
|
"id",
|
|
'Home',
|
|
'home',
|
|
true,
|
|
0,
|
|
COALESCE("default_dashboard_layout", '{"version":1,"widgets":[]}')
|
|
FROM "users"
|
|
ON CONFLICT DO NOTHING;
|
|
|
|
ALTER TABLE "users" DROP COLUMN IF EXISTS "default_dashboard_layout";
|