feat: added file upload + dir creation

This commit is contained in:
Smigz 2025-05-01 20:59:01 -04:00
parent b1c295d2ac
commit eedab606f8
25 changed files with 965 additions and 103 deletions

View file

@ -0,0 +1,12 @@
-- CreateTable
CREATE TABLE "Session" (
"id" TEXT NOT NULL,
"sid" TEXT NOT NULL,
"data" TEXT NOT NULL,
"expiresAt" TIMESTAMP(3) NOT NULL,
CONSTRAINT "Session_pkey" PRIMARY KEY ("id")
);
-- CreateIndex
CREATE UNIQUE INDEX "Session_sid_key" ON "Session"("sid");

View file

@ -0,0 +1,10 @@
/*
Warnings:
- Added the required column `mimetype` to the `File` table without a default value. This is not possible if the table is not empty.
- Added the required column `size` to the `File` table without a default value. This is not possible if the table is not empty.
*/
-- AlterTable
ALTER TABLE "File" ADD COLUMN "mimetype" TEXT NOT NULL,
ADD COLUMN "size" INTEGER NOT NULL;

View file

@ -0,0 +1,17 @@
/*
Warnings:
- Added the required column `full_path` to the `Folder` table without a default value. This is not possible if the table is not empty.
- Added the required column `modification_date` to the `Folder` table without a default value. This is not possible if the table is not empty.
- Added the required column `parent_folder_id` to the `Folder` table without a default value. This is not possible if the table is not empty.
*/
-- AlterTable
ALTER TABLE "Folder" ADD COLUMN "creation_date" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
ADD COLUMN "full_path" TEXT NOT NULL,
ADD COLUMN "modification_date" TIMESTAMP(3) NOT NULL,
ADD COLUMN "owner_user_id" INTEGER,
ADD COLUMN "parent_folder_id" INTEGER NOT NULL;
-- AddForeignKey
ALTER TABLE "Folder" ADD CONSTRAINT "Folder_owner_user_id_fkey" FOREIGN KEY ("owner_user_id") REFERENCES "User"("id") ON DELETE SET NULL ON UPDATE CASCADE;

View file

@ -0,0 +1,14 @@
/*
Warnings:
- You are about to drop the column `full_path` on the `Folder` table. All the data in the column will be lost.
- You are about to drop the column `parent_folder_id` on the `Folder` table. All the data in the column will be lost.
*/
-- AlterTable
ALTER TABLE "Folder" DROP COLUMN "full_path",
DROP COLUMN "parent_folder_id",
ADD COLUMN "parentId" INTEGER;
-- AddForeignKey
ALTER TABLE "Folder" ADD CONSTRAINT "Folder_parentId_fkey" FOREIGN KEY ("parentId") REFERENCES "Folder"("id") ON DELETE SET NULL ON UPDATE CASCADE;

View file

@ -0,0 +1,2 @@
-- AlterTable
ALTER TABLE "Folder" ALTER COLUMN "modification_date" SET DEFAULT CURRENT_TIMESTAMP;

View file

@ -15,17 +15,20 @@ datasource db {
}
model User {
id Int @id @default(autoincrement())
username String @unique @db.VarChar(50)
email String @unique
id Int @id @default(autoincrement())
username String @unique @db.VarChar(50)
email String @unique
password String
files File[]
Folder Folder[]
}
model File {
id Int @id @default(autoincrement())
name String @db.VarChar(255)
url String
size Int
mimetype String
createdAt DateTime @default(now())
owner User? @relation(fields: [ownerId], references: [id])
ownerId Int?
@ -34,7 +37,21 @@ model File {
}
model Folder {
id Int @id @default(autoincrement())
name String @db.VarChar(255)
File File[]
id Int @id @default(autoincrement())
name String @db.VarChar(255)
creation_date DateTime @default(now())
modification_date DateTime @default(now())
File File[]
owner User? @relation(fields: [owner_user_id], references: [id])
owner_user_id Int?
parentId Int?
parent Folder? @relation("ParentDirectory", fields: [parentId], references: [id])
Directories Folder[] @relation("ParentDirectory")
}
model Session {
id String @id
sid String @unique
data String
expiresAt DateTime
}