refactor: update organization

This commit is contained in:
Mauricio Siu
2025-02-15 20:25:58 -06:00
parent 87b12ff6e9
commit 53ce5e57fa
16 changed files with 5776 additions and 82 deletions
+7 -5
View File
@@ -6,6 +6,7 @@ import { z } from "zod";
import { admins } from "./admin";
import { backups } from "./backups";
import { users_temp } from "./user";
import { organization } from "./account";
// import { user } from "./user";
export const destinations = pgTable("destination", {
@@ -21,18 +22,19 @@ export const destinations = pgTable("destination", {
region: text("region").notNull(),
// maybe it can be null
endpoint: text("endpoint").notNull(),
// userId: text("userId")
// .notNull()
// .references(() => user.userId, { onDelete: "cascade" }),
userId: text("userId")
organizationId: text("organizationId")
.notNull()
.references(() => users_temp.id, { onDelete: "cascade" }),
.references(() => organization.id, { onDelete: "cascade" }),
});
export const destinationsRelations = relations(
destinations,
({ many, one }) => ({
backups: many(backups),
organization: one(organization, {
fields: [destinations.organizationId],
references: [organization.id],
}),
// user: one(user, {
// fields: [destinations.userId],
// references: [user.id],