refactor: update

This commit is contained in:
Mauricio Siu
2025-02-15 20:26:05 -06:00
parent 53ce5e57fa
commit 6d0e195a4d
10 changed files with 91 additions and 73 deletions

View File

@@ -1,77 +1,95 @@
import { pgTable, text, integer, timestamp, boolean } from "drizzle-orm/pg-core"; import {
boolean,
integer,
pgTable,
text,
timestamp,
} from "drizzle-orm/pg-core";
export const users_temp = pgTable("users_temp", { export const users_temp = pgTable("users_temp", {
id: text("id").primaryKey(), id: text("id").primaryKey(),
name: text('name').notNull(), name: text("name").notNull(),
email: text('email').notNull().unique(), email: text("email").notNull().unique(),
emailVerified: boolean('email_verified').notNull(), emailVerified: boolean("email_verified").notNull(),
image: text('image'), image: text("image"),
createdAt: timestamp('created_at').notNull(), createdAt: timestamp("created_at").notNull(),
updatedAt: timestamp('updated_at').notNull(), updatedAt: timestamp("updated_at").notNull(),
role: text('role').notNull(), role: text("role").notNull(),
ownerId: text('owner_id').notNull() ownerId: text("owner_id").notNull(),
}); });
export const session = pgTable("session", { export const session = pgTable("session", {
id: text("id").primaryKey(), id: text("id").primaryKey(),
expiresAt: timestamp('expires_at').notNull(), expiresAt: timestamp("expires_at").notNull(),
token: text('token').notNull().unique(), token: text("token").notNull().unique(),
createdAt: timestamp('created_at').notNull(), createdAt: timestamp("created_at").notNull(),
updatedAt: timestamp('updated_at').notNull(), updatedAt: timestamp("updated_at").notNull(),
ipAddress: text('ip_address'), ipAddress: text("ip_address"),
userAgent: text('user_agent'), userAgent: text("user_agent"),
userId: text('user_id').notNull().references(()=> users_temp.id, { onDelete: 'cascade' }), userId: text("user_id")
activeOrganizationId: text('active_organization_id') .notNull()
}); .references(() => users_temp.id, { onDelete: "cascade" }),
activeOrganizationId: text("active_organization_id"),
});
export const account = pgTable("account", { export const account = pgTable("account", {
id: text("id").primaryKey(), id: text("id").primaryKey(),
accountId: text('account_id').notNull(), accountId: text("account_id").notNull(),
providerId: text('provider_id').notNull(), providerId: text("provider_id").notNull(),
userId: text('user_id').notNull().references(()=> users_temp.id, { onDelete: 'cascade' }), userId: text("user_id")
accessToken: text('access_token'), .notNull()
refreshToken: text('refresh_token'), .references(() => users_temp.id, { onDelete: "cascade" }),
idToken: text('id_token'), accessToken: text("access_token"),
accessTokenExpiresAt: timestamp('access_token_expires_at'), refreshToken: text("refresh_token"),
refreshTokenExpiresAt: timestamp('refresh_token_expires_at'), idToken: text("id_token"),
scope: text('scope'), accessTokenExpiresAt: timestamp("access_token_expires_at"),
password: text('password'), refreshTokenExpiresAt: timestamp("refresh_token_expires_at"),
createdAt: timestamp('created_at').notNull(), scope: text("scope"),
updatedAt: timestamp('updated_at').notNull() password: text("password"),
}); createdAt: timestamp("created_at").notNull(),
updatedAt: timestamp("updated_at").notNull(),
});
export const verification = pgTable("verification", { export const verification = pgTable("verification", {
id: text("id").primaryKey(), id: text("id").primaryKey(),
identifier: text('identifier').notNull(), identifier: text("identifier").notNull(),
value: text('value').notNull(), value: text("value").notNull(),
expiresAt: timestamp('expires_at').notNull(), expiresAt: timestamp("expires_at").notNull(),
createdAt: timestamp('created_at'), createdAt: timestamp("created_at"),
updatedAt: timestamp('updated_at') updatedAt: timestamp("updated_at"),
}); });
export const organization = pgTable("organization", { export const organization = pgTable("organization", {
id: text("id").primaryKey(), id: text("id").primaryKey(),
name: text('name').notNull(), name: text("name").notNull(),
slug: text('slug').unique(), slug: text("slug").unique(),
logo: text('logo'), logo: text("logo"),
createdAt: timestamp('created_at').notNull(), createdAt: timestamp("created_at").notNull(),
metadata: text('metadata') metadata: text("metadata"),
}); });
export const member = pgTable("member", { export const member = pgTable("member", {
id: text("id").primaryKey(), id: text("id").primaryKey(),
organizationId: text('organization_id').notNull().references(()=> organization.id, { onDelete: 'cascade' }), organizationId: text("organization_id")
userId: text('user_id').notNull().references(()=> user.id, { onDelete: 'cascade' }), .notNull()
role: text('role').notNull(), .references(() => organization.id, { onDelete: "cascade" }),
createdAt: timestamp('created_at').notNull() userId: text("user_id")
}); .notNull()
.references(() => user.id, { onDelete: "cascade" }),
role: text("role").notNull(),
createdAt: timestamp("created_at").notNull(),
});
export const invitation = pgTable("invitation", { export const invitation = pgTable("invitation", {
id: text("id").primaryKey(), id: text("id").primaryKey(),
organizationId: text('organization_id').notNull().references(()=> organization.id, { onDelete: 'cascade' }), organizationId: text("organization_id")
email: text('email').notNull(), .notNull()
role: text('role'), .references(() => organization.id, { onDelete: "cascade" }),
status: text('status').notNull(), email: text("email").notNull(),
expiresAt: timestamp('expires_at').notNull(), role: text("role"),
inviterId: text('inviter_id').notNull().references(()=> user.id, { onDelete: 'cascade' }) status: text("status").notNull(),
}); expiresAt: timestamp("expires_at").notNull(),
inviterId: text("inviter_id")
.notNull()
.references(() => user.id, { onDelete: "cascade" }),
});

