-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
13 changed files
with
332 additions
and
185 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -14,4 +14,6 @@ README.md | |
node_modules | ||
build | ||
package | ||
**/.env | ||
**/.env | ||
|
||
db/database.db |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
CREATE TABLE `question` ( | ||
`id` text PRIMARY KEY NOT NULL, | ||
`for_username` text NOT NULL, | ||
`text` text NOT NULL, | ||
`created_at` text DEFAULT (CURRENT_TIMESTAMP), | ||
FOREIGN KEY (`for_username`) REFERENCES `user`(`username`) ON UPDATE no action ON DELETE no action | ||
); | ||
--> statement-breakpoint | ||
CREATE TABLE `session` ( | ||
`id` text PRIMARY KEY NOT NULL, | ||
`user_id` text NOT NULL, | ||
`expires_at` integer NOT NULL, | ||
FOREIGN KEY (`user_id`) REFERENCES `user`(`id`) ON UPDATE no action ON DELETE no action | ||
); | ||
--> statement-breakpoint | ||
CREATE TABLE `user` ( | ||
`id` text PRIMARY KEY NOT NULL, | ||
`username` text NOT NULL, | ||
`hashed_password` text NOT NULL, | ||
`image_url` text DEFAULT '/tbh.webp' | ||
); | ||
--> statement-breakpoint | ||
CREATE UNIQUE INDEX `user_username_unique` ON `user` (`username`); |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,8 @@ | ||
import { drizzle } from 'drizzle-orm/postgres-js'; | ||
import { drizzle } from 'drizzle-orm/better-sqlite3'; | ||
import * as schema from './schema'; | ||
import { DATABASE_URL } from '$env/static/private'; | ||
import postgres from 'postgres'; | ||
import Database from 'better-sqlite3'; | ||
|
||
const pg = postgres(DATABASE_URL); | ||
const db = drizzle(pg, { schema }); | ||
const sqlite = new Database('db/database.db') | ||
const db = drizzle(sqlite, { schema }); | ||
|
||
export default db; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,29 +1,26 @@ | ||
import { sql } from "drizzle-orm"; | ||
import { pgTable, text, integer, date, timestamp } from "drizzle-orm/pg-core"; | ||
import { sqliteTable, text, integer } from "drizzle-orm/sqlite-core"; | ||
|
||
export const user = pgTable("user", { | ||
id: text("id").primaryKey().default(crypto.randomUUID()), | ||
export const user = sqliteTable("user", { | ||
id: text("id").primaryKey().notNull(), | ||
username: text("username").notNull().unique(), | ||
hashedPassword: text("hashed_password").notNull(), | ||
imageUrl: text("image_url").default('/tbh.webp'), | ||
}); | ||
|
||
export const session = pgTable("session", { | ||
id: text("id").primaryKey(), | ||
export const session = sqliteTable("session", { | ||
id: text("id").notNull().primaryKey(), | ||
userId: text("user_id") | ||
.notNull() | ||
.references(() => user.id), | ||
expiresAt: timestamp("expires_at", { | ||
withTimezone: true, | ||
mode: "date" | ||
}).notNull() | ||
expiresAt: integer("expires_at").notNull() | ||
}); | ||
|
||
export const question = pgTable("question", { | ||
export const question = sqliteTable("question", { | ||
id: text("id").primaryKey(), | ||
forUsername: text("for_username") | ||
.notNull() | ||
.references(() => user.username), | ||
body: text("text").notNull(), | ||
createdAt: date('created-at') | ||
createdAt: text("created_at").default(sql`(CURRENT_TIMESTAMP)`), | ||
}); |
Oops, something went wrong.