CREATE TABLE `employment_periods` (
	`id` varchar(36) NOT NULL,
	`user_id` varchar(36) NOT NULL,
	`start_date` date NOT NULL,
	`end_date` date,
	`is_maid` boolean DEFAULT false,
	`created_at` timestamp NOT NULL DEFAULT (now()),
	CONSTRAINT `employment_periods_id` PRIMARY KEY(`id`)
);
--> statement-breakpoint
DROP TABLE `employees`;--> statement-breakpoint
ALTER TABLE `users` MODIFY COLUMN `username` varchar(50);--> statement-breakpoint
ALTER TABLE `users` MODIFY COLUMN `role` enum('ADMIN','MANAGER','MAID') DEFAULT 'MANAGER';--> statement-breakpoint
ALTER TABLE `users` MODIFY COLUMN `is_maid_also` boolean;--> statement-breakpoint
ALTER TABLE `shifts` ADD CONSTRAINT `unique_user_date` UNIQUE(`user_id`,`date`,`role_at_shift`);--> statement-breakpoint
ALTER 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
ALTER TABLE `users` DROP COLUMN `user_id`;--> statement-breakpoint
ALTER TABLE `users` DROP COLUMN `employee_id`;