Updated path for drizzle

This commit is contained in:
2024-10-03 17:55:01 +02:00
parent f5827809c0
commit 1497ec084c
28 changed files with 37 additions and 37 deletions

11
src/drizzle/db.ts Normal file
View File

@@ -0,0 +1,11 @@
import { drizzle } from "drizzle-orm/postgres-js"
import postgres from "postgres"
import env from "utils/Env.js"
import * as schema from "./schema.js"
const queryClient = postgres(env.prod.postgresURI)
const db = drizzle(queryClient, {
schema
})
export default db

View File

@@ -0,0 +1,40 @@
CREATE TABLE IF NOT EXISTS "guildApps" (
"id" serial PRIMARY KEY NOT NULL,
"userID" text NOT NULL,
"uuid" text NOT NULL,
"createdAt" timestamp DEFAULT now() NOT NULL,
"updatedAt" timestamp DEFAULT now() NOT NULL
);
--> statement-breakpoint
CREATE TABLE IF NOT EXISTS "settings" (
"id" serial PRIMARY KEY NOT NULL,
"name" text NOT NULL,
"value" text NOT NULL,
"createdAt" timestamp DEFAULT now() NOT NULL,
"updatedAt" timestamp DEFAULT now() NOT NULL
);
--> statement-breakpoint
CREATE TABLE IF NOT EXISTS "staffApps" (
"id" serial PRIMARY KEY NOT NULL,
"userID" text NOT NULL,
"uuid" text NOT NULL,
"createdAt" timestamp DEFAULT now() NOT NULL,
"updatedAt" timestamp DEFAULT now() NOT NULL
);
--> statement-breakpoint
CREATE TABLE IF NOT EXISTS "verifies" (
"id" serial PRIMARY KEY NOT NULL,
"userID" text NOT NULL,
"uuid" text NOT NULL,
"createdAt" timestamp DEFAULT now() NOT NULL,
"updatedAt" timestamp DEFAULT now() NOT NULL
);
--> statement-breakpoint
CREATE TABLE IF NOT EXISTS "waitingLists" (
"id" serial PRIMARY KEY NOT NULL,
"userID" text NOT NULL,
"uuid" text NOT NULL,
"timestamp" bigint NOT NULL,
"createdAt" timestamp DEFAULT now() NOT NULL,
"updatedAt" timestamp DEFAULT now() NOT NULL
);

View File

