Files
Refood-One/drizzle/0000_light_red_wolf.sql
2026-06-03 01:13:58 +01:00

61 lines
1.9 KiB
SQL

CREATE TABLE `beneficiaries` (
`id` text PRIMARY KEY NOT NULL,
`number` integer,
`name` text NOT NULL,
`contact` text NOT NULL,
`household_size` integer DEFAULT 1 NOT NULL,
`observations` text,
`status` text DEFAULT 'ativo' NOT NULL,
`odoo_id` integer,
`odoo_number` text,
`parent_odoo_id` integer,
`created_at` integer NOT NULL,
`updated_at` integer NOT NULL
);
--> statement-breakpoint
CREATE UNIQUE INDEX `odoo_id_idx` ON `beneficiaries` (`odoo_id`);--> statement-breakpoint
CREATE INDEX `number_idx` ON `beneficiaries` (`number`);--> statement-breakpoint
CREATE TABLE `deliveries` (
`id` text PRIMARY KEY NOT NULL,
`beneficiary_id` text NOT NULL,
`shift_id` text NOT NULL,
`date` text NOT NULL,
`created_at` integer NOT NULL,
FOREIGN KEY (`beneficiary_id`) REFERENCES `beneficiaries`(`id`) ON UPDATE no action ON DELETE cascade,
FOREIGN KEY (`shift_id`) REFERENCES `shifts`(`id`) ON UPDATE no action ON DELETE cascade
);
--> statement-breakpoint
CREATE TABLE `sessions` (
`id` text PRIMARY KEY NOT NULL,
`user_id` text NOT NULL,
`expires_at` integer NOT NULL,
FOREIGN KEY (`user_id`) REFERENCES `users`(`id`) ON UPDATE no action ON DELETE cascade
);
--> statement-breakpoint
CREATE TABLE `settings` (
`key` text PRIMARY KEY NOT NULL,
`value` text NOT NULL,
`updated_at` integer NOT NULL
);
--> statement-breakpoint
CREATE TABLE `shifts` (
`id` text PRIMARY KEY NOT NULL,
`code` text NOT NULL,
`start_time` text NOT NULL,
`end_time` text NOT NULL,
`days` text NOT NULL,
`created_at` integer NOT NULL,
`updated_at` integer NOT NULL
);
--> statement-breakpoint
CREATE UNIQUE INDEX `shifts_code_unique` ON `shifts` (`code`);--> statement-breakpoint
CREATE TABLE `users` (
`id` text PRIMARY KEY NOT NULL,
`name` text NOT NULL,
`username` text NOT NULL,
`password_hash` text NOT NULL,
`role` text NOT NULL,
`created_at` integer NOT NULL
);
--> statement-breakpoint
CREATE UNIQUE INDEX `users_username_unique` ON `users` (`username`);