diff --git a/packages/database/prisma/migrations/20241025092424_registration/migration.sql b/packages/database/prisma/migrations/20241025092424_registration/migration.sql new file mode 100644 index 00000000..5ec10edf --- /dev/null +++ b/packages/database/prisma/migrations/20241025092424_registration/migration.sql @@ -0,0 +1,53 @@ +-- CreateTable +CREATE TABLE "Registrant" ( + "id" UUID NOT NULL DEFAULT gen_random_uuid(), + "firstName" TEXT NOT NULL, + "lastName" TEXT, + "email" TEXT NOT NULL, + "phone" TEXT, + "eventId" UUID NOT NULL, + "organizationId" TEXT NOT NULL, + + CONSTRAINT "Registrant_pkey" PRIMARY KEY ("id") +); + +-- CreateTable +CREATE TABLE "RegistrantAttributes" ( + "id" UUID NOT NULL DEFAULT gen_random_uuid(), + "value" TEXT NOT NULL, + "createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP, + "updatedAt" TIMESTAMP(3) NOT NULL, + "registrantId" UUID NOT NULL, + "attributeId" UUID NOT NULL, + + CONSTRAINT "RegistrantAttributes_pkey" PRIMARY KEY ("id") +); + +-- CreateTable +CREATE TABLE "RegistrantExtras" ( + "id" UUID NOT NULL DEFAULT gen_random_uuid(), + "createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP, + "updatedAt" TIMESTAMP(3) NOT NULL, + "registrantId" UUID NOT NULL, + "extraId" UUID NOT NULL, + + CONSTRAINT "RegistrantExtras_pkey" PRIMARY KEY ("id") +); + +-- AddForeignKey +ALTER TABLE "Registrant" ADD CONSTRAINT "Registrant_eventId_fkey" FOREIGN KEY ("eventId") REFERENCES "Event"("id") ON DELETE RESTRICT ON UPDATE CASCADE; + +-- AddForeignKey +ALTER TABLE "Registrant" ADD CONSTRAINT "Registrant_organizationId_fkey" FOREIGN KEY ("organizationId") REFERENCES "Organization"("id") ON DELETE RESTRICT ON UPDATE CASCADE; + +-- AddForeignKey +ALTER TABLE "RegistrantAttributes" ADD CONSTRAINT "RegistrantAttributes_registrantId_fkey" FOREIGN KEY ("registrantId") REFERENCES "Registrant"("id") ON DELETE RESTRICT ON UPDATE CASCADE; + +-- AddForeignKey +ALTER TABLE "RegistrantAttributes" ADD CONSTRAINT "RegistrantAttributes_attributeId_fkey" FOREIGN KEY ("attributeId") REFERENCES "Attributes"("id") ON DELETE RESTRICT ON UPDATE CASCADE; + +-- AddForeignKey +ALTER TABLE "RegistrantExtras" ADD CONSTRAINT "RegistrantExtras_registrantId_fkey" FOREIGN KEY ("registrantId") REFERENCES "Registrant"("id") ON DELETE RESTRICT ON UPDATE CASCADE; + +-- AddForeignKey +ALTER TABLE "RegistrantExtras" ADD CONSTRAINT "RegistrantExtras_extraId_fkey" FOREIGN KEY ("extraId") REFERENCES "Extras"("id") ON DELETE RESTRICT ON UPDATE CASCADE;