diff --git a/prisma/migrations/20240317125704_feature_file/migration.sql b/prisma/migrations/20240317125704_feature_file/migration.sql new file mode 100644 index 00000000..549ae04a --- /dev/null +++ b/prisma/migrations/20240317125704_feature_file/migration.sql @@ -0,0 +1,42 @@ +-- DropForeignKey +ALTER TABLE "Media" DROP CONSTRAINT "Media_noteId_fkey"; + +-- DropForeignKey +ALTER TABLE "Media" DROP CONSTRAINT "Media_urlShortenerHistoryId_fkey"; + +-- DropIndex +DROP INDEX "Media_urlShortenerHistoryId_key"; + +-- CreateTable +CREATE TABLE "File" ( + "id" SERIAL NOT NULL, + "createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP, + "updatedAt" TIMESTAMP(3) NOT NULL, + "hash" TEXT NOT NULL, + "urlShortenerHistoryId" INTEGER NOT NULL, + "urlShortenerRecordId" INTEGER, + "mediaId" INTEGER NOT NULL, + + CONSTRAINT "File_pkey" PRIMARY KEY ("id") +); + +-- CreateIndex +CREATE UNIQUE INDEX "File_hash_key" ON "File"("hash"); + +-- CreateIndex +CREATE UNIQUE INDEX "File_mediaId_key" ON "File"("mediaId"); + +-- AddForeignKey +ALTER TABLE "Media" ADD CONSTRAINT "Media_urlShortenerHistoryId_fkey" FOREIGN KEY ("urlShortenerHistoryId") REFERENCES "UrlShortenerHistory"("id") ON DELETE SET NULL ON UPDATE CASCADE; + +-- AddForeignKey +ALTER TABLE "Media" ADD CONSTRAINT "Media_noteId_fkey" FOREIGN KEY ("noteId") REFERENCES "Note"("id") ON DELETE SET NULL ON UPDATE CASCADE; + +-- AddForeignKey +ALTER TABLE "File" ADD CONSTRAINT "File_urlShortenerHistoryId_fkey" FOREIGN KEY ("urlShortenerHistoryId") REFERENCES "UrlShortenerHistory"("id") ON DELETE CASCADE ON UPDATE CASCADE; + +-- AddForeignKey +ALTER TABLE "File" ADD CONSTRAINT "File_urlShortenerRecordId_fkey" FOREIGN KEY ("urlShortenerRecordId") REFERENCES "UrlShortenerRecord"("id") ON DELETE SET NULL ON UPDATE CASCADE; + +-- AddForeignKey +ALTER TABLE "File" ADD CONSTRAINT "File_mediaId_fkey" FOREIGN KEY ("mediaId") REFERENCES "Media"("id") ON DELETE RESTRICT ON UPDATE CASCADE; diff --git a/src/components/atoms/BlobUploader.tsx b/src/components/atoms/BlobUploader.tsx index b41ab889..980281b2 100644 --- a/src/components/atoms/BlobUploader.tsx +++ b/src/components/atoms/BlobUploader.tsx @@ -212,7 +212,7 @@ export const BlobUploader = ({ name = '', selectedMedia }: Props) => {

Download

)} - {hasFile && ( + {!!downloadUrl && (

Delete

diff --git a/src/components/atoms/Tabs.tsx b/src/components/atoms/Tabs.tsx index 79560aac..9353060c 100644 --- a/src/components/atoms/Tabs.tsx +++ b/src/components/atoms/Tabs.tsx @@ -34,7 +34,7 @@ export const Tabs = (props: Props) => {