Updated schema

This commit is contained in:
2024-10-07 19:16:08 +02:00
parent a22c2b75a6
commit 2be6cd60c5
5 changed files with 413 additions and 13 deletions

View File

@@ -0,0 +1,9 @@
CREATE INDEX IF NOT EXISTS "guildapps_userid_index" ON "guildApps" USING btree ("userID");--> statement-breakpoint
CREATE INDEX IF NOT EXISTS "guildapps_uuid_index" ON "guildApps" USING btree ("uuid");--> statement-breakpoint
CREATE INDEX IF NOT EXISTS "settings_name_index" ON "settings" USING btree ("name");--> statement-breakpoint
CREATE INDEX IF NOT EXISTS "staffapps_userid_index" ON "staffApps" USING btree ("userID");--> statement-breakpoint
CREATE INDEX IF NOT EXISTS "staffapps_uuid_index" ON "staffApps" USING btree ("uuid");--> statement-breakpoint
CREATE INDEX IF NOT EXISTS "verifies_userid_index" ON "verifies" USING btree ("userID");--> statement-breakpoint
CREATE INDEX IF NOT EXISTS "verifies_uuid_index" ON "verifies" USING btree ("uuid");--> statement-breakpoint
CREATE INDEX IF NOT EXISTS "wl_userid_index" ON "waitingLists" USING btree ("userID");--> statement-breakpoint
CREATE INDEX IF NOT EXISTS "wl_uuid_index" ON "waitingLists" USING btree ("uuid");

View File