View File

@@ -3,12 +3,12 @@ import { boolean, pgTable, text } from "drizzle-orm/pg-core";
import { createInsertSchema } from "drizzle-zod"; import { createInsertSchema } from "drizzle-zod";
import { nanoid } from "nanoid"; import { nanoid } from "nanoid";
import { z } from "zod"; import { z } from "zod";
import { organization } from "./account";
import { admins } from "./admin"; import { admins } from "./admin";
import { server } from "./server"; import { server } from "./server";
import { users_temp } from "./user"; import { users_temp } from "./user";
// import { user } from "./user"; // import { user } from "./user";
import { generateAppName } from "./utils"; import { generateAppName } from "./utils";
import { organization } from "./account";
export const certificates = pgTable("certificate", { export const certificates = pgTable("certificate", {
certificateId: text("certificateId") certificateId: text("certificateId")

View File

@@ -3,10 +3,10 @@ import { pgTable, text } from "drizzle-orm/pg-core";
import { createInsertSchema } from "drizzle-zod"; import { createInsertSchema } from "drizzle-zod";
import { nanoid } from "nanoid"; import { nanoid } from "nanoid";
import { z } from "zod"; import { z } from "zod";
import { organization } from "./account";
import { admins } from "./admin"; import { admins } from "./admin";
import { backups } from "./backups"; import { backups } from "./backups";
import { users_temp } from "./user"; import { users_temp } from "./user";
import { organization } from "./account";
// import { user } from "./user"; // import { user } from "./user";
export const destinations = pgTable("destination", { export const destinations = pgTable("destination", {

View File

@@ -3,12 +3,12 @@ import { pgEnum, pgTable, text } from "drizzle-orm/pg-core";
import { createInsertSchema } from "drizzle-zod"; import { createInsertSchema } from "drizzle-zod";
import { nanoid } from "nanoid"; import { nanoid } from "nanoid";
import { z } from "zod"; import { z } from "zod";
import { organization } from "./account";
import { admins } from "./admin"; import { admins } from "./admin";
import { bitbucket } from "./bitbucket"; import { bitbucket } from "./bitbucket";
import { github } from "./github"; import { github } from "./github";
import { gitlab } from "./gitlab"; import { gitlab } from "./gitlab";
import { users_temp } from "./user"; import { users_temp } from "./user";
import { organization } from "./account";
// import { user } from "./user"; // import { user } from "./user";
export const gitProviderType = pgEnum("gitProviderType", [ export const gitProviderType = pgEnum("gitProviderType", [

View File

@@ -3,8 +3,8 @@ import { boolean, integer, pgEnum, pgTable, text } from "drizzle-orm/pg-core";
import { createInsertSchema } from "drizzle-zod"; import { createInsertSchema } from "drizzle-zod";
import { nanoid } from "nanoid"; import { nanoid } from "nanoid";
import { z } from "zod"; import { z } from "zod";
import { users_temp } from "./user";
import { organization } from "./account"; import { organization } from "./account";
import { users_temp } from "./user";
// import { user } from "./user"; // import { user } from "./user";
export const notificationType = pgEnum("notificationType", [ export const notificationType = pgEnum("notificationType", [

View File

@@ -4,6 +4,7 @@ import { pgTable, text } from "drizzle-orm/pg-core";
import { createInsertSchema } from "drizzle-zod"; import { createInsertSchema } from "drizzle-zod";
import { nanoid } from "nanoid"; import { nanoid } from "nanoid";
import { z } from "zod"; import { z } from "zod";
import { organization } from "./account";
import { admins } from "./admin"; import { admins } from "./admin";
// import { admins } from "./admin"; // import { admins } from "./admin";
import { applications } from "./application"; import { applications } from "./application";
@@ -14,7 +15,6 @@ import { mysql } from "./mysql";
import { postgres } from "./postgres"; import { postgres } from "./postgres";
import { redis } from "./redis"; import { redis } from "./redis";
import { users, users_temp } from "./user"; import { users, users_temp } from "./user";
import { organization } from "./account";
export const projects = pgTable("project", { export const projects = pgTable("project", {
projectId: text("projectId") projectId: text("projectId")

View File

@@ -3,10 +3,10 @@ import { pgEnum, pgTable, text } from "drizzle-orm/pg-core";
import { createInsertSchema } from "drizzle-zod"; import { createInsertSchema } from "drizzle-zod";
import { nanoid } from "nanoid"; import { nanoid } from "nanoid";
import { z } from "zod"; import { z } from "zod";
import { organization } from "./account";
import { admins } from "./admin"; import { admins } from "./admin";
import { applications } from "./application"; import { applications } from "./application";
import { users_temp } from "./user"; import { users_temp } from "./user";
import { organization } from "./account";
// import { user } from "./user"; // import { user } from "./user";
/** /**
* This is an example of how to use the multi-project schema feature of Drizzle ORM. Use the same * This is an example of how to use the multi-project schema feature of Drizzle ORM. Use the same

View File

@@ -11,6 +11,7 @@ import { createInsertSchema } from "drizzle-zod";
import { nanoid } from "nanoid"; import { nanoid } from "nanoid";
import { z } from "zod"; import { z } from "zod";
import { organization } from "./account";
import { admins } from "./admin"; import { admins } from "./admin";
import { applications } from "./application"; import { applications } from "./application";
import { certificates } from "./certificate"; import { certificates } from "./certificate";
@@ -25,7 +26,6 @@ import { sshKeys } from "./ssh-key";
import { users_temp } from "./user"; import { users_temp } from "./user";
// import { user } from "./user"; // import { user } from "./user";
import { generateAppName } from "./utils"; import { generateAppName } from "./utils";
import { organization } from "./account";
export const serverStatus = pgEnum("serverStatus", ["active", "inactive"]); export const serverStatus = pgEnum("serverStatus", ["active", "inactive"]);

View File

@@ -3,12 +3,12 @@ import { pgTable, text } from "drizzle-orm/pg-core";
import { createInsertSchema } from "drizzle-zod"; import { createInsertSchema } from "drizzle-zod";
import { nanoid } from "nanoid"; import { nanoid } from "nanoid";
import { sshKeyCreate, sshKeyType } from "../validations"; import { sshKeyCreate, sshKeyType } from "../validations";
import { organization } from "./account";
import { admins } from "./admin"; import { admins } from "./admin";
import { applications } from "./application"; import { applications } from "./application";
import { compose } from "./compose"; import { compose } from "./compose";
import { server } from "./server"; import { server } from "./server";
import { users_temp } from "./user"; import { users_temp } from "./user";
import { organization } from "./account";
// import { user } from "./user"; // import { user } from "./user";
export const sshKeys = pgTable("ssh-key", { export const sshKeys = pgTable("ssh-key", {

View File

@@ -13,8 +13,8 @@ import { z } from "zod";
import { account, organization } from "./account"; import { account, organization } from "./account";
import { admins } from "./admin"; import { admins } from "./admin";
import { auth } from "./auth"; import { auth } from "./auth";
import { certificateType } from "./shared";
import { projects } from "./project"; import { projects } from "./project";
import { certificateType } from "./shared";
/** /**
* This is an example of how to use the multi-project schema feature of Drizzle ORM. Use the same * This is an example of how to use the multi-project schema feature of Drizzle ORM. Use the same
* database instance for multiple projects. * database instance for multiple projects.