Replica of the reference start page: wallpaper, serif clock, search bar and link cards, as a TanStack Start app. - Better Auth: email/password and OIDC single sign-on - Postgres with Drizzle for the auth tables, cards, links, settings and uploaded wallpapers; the server applies the migrations on start - cards group links; links are dragged inside and between cards - search with DuckDuckGo, SearXNG or Google, suggestions and / commands - settings page: name, search engine, wallpaper, account - UI from collabry-components, copied into src/vendor/collabry - Dockerfile and a Gitea workflow that checks the code, builds the image for amd64 and arm64 and pushes it to the registry on main
26 lines
1.8 KiB
SQL
26 lines
1.8 KiB
SQL
CREATE TABLE "card" (
|
|
"id" uuid PRIMARY KEY DEFAULT gen_random_uuid() NOT NULL,
|
|
"user_id" text NOT NULL,
|
|
"name" text NOT NULL,
|
|
"created_at" timestamp DEFAULT now() NOT NULL
|
|
);
|
|
--> statement-breakpoint
|
|
ALTER TABLE "link" ADD COLUMN "card_id" uuid;--> statement-breakpoint
|
|
ALTER TABLE "link" ADD COLUMN "position" integer DEFAULT 0 NOT NULL;--> statement-breakpoint
|
|
-- Hand-written: move existing links into cards. The old top row becomes "Apps",
|
|
-- the old "Everything else" section becomes a card of that name.
|
|
INSERT INTO "card" ("user_id", "name", "created_at")
|
|
SELECT DISTINCT "user_id", 'Apps', now() FROM "link" WHERE "pinned";--> statement-breakpoint
|
|
INSERT INTO "card" ("user_id", "name", "created_at")
|
|
SELECT DISTINCT "user_id", 'Everything else', now() + interval '1 second' FROM "link" WHERE NOT "pinned";--> statement-breakpoint
|
|
UPDATE "link" SET "card_id" = "card"."id" FROM "card"
|
|
WHERE "card"."user_id" = "link"."user_id"
|
|
AND "card"."name" = CASE WHEN "link"."pinned" THEN 'Apps' ELSE 'Everything else' END;--> statement-breakpoint
|
|
UPDATE "link" SET "position" = "ordered"."n" FROM (
|
|
SELECT "id", row_number() OVER (PARTITION BY "card_id" ORDER BY "created_at") - 1 AS "n" FROM "link"
|
|
) AS "ordered" WHERE "ordered"."id" = "link"."id";--> statement-breakpoint
|
|
ALTER TABLE "link" ALTER COLUMN "card_id" SET NOT NULL;--> statement-breakpoint
|
|
ALTER TABLE "card" ADD CONSTRAINT "card_user_id_user_id_fk" FOREIGN KEY ("user_id") REFERENCES "public"."user"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
|
|
CREATE INDEX "card_user_id_idx" ON "card" USING btree ("user_id");--> statement-breakpoint
|
|
ALTER TABLE "link" ADD CONSTRAINT "link_card_id_card_id_fk" FOREIGN KEY ("card_id") REFERENCES "public"."card"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
|
|
CREATE INDEX "link_card_id_idx" ON "link" USING btree ("card_id"); |