shellphone.app/db/migrations/20210924173647_add_processing_phone_number_table/migration.sql

20 lines
767 B
MySQL
Raw Normal View History

2021-09-24 23:07:40 +00:00
-- CreateTable
CREATE TABLE "ProcessingPhoneNumber" (
"createdAt" TIMESTAMPTZ NOT NULL DEFAULT CURRENT_TIMESTAMP,
"hasFetchedMessages" BOOLEAN NOT NULL,
"hasFetchedCalls" BOOLEAN NOT NULL,
"phoneNumberId" TEXT NOT NULL,
"organizationId" TEXT NOT NULL,
PRIMARY KEY ("organizationId","phoneNumberId")
);
-- CreateIndex
CREATE UNIQUE INDEX "ProcessingPhoneNumber_phoneNumberId_unique" ON "ProcessingPhoneNumber"("phoneNumberId");
-- AddForeignKey
ALTER TABLE "ProcessingPhoneNumber" ADD FOREIGN KEY ("phoneNumberId") REFERENCES "PhoneNumber"("id") ON DELETE CASCADE ON UPDATE CASCADE;
-- AddForeignKey
ALTER TABLE "ProcessingPhoneNumber" ADD FOREIGN KEY ("organizationId") REFERENCES "Organization"("id") ON DELETE CASCADE ON UPDATE CASCADE;