🎉 init

This commit is contained in:
2026-07-01 15:43:18 +02:00
commit 2f492c55be
64 changed files with 11645 additions and 0 deletions
+41
View File
@@ -0,0 +1,41 @@
import { sql } from 'drizzle-orm'
import { index, integer, sqliteTable, text } from 'drizzle-orm/sqlite-core'
export const pots = sqliteTable('pots', {
slug: text('slug').primaryKey(),
name: text('name').notNull(),
currency: text('currency').notNull(),
createdAt: integer('created_at').notNull().default(sql`(unixepoch())`),
})
export const participants = sqliteTable('participants', {
id: integer('id').primaryKey({ autoIncrement: true }),
potSlug: text('pot_slug').notNull().references(() => pots.slug),
name: text('name').notNull(),
paymentLink: text('payment_link'),
createdAt: integer('created_at').notNull().default(sql`(unixepoch())`),
}, table => [
index('participants_pot_slug_idx').on(table.potSlug),
])
export const expenses = sqliteTable('expenses', {
id: integer('id').primaryKey({ autoIncrement: true }),
potSlug: text('pot_slug').notNull().references(() => pots.slug),
// 'payment' rows are settlements: payerId is who paid, and the single row
// in expenseParticipants is who received it — same shape as a one-person
// split expense, which is mathematically what a settlement is.
type: text('type').notNull().default('expense'),
description: text('description').notNull(),
amountCents: integer('amount_cents').notNull(),
payerId: integer('payer_id').notNull().references(() => participants.id),
createdAt: integer('created_at').notNull().default(sql`(unixepoch())`),
}, table => [
index('expenses_pot_slug_idx').on(table.potSlug),
])
export const expenseParticipants = sqliteTable('expense_participants', {
expenseId: integer('expense_id').notNull().references(() => expenses.id),
participantId: integer('participant_id').notNull().references(() => participants.id),
}, table => [
index('expense_participants_expense_id_idx').on(table.expenseId),
])