{
  "stmt": "CREATE TABLE `users` (\n\t`id` varchar(36) NOT NULL,\n\t`username` varchar(50),\n\t`password_hash` varchar(255),\n\t`email` varchar(100),\n\t`role` enum('ADMIN','MANAGER','MAID','GOD') DEFAULT 'MANAGER',\n\t`is_maid_also` boolean DEFAULT false,\n\t`full_name` varchar(255),\n\t`position` varchar(100),\n\t`birth_date` date,\n\t`address` text,\n\t`phone` varchar(20),\n\t`notes` text,\n\t`is_fired` boolean DEFAULT false,\n\t`fired_reason` text,\n\t`created_at` timestamp NOT NULL DEFAULT (now()),\n\t`updated_at` timestamp NOT NULL DEFAULT (now()) ON UPDATE CURRENT_TIMESTAMP,\n\t`archived_at` timestamp,\n\tCONSTRAINT `users_id` PRIMARY KEY(`id`),\n\tCONSTRAINT `users_username_unique` UNIQUE(`username`),\n\tCONSTRAINT `users_email_unique` UNIQUE(`email`)\n);\n--> statement-breakpoint\nCREATE TABLE `employment_periods` (\n\t`id` varchar(36) NOT NULL,\n\t`user_id` varchar(36) NOT NULL,\n\t`start_date` date NOT NULL,\n\t`end_date` date,\n\t`is_maid` boolean DEFAULT false,\n\t`created_at` timestamp NOT NULL DEFAULT (now()),\n\tCONSTRAINT `employment_periods_id` PRIMARY KEY(`id`)\n);\n--> statement-breakpoint\nCREATE TABLE `notes` (\n\t`id` varchar(36) NOT NULL,\n\t`title` varchar(255) NOT NULL,\n\t`content` text NOT NULL,\n\t`author_id` varchar(36) NOT NULL,\n\t`user_id` varchar(36) NOT NULL,\n\t`space_id` varchar(36) NOT NULL,\n\t`priority` enum('low','normal','high') NOT NULL DEFAULT 'normal',\n\t`status` enum('active','done','cancelled') NOT NULL DEFAULT 'active',\n\t`column` int NOT NULL DEFAULT 1,\n\t`position_y` int NOT NULL DEFAULT 0,\n\t`height` int NOT NULL DEFAULT 220,\n\t`is_public` boolean NOT NULL DEFAULT false,\n\t`last_comment_at` timestamp,\n\t`last_comment_author_id` varchar(36),\n\t`priority_updated_at` timestamp,\n\t`last_priority_author_id` varchar(36),\n\t`created_at` timestamp NOT NULL DEFAULT (now()),\n\t`updated_at` timestamp NOT NULL DEFAULT (now()) ON UPDATE CURRENT_TIMESTAMP,\n\t`archived_at` timestamp,\n\tCONSTRAINT `notes_id` PRIMARY KEY(`id`)\n);\n--> statement-breakpoint\nCREATE TABLE `note_layouts` (\n\t`id` varchar(36) NOT NULL,\n\t`note_id` varchar(36) NOT NULL,\n\t`user_id` varchar(36) NOT NULL,\n\t`column` int NOT NULL DEFAULT 1,\n\t`position_y` int NOT NULL DEFAULT 0,\n\t`height` int NOT NULL DEFAULT 220,\n\t`reminder_at` timestamp,\n\t`last_comment_viewed_at` timestamp,\n\t`last_priority_viewed_at` timestamp,\n\t`created_at` timestamp NOT NULL DEFAULT (now()),\n\t`updated_at` timestamp NOT NULL DEFAULT (now()) ON UPDATE CURRENT_TIMESTAMP,\n\tCONSTRAINT `note_layouts_id` PRIMARY KEY(`id`),\n\tCONSTRAINT `unique_note_user_idx` UNIQUE(`note_id`,`user_id`)\n);\n--> statement-breakpoint\nCREATE TABLE `note_comments` (\n\t`id` varchar(36) NOT NULL,\n\t`note_id` varchar(36) NOT NULL,\n\t`author_id` varchar(36) NOT NULL,\n\t`content` text NOT NULL,\n\t`is_read` boolean NOT NULL DEFAULT false,\n\t`created_at` timestamp NOT NULL DEFAULT (now()),\n\t`updated_at` timestamp NOT NULL DEFAULT (now()) ON UPDATE CURRENT_TIMESTAMP,\n\tCONSTRAINT `note_comments_id` PRIMARY KEY(`id`)\n);\n--> statement-breakpoint\nCREATE TABLE `note_history` (\n\t`id` varchar(36) NOT NULL,\n\t`note_id` varchar(36) NOT NULL,\n\t`action` enum('created','updated','status_changed','commented','returned','priority_changed') NOT NULL,\n\t`payload` json,\n\t`author_id` varchar(36) NOT NULL,\n\t`created_at` timestamp NOT NULL DEFAULT (now()),\n\tCONSTRAINT `note_history_id` PRIMARY KEY(`id`)\n);\n--> statement-breakpoint\nCREATE TABLE `shifts` (\n\t`id` varchar(36) NOT NULL,\n\t`date` timestamp NOT NULL,\n\t`user_id` varchar(36) NOT NULL,\n\t`role_at_shift` enum('Manager','Maid') NOT NULL,\n\t`status` enum('Blank','Work','Holiday','Unavailable') NOT NULL DEFAULT 'Blank',\n\t`is_approved` boolean NOT NULL DEFAULT false,\n\t`created_by` varchar(36) NOT NULL,\n\t`created_at` timestamp NOT NULL DEFAULT (now()),\n\t`updated_at` timestamp NOT NULL DEFAULT (now()) ON UPDATE CURRENT_TIMESTAMP,\n\t`archived_at` timestamp,\n\tCONSTRAINT `shifts_id` PRIMARY KEY(`id`),\n\tCONSTRAINT `unique_user_date_approved` UNIQUE(`user_id`,`date`,`role_at_shift`,`is_approved`)\n);\n--> statement-breakpoint\nCREATE TABLE `shift_tasks` (\n\t`id` varchar(36) NOT NULL,\n\t`text` text NOT NULL,\n\t`is_completed` boolean NOT NULL DEFAULT false,\n\t`parent_id` varchar(36),\n\t`date` date NOT NULL,\n\t`created_at` timestamp NOT NULL DEFAULT (now()),\n\t`updated_at` timestamp NOT NULL DEFAULT (now()) ON UPDATE CURRENT_TIMESTAMP,\n\t`archived_at` timestamp,\n\tCONSTRAINT `shift_tasks_id` PRIMARY KEY(`id`)\n);\n--> statement-breakpoint\nCREATE TABLE `tasks` (\n\t`id` varchar(36) NOT NULL,\n\t`user_id` varchar(36) NOT NULL,\n\t`text` text NOT NULL,\n\t`is_completed` boolean NOT NULL DEFAULT false,\n\t`parent_id` varchar(36),\n\t`position` text,\n\t`order` int,\n\t`created_at` timestamp NOT NULL DEFAULT (now()),\n\t`updated_at` timestamp NOT NULL DEFAULT (now()) ON UPDATE CURRENT_TIMESTAMP,\n\t`archived_at` timestamp,\n\tCONSTRAINT `tasks_id` PRIMARY KEY(`id`)\n);\n--> statement-breakpoint\nCREATE TABLE `checkins` (\n\t`id` varchar(36) NOT NULL,\n\t`guest_name` varchar(255) NOT NULL,\n\t`room_number` varchar(10) NOT NULL,\n\t`check_in_time` timestamp NOT NULL,\n\t`check_out_time` timestamp,\n\t`date` timestamp NOT NULL,\n\t`is_archived` boolean NOT NULL DEFAULT false,\n\t`created_at` timestamp NOT NULL DEFAULT (now()),\n\t`updated_at` timestamp NOT NULL DEFAULT (now()) ON UPDATE CURRENT_TIMESTAMP,\n\tCONSTRAINT `checkins_id` PRIMARY KEY(`id`)\n);\n--> statement-breakpoint\nCREATE TABLE `linen` (\n\t`id` varchar(36) NOT NULL,\n\t`room_number` varchar(10) NOT NULL,\n\t`type` varchar(50) NOT NULL,\n\t`quantity` int NOT NULL,\n\t`status` varchar(50) NOT NULL,\n\t`created_at` timestamp NOT NULL DEFAULT (now()),\n\t`updated_at` timestamp NOT NULL DEFAULT (now()) ON UPDATE CURRENT_TIMESTAMP,\n\tCONSTRAINT `linen_id` PRIMARY KEY(`id`)\n);\n--> statement-breakpoint\nCREATE TABLE `daily_checkins` (\n\t`id` varchar(36) NOT NULL,\n\t`room_id` varchar(10) NOT NULL,\n\t`room_type` varchar(100) NOT NULL,\n\t`date` date NOT NULL,\n\t`is_occupied` boolean NOT NULL DEFAULT false,\n\t`is_permanent` boolean NOT NULL DEFAULT false,\n\t`beds_count` int NOT NULL DEFAULT 0,\n\t`is_cleaned` boolean NOT NULL DEFAULT false,\n\t`cleaner_name` varchar(255),\n\t`linen_data` json,\n\t`is_dispatched` boolean NOT NULL DEFAULT false,\n\t`created_at` timestamp NOT NULL DEFAULT (now()),\n\t`updated_at` timestamp NOT NULL DEFAULT (now()) ON UPDATE CURRENT_TIMESTAMP,\n\t`archived_at` timestamp,\n\tCONSTRAINT `daily_checkins_id` PRIMARY KEY(`id`),\n\tCONSTRAINT `date_room_idx` UNIQUE(`date`,`room_id`)\n);\n--> statement-breakpoint\nCREATE TABLE `inv_linen` (\n\t`id` varchar(36) NOT NULL,\n\t`name` varchar(255) NOT NULL,\n\t`type` varchar(50) NOT NULL,\n\t`weight` decimal(5,2) NOT NULL,\n\t`unit` varchar(20) NOT NULL DEFAULT 'шт',\n\t`description` varchar(500),\n\t`created_at` timestamp NOT NULL DEFAULT (now()),\n\t`updated_at` timestamp NOT NULL DEFAULT (now()) ON UPDATE CURRENT_TIMESTAMP,\n\t`archived_at` timestamp,\n\tCONSTRAINT `inv_linen_id` PRIMARY KEY(`id`)\n);\n--> statement-breakpoint\nCREATE TABLE `linen_dispatch_log` (\n\t`id` varchar(36) NOT NULL,\n\t`dispatch_date` varchar(10) NOT NULL,\n\t`total_weight` float NOT NULL,\n\t`details` json NOT NULL,\n\t`dispatched_at` timestamp NOT NULL,\n\t`created_at` timestamp NOT NULL DEFAULT (now()),\n\tCONSTRAINT `linen_dispatch_log_id` PRIMARY KEY(`id`)\n);\n--> statement-breakpoint\nCREATE TABLE `daily_linen_usage` (\n\t`id` varchar(36) NOT NULL,\n\t`date` date NOT NULL,\n\t`linen_data` json,\n\t`updated_at` timestamp NOT NULL DEFAULT (now()) ON UPDATE CURRENT_TIMESTAMP,\n\tCONSTRAINT `daily_linen_usage_id` PRIMARY KEY(`id`),\n\tCONSTRAINT `daily_linen_usage_date_unique` UNIQUE(`date`),\n\tCONSTRAINT `daily_linen_usage_date_idx` UNIQUE(`date`)\n);\n--> statement-breakpoint\nCREATE TABLE `paymaster_rows` (\n\t`id` varchar(36) NOT NULL,\n\t`room_number` varchar(100),\n\t`contractor` varchar(255),\n\t`stay_dates` varchar(100),\n\t`amount` decimal(10,2) NOT NULL,\n\t`type` varchar(100) NOT NULL,\n\t`comment` varchar(500),\n\t`operational_day` date NOT NULL,\n\t`created_at` timestamp NOT NULL DEFAULT (now()),\n\t`updated_at` timestamp NOT NULL DEFAULT (now()) ON UPDATE CURRENT_TIMESTAMP,\n\tCONSTRAINT `paymaster_rows_id` PRIMARY KEY(`id`)\n);\n--> statement-breakpoint\nCREATE TABLE `approval_requests` (\n\t`id` varchar(36) NOT NULL,\n\t`entity_type` varchar(50) NOT NULL,\n\t`target_id` varchar(36),\n\t`requester_id` varchar(36) NOT NULL,\n\t`payload` json NOT NULL,\n\t`status` varchar(20) NOT NULL DEFAULT 'pending',\n\t`created_at` timestamp NOT NULL DEFAULT (now()),\n\t`updated_at` timestamp NOT NULL DEFAULT (now()) ON UPDATE CURRENT_TIMESTAMP,\n\t`archived_at` timestamp,\n\tCONSTRAINT `approval_requests_id` PRIMARY KEY(`id`)\n);\n--> statement-breakpoint\nCREATE TABLE `blacklist` (\n\t`id` varchar(36) NOT NULL,\n\t`name` varchar(100) NOT NULL,\n\t`phone` varchar(20) NOT NULL,\n\t`booking_engine_check` varchar(20) NOT NULL DEFAULT 'NO',\n\t`comment` text,\n\t`is_approved` boolean NOT NULL DEFAULT false,\n\t`created_by` varchar(36),\n\t`created_at` timestamp NOT NULL DEFAULT (now()),\n\t`updated_at` timestamp NOT NULL DEFAULT (now()) ON UPDATE CURRENT_TIMESTAMP,\n\t`archived_at` timestamp,\n\tCONSTRAINT `blacklist_id` PRIMARY KEY(`id`)\n);\n--> statement-breakpoint\nCREATE TABLE `blacklist_pending` (\n\t`id` varchar(36) NOT NULL,\n\t`name` varchar(100) NOT NULL,\n\t`phone` varchar(20) NOT NULL,\n\t`booking_engine_check` varchar(20) NOT NULL DEFAULT 'NO',\n\t`comment` text,\n\t`status` varchar(20) NOT NULL DEFAULT 'pending',\n\t`target_id` varchar(36),\n\t`created_by` varchar(36),\n\t`reviewed_by` varchar(36),\n\t`reviewed_at` timestamp,\n\t`rejection_reason` text,\n\t`created_at` timestamp NOT NULL DEFAULT (now()),\n\t`updated_at` timestamp NOT NULL DEFAULT (now()) ON UPDATE CURRENT_TIMESTAMP,\n\tCONSTRAINT `blacklist_pending_id` PRIMARY KEY(`id`)\n);\n--> statement-breakpoint\nCREATE TABLE `external_access` (\n\t`id` varchar(36) NOT NULL,\n\t`resource_name` varchar(100) NOT NULL,\n\t`link` varchar(500) NOT NULL,\n\t`login` varchar(100) NOT NULL,\n\t`password` varchar(100) NOT NULL,\n\t`comment` text,\n\t`created_at` timestamp NOT NULL DEFAULT (now()),\n\t`updated_at` timestamp NOT NULL DEFAULT (now()) ON UPDATE CURRENT_TIMESTAMP,\n\t`archived_at` timestamp,\n\tCONSTRAINT `external_access_id` PRIMARY KEY(`id`)\n);\n--> statement-breakpoint\nCREATE TABLE `contractors` (\n\t`id` varchar(36) NOT NULL,\n\t`name` varchar(100) NOT NULL,\n\t`category` varchar(50) NOT NULL,\n\t`contract_number` varchar(100),\n\t`phone` varchar(20) NOT NULL,\n\t`email` varchar(100),\n\t`web_link` varchar(500),\n\t`manager_name` varchar(100),\n\t`manager_phone` varchar(20),\n\t`manager_email` varchar(100),\n\t`comment` text,\n\t`created_at` timestamp NOT NULL DEFAULT (now()),\n\t`updated_at` timestamp NOT NULL DEFAULT (now()) ON UPDATE CURRENT_TIMESTAMP,\n\t`archived_at` timestamp,\n\tCONSTRAINT `contractors_id` PRIMARY KEY(`id`)\n);\n--> statement-breakpoint\nCREATE TABLE `local_it` (\n\t`id` varchar(36) NOT NULL,\n\t`description` varchar(255) NOT NULL,\n\t`manufacturer` varchar(100),\n\t`model` varchar(100),\n\t`network_address` varchar(50),\n\t`access_ports` json,\n\t`username` varchar(100),\n\t`password` varchar(100),\n\t`location` varchar(100) NOT NULL,\n\t`created_at` timestamp NOT NULL DEFAULT (now()),\n\t`updated_at` timestamp NOT NULL DEFAULT (now()) ON UPDATE CURRENT_TIMESTAMP,\n\t`archived_at` timestamp,\n\tCONSTRAINT `local_it_id` PRIMARY KEY(`id`)\n);\n--> statement-breakpoint\nCREATE TABLE `local_security` (\n\t`id` varchar(36) NOT NULL,\n\t`type` varchar(50) NOT NULL,\n\t`manufacturer` varchar(100),\n\t`model` varchar(100),\n\t`location` varchar(100) NOT NULL,\n\t`created_at` timestamp NOT NULL DEFAULT (now()),\n\t`updated_at` timestamp NOT NULL DEFAULT (now()) ON UPDATE CURRENT_TIMESTAMP,\n\t`archived_at` timestamp,\n\tCONSTRAINT `local_security_id` PRIMARY KEY(`id`)\n);\n--> statement-breakpoint\nCREATE TABLE `other_equipment` (\n\t`id` varchar(36) NOT NULL,\n\t`description` varchar(255) NOT NULL,\n\t`type` varchar(50),\n\t`manufacturer` varchar(100),\n\t`model` varchar(100),\n\t`location` varchar(100) NOT NULL,\n\t`created_at` timestamp NOT NULL DEFAULT (now()),\n\t`updated_at` timestamp NOT NULL DEFAULT (now()) ON UPDATE CURRENT_TIMESTAMP,\n\t`archived_at` timestamp,\n\tCONSTRAINT `other_equipment_id` PRIMARY KEY(`id`)\n);\n--> statement-breakpoint\nCREATE TABLE `inventory` (\n\t`id` varchar(36) NOT NULL,\n\t`name` varchar(100) NOT NULL,\n\t`category` varchar(20) NOT NULL,\n\t`quantity` decimal(10,2) NOT NULL,\n\t`unit` varchar(20),\n\t`location` varchar(100) NOT NULL,\n\t`comment` text,\n\t`weight_per_unit` decimal(10,3),\n\t`manufacturer` varchar(100),\n\t`model` varchar(100),\n\t`serial_number` varchar(100),\n\t`ordering_link` varchar(500),\n\t`article_number` varchar(100),\n\t`created_at` timestamp NOT NULL DEFAULT (now()),\n\t`updated_at` timestamp NOT NULL DEFAULT (now()) ON UPDATE CURRENT_TIMESTAMP,\n\t`archived_at` timestamp,\n\tCONSTRAINT `inventory_id` PRIMARY KEY(`id`)\n);\n--> statement-breakpoint\nCREATE TABLE `pending_notifications` (\n\t`id` varchar(36) NOT NULL,\n\t`user_id` varchar(36) NOT NULL,\n\t`room_id` varchar(50) NOT NULL,\n\t`event` varchar(50) NOT NULL,\n\t`data` json NOT NULL,\n\t`read_at` timestamp,\n\t`created_at` timestamp NOT NULL DEFAULT (now()),\n\t`archived_at` timestamp,\n\tCONSTRAINT `pending_notifications_id` PRIMARY KEY(`id`)\n);\n--> statement-breakpoint\nCREATE TABLE `rooms` (\n\t`id` varchar(10) NOT NULL,\n\t`type` varchar(10) NOT NULL,\n\t`has_hood` boolean NOT NULL DEFAULT false,\n\t`beds` tinyint NOT NULL DEFAULT 2,\n\t`armchair` boolean NOT NULL DEFAULT false,\n\t`air_cond` boolean NOT NULL DEFAULT false,\n\t`is_repairing` boolean NOT NULL DEFAULT false,\n\t`repair_reason` text,\n\t`comment` text,\n\t`created_at` timestamp NOT NULL DEFAULT (now()),\n\t`updated_at` timestamp NOT NULL DEFAULT (now()) ON UPDATE CURRENT_TIMESTAMP,\n\tCONSTRAINT `rooms_id` PRIMARY KEY(`id`)\n);\n--> statement-breakpoint\nALTER TABLE `employment_periods` ADD CONSTRAINT `employment_periods_user_id_users_id_fk` FOREIGN KEY (`user_id`) REFERENCES `users`(`id`) ON DELETE no action ON UPDATE no action;--> statement-breakpoint\nALTER TABLE `note_layouts` ADD CONSTRAINT `note_layouts_note_id_notes_id_fk` FOREIGN KEY (`note_id`) REFERENCES `notes`(`id`) ON DELETE cascade ON UPDATE no action;--> statement-breakpoint\nALTER TABLE `note_comments` ADD CONSTRAINT `note_comments_note_id_notes_id_fk` FOREIGN KEY (`note_id`) REFERENCES `notes`(`id`) ON DELETE cascade ON UPDATE no action;--> statement-breakpoint\nALTER TABLE `note_comments` ADD CONSTRAINT `note_comments_author_id_users_id_fk` FOREIGN KEY (`author_id`) REFERENCES `users`(`id`) ON DELETE cascade ON UPDATE no action;--> statement-breakpoint\nALTER TABLE `note_history` ADD CONSTRAINT `note_history_note_id_notes_id_fk` FOREIGN KEY (`note_id`) REFERENCES `notes`(`id`) ON DELETE cascade ON UPDATE no action;--> statement-breakpoint\nALTER TABLE `note_history` ADD CONSTRAINT `note_history_author_id_users_id_fk` FOREIGN KEY (`author_id`) REFERENCES `users`(`id`) ON DELETE cascade ON UPDATE no action;--> statement-breakpoint\nCREATE INDEX `idx_tasks_user_id` ON `tasks` (`user_id`);"
}