initial: pulsy from pulse-clock-main
This commit is contained in:
@@ -0,0 +1,44 @@
|
||||
CREATE TABLE `audit_log` (
|
||||
`id` integer PRIMARY KEY AUTOINCREMENT NOT NULL,
|
||||
`employee_id` integer NOT NULL,
|
||||
`company_id` integer NOT NULL,
|
||||
`admin_id` integer DEFAULT 0 NOT NULL,
|
||||
`action` text NOT NULL,
|
||||
`detail` text NOT NULL,
|
||||
`created_at` text DEFAULT (datetime('now')) NOT NULL,
|
||||
FOREIGN KEY (`employee_id`) REFERENCES `employees`(`id`) ON UPDATE no action ON DELETE no action,
|
||||
FOREIGN KEY (`company_id`) REFERENCES `companies`(`id`) ON UPDATE no action ON DELETE no action
|
||||
);
|
||||
--> statement-breakpoint
|
||||
CREATE INDEX `audit_employee_idx` ON `audit_log` (`employee_id`);--> statement-breakpoint
|
||||
CREATE INDEX `audit_company_idx` ON `audit_log` (`company_id`);--> statement-breakpoint
|
||||
CREATE TABLE `companies` (
|
||||
`id` integer PRIMARY KEY AUTOINCREMENT NOT NULL,
|
||||
`name` text NOT NULL,
|
||||
`created_at` text DEFAULT (datetime('now')) NOT NULL
|
||||
);
|
||||
--> statement-breakpoint
|
||||
CREATE TABLE `employees` (
|
||||
`id` integer PRIMARY KEY AUTOINCREMENT NOT NULL,
|
||||
`company_id` integer NOT NULL,
|
||||
`name` text NOT NULL,
|
||||
`is_active` integer DEFAULT true NOT NULL,
|
||||
`created_at` text DEFAULT (datetime('now')) NOT NULL,
|
||||
FOREIGN KEY (`company_id`) REFERENCES `companies`(`id`) ON UPDATE no action ON DELETE no action
|
||||
);
|
||||
--> statement-breakpoint
|
||||
CREATE INDEX `company_active_idx` ON `employees` (`company_id`,`is_active`);--> statement-breakpoint
|
||||
CREATE TABLE `time_entries` (
|
||||
`id` integer PRIMARY KEY AUTOINCREMENT NOT NULL,
|
||||
`employee_id` integer NOT NULL,
|
||||
`company_id` integer NOT NULL,
|
||||
`type` text NOT NULL,
|
||||
`timestamp` integer DEFAULT (unixepoch()) NOT NULL,
|
||||
`photo_base64` text,
|
||||
`is_deleted` integer DEFAULT false NOT NULL,
|
||||
FOREIGN KEY (`employee_id`) REFERENCES `employees`(`id`) ON UPDATE no action ON DELETE no action,
|
||||
FOREIGN KEY (`company_id`) REFERENCES `companies`(`id`) ON UPDATE no action ON DELETE no action
|
||||
);
|
||||
--> statement-breakpoint
|
||||
CREATE INDEX `employee_timestamp_idx` ON `time_entries` (`employee_id`,`timestamp`);--> statement-breakpoint
|
||||
CREATE INDEX `company_timestamp_idx` ON `time_entries` (`company_id`,`timestamp`);
|
||||
Reference in New Issue
Block a user