mirror of
https://github.com/BradNut/boredgame
synced 2025-09-08 17:40:22 +00:00
Migrating to Drizzle.
This commit is contained in:
parent
6a66a51085
commit
354838f4f6
4 changed files with 726 additions and 25 deletions
11
drizzle.config.ts
Normal file
11
drizzle.config.ts
Normal file
|
|
@ -0,0 +1,11 @@
|
||||||
|
import 'dotenv/config';
|
||||||
|
import { defineConfig } from 'drizzle-kit';
|
||||||
|
|
||||||
|
export default defineConfig({
|
||||||
|
schema: './src/schema.ts',
|
||||||
|
out: './drizzle',
|
||||||
|
driver: 'mysql2',
|
||||||
|
dbCredentials: {
|
||||||
|
connectionString: process.env.DATABASE_URL
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
@ -39,6 +39,7 @@
|
||||||
"@typescript-eslint/eslint-plugin": "^6.20.0",
|
"@typescript-eslint/eslint-plugin": "^6.20.0",
|
||||||
"@typescript-eslint/parser": "^6.20.0",
|
"@typescript-eslint/parser": "^6.20.0",
|
||||||
"autoprefixer": "^10.4.17",
|
"autoprefixer": "^10.4.17",
|
||||||
|
"drizzle-kit": "^0.20.13",
|
||||||
"eslint": "^8.56.0",
|
"eslint": "^8.56.0",
|
||||||
"eslint-config-prettier": "^9.1.0",
|
"eslint-config-prettier": "^9.1.0",
|
||||||
"eslint-plugin-svelte": "^2.35.1",
|
"eslint-plugin-svelte": "^2.35.1",
|
||||||
|
|
@ -78,9 +79,11 @@
|
||||||
"@fontsource/fira-mono": "^4.5.10",
|
"@fontsource/fira-mono": "^4.5.10",
|
||||||
"@iconify-icons/line-md": "^1.2.26",
|
"@iconify-icons/line-md": "^1.2.26",
|
||||||
"@iconify-icons/mdi": "^1.2.47",
|
"@iconify-icons/mdi": "^1.2.47",
|
||||||
|
"@lucia-auth/adapter-drizzle": "^1.0.0",
|
||||||
"@lucia-auth/adapter-prisma": "4.0.0",
|
"@lucia-auth/adapter-prisma": "4.0.0",
|
||||||
"@lukeed/uuid": "^2.0.1",
|
"@lukeed/uuid": "^2.0.1",
|
||||||
"@paralleldrive/cuid2": "^2.2.2",
|
"@paralleldrive/cuid2": "^2.2.2",
|
||||||
|
"@planetscale/database": "^1.14.0",
|
||||||
"@prisma/client": "^5.8.1",
|
"@prisma/client": "^5.8.1",
|
||||||
"@sentry/sveltekit": "^7.88.0",
|
"@sentry/sveltekit": "^7.88.0",
|
||||||
"@sveltejs/adapter-vercel": "^5.1.0",
|
"@sveltejs/adapter-vercel": "^5.1.0",
|
||||||
|
|
@ -91,6 +94,7 @@
|
||||||
"class-variance-authority": "^0.7.0",
|
"class-variance-authority": "^0.7.0",
|
||||||
"clsx": "^2.1.0",
|
"clsx": "^2.1.0",
|
||||||
"cookie": "^0.5.0",
|
"cookie": "^0.5.0",
|
||||||
|
"drizzle-orm": "^0.29.3",
|
||||||
"feather-icons": "^4.29.1",
|
"feather-icons": "^4.29.1",
|
||||||
"formsnap": "^0.4.3",
|
"formsnap": "^0.4.3",
|
||||||
"html-entities": "^2.4.0",
|
"html-entities": "^2.4.0",
|
||||||
|
|
@ -99,6 +103,7 @@
|
||||||
"loader": "^2.1.1",
|
"loader": "^2.1.1",
|
||||||
"lucia": "3.0.1",
|
"lucia": "3.0.1",
|
||||||
"lucide-svelte": "^0.298.0",
|
"lucide-svelte": "^0.298.0",
|
||||||
|
"mysql2": "^3.9.1",
|
||||||
"open-props": "^1.6.18",
|
"open-props": "^1.6.18",
|
||||||
"oslo": "^1.0.3",
|
"oslo": "^1.0.3",
|
||||||
"radix-svelte": "^0.9.0",
|
"radix-svelte": "^0.9.0",
|
||||||
|
|
|
||||||
708
pnpm-lock.yaml
708
pnpm-lock.yaml
File diff suppressed because it is too large
Load diff
27
src/schema.ts
Normal file
27
src/schema.ts
Normal file
|
|
@ -0,0 +1,27 @@
|
||||||
|
import { DrizzleMySQLAdapter } from "@lucia-auth/adapter-drizzle";
|
||||||
|
import mysql from "mysql2/promise";
|
||||||
|
import { int, mysqlEnum, mysqlTable, uniqueIndex, datetime, varchar, serial } from 'drizzle-orm/mysql-core';
|
||||||
|
import { drizzle } from "drizzle-orm/mysql2";
|
||||||
|
|
||||||
|
const connection = await mysql.createConnection();
|
||||||
|
const db = drizzle(connection);
|
||||||
|
|
||||||
|
const userTable = mysqlTable("user", {
|
||||||
|
id: varchar("id", {
|
||||||
|
length: 255
|
||||||
|
}).primaryKey()
|
||||||
|
});
|
||||||
|
|
||||||
|
const sessionTable = mysqlTable("session", {
|
||||||
|
id: varchar("id", {
|
||||||
|
length: 255
|
||||||
|
}).primaryKey(),
|
||||||
|
userId: varchar("user_id", {
|
||||||
|
length: 255
|
||||||
|
})
|
||||||
|
.notNull()
|
||||||
|
.references(() => userTable.id),
|
||||||
|
expiresAt: datetime("expires_at").notNull()
|
||||||
|
});
|
||||||
|
|
||||||
|
const adapter = new DrizzleMySQLAdapter(db, sessionTable, userTable);
|
||||||
Loading…
Reference in a new issue