diff --git a/bun.lockb b/bun.lockb index 0c0572e..cb1892f 100755 Binary files a/bun.lockb and b/bun.lockb differ diff --git a/database/index.ts b/database/index.ts new file mode 100644 index 0000000..8ea5dfb --- /dev/null +++ b/database/index.ts @@ -0,0 +1,5 @@ +import { drizzle } from "drizzle-orm/libsql"; +import Database from "libsql"; + +const sqlite = new Database(":memory:"); +export const db = drizzle(sqlite); diff --git a/database/schema.ts b/database/schema.ts new file mode 100644 index 0000000..00798f4 --- /dev/null +++ b/database/schema.ts @@ -0,0 +1,25 @@ +import { integer, sqliteTable, text } from "drizzle-orm/sqlite-core"; + +export const guilds = sqliteTable("guilds", { + id: integer("id").primaryKey(), + name: text("name"), +}); +export type Guild = typeof guilds.$inferSelect; +export type InsertGuild = typeof guilds.$inferInsert; + +export const users = sqliteTable("users", { + id: integer("id").primaryKey(), + name: text("name"), + opt_out: integer("opt_out"), +}); +export type User = typeof users.$inferSelect; +export type InsertUser = typeof users.$inferInsert; + +export const messages = sqliteTable("messages", { + id: integer("id").primaryKey(), + content: text("content"), + user_id: integer("user_id").references(() => users.id), + guild_id: integer("guild_id").references(() => guilds.id), +}); +export type Message = typeof messages.$inferSelect; +export type InsertMessage = typeof messages.$inferInsert; \ No newline at end of file diff --git a/package.json b/package.json index 01845ab..3af9ced 100644 --- a/package.json +++ b/package.json @@ -7,7 +7,8 @@ }, "type": "module", "devDependencies": { - "@types/bun": "latest" + "@types/bun": "latest", + "drizzle-kit": "^0.20.17" }, "peerDependencies": { "typescript": "^5.0.0" @@ -15,6 +16,8 @@ "dependencies": { "@huggingface/inference": "^2.6.7", "discord.js": "^14.14.1", + "drizzle-orm": "^0.30.10", + "libsql": "^0.3.18", "openai": "^4.36.0" } }