212 lines
6.7 KiB
SQL
212 lines
6.7 KiB
SQL
/*
|
|
Warnings:
|
|
|
|
- You are about to drop the `AuthSession` table. If the table is not empty, all the data it contains will be lost.
|
|
- You are about to drop the `Invoice` table. If the table is not empty, all the data it contains will be lost.
|
|
- You are about to drop the `Notification` table. If the table is not empty, all the data it contains will be lost.
|
|
- You are about to drop the `Operator` table. If the table is not empty, all the data it contains will be lost.
|
|
- You are about to drop the `Partner` table. If the table is not empty, all the data it contains will be lost.
|
|
- You are about to drop the `Payment` table. If the table is not empty, all the data it contains will be lost.
|
|
- You are about to drop the `Plan` table. If the table is not empty, all the data it contains will be lost.
|
|
- You are about to drop the `Refund` table. If the table is not empty, all the data it contains will be lost.
|
|
- You are about to drop the `Subscription` table. If the table is not empty, all the data it contains will be lost.
|
|
- You are about to drop the `User` table. If the table is not empty, all the data it contains will be lost.
|
|
- You are about to drop the `Webhook` table. If the table is not empty, all the data it contains will be lost.
|
|
|
|
*/
|
|
-- CreateEnum
|
|
CREATE TYPE "Currency" AS ENUM ('XOF', 'XAF', 'EURO', 'DOLLARS');
|
|
|
|
-- CreateEnum
|
|
CREATE TYPE "Periodicity" AS ENUM ('Daily', 'Weekly', 'Monthly', 'OneTime');
|
|
|
|
-- DropForeignKey
|
|
ALTER TABLE "public"."AuthSession" DROP CONSTRAINT "AuthSession_partnerId_fkey";
|
|
|
|
-- DropForeignKey
|
|
ALTER TABLE "public"."Invoice" DROP CONSTRAINT "Invoice_partnerId_fkey";
|
|
|
|
-- DropForeignKey
|
|
ALTER TABLE "public"."Invoice" DROP CONSTRAINT "Invoice_paymentId_fkey";
|
|
|
|
-- DropForeignKey
|
|
ALTER TABLE "public"."Invoice" DROP CONSTRAINT "Invoice_subscriptionId_fkey";
|
|
|
|
-- DropForeignKey
|
|
ALTER TABLE "public"."Invoice" DROP CONSTRAINT "Invoice_userId_fkey";
|
|
|
|
-- DropForeignKey
|
|
ALTER TABLE "public"."Notification" DROP CONSTRAINT "Notification_partnerId_fkey";
|
|
|
|
-- DropForeignKey
|
|
ALTER TABLE "public"."Notification" DROP CONSTRAINT "Notification_userId_fkey";
|
|
|
|
-- DropForeignKey
|
|
ALTER TABLE "public"."Payment" DROP CONSTRAINT "Payment_partnerId_fkey";
|
|
|
|
-- DropForeignKey
|
|
ALTER TABLE "public"."Payment" DROP CONSTRAINT "Payment_subscriptionId_fkey";
|
|
|
|
-- DropForeignKey
|
|
ALTER TABLE "public"."Payment" DROP CONSTRAINT "Payment_userId_fkey";
|
|
|
|
-- DropForeignKey
|
|
ALTER TABLE "public"."Plan" DROP CONSTRAINT "Plan_partnerId_fkey";
|
|
|
|
-- DropForeignKey
|
|
ALTER TABLE "public"."Refund" DROP CONSTRAINT "Refund_paymentId_fkey";
|
|
|
|
-- DropForeignKey
|
|
ALTER TABLE "public"."Subscription" DROP CONSTRAINT "Subscription_partnerId_fkey";
|
|
|
|
-- DropForeignKey
|
|
ALTER TABLE "public"."Subscription" DROP CONSTRAINT "Subscription_planId_fkey";
|
|
|
|
-- DropForeignKey
|
|
ALTER TABLE "public"."Subscription" DROP CONSTRAINT "Subscription_userId_fkey";
|
|
|
|
-- DropForeignKey
|
|
ALTER TABLE "public"."User" DROP CONSTRAINT "User_operatorId_fkey";
|
|
|
|
-- DropForeignKey
|
|
ALTER TABLE "public"."User" DROP CONSTRAINT "User_partnerId_fkey";
|
|
|
|
-- DropForeignKey
|
|
ALTER TABLE "public"."Webhook" DROP CONSTRAINT "Webhook_partnerId_fkey";
|
|
|
|
-- DropTable
|
|
DROP TABLE "public"."AuthSession";
|
|
|
|
-- DropTable
|
|
DROP TABLE "public"."Invoice";
|
|
|
|
-- DropTable
|
|
DROP TABLE "public"."Notification";
|
|
|
|
-- DropTable
|
|
DROP TABLE "public"."Operator";
|
|
|
|
-- DropTable
|
|
DROP TABLE "public"."Partner";
|
|
|
|
-- DropTable
|
|
DROP TABLE "public"."Payment";
|
|
|
|
-- DropTable
|
|
DROP TABLE "public"."Plan";
|
|
|
|
-- DropTable
|
|
DROP TABLE "public"."Refund";
|
|
|
|
-- DropTable
|
|
DROP TABLE "public"."Subscription";
|
|
|
|
-- DropTable
|
|
DROP TABLE "public"."User";
|
|
|
|
-- DropTable
|
|
DROP TABLE "public"."Webhook";
|
|
|
|
-- DropEnum
|
|
DROP TYPE "public"."OperatorCode";
|
|
|
|
-- DropEnum
|
|
DROP TYPE "public"."PaymentStatus";
|
|
|
|
-- DropEnum
|
|
DROP TYPE "public"."SubscriptionStatus";
|
|
|
|
-- CreateTable
|
|
CREATE TABLE "merchant_partners" (
|
|
"id" SERIAL NOT NULL,
|
|
"name" TEXT NOT NULL,
|
|
"logo" TEXT,
|
|
"description" TEXT,
|
|
"adresse" TEXT,
|
|
"phone" TEXT,
|
|
"createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
|
"updatedAt" TIMESTAMP(3) NOT NULL,
|
|
|
|
CONSTRAINT "merchant_partners_pkey" PRIMARY KEY ("id")
|
|
);
|
|
|
|
-- CreateTable
|
|
CREATE TABLE "configs" (
|
|
"id" SERIAL NOT NULL,
|
|
"name" TEXT NOT NULL,
|
|
"value" TEXT NOT NULL,
|
|
"merchantPartnerId" INTEGER NOT NULL,
|
|
"operatorId" INTEGER,
|
|
"createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
|
"updatedAt" TIMESTAMP(3) NOT NULL,
|
|
|
|
CONSTRAINT "configs_pkey" PRIMARY KEY ("id")
|
|
);
|
|
|
|
-- CreateTable
|
|
CREATE TABLE "services" (
|
|
"id" SERIAL NOT NULL,
|
|
"name" TEXT NOT NULL,
|
|
"description" TEXT,
|
|
"merchantPartnerId" INTEGER NOT NULL,
|
|
"createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
|
"updatedAt" TIMESTAMP(3) NOT NULL,
|
|
|
|
CONSTRAINT "services_pkey" PRIMARY KEY ("id")
|
|
);
|
|
|
|
-- CreateTable
|
|
CREATE TABLE "pricings" (
|
|
"id" SERIAL NOT NULL,
|
|
"name" TEXT NOT NULL,
|
|
"type" "Periodicity" NOT NULL,
|
|
"amount" DOUBLE PRECISION NOT NULL,
|
|
"tax" DOUBLE PRECISION NOT NULL,
|
|
"currency" "Currency" NOT NULL,
|
|
"periodicity" "Periodicity" NOT NULL,
|
|
"serviceId" INTEGER NOT NULL,
|
|
"createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
|
"updatedAt" TIMESTAMP(3) NOT NULL,
|
|
|
|
CONSTRAINT "pricings_pkey" PRIMARY KEY ("id")
|
|
);
|
|
|
|
-- CreateTable
|
|
CREATE TABLE "technical_contacts" (
|
|
"id" SERIAL NOT NULL,
|
|
"firstName" TEXT NOT NULL,
|
|
"lastName" TEXT NOT NULL,
|
|
"phone" TEXT NOT NULL,
|
|
"email" TEXT NOT NULL,
|
|
"merchantPartnerId" INTEGER NOT NULL,
|
|
"createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
|
"updatedAt" TIMESTAMP(3) NOT NULL,
|
|
|
|
CONSTRAINT "technical_contacts_pkey" PRIMARY KEY ("id")
|
|
);
|
|
|
|
-- CreateTable
|
|
CREATE TABLE "operators" (
|
|
"id" SERIAL NOT NULL,
|
|
"name" TEXT NOT NULL,
|
|
"createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
|
"updatedAt" TIMESTAMP(3) NOT NULL,
|
|
|
|
CONSTRAINT "operators_pkey" PRIMARY KEY ("id")
|
|
);
|
|
|
|
-- AddForeignKey
|
|
ALTER TABLE "configs" ADD CONSTRAINT "configs_merchantPartnerId_fkey" FOREIGN KEY ("merchantPartnerId") REFERENCES "merchant_partners"("id") ON DELETE CASCADE ON UPDATE CASCADE;
|
|
|
|
-- AddForeignKey
|
|
ALTER TABLE "configs" ADD CONSTRAINT "configs_operatorId_fkey" FOREIGN KEY ("operatorId") REFERENCES "operators"("id") ON DELETE SET NULL ON UPDATE CASCADE;
|
|
|
|
-- AddForeignKey
|
|
ALTER TABLE "services" ADD CONSTRAINT "services_merchantPartnerId_fkey" FOREIGN KEY ("merchantPartnerId") REFERENCES "merchant_partners"("id") ON DELETE CASCADE ON UPDATE CASCADE;
|
|
|
|
-- AddForeignKey
|
|
ALTER TABLE "pricings" ADD CONSTRAINT "pricings_serviceId_fkey" FOREIGN KEY ("serviceId") REFERENCES "services"("id") ON DELETE CASCADE ON UPDATE CASCADE;
|
|
|
|
-- AddForeignKey
|
|
ALTER TABLE "technical_contacts" ADD CONSTRAINT "technical_contacts_merchantPartnerId_fkey" FOREIGN KEY ("merchantPartnerId") REFERENCES "merchant_partners"("id") ON DELETE CASCADE ON UPDATE CASCADE;
|