-- CreateTable (idempotent)
CREATE TABLE IF NOT EXISTS "CwMember" (
    "id" TEXT NOT NULL,
    "cwMemberId" INTEGER NOT NULL,
    "identifier" TEXT NOT NULL,
    "firstName" TEXT NOT NULL,
    "lastName" TEXT NOT NULL,
    "officeEmail" TEXT,
    "inactiveFlag" BOOLEAN NOT NULL DEFAULT false,
    "apiKey" TEXT,
    "cwLastUpdated" TIMESTAMP(3),
    "createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
    "updatedAt" TIMESTAMP(3) NOT NULL,

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

-- CreateIndex (idempotent)
CREATE UNIQUE INDEX IF NOT EXISTS "CwMember_cwMemberId_key" ON "CwMember"("cwMemberId");

-- CreateIndex (idempotent)
CREATE UNIQUE INDEX IF NOT EXISTS "CwMember_identifier_key" ON "CwMember"("identifier");
