/*
  Warnings:

  - The values [DELIVERED] on the enum `OrderStatus` will be removed. If these variants are still used in the database, this will fail.
  - You are about to drop the column `vehicleType` on the `Rider` table. All the data in the column will be lost.
  - The `approvalStatus` column on the `Rider` table would be dropped and recreated. This will lead to data loss if there is data in the column.
  - A unique constraint covering the columns `[merchantId]` on the table `Order` will be added. If there are existing duplicate values, this will fail.
  - Added the required column `merchantId` to the `Order` table without a default value. This is not possible if the table is not empty.
  - Added the required column `imgUrl` to the `Product` table without a default value. This is not possible if the table is not empty.
  - Added the required column `coins` to the `Rider` table without a default value. This is not possible if the table is not empty.

*/
-- CreateEnum
CREATE TYPE "RiderStatus" AS ENUM ('PENDING', 'DECLINED', 'ACCEPTED');

-- AlterEnum
BEGIN;
CREATE TYPE "OrderStatus_new" AS ENUM ('INCOMING', 'PREPARING', 'READY', 'DELIVERY', 'COMPLETED');
ALTER TABLE "Order" ALTER COLUMN "status" DROP DEFAULT;
ALTER TABLE "Order" ALTER COLUMN "status" TYPE "OrderStatus_new" USING ("status"::text::"OrderStatus_new");
ALTER TYPE "OrderStatus" RENAME TO "OrderStatus_old";
ALTER TYPE "OrderStatus_new" RENAME TO "OrderStatus";
DROP TYPE "OrderStatus_old";
ALTER TABLE "Order" ALTER COLUMN "status" SET DEFAULT 'INCOMING';
COMMIT;

-- AlterTable
ALTER TABLE "Customer" ADD COLUMN     "isFirstLogin" BOOLEAN NOT NULL DEFAULT true;

-- AlterTable
ALTER TABLE "Merchant" ADD COLUMN     "isFirstLogin" BOOLEAN NOT NULL DEFAULT true,
ALTER COLUMN "rating" SET DATA TYPE DOUBLE PRECISION;

-- AlterTable
ALTER TABLE "Order" ADD COLUMN     "merchantId" INTEGER NOT NULL,
ALTER COLUMN "status" SET DEFAULT 'INCOMING';

-- AlterTable
ALTER TABLE "Product" ADD COLUMN     "imgUrl" TEXT NOT NULL;

-- AlterTable
ALTER TABLE "Rider" DROP COLUMN "vehicleType",
ADD COLUMN     "coins" INTEGER NOT NULL,
DROP COLUMN "approvalStatus",
ADD COLUMN     "approvalStatus" "RiderStatus" NOT NULL DEFAULT 'PENDING';

-- AlterTable
ALTER TABLE "User" ADD COLUMN     "imgProfileUrl" TEXT,
ALTER COLUMN "name" DROP NOT NULL;

-- DropEnum
DROP TYPE "riderStatus";

-- CreateIndex
CREATE UNIQUE INDEX "Order_merchantId_key" ON "Order"("merchantId");

-- AddForeignKey
ALTER TABLE "Order" ADD CONSTRAINT "Order_merchantId_fkey" FOREIGN KEY ("merchantId") REFERENCES "Merchant"("id") ON DELETE RESTRICT ON UPDATE CASCADE;
