-- CreateEnum
CREATE TYPE "Civility" AS ENUM ('Mme', 'M');

-- CreateEnum
CREATE TYPE "Role" AS ENUM ('User', 'Admin');

-- CreateEnum
CREATE TYPE "LegalForm" AS ENUM ('SA', 'SARL', 'SNC', 'PPH', 'Autre');

-- CreateTable
CREATE TABLE "User" (
    "id" TEXT NOT NULL,
    "civility" "Civility" NOT NULL DEFAULT 'M',
    "firstName" VARCHAR(255) NOT NULL,
    "lastName" VARCHAR(255) NOT NULL,
    "email" VARCHAR(255) NOT NULL,
    "password" VARCHAR(255) NOT NULL,
    "postion" VARCHAR(255) NOT NULL,
    "city" VARCHAR(255) NOT NULL,
    "phoneNumber" VARCHAR(255) NOT NULL,
    "expertiseAreas" TEXT[],
    "interestAreas" TEXT[],
    "bio" VARCHAR(255) NOT NULL,
    "companyId" TEXT,
    "actif" BOOLEAN NOT NULL DEFAULT true,
    "role" "Role" NOT NULL DEFAULT 'User',
    "varified" BOOLEAN NOT NULL DEFAULT false,
    "resetPasswordCode" TEXT,
    "resetPasswordAt" TIMESTAMP(3),
    "createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,

    CONSTRAINT "User_pkey" PRIMARY KEY ("id")
);

-- CreateTable
CREATE TABLE "Company" (
    "id" TEXT NOT NULL,
    "logo" VARCHAR(255),
    "name" VARCHAR(255) NOT NULL,
    "legalForm" "LegalForm" NOT NULL DEFAULT 'SA',
    "city" VARCHAR(255) NOT NULL,
    "address" VARCHAR(255) NOT NULL,
    "phoneNumber" VARCHAR(255) NOT NULL,
    "email" VARCHAR(255) NOT NULL,
    "websitte" VARCHAR(255) NOT NULL,
    "linkedin" VARCHAR(255) NOT NULL,
    "facebook" VARCHAR(255) NOT NULL,
    "contactFirstName" VARCHAR(255) NOT NULL,
    "contactLastName" VARCHAR(255) NOT NULL,
    "contactEmail" VARCHAR(255) NOT NULL,
    "contactPostion" VARCHAR(255) NOT NULL,
    "contactLinkedin" VARCHAR(255) NOT NULL,
    "contactFacebook" VARCHAR(255) NOT NULL,
    "businessLicense" VARCHAR(255) NOT NULL,
    "numRC" VARCHAR(255) NOT NULL,
    "numICE" VARCHAR(255) NOT NULL,
    "capital" DOUBLE PRECISION,
    "turnover" VARCHAR(255) NOT NULL,
    "nEmployees" VARCHAR(255) NOT NULL,
    "activities" TEXT[],
    "importCountries" TEXT[],
    "exportCountries" TEXT[],
    "actif" BOOLEAN NOT NULL DEFAULT true,
    "verified" BOOLEAN NOT NULL DEFAULT false,
    "partner" BOOLEAN NOT NULL DEFAULT false,
    "contributor" BOOLEAN NOT NULL DEFAULT false,
    "createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,

    CONSTRAINT "Company_pkey" PRIMARY KEY ("id")
);

-- CreateIndex
CREATE UNIQUE INDEX "User_email_key" ON "User"("email");

-- AddForeignKey
ALTER TABLE "User" ADD CONSTRAINT "User_companyId_fkey" FOREIGN KEY ("companyId") REFERENCES "Company"("id") ON DELETE RESTRICT ON UPDATE CASCADE;
