-- CreateTable
CREATE TABLE "complex_users" (
    "complex_id" UUID NOT NULL,
    "user_id" TEXT NOT NULL,
    "role" "ComplexUserRole" NOT NULL DEFAULT 'ADMIN',
    "created_at" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,

    CONSTRAINT "complex_users_pkey" PRIMARY KEY ("complex_id","user_id")
);

-- CreateIndex
CREATE INDEX "complex_users_user_id_idx" ON "complex_users"("user_id");

-- AddForeignKey
ALTER TABLE "complex_users" ADD CONSTRAINT "complex_users_complex_id_fkey" FOREIGN KEY ("complex_id") REFERENCES "complexes"("id") ON DELETE CASCADE ON UPDATE CASCADE;

-- AddForeignKey
ALTER TABLE "complex_users" ADD CONSTRAINT "complex_users_user_id_fkey" FOREIGN KEY ("user_id") REFERENCES "users"("id") ON DELETE CASCADE ON UPDATE CASCADE;
