/*
  Warnings:

  - You are about to drop the column `inscription_id` on the `paiements_tranches` table. All the data in the column will be lost.
  - You are about to drop the `inscriptions_pelerins` table. If the table is not empty, all the data it contains will be lost.
  - A unique constraint covering the columns `[pelerin_id,numero_sequence]` on the table `paiements_tranches` will be added. If there are existing duplicate values, this will fail.
  - A unique constraint covering the columns `[numero_pasport,voyage_id]` on the table `pelerins` will be added. If there are existing duplicate values, this will fail.
  - Added the required column `pelerin_id` to the `paiements_tranches` table without a default value. This is not possible if the table is not empty.
  - Added the required column `montant_total` to the `pelerins` table without a default value. This is not possible if the table is not empty.
  - Added the required column `voyage_id` to the `pelerins` table without a default value. This is not possible if the table is not empty.

*/
-- DropForeignKey
ALTER TABLE "inscriptions_pelerins" DROP CONSTRAINT "inscriptions_pelerins_pelerin_id_fkey";

-- DropForeignKey
ALTER TABLE "inscriptions_pelerins" DROP CONSTRAINT "inscriptions_pelerins_voyage_id_fkey";

-- DropForeignKey
ALTER TABLE "paiements_tranches" DROP CONSTRAINT "paiements_tranches_inscription_id_fkey";

-- DropIndex
DROP INDEX "paiements_tranches_inscription_id_idx";

-- DropIndex
DROP INDEX "paiements_tranches_inscription_id_numero_sequence_key";

-- DropIndex
DROP INDEX "pelerins_numero_pasport_key";

-- AlterTable
ALTER TABLE "paiements_tranches" DROP COLUMN "inscription_id",
ADD COLUMN     "pelerin_id" TEXT NOT NULL;

-- AlterTable
ALTER TABLE "pelerins" ADD COLUMN     "date_inscription" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
ADD COLUMN     "montant_total" DECIMAL(12,2) NOT NULL,
ADD COLUMN     "statut_inscription" TEXT NOT NULL DEFAULT 'EN_ATTENTE',
ADD COLUMN     "voyage_id" TEXT NOT NULL;

-- DropTable
DROP TABLE "inscriptions_pelerins";

-- CreateIndex
CREATE INDEX "paiements_tranches_pelerin_id_idx" ON "paiements_tranches"("pelerin_id");

-- CreateIndex
CREATE UNIQUE INDEX "paiements_tranches_pelerin_id_numero_sequence_key" ON "paiements_tranches"("pelerin_id", "numero_sequence");

-- CreateIndex
CREATE INDEX "pelerins_voyage_id_idx" ON "pelerins"("voyage_id");

-- CreateIndex
CREATE INDEX "pelerins_statut_inscription_idx" ON "pelerins"("statut_inscription");

-- CreateIndex
CREATE UNIQUE INDEX "pelerins_numero_pasport_voyage_id_key" ON "pelerins"("numero_pasport", "voyage_id");

-- AddForeignKey
ALTER TABLE "pelerins" ADD CONSTRAINT "pelerins_voyage_id_fkey" FOREIGN KEY ("voyage_id") REFERENCES "voyages"("id") ON DELETE RESTRICT ON UPDATE CASCADE;

-- AddForeignKey
ALTER TABLE "paiements_tranches" ADD CONSTRAINT "paiements_tranches_pelerin_id_fkey" FOREIGN KEY ("pelerin_id") REFERENCES "pelerins"("id") ON DELETE CASCADE ON UPDATE CASCADE;
