/*
  Warnings:

  - The values [SUPERVISER] on the enum `roles` will be removed. If these variants are still used in the database, this will fail.

*/
-- AlterEnum
BEGIN;
CREATE TYPE "roles_new" AS ENUM ('USER', 'ADMIN', 'CUSTOMER', 'DEALER', 'EMPLOYEE', 'HR', 'SUPERVISOR', 'ACCOUNTING');
ALTER TABLE "customers" ALTER COLUMN "role" DROP DEFAULT;
ALTER TABLE "employees" ALTER COLUMN "role" DROP DEFAULT;
ALTER TABLE "users" ALTER COLUMN "role" DROP DEFAULT;
ALTER TABLE "users" ALTER COLUMN "role" TYPE "roles_new" USING ("role"::text::"roles_new");
ALTER TABLE "employees" ALTER COLUMN "role" TYPE "roles_new" USING ("role"::text::"roles_new");
ALTER TABLE "customers" ALTER COLUMN "role" TYPE "roles_new" USING ("role"::text::"roles_new");
ALTER TYPE "roles" RENAME TO "roles_old";
ALTER TYPE "roles_new" RENAME TO "roles";
DROP TYPE "roles_old";
ALTER TABLE "customers" ALTER COLUMN "role" SET DEFAULT 'CUSTOMER';
ALTER TABLE "employees" ALTER COLUMN "role" SET DEFAULT 'EMPLOYEE';
ALTER TABLE "users" ALTER COLUMN "role" SET DEFAULT 'USER';
COMMIT;

-- AlterTable
ALTER TABLE "customers" ALTER COLUMN "invoice_id" DROP NOT NULL;

-- AlterTable
ALTER TABLE "employees" ALTER COLUMN "last_work_day" DROP NOT NULL;

-- AlterTable
ALTER TABLE "users" ALTER COLUMN "email" DROP NOT NULL,
ALTER COLUMN "residence" DROP NOT NULL;
