feat(database): add project_tag and tag tables with foreign key constraints

- Introduced new SQL migration to create 'project_tag' and 'tag' tables.
- Added unique constraints and foreign key relationships to ensure data integrity.
- Updated journal and snapshot metadata to reflect the new migration.
This commit is contained in:
Mauricio Siu
2026-03-19 01:05:04 -06:00
parent 43f9c114c8
commit b3579d1321
5 changed files with 7881 additions and 4 deletions

View File

@@ -15,7 +15,6 @@ import { toast } from "sonner";
import { BreadcrumbSidebar } from "@/components/shared/breadcrumb-sidebar";
import { DateTooltip } from "@/components/shared/date-tooltip";
import { FocusShortcutInput } from "@/components/shared/focus-shortcut-input";
import { StatusTooltip } from "@/components/shared/status-tooltip";
import { TagBadge } from "@/components/shared/tag-badge";
import { TagFilter } from "@/components/shared/tag-filter";
import {

View File

@@ -0,0 +1,19 @@
CREATE TABLE "project_tag" (
"id" text PRIMARY KEY NOT NULL,
"projectId" text NOT NULL,
"tagId" text NOT NULL,
CONSTRAINT "unique_project_tag" UNIQUE("projectId","tagId")
);
--> statement-breakpoint
CREATE TABLE "tag" (
"tagId" text PRIMARY KEY NOT NULL,
"name" text NOT NULL,
"color" text,
"createdAt" text NOT NULL,
"organizationId" text NOT NULL,
CONSTRAINT "unique_org_tag_name" UNIQUE("organizationId","name")
);
--> statement-breakpoint
ALTER TABLE "project_tag" ADD CONSTRAINT "project_tag_projectId_project_projectId_fk" FOREIGN KEY ("projectId") REFERENCES "public"."project"("projectId") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
ALTER TABLE "project_tag" ADD CONSTRAINT "project_tag_tagId_tag_tagId_fk" FOREIGN KEY ("tagId") REFERENCES "public"."tag"("tagId") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
ALTER TABLE "tag" ADD CONSTRAINT "tag_organizationId_organization_id_fk" FOREIGN KEY ("organizationId") REFERENCES "public"."organization"("id") ON DELETE cascade ON UPDATE no action;

File diff suppressed because it is too large Load Diff

View File

@@ -1065,6 +1065,13 @@
"when": 1773872561300,
"tag": "0151_modern_sunfire",
"breakpoints": true
},
{
"idx": 152,
"version": "7",
"when": 1773903778014,
"tag": "0152_odd_firelord",
"breakpoints": true
}
]
}

View File

@@ -6,7 +6,6 @@ import superjson from "superjson";
import { TagManager } from "@/components/dashboard/settings/tags/tag-manager";
import { DashboardLayout } from "@/components/layouts/dashboard-layout";
import { appRouter } from "@/server/api/root";
import { getLocale, serverSideTranslations } from "@/utils/i18n";
const Page = () => {
return (
@@ -26,7 +25,6 @@ export async function getServerSideProps(
) {
const { req, res } = ctx;
const { user, session } = await validateRequest(req);
const locale = getLocale(req.cookies);
const helpers = createServerSideHelpers({
router: appRouter,
@@ -55,7 +53,6 @@ export async function getServerSideProps(
return {
props: {
trpcState: helpers.dehydrate(),
...(await serverSideTranslations(locale, ["settings"])),
},
};
}