@@ -0,0 +1,232 @@
{
"id": "6343d646-6e68-4bcd-ae1e-5cecb4569268",
"prevId": "00000000-0000-0000-0000-000000000000",
"version": "7",
"dialect": "postgresql",
"tables": {
"public.guildApps": {
"name": "guildApps",
"schema": "",
"columns": {
"id": {
"name": "id",
"type": "serial",
"primaryKey": true,
"notNull": true
},
"userID": {
"name": "userID",
"type": "text",
"primaryKey": false,
"notNull": true
},
"uuid": {
"name": "uuid",
"type": "text",
"primaryKey": false,
"notNull": true
},
"createdAt": {
"name": "createdAt",
"type": "timestamp",
"primaryKey": false,
"notNull": true,
"default": "now()"
},
"updatedAt": {
"name": "updatedAt",
"type": "timestamp",
"primaryKey": false,
"notNull": true,
"default": "now()"
}
},
"indexes": {},
"foreignKeys": {},
"compositePrimaryKeys": {},
"uniqueConstraints": {}
},
"public.settings": {
"name": "settings",
"schema": "",
"columns": {
"id": {
"name": "id",
"type": "serial",
"primaryKey": true,
"notNull": true
},
"name": {
"name": "name",
"type": "text",
"primaryKey": false,
"notNull": true
},
"value": {
"name": "value",
"type": "text",
"primaryKey": false,
"notNull": true
},
"createdAt": {
"name": "createdAt",
"type": "timestamp",
"primaryKey": false,
"notNull": true,
"default": "now()"
},
"updatedAt": {
"name": "updatedAt",
"type": "timestamp",
"primaryKey": false,
"notNull": true,
"default": "now()"
}
},
"indexes": {},
"foreignKeys": {},
"compositePrimaryKeys": {},
"uniqueConstraints": {}
},
"public.staffApps": {
"name": "staffApps",
"schema": "",
"columns": {
"id": {
"name": "id",
"type": "serial",
"primaryKey": true,
"notNull": true
},
"userID": {
"name": "userID",
"type": "text",
"primaryKey": false,
"notNull": true
},
"uuid": {
"name": "uuid",
"type": "text",
"primaryKey": false,
"notNull": true
},
"createdAt": {
"name": "createdAt",
"type": "timestamp",
"primaryKey": false,
"notNull": true,
"default": "now()"
},
"updatedAt": {
"name": "updatedAt",
"type": "timestamp",
"primaryKey": false,
"notNull": true,
"default": "now()"
}
},
"indexes": {},
"foreignKeys": {},
"compositePrimaryKeys": {},
"uniqueConstraints": {}
},
"public.verifies": {
"name": "verifies",
"schema": "",
"columns": {
"id": {
"name": "id",
"type": "serial",
"primaryKey": true,
"notNull": true
},
"userID": {
"name": "userID",
"type": "text",
"primaryKey": false,
"notNull": true
},
"uuid": {
"name": "uuid",
"type": "text",
"primaryKey": false,
"notNull": true
},
"createdAt": {
"name": "createdAt",
"type": "timestamp",
"primaryKey": false,
"notNull": true,
"default": "now()"
},
"updatedAt": {
"name": "updatedAt",
"type": "timestamp",
"primaryKey": false,
"notNull": true,
"default": "now()"
}
},
"indexes": {},
"foreignKeys": {},
"compositePrimaryKeys": {},
"uniqueConstraints": {}
},
"public.waitingLists": {
"name": "waitingLists",
"schema": "",
"columns": {
"id": {
"name": "id",
"type": "serial",
"primaryKey": true,
"notNull": true
},
"userID": {
"name": "userID",
"type": "text",
"primaryKey": false,
"notNull": true
},
"uuid": {
"name": "uuid",
"type": "text",
"primaryKey": false,
"notNull": true
},
"timestamp": {
"name": "timestamp",
"type": "bigint",
"primaryKey": false,
"notNull": true
},
"createdAt": {
"name": "createdAt",
"type": "timestamp",
"primaryKey": false,
"notNull": true,
"default": "now()"
},
"updatedAt": {
"name": "updatedAt",
"type": "timestamp",
"primaryKey": false,
"notNull": true,
"default": "now()"
}
},
"indexes": {},
"foreignKeys": {},
"compositePrimaryKeys": {},
"uniqueConstraints": {}
}
},
"enums": {},
"schemas": {},
"sequences": {},
"_meta": {
"columns": {},
"schemas": {},
"tables": {}
}
}

View File

@@ -0,0 +1,13 @@
{
"version": "7",
"dialect": "postgresql",
"entries": [
{
"idx": 0,
"version": "7",
"when": 1727906753913,
"tag": "0000_bouncy_thor_girl",
"breakpoints": true
}
]
}

45
src/drizzle/schema.ts Normal file
View File

@@ -0,0 +1,45 @@
import { bigint, pgTable, serial, text, timestamp } from "drizzle-orm/pg-core"
const createdAt = timestamp("createdAt").notNull().defaultNow()
const updatedAt = timestamp("updatedAt").notNull().defaultNow().$onUpdate(() => new Date())
export const verifies = pgTable("verifies", {
id: serial("id").primaryKey(),
userID: text("userID").notNull(),
uuid: text("uuid").notNull(),
createdAt,
updatedAt
})
export const guildApps = pgTable("guildApps", {
id: serial("id").primaryKey(),
userID: text("userID").notNull(),
uuid: text("uuid").notNull(),
createdAt,
updatedAt
})
export const staffApps = pgTable("staffApps", {
id: serial("id").primaryKey(),
userID: text("userID").notNull(),
uuid: text("uuid").notNull(),
createdAt,
updatedAt
})
export const waitingLists = pgTable("waitingLists", {
id: serial("id").primaryKey(),
userID: text("userID").notNull(),
uuid: text("uuid").notNull(),
timestamp: bigint("timestamp", { mode: "number" }).notNull(),
createdAt,
updatedAt
})
export const settings = pgTable("settings", {
id: serial("id").primaryKey(),
name: text("name").notNull(),
value: text("value").notNull(),
createdAt,
updatedAt
})