🐛 add env to useDb and apply prettier
tinyedge/deploy Deployed by TinyEdge

This commit is contained in:
2026-08-07 13:28:26 +02:00
parent 67727f96ab
commit cbe1b42f6e
54 changed files with 5492 additions and 2406 deletions
+55 -33
View File
@@ -1,41 +1,63 @@
import { sql } from 'drizzle-orm'
import { index, integer, sqliteTable, text } from 'drizzle-orm/sqlite-core'
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())`),
})
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 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 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),
])
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)],
);