first
This commit is contained in:
commit
0738070ce1
287 changed files with 10116 additions and 0 deletions
6
src/lib/server/db/index.js
Normal file
6
src/lib/server/db/index.js
Normal file
|
@ -0,0 +1,6 @@
|
|||
import { env } from "$env/dynamic/private";
|
||||
import { drizzle } from "drizzle-orm/postgres-js";
|
||||
import postgres from "postgres";
|
||||
if (!env.DATABASE_URL) throw new Error("DATABASE_URL is not set");
|
||||
const client = postgres(env.DATABASE_URL);
|
||||
export const db = drizzle(client, { casing: "snake_case" });
|
16
src/lib/server/db/schema.js
Normal file
16
src/lib/server/db/schema.js
Normal file
|
@ -0,0 +1,16 @@
|
|||
import { integer, pgTable, text, timestamp } from "drizzle-orm/pg-core";
|
||||
|
||||
export const users = pgTable("users", {
|
||||
id: text().primaryKey(),
|
||||
age: integer(),
|
||||
username: text().notNull().unique(),
|
||||
passwordHash: text().notNull(),
|
||||
});
|
||||
|
||||
export const sessions = pgTable("sessions", {
|
||||
id: text().primaryKey(),
|
||||
userId: text()
|
||||
.notNull()
|
||||
.references(() => users.id),
|
||||
expiresAt: timestamp({ withTimezone: true, mode: "date" }).notNull(),
|
||||
});
|
Loading…
Add table
Add a link
Reference in a new issue