refactor: update name

This commit is contained in:
Mauricio Siu
2025-02-10 02:13:52 -06:00
parent b7112b89fd
commit 6179cef1ee
16 changed files with 249 additions and 446 deletions

View File

@@ -7,7 +7,7 @@ export const account = pgTable("account", {
providerId: text("provider_id").notNull(),
userId: text("user_id")
.notNull()
.references(() => user.id),
.references(() => user.userId),
accessToken: text("access_token"),
refreshToken: text("refresh_token"),
idToken: text("id_token"),
@@ -42,7 +42,7 @@ export const organization = pgTable("organization", {
metadata: text("metadata"),
ownerId: text("owner_id")
.notNull()
.references(() => user.id),
.references(() => user.userId),
});
export const member = pgTable("member", {
@@ -52,7 +52,7 @@ export const member = pgTable("member", {
.references(() => organization.id),
userId: text("user_id")
.notNull()
.references(() => user.id),
.references(() => user.userId),
role: text("role").notNull(),
createdAt: timestamp("created_at").notNull(),
});
@@ -68,5 +68,5 @@ export const invitation = pgTable("invitation", {
expiresAt: timestamp("expires_at").notNull(),
inviterId: text("inviter_id")
.notNull()
.references(() => user.id),
.references(() => user.userId),
});

View File

@@ -20,7 +20,7 @@ export const certificates = pgTable("certificate", {
.$defaultFn(() => generateAppName("certificate"))
.unique(),
autoRenew: boolean("autoRenew"),
userId: text("userId").references(() => user.id, {
userId: text("userId").references(() => user.userId, {
onDelete: "cascade",
}),
serverId: text("serverId").references(() => server.serverId, {

View File

@@ -22,7 +22,7 @@ export const destinations = pgTable("destination", {
endpoint: text("endpoint").notNull(),
userId: text("userId")
.notNull()
.references(() => user.id, { onDelete: "cascade" }),
.references(() => user.userId, { onDelete: "cascade" }),
});
export const destinationsRelations = relations(

View File

@@ -25,7 +25,7 @@ export const gitProvider = pgTable("git_provider", {
createdAt: text("createdAt")
.notNull()
.$defaultFn(() => new Date().toISOString()),
userId: text("userId").references(() => user.id, {
userId: text("userId").references(() => user.userId, {
onDelete: "cascade",
}),
});

View File

@@ -45,7 +45,7 @@ export const notifications = pgTable("notification", {
gotifyId: text("gotifyId").references(() => gotify.gotifyId, {
onDelete: "cascade",
}),
userId: text("userId").references(() => user.id, {
userId: text("userId").references(() => user.userId, {
onDelete: "cascade",
}),
});

View File

@@ -26,7 +26,7 @@ export const projects = pgTable("project", {
.$defaultFn(() => new Date().toISOString()),
userId: text("userId")
.notNull()
.references(() => user.id, { onDelete: "cascade" }),
.references(() => user.userId, { onDelete: "cascade" }),
env: text("env").notNull().default(""),
});

View File

@@ -30,7 +30,7 @@ export const registry = pgTable("registry", {
registryType: registryType("selfHosted").notNull().default("cloud"),
userId: text("userId")
.notNull()
.references(() => user.id, { onDelete: "cascade" }),
.references(() => user.userId, { onDelete: "cascade" }),
});
export const registryRelations = relations(registry, ({ one, many }) => ({

View File

@@ -46,7 +46,7 @@ export const server = pgTable("server", {
.$defaultFn(() => new Date().toISOString()),
userId: text("userId")
.notNull()
.references(() => user.id, { onDelete: "cascade" }),
.references(() => user.userId, { onDelete: "cascade" }),
serverStatus: serverStatus("serverStatus").notNull().default("active"),
command: text("command").notNull().default(""),
sshKeyId: text("sshKeyId").references(() => sshKeys.sshKeyId, {

View File

@@ -1,3 +1,4 @@
import { sql } from "drizzle-orm";
import { pgTable, text, timestamp } from "drizzle-orm/pg-core";
import { user } from "./user";
@@ -5,14 +6,14 @@ import { user } from "./user";
export const session = pgTable("session", {
id: text("id").primaryKey(),
expiresAt: timestamp("expires_at").notNull(),
token: text("token").notNull().unique(),
// token: text("token").notNull().unique().default(sql`gen_random_uuid()`),
createdAt: timestamp("created_at").notNull(),
updatedAt: timestamp("updated_at").notNull(),
ipAddress: text("ip_address"),
userAgent: text("user_agent"),
userId: text("user_id")
.notNull()
.references(() => user.id),
.references(() => user.userId),
impersonatedBy: text("impersonated_by"),
activeOrganizationId: text("active_organization_id"),
});

View File

@@ -22,7 +22,7 @@ export const sshKeys = pgTable("ssh-key", {
.notNull()
.$defaultFn(() => new Date().toISOString()),
lastUsedAt: text("lastUsedAt"),
userId: text("userId").references(() => user.id, {
userId: text("userId").references(() => user.userId, {
onDelete: "cascade",
}),
});

View File

@@ -22,7 +22,7 @@ import { certificateType } from "./shared";
// OLD TABLE
export const user = pgTable("user", {
id: text("id")
userId: text("userId")
.notNull()
.primaryKey()
.$defaultFn(() => nanoid()),