@@ -0,0 +1,372 @@
{
"id": "85b695a3-72dd-4eb8-961b-0fe5220542ad",
"prevId": "de8f78f2-dc26-427d-9c12-233b5d3fa301",
"version": "7",
"dialect": "postgresql",
"tables": {
"public.guildApps": {
"name": "guildApps",
"schema": "",
"columns": {
"id": {
"name": "id",
"type": "serial",
"primaryKey": true,
"notNull": true
},
"userID": {
"name": "userID",
"type": "varchar(32)",
"primaryKey": false,
"notNull": true
},
"uuid": {
"name": "uuid",
"type": "varchar(32)",
"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": {
"guildapps_userid_index": {
"name": "guildapps_userid_index",
"columns": [
{
"expression": "userID",
"isExpression": false,
"asc": true,
"nulls": "last"
}
],
"isUnique": false,
"concurrently": false,
"method": "btree",
"with": {}
},
"guildapps_uuid_index": {
"name": "guildapps_uuid_index",
"columns": [
{
"expression": "uuid",
"isExpression": false,
"asc": true,
"nulls": "last"
}
],
"isUnique": false,
"concurrently": false,
"method": "btree",
"with": {}
}
},
"foreignKeys": {},
"compositePrimaryKeys": {},
"uniqueConstraints": {}
},
"public.settings": {
"name": "settings",
"schema": "",
"columns": {
"id": {
"name": "id",
"type": "serial",
"primaryKey": true,
"notNull": true
},
"name": {
"name": "name",
"type": "varchar(32)",
"primaryKey": false,
"notNull": true
},
"value": {
"name": "value",
"type": "varchar(256)",
"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": {
"settings_name_index": {
"name": "settings_name_index",
"columns": [
{
"expression": "name",
"isExpression": false,
"asc": true,
"nulls": "last"
}
],
"isUnique": false,
"concurrently": false,
"method": "btree",
"with": {}
}
},
"foreignKeys": {},
"compositePrimaryKeys": {},
"uniqueConstraints": {}
},
"public.staffApps": {
"name": "staffApps",
"schema": "",
"columns": {
"id": {
"name": "id",
"type": "serial",
"primaryKey": true,
"notNull": true
},
"userID": {
"name": "userID",
"type": "varchar(32)",
"primaryKey": false,
"notNull": true
},
"uuid": {
"name": "uuid",
"type": "varchar(32)",
"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": {
"staffapps_userid_index": {
"name": "staffapps_userid_index",
"columns": [
{
"expression": "userID",
"isExpression": false,
"asc": true,
"nulls": "last"
}
],
"isUnique": false,
"concurrently": false,
"method": "btree",
"with": {}
},
"staffapps_uuid_index": {
"name": "staffapps_uuid_index",
"columns": [
{
"expression": "uuid",
"isExpression": false,
"asc": true,
"nulls": "last"
}
],
"isUnique": false,
"concurrently": false,
"method": "btree",
"with": {}
}
},
"foreignKeys": {},
"compositePrimaryKeys": {},
"uniqueConstraints": {}
},
"public.verifies": {
"name": "verifies",
"schema": "",
"columns": {
"id": {
"name": "id",
"type": "serial",
"primaryKey": true,
"notNull": true
},
"userID": {
"name": "userID",
"type": "varchar(32)",
"primaryKey": false,
"notNull": true
},
"uuid": {
"name": "uuid",
"type": "varchar(32)",
"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": {
"verifies_userid_index": {
"name": "verifies_userid_index",
"columns": [
{
"expression": "userID",
"isExpression": false,
"asc": true,
"nulls": "last"
}
],
"isUnique": false,
"concurrently": false,
"method": "btree",
"with": {}
},
"verifies_uuid_index": {
"name": "verifies_uuid_index",
"columns": [
{
"expression": "uuid",
"isExpression": false,
"asc": true,
"nulls": "last"
}
],
"isUnique": false,
"concurrently": false,
"method": "btree",
"with": {}
}
},
"foreignKeys": {},
"compositePrimaryKeys": {},
"uniqueConstraints": {}
},
"public.waitingLists": {
"name": "waitingLists",
"schema": "",
"columns": {
"id": {
"name": "id",
"type": "serial",
"primaryKey": true,
"notNull": true
},
"userID": {
"name": "userID",
"type": "varchar(32)",
"primaryKey": false,
"notNull": true
},
"uuid": {
"name": "uuid",
"type": "varchar(32)",
"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": {
"wl_userid_index": {
"name": "wl_userid_index",
"columns": [
{
"expression": "userID",
"isExpression": false,
"asc": true,
"nulls": "last"
}
],
"isUnique": false,
"concurrently": false,
"method": "btree",
"with": {}
},
"wl_uuid_index": {
"name": "wl_uuid_index",
"columns": [
{
"expression": "uuid",
"isExpression": false,
"asc": true,
"nulls": "last"
}
],
"isUnique": false,
"concurrently": false,
"method": "btree",
"with": {}
}
},
"foreignKeys": {},
"compositePrimaryKeys": {},
"uniqueConstraints": {}
}
},
"enums": {},
"schemas": {},
"sequences": {},
"_meta": {
"columns": {},
"schemas": {},
"tables": {}
}
}

View File

@@ -15,6 +15,13 @@
"when": 1728318584421,
"tag": "0001_quick_meggan",
"breakpoints": true
},
{
"idx": 2,
"version": "7",
"when": 1728321163523,
"tag": "0002_jittery_wallow",
"breakpoints": true
}
]
}

View File

@@ -1,4 +1,4 @@
import { bigint, pgTable, serial, timestamp, varchar } from "drizzle-orm/pg-core"
import { bigint, index, pgTable, serial, timestamp, varchar } from "drizzle-orm/pg-core"
const createdAt = timestamp("createdAt").notNull().defaultNow()
const updatedAt = timestamp("updatedAt").notNull().defaultNow().$onUpdate(() => new Date())
@@ -9,6 +9,11 @@ export const verifies = pgTable("verifies", {
uuid: varchar("uuid", { length: 32 }).notNull(),
createdAt,
updatedAt
}, table => {
return {
useridIndex: index("verifies_userid_index").on(table.userID),
uuidIndex: index("verifies_uuid_index").on(table.uuid)
}
})
export const guildApps = pgTable("guildApps", {
@@ -17,6 +22,11 @@ export const guildApps = pgTable("guildApps", {
uuid: varchar("uuid", { length: 32 }).notNull(),
createdAt,
updatedAt
}, table => {
return {
useridIndex: index("guildapps_userid_index").on(table.userID),
uuidIndex: index("guildapps_uuid_index").on(table.uuid)
}
})
export const staffApps = pgTable("staffApps", {
@@ -25,6 +35,11 @@ export const staffApps = pgTable("staffApps", {
uuid: varchar("uuid", { length: 32 }).notNull(),
createdAt,
updatedAt
}, table => {
return {
useridIndex: index("staffapps_userid_index").on(table.userID),
uuidIndex: index("staffapps_uuid_index").on(table.uuid)
}
})
export const waitingLists = pgTable("waitingLists", {
@@ -34,6 +49,11 @@ export const waitingLists = pgTable("waitingLists", {
timestamp: bigint("timestamp", { mode: "number" }).notNull(),
createdAt,
updatedAt
}, table => {
return {
useridIndex: index("wl_userid_index").on(table.userID),
uuidIndex: index("wl_uuid_index").on(table.uuid)
}
})
export const settings = pgTable("settings", {
@@ -42,6 +62,10 @@ export const settings = pgTable("settings", {
value: varchar("value", { length: 256 }).notNull(),
createdAt,
updatedAt
}, table => {
return {
nameIndex: index("settings_name_index").on(table.name)
}
})
export type SelectVerify = typeof verifies.$inferSelect

View File

@@ -1,9 +1,6 @@
import { Player } from "discord-player"
import { YoutubeiExtractor } from "discord-player-youtubei"
import { drizzle } from "drizzle-orm/postgres-js"
import { migrate } from "drizzle-orm/postgres-js/migrator"
import { Redis } from "ioredis"
import postgres from "postgres"
import { ExtendedClient as Client } from "~/utils/Client.js"
import env from "~/utils/Env.js"
import { color } from "~/utils/functions/colors.js"
@@ -24,7 +21,6 @@ if (process.env.NODE_ENV === "dev" && process.env.TYPESCRIPT === "true") {
class Illegitimate {
async start() {
await this.init()
await this.migrations()
await loadAllEvents(client, ft)
// await player.extractors.loadDefault()
await player.extractors.loadDefault(ext => ext != "YouTubeExtractor")
@@ -58,14 +54,6 @@ class Illegitimate {
}
}
private async migrations() {
const migrationsClient = postgres(env.prod.postgresURI)
const migrations = drizzle(migrationsClient)
await migrate(migrations, {
migrationsFolder: "./src/drizzle/migrations/"
})
}
private loadMethods() {
String.prototype.removeIndents = function(this: string) {
return this.replace(/^ */gm, "")