-- Use NULL for "not deleted" instead of sentinel date 1970-01-01

-- users
ALTER TABLE `users` MODIFY COLUMN `deleted_at` DATETIME(6) NULL DEFAULT NULL;
UPDATE `users` SET `deleted_at` = NULL WHERE `deleted_at` = '1970-01-01 00:00:00';
ALTER TABLE `users` DROP INDEX `users_username_deleted_at_key`;
ALTER TABLE `users` DROP INDEX `users_email_deleted_at_key`;

-- roles
ALTER TABLE `roles` MODIFY COLUMN `deleted_at` DATETIME(6) NULL DEFAULT NULL;
UPDATE `roles` SET `deleted_at` = NULL WHERE `deleted_at` = '1970-01-01 00:00:00';
ALTER TABLE `roles` DROP INDEX `roles_name_deleted_at_key`;
ALTER TABLE `roles` DROP INDEX `roles_identifier_deleted_at_key`;

-- permissions
ALTER TABLE `permissions` MODIFY COLUMN `deleted_at` DATETIME(6) NULL DEFAULT NULL;
UPDATE `permissions` SET `deleted_at` = NULL WHERE `deleted_at` = '1970-01-01 00:00:00';
ALTER TABLE `permissions` DROP INDEX `permissions_name_deleted_at_key`;
ALTER TABLE `permissions` DROP INDEX `permissions_identifier_deleted_at_key`;

-- role_permissions
ALTER TABLE `role_permissions` MODIFY COLUMN `deleted_at` DATETIME(6) NULL DEFAULT NULL;
UPDATE `role_permissions` SET `deleted_at` = NULL WHERE `deleted_at` = '1970-01-01 00:00:00';
ALTER TABLE `role_permissions` DROP INDEX `role_permissions_role_id_permission_id_deleted_at_key`;

-- user_profiles
ALTER TABLE `user_profiles` MODIFY COLUMN `deleted_at` DATETIME(6) NULL DEFAULT NULL;
UPDATE `user_profiles` SET `deleted_at` = NULL WHERE `deleted_at` = '1970-01-01 00:00:00';
