Files
tt-booking/lib/db/migrations/0000_tidy_kang.sql
T
2025-09-22 22:46:33 +01:00

77 lines
2.2 KiB
SQL

CREATE TABLE `activity_logs` (
`id` text PRIMARY KEY NOT NULL,
`user_id` text,
`action` text NOT NULL,
`entity_type` text NOT NULL,
`entity_id` text,
`details` text,
`ip_address` text,
`user_agent` text,
`created_at` integer NOT NULL,
FOREIGN KEY (`user_id`) REFERENCES `users`(`id`) ON UPDATE no action ON DELETE set null
);
--> statement-breakpoint
CREATE TABLE `announcements` (
`id` text PRIMARY KEY NOT NULL,
`title` text NOT NULL,
`content` text NOT NULL,
`is_active` integer DEFAULT true NOT NULL,
`priority` text DEFAULT 'medium' NOT NULL,
`expires_at` integer,
`created_at` integer NOT NULL,
`updated_at` integer NOT NULL
);
--> statement-breakpoint
CREATE TABLE `bookings` (
`id` text PRIMARY KEY NOT NULL,
`user_id` text NOT NULL,
`court_id` text NOT NULL,
`date` text NOT NULL,
`start_time` text NOT NULL,
`end_time` text NOT NULL,
`status` text DEFAULT 'active' NOT NULL,
`notes` text,
`created_at` integer NOT NULL,
`updated_at` integer NOT NULL,
FOREIGN KEY (`user_id`) REFERENCES `users`(`id`) ON UPDATE no action ON DELETE cascade,
FOREIGN KEY (`court_id`) REFERENCES `courts`(`id`) ON UPDATE no action ON DELETE cascade
);
--> statement-breakpoint
CREATE TABLE `courts` (
`id` text PRIMARY KEY NOT NULL,
`name` text NOT NULL,
`is_active` integer DEFAULT true NOT NULL,
`created_at` integer NOT NULL,
`updated_at` integer NOT NULL
);
--> statement-breakpoint
CREATE TABLE `settings` (
`id` text PRIMARY KEY NOT NULL,
`key` text NOT NULL,
`value` text NOT NULL,
`updated_at` integer NOT NULL
);
--> statement-breakpoint
CREATE TABLE `time_slots` (
`id` text PRIMARY KEY NOT NULL,
`day_of_week` integer NOT NULL,
`start_time` text NOT NULL,
`end_time` text NOT NULL,
`is_active` integer DEFAULT true NOT NULL,
`created_at` integer NOT NULL,
`updated_at` integer NOT NULL
);
--> statement-breakpoint
CREATE TABLE `users` (
`id` text PRIMARY KEY NOT NULL,
`email` text NOT NULL,
`name` text NOT NULL,
`surname` text NOT NULL,
`password` text NOT NULL,
`role` text DEFAULT 'user' NOT NULL,
`created_at` integer NOT NULL,
`updated_at` integer NOT NULL
);
--> statement-breakpoint
CREATE UNIQUE INDEX `settings_key_unique` ON `settings` (`key`);--> statement-breakpoint
CREATE UNIQUE INDEX `users_email_unique` ON `users` (`email`);