Files
splitt-the-bill/server/database/migrations/0000_even_shinobi_shaw.sql
T
2026-07-01 15:43:18 +02:00

36 lines
1.5 KiB
SQL

CREATE TABLE `expense_participants` (
`expense_id` integer NOT NULL,
`participant_id` integer NOT NULL,
FOREIGN KEY (`expense_id`) REFERENCES `expenses`(`id`) ON UPDATE no action ON DELETE no action,
FOREIGN KEY (`participant_id`) REFERENCES `participants`(`id`) ON UPDATE no action ON DELETE no action
);
--> statement-breakpoint
CREATE INDEX `expense_participants_expense_id_idx` ON `expense_participants` (`expense_id`);--> statement-breakpoint
CREATE TABLE `expenses` (
`id` integer PRIMARY KEY AUTOINCREMENT NOT NULL,
`pot_slug` text NOT NULL,
`description` text NOT NULL,
`amount_cents` integer NOT NULL,
`payer_id` integer NOT NULL,
`created_at` integer DEFAULT (unixepoch()) NOT NULL,
FOREIGN KEY (`pot_slug`) REFERENCES `pots`(`slug`) ON UPDATE no action ON DELETE no action,
FOREIGN KEY (`payer_id`) REFERENCES `participants`(`id`) ON UPDATE no action ON DELETE no action
);
--> statement-breakpoint
CREATE INDEX `expenses_pot_slug_idx` ON `expenses` (`pot_slug`);--> statement-breakpoint
CREATE TABLE `participants` (
`id` integer PRIMARY KEY AUTOINCREMENT NOT NULL,
`pot_slug` text NOT NULL,
`name` text NOT NULL,
`created_at` integer DEFAULT (unixepoch()) NOT NULL,
FOREIGN KEY (`pot_slug`) REFERENCES `pots`(`slug`) ON UPDATE no action ON DELETE no action
);
--> statement-breakpoint
CREATE INDEX `participants_pot_slug_idx` ON `participants` (`pot_slug`);--> statement-breakpoint
CREATE TABLE `pots` (
`slug` text PRIMARY KEY NOT NULL,
`name` text NOT NULL,
`currency` text NOT NULL,
`created_at` integer DEFAULT (unixepoch()) NOT NULL
);