CREATE TABLE `daily_linen_usage` (
	`id` varchar(36) NOT NULL,
	`date` date NOT NULL,
	`linen_data` json,
	`updated_at` timestamp NOT NULL DEFAULT (now()) ON UPDATE CURRENT_TIMESTAMP,
	CONSTRAINT `daily_linen_usage_id` PRIMARY KEY(`id`),
	CONSTRAINT `daily_linen_usage_date_unique` UNIQUE(`date`),
	CONSTRAINT `daily_linen_usage_date_idx` UNIQUE(`date`)
);
--> statement-breakpoint
CREATE TABLE `blacklist_pending` (
	`id` varchar(36) NOT NULL,
	`name` varchar(100) NOT NULL,
	`phone` varchar(20) NOT NULL,
	`booking_engine_check` varchar(20) NOT NULL DEFAULT 'NO',
	`comment` text,
	`status` varchar(20) NOT NULL DEFAULT 'pending',
	`target_id` varchar(36),
	`created_by` varchar(36),
	`reviewed_by` varchar(36),
	`reviewed_at` timestamp,
	`rejection_reason` text,
	`created_at` timestamp NOT NULL DEFAULT (now()),
	`updated_at` timestamp NOT NULL DEFAULT (now()) ON UPDATE CURRENT_TIMESTAMP,
	CONSTRAINT `blacklist_pending_id` PRIMARY KEY(`id`)
);
--> statement-breakpoint
CREATE TABLE `rooms` (
	`id` varchar(10) NOT NULL,
	`type` varchar(10) NOT NULL,
	`has_hood` boolean NOT NULL DEFAULT false,
	`beds` tinyint NOT NULL DEFAULT 2,
	`armchair` boolean NOT NULL DEFAULT false,
	`air_cond` boolean NOT NULL DEFAULT false,
	`is_repairing` boolean NOT NULL DEFAULT false,
	`repair_reason` text,
	`comment` text,
	`created_at` timestamp NOT NULL DEFAULT (now()),
	`updated_at` timestamp NOT NULL DEFAULT (now()) ON UPDATE CURRENT_TIMESTAMP,
	CONSTRAINT `rooms_id` PRIMARY KEY(`id`)
);
--> statement-breakpoint
DROP TABLE `inventory_details`;--> statement-breakpoint
ALTER TABLE `shifts` DROP INDEX `unique_user_date`;--> statement-breakpoint
ALTER TABLE `notes` MODIFY COLUMN `status` enum('active','done','cancelled') NOT NULL DEFAULT 'active';--> statement-breakpoint
ALTER TABLE `daily_checkins` MODIFY COLUMN `room_id` varchar(36);--> statement-breakpoint
ALTER TABLE `inventory` MODIFY COLUMN `category` varchar(20) NOT NULL;--> statement-breakpoint
ALTER TABLE `notes` ADD `last_comment_at` timestamp;--> statement-breakpoint
ALTER TABLE `notes` ADD `last_comment_author_id` varchar(36);--> statement-breakpoint
ALTER TABLE `note_layouts` ADD `reminder_at` timestamp;--> statement-breakpoint
ALTER TABLE `note_layouts` ADD `last_comment_viewed_at` timestamp;--> statement-breakpoint
ALTER TABLE `daily_checkins` ADD `room_number` varchar(50) NOT NULL;--> statement-breakpoint
ALTER TABLE `daily_checkins` ADD `room_type` varchar(100) NOT NULL;--> statement-breakpoint
ALTER TABLE `daily_checkins` ADD `is_occupied` boolean DEFAULT false NOT NULL;--> statement-breakpoint
ALTER TABLE `daily_checkins` ADD `is_permanent` boolean DEFAULT false NOT NULL;--> statement-breakpoint
ALTER TABLE `daily_checkins` ADD `beds_count` int DEFAULT 0 NOT NULL;--> statement-breakpoint
ALTER TABLE `blacklist` ADD `is_approved` boolean DEFAULT false NOT NULL;--> statement-breakpoint
ALTER TABLE `blacklist` ADD `created_by` varchar(36);--> statement-breakpoint
ALTER TABLE `inventory` ADD `weight_per_unit` decimal(10,3);--> statement-breakpoint
ALTER TABLE `inventory` ADD `manufacturer` varchar(100);--> statement-breakpoint
ALTER TABLE `inventory` ADD `model` varchar(100);--> statement-breakpoint
ALTER TABLE `inventory` ADD `serial_number` varchar(100);--> statement-breakpoint
ALTER TABLE `inventory` ADD `ordering_link` varchar(500);--> statement-breakpoint
ALTER TABLE `inventory` ADD `article_number` varchar(100);--> statement-breakpoint
ALTER TABLE `shifts` ADD CONSTRAINT `unique_user_date_approved` UNIQUE(`user_id`,`date`,`role_at_shift`,`is_approved`);--> statement-breakpoint
ALTER TABLE `notes` DROP COLUMN `reminder_at`;--> statement-breakpoint
ALTER TABLE `notes` DROP COLUMN `defer_until`;--> statement-breakpoint
ALTER TABLE `daily_checkins` DROP COLUMN `guests_count`;