Refactoring in roles.

This commit is contained in:
charlesgauthereau
2025-11-01 14:50:08 +01:00
parent 027928c29f
commit ae766dab2f
36 changed files with 1800 additions and 383 deletions
+3
View File
@@ -0,0 +1,3 @@
ALTER TABLE "projects" DROP CONSTRAINT "projects_organization_id_organization_id_fk";
--> statement-breakpoint
ALTER TABLE "projects" ADD CONSTRAINT "projects_organization_id_organization_id_fk" FOREIGN KEY ("organization_id") REFERENCES "public"."organization"("id") ON DELETE cascade ON UPDATE no action;
File diff suppressed because it is too large Load Diff
+7
View File
@@ -36,6 +36,13 @@
"when": 1756473637441,
"tag": "0004_dazzling_hawkeye",
"breakpoints": true
},
{
"idx": 5,
"version": "7",
"when": 1762004436821,
"tag": "0005_old_swarm",
"breakpoints": true
}
]
}
+3 -2
View File
@@ -1,5 +1,5 @@
import {pgTable, text, timestamp, uuid} from "drizzle-orm/pg-core";
import {user} from "@/db/schema/02_user";
import {User, user} from "@/db/schema/02_user";
import {organization} from "@/db/schema/03_organization";
import {relations} from "drizzle-orm";
import {createSelectSchema} from "drizzle-zod";
@@ -32,4 +32,5 @@ export const memberRelations = relations(member, ({ one }) => ({
export const organizationMemberSchema = createSelectSchema(member);
export type OrganizationMember = z.infer<typeof organizationMemberSchema>;
export type OrganizationMember = z.infer<typeof organizationMemberSchema>;
+8 -9
View File
@@ -1,9 +1,9 @@
import { pgTable, text, boolean, uuid, timestamp } from "drizzle-orm/pg-core";
import { relations } from "drizzle-orm";
import { Organization, organization } from "./03_organization";
import { createSelectSchema } from "drizzle-zod";
import { z } from "zod";
import { Database, database } from "./07_database";
import {pgTable, text, boolean, uuid} from "drizzle-orm/pg-core";
import {relations} from "drizzle-orm";
import {Organization, organization} from "./03_organization";
import {createSelectSchema} from "drizzle-zod";
import {z} from "zod";
import {Database, database} from "./07_database";
import {timestamps} from "@/db/schema/00_common";
export const project = pgTable("projects", {
@@ -13,12 +13,11 @@ export const project = pgTable("projects", {
isArchived: boolean("is_archived").default(false),
organizationId: uuid("organization_id")
.notNull()
.references(() => organization.id),
.references(() => organization.id, {onDelete: "cascade"}),
...timestamps
});
export const projectRelations = relations(project, ({ one, many }) => ({
export const projectRelations = relations(project, ({one, many}) => ({
organization: one(organization, {
fields: [project.organizationId],
references: [organization.id],