Skip to content
Draft
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
48 commits
Select commit Hold shift + click to select a range
355f21b
Passwords also refuse a distinctive word of an institute's name, not …
omerFixesBugs Nov 16, 2026
7016eff
Sprint 1 P1-J plan (docs/plans/sprint-1-p1j-password-hash.md): the ap…
omerFixesBugs Nov 16, 2026
25da8a3
Sprint 1 P2 plan (docs/plans/sprint-1-p2-files.md): institute profile…
omerFixesBugs Nov 16, 2026
995e61e
Test users get phone numbers no other test user of the same database …
omerFixesBugs Nov 16, 2026
356c448
The app login can no longer read users.password_hash (P1-J): SELECT o…
omerFixesBugs Nov 16, 2026
3ca69eb
Every Prisma client leaves users.password_hash out of its reads (P1-J…
omerFixesBugs Nov 16, 2026
30e85f6
Files and the institute profile in the database (P2 task 1): stored_f…
omerFixesBugs Nov 16, 2026
687a83b
CORS_ORIGINS is normalised in env.ts as browsers send Origin (lower-c…
omerFixesBugs Nov 16, 2026
ff8981c
Shared file caps, types and the institute profile schema (P2 task 2):…
omerFixesBugs Nov 16, 2026
917d5eb
The start-up login check also refuses a login with REPLICATION (a rep…
omerFixesBugs Nov 16, 2026
bc6644b
Password login without the hash (P1-J): the API hashes the typed pass…
omerFixesBugs Nov 16, 2026
b0e6315
GET /me/password reads hasPassword from auth_my_password_is_set() (P1…
omerFixesBugs Nov 16, 2026
47fb357
Docs for P1-J: database.md (password_hash not readable by the app, a …
omerFixesBugs Nov 16, 2026
20b29e9
Redis is pinned to one exact version, redis:7.4.11-alpine (the versio…
omerFixesBugs Nov 16, 2026
81bfc26
Docs for the follow-ups: decisions-pending gets the section "Small fo…
omerFixesBugs Nov 16, 2026
9cc9d54
Image processing for uploads (P2 task 3): sharp 0.35.5 (already in th…
omerFixesBugs Nov 16, 2026
b0e010b
FileStore and the per-institute cap (P2 task 4): PostgresFileStore is…
omerFixesBugs Nov 16, 2026
caec9f7
Photo and profile routes (P2 task 5): GET/PUT/DELETE /students/:id/ph…
omerFixesBugs Nov 16, 2026
57cf79f
Web (P2 task 6): Settings → Institute profile (names, EIIN, contact, …
omerFixesBugs Nov 16, 2026
4e4cbb2
Docs for P2 (task 7): docs/files.md, database.md (the three tables an…
omerFixesBugs Nov 16, 2026
724ffb0
The photo dialog's preview URL is made when a file is chosen, not in …
omerFixesBugs Nov 16, 2026
110857d
files.spec: the profile fields by id ("নাম (বাংলা)" is also part of t…
omerFixesBugs Nov 16, 2026
8c3a4f9
After the review (P1-J7): a dedicated login for the password login. j…
omerFixesBugs Nov 16, 2026
72b714b
The password login looks the hash up on its own database login (Login…
omerFixesBugs Nov 16, 2026
06f3236
Docs after the P1-J review: what an injection in an ordinary request …
omerFixesBugs Nov 16, 2026
82f6600
Test phones never wrap and their lock survives races (review of PR #1…
omerFixesBugs Nov 16, 2026
27403c3
The institute-name rule compares passwords and names like the phone r…
omerFixesBugs Nov 16, 2026
7aa31c5
An origin setting with a login, a path, a query or a fragment is no o…
omerFixesBugs Nov 16, 2026
fd6430e
Docs after the review of PR #17: P1-I's title line says it is built h…
omerFixesBugs Nov 16, 2026
9dbee45
P1-J migration after the second review: it first checks that jantrik_…
omerFixesBugs Nov 16, 2026
a980a60
The password login's database login must reach the same database, por…
omerFixesBugs Nov 16, 2026
ff673b8
Docs after the second P1-J review: the server upgrade creates the rol…
omerFixesBugs Nov 16, 2026
13deed2
A file reference is tied to its kind (review R6): UNIQUE (tenant_id, …
omerFixesBugs Nov 16, 2026
cb86722
Uploads hold no database connection while they arrive (review R1): th…
omerFixesBugs Nov 16, 2026
459bcf7
Web after the review: a chosen image is shrunk in the browser to 1600…
omerFixesBugs Nov 16, 2026
944e840
Docs after the review: auth.md (the request pipeline and @OwnTransact…
omerFixesBugs Nov 16, 2026
282c8b6
Review round 2, API: uploads in flight bounded before multer (16 per …
omerFixesBugs Nov 16, 2026
cfd4506
Review round 2, web: the browser asks for the EXIF orientation explic…
omerFixesBugs Nov 16, 2026
73eb83b
Docs for review round 2: auth.md (the upload routes' re-checks, Uploa…
omerFixesBugs Nov 16, 2026
e622e52
The interceptor opens its transaction through an unchecked entry (aro…
omerFixesBugs Nov 16, 2026
3d2c5d5
Review round 3: no upload slot leaks when the client left before Uplo…
omerFixesBugs Nov 16, 2026
de19108
The two new origin tests' development settings also name DATABASE_LOG…
omerFixesBugs Nov 16, 2026
aa0105b
Merge P1-J (#16) into the small follow-ups (#17): the ready resolutio…
omerFixesBugs Nov 16, 2026
b1efceb
Merge remote-tracking branch 'origin/feature/sprint-1-p1j-password-ha…
omerFixesBugs Nov 16, 2026
b5d3697
Merge remote-tracking branch 'origin/feature/sprint-1-p2-files' into …
omerFixesBugs Nov 16, 2026
c857102
Merge remote-tracking branch 'origin/feature/small-followups-after-p1…
omerFixesBugs Nov 16, 2026
9309fa8
Work in progress: a staff guide draft and draft legal texts (terms of…
omerFixesBugs Nov 19, 2026
ed5d56c
Docs only: a plain staff guide draft (signing in, setup, students, gu…
omerFixesBugs Nov 19, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Files and the institute profile in the database (P2 task 1): stored_f…
…iles (S I D; per-kind formats and caps by CHECK), stored_file_usage (S I U), institute_profiles (S I U, one per institute, the field CHECKs), students.photo_file_id (composite key, one student per file) replacing the never-written photo_url; forced RLS and isolation tests for each

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
  • Loading branch information
omerFixesBugs and claude committed Nov 16, 2026
commit 30e85f63f9bc0a6e2e250df20f6ec820bf281509
Original file line number Diff line number Diff line change
@@ -0,0 +1,190 @@
-- Sprint 1 P2 (docs/plans/sprint-1-p2-files.md, docs/files.md): images stored in the database
-- behind the API's FileStore, the per-institute usage total, and the institute's own profile.

-- CreateEnum
CREATE TYPE "stored_file_kind" AS ENUM ('STUDENT_PHOTO', 'APPLICANT_PHOTO', 'LOGO', 'SIGNATURE', 'SEAL', 'DOCUMENT_ASSET');

-- CreateTable
CREATE TABLE "stored_files" (
"id" UUID NOT NULL,
"tenant_id" UUID NOT NULL,
"kind" "stored_file_kind" NOT NULL,
"mime" TEXT NOT NULL,
"bytes" BYTEA NOT NULL,
"size_bytes" INTEGER NOT NULL,
"sha256" CHAR(64) NOT NULL,
"width" INTEGER NOT NULL,
"height" INTEGER NOT NULL,
"created_by_id" UUID,
"created_at" TIMESTAMPTZ(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,

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

-- CreateTable
CREATE TABLE "stored_file_usage" (
"id" UUID NOT NULL,
"tenant_id" UUID NOT NULL,
"bytes_used" BIGINT NOT NULL DEFAULT 0,
"file_count" INTEGER NOT NULL DEFAULT 0,
"created_at" TIMESTAMPTZ(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
"updated_at" TIMESTAMPTZ(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,

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

-- CreateTable
CREATE TABLE "institute_profiles" (
"id" UUID NOT NULL,
"tenant_id" UUID NOT NULL,
"name_bn" TEXT,
"name_en" TEXT,
"short_name" TEXT,
"eiin" TEXT,
"address_bn" TEXT,
"address_en" TEXT,
"phone" TEXT,
"email" TEXT,
"website" TEXT,
"head_title_bn" TEXT,
"head_title_en" TEXT,
"head_name_bn" TEXT,
"head_name_en" TEXT,
"established_year" SMALLINT,
"logo_file_id" UUID,
"head_signature_file_id" UUID,
"seal_file_id" UUID,
"created_at" TIMESTAMPTZ(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
"updated_at" TIMESTAMPTZ(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,

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

-- CreateIndex
CREATE INDEX "stored_files_tenant_id_kind_idx" ON "stored_files"("tenant_id", "kind");

-- CreateIndex
CREATE UNIQUE INDEX "stored_files_tenant_id_id_key" ON "stored_files"("tenant_id", "id");

-- CreateIndex
CREATE UNIQUE INDEX "stored_file_usage_tenant_id_key" ON "stored_file_usage"("tenant_id");

-- CreateIndex
CREATE UNIQUE INDEX "stored_file_usage_tenant_id_id_key" ON "stored_file_usage"("tenant_id", "id");

-- CreateIndex
CREATE UNIQUE INDEX "institute_profiles_tenant_id_key" ON "institute_profiles"("tenant_id");

-- CreateIndex
CREATE UNIQUE INDEX "institute_profiles_tenant_id_id_key" ON "institute_profiles"("tenant_id", "id");

-- CreateIndex
CREATE UNIQUE INDEX "institute_profiles_tenant_id_logo_file_id_key" ON "institute_profiles"("tenant_id", "logo_file_id");

-- CreateIndex
CREATE UNIQUE INDEX "institute_profiles_tenant_id_head_signature_file_id_key" ON "institute_profiles"("tenant_id", "head_signature_file_id");

-- CreateIndex
CREATE UNIQUE INDEX "institute_profiles_tenant_id_seal_file_id_key" ON "institute_profiles"("tenant_id", "seal_file_id");

-- AddForeignKey
ALTER TABLE "stored_files" ADD CONSTRAINT "stored_files_tenant_id_fkey" FOREIGN KEY ("tenant_id") REFERENCES "tenants"("id") ON DELETE RESTRICT ON UPDATE RESTRICT;

-- AddForeignKey
ALTER TABLE "stored_files" ADD CONSTRAINT "stored_files_created_by_id_fkey" FOREIGN KEY ("created_by_id") REFERENCES "users"("id") ON DELETE SET NULL ON UPDATE RESTRICT;

-- AddForeignKey
ALTER TABLE "stored_file_usage" ADD CONSTRAINT "stored_file_usage_tenant_id_fkey" FOREIGN KEY ("tenant_id") REFERENCES "tenants"("id") ON DELETE RESTRICT ON UPDATE RESTRICT;

-- AddForeignKey
ALTER TABLE "institute_profiles" ADD CONSTRAINT "institute_profiles_tenant_id_fkey" FOREIGN KEY ("tenant_id") REFERENCES "tenants"("id") ON DELETE RESTRICT ON UPDATE RESTRICT;

-- AddForeignKey
ALTER TABLE "institute_profiles" ADD CONSTRAINT "institute_profiles_tenant_id_logo_file_id_fkey" FOREIGN KEY ("tenant_id", "logo_file_id") REFERENCES "stored_files"("tenant_id", "id") ON DELETE RESTRICT ON UPDATE RESTRICT;

-- AddForeignKey
ALTER TABLE "institute_profiles" ADD CONSTRAINT "institute_profiles_tenant_id_head_signature_file_id_fkey" FOREIGN KEY ("tenant_id", "head_signature_file_id") REFERENCES "stored_files"("tenant_id", "id") ON DELETE RESTRICT ON UPDATE RESTRICT;

-- AddForeignKey
ALTER TABLE "institute_profiles" ADD CONSTRAINT "institute_profiles_tenant_id_seal_file_id_fkey" FOREIGN KEY ("tenant_id", "seal_file_id") REFERENCES "stored_files"("tenant_id", "id") ON DELETE RESTRICT ON UPDATE RESTRICT;

-- Row-Level Security (docs/database.md → Checklist).
ALTER TABLE stored_files ENABLE ROW LEVEL SECURITY;
ALTER TABLE stored_files FORCE ROW LEVEL SECURITY;
CREATE POLICY tenant_isolation ON stored_files
USING (tenant_id = app_current_tenant_id())
WITH CHECK (tenant_id = app_current_tenant_id());

ALTER TABLE stored_file_usage ENABLE ROW LEVEL SECURITY;
ALTER TABLE stored_file_usage FORCE ROW LEVEL SECURITY;
CREATE POLICY tenant_isolation ON stored_file_usage
USING (tenant_id = app_current_tenant_id())
WITH CHECK (tenant_id = app_current_tenant_id());

ALTER TABLE institute_profiles ENABLE ROW LEVEL SECURITY;
ALTER TABLE institute_profiles FORCE ROW LEVEL SECURITY;
CREATE POLICY tenant_isolation ON institute_profiles
USING (tenant_id = app_current_tenant_id())
WITH CHECK (tenant_id = app_current_tenant_id());

-- A file never changes (a replaced image is a new row; the old one is deleted). The usage total
-- and the profile are never deleted.
GRANT SELECT, INSERT, DELETE ON stored_files TO jantrik_app;
GRANT SELECT, INSERT, UPDATE ON stored_file_usage TO jantrik_app;
GRANT SELECT, INSERT, UPDATE ON institute_profiles TO jantrik_app;

-- The caps of docs/files.md, also checked in code (packages/shared/src/files.ts → FILE_LIMITS):
-- formats per kind, bytes per kind, and the stored size is the bytes' real length.
ALTER TABLE stored_files
ADD CONSTRAINT stored_files_mime CHECK (
(kind IN ('STUDENT_PHOTO', 'APPLICANT_PHOTO') AND mime = 'image/jpeg')
OR (kind IN ('LOGO', 'SEAL') AND mime IN ('image/png', 'image/webp'))
OR (kind = 'SIGNATURE' AND mime = 'image/png')
OR (kind = 'DOCUMENT_ASSET' AND mime IN ('image/jpeg', 'image/png', 'image/webp'))
),
ADD CONSTRAINT stored_files_size CHECK (
size_bytes = octet_length(bytes)
AND size_bytes > 0
AND size_bytes <= CASE kind
WHEN 'STUDENT_PHOTO' THEN 204800
WHEN 'APPLICANT_PHOTO' THEN 204800
WHEN 'DOCUMENT_ASSET' THEN 262144
ELSE 102400
END
),
ADD CONSTRAINT stored_files_sha256 CHECK (sha256 ~ '^[0-9a-f]{64}$'),
ADD CONSTRAINT stored_files_dimensions CHECK (width BETWEEN 1 AND 4000 AND height BETWEEN 1 AND 4000);

ALTER TABLE stored_file_usage
ADD CONSTRAINT stored_file_usage_non_negative CHECK (bytes_used >= 0 AND file_count >= 0);

ALTER TABLE institute_profiles
ADD CONSTRAINT institute_profiles_name CHECK (name_bn IS NOT NULL OR name_en IS NOT NULL),
ADD CONSTRAINT institute_profiles_lengths CHECK (
(name_bn IS NULL OR char_length(name_bn) BETWEEN 1 AND 200)
AND (name_en IS NULL OR char_length(name_en) BETWEEN 1 AND 200)
AND (short_name IS NULL OR char_length(short_name) BETWEEN 1 AND 30)
AND (address_bn IS NULL OR char_length(address_bn) BETWEEN 1 AND 300)
AND (address_en IS NULL OR char_length(address_en) BETWEEN 1 AND 300)
AND (head_title_bn IS NULL OR char_length(head_title_bn) BETWEEN 1 AND 60)
AND (head_title_en IS NULL OR char_length(head_title_en) BETWEEN 1 AND 60)
AND (head_name_bn IS NULL OR char_length(head_name_bn) BETWEEN 1 AND 100)
AND (head_name_en IS NULL OR char_length(head_name_en) BETWEEN 1 AND 100)
),
ADD CONSTRAINT institute_profiles_eiin CHECK (eiin IS NULL OR eiin ~ '^[0-9]{6}$'),
ADD CONSTRAINT institute_profiles_phone CHECK (phone IS NULL OR phone ~ '^\+?[0-9]{5,15}$'),
ADD CONSTRAINT institute_profiles_email CHECK (
email IS NULL OR (char_length(email) <= 254 AND email ~ '^[^@\s]+@[^@\s]+\.[^@\s]+$')
),
ADD CONSTRAINT institute_profiles_website CHECK (
website IS NULL OR (char_length(website) <= 200 AND website ~ '^https?://\S+$')
),
ADD CONSTRAINT institute_profiles_established_year CHECK (
established_year IS NULL OR established_year BETWEEN 1800 AND 2100
),
-- One file in one place: the unique indexes cover each column; this covers the row's three.
ADD CONSTRAINT institute_profiles_distinct_files CHECK (
(logo_file_id IS NULL OR (logo_file_id IS DISTINCT FROM head_signature_file_id
AND logo_file_id IS DISTINCT FROM seal_file_id))
AND (head_signature_file_id IS NULL OR head_signature_file_id IS DISTINCT FROM seal_file_id)
);
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
-- Sprint 1 P2: a student's photo is a stored file (kind STUDENT_PHOTO), referenced by a composite
-- key so it can only be a file of the student's own institute. The old photo_url column was never
-- written (always null) and goes.

-- AlterTable
ALTER TABLE "students" DROP COLUMN "photo_url",
ADD COLUMN "photo_file_id" UUID;

-- CreateIndex (also the foreign key's index: a file belongs to one student)
CREATE UNIQUE INDEX "students_tenant_id_photo_file_id_key" ON "students"("tenant_id", "photo_file_id");

-- AddForeignKey
ALTER TABLE "students" ADD CONSTRAINT "students_tenant_id_photo_file_id_fkey" FOREIGN KEY ("tenant_id", "photo_file_id") REFERENCES "stored_files"("tenant_id", "id") ON DELETE RESTRICT ON UPDATE RESTRICT;
114 changes: 113 additions & 1 deletion packages/db/prisma/schema.prisma
Original file line number Diff line number Diff line change
Expand Up @@ -592,6 +592,8 @@ model User {
deviceSourceIpsTrusted DeviceSourceIp[] @relation("DeviceSourceIpTrustedBy")
staffDaysUpdated StaffAttendanceDay[] @relation("StaffAttendanceDayUpdatedBy")

storedFilesCreated StoredFile[] @relation("StoredFileCreatedBy")

@@map("users")
}

Expand Down Expand Up @@ -687,6 +689,10 @@ model Tenant {
deviceSourceIps DeviceSourceIp[]
staffAttendanceDays StaffAttendanceDay[]

storedFiles StoredFile[]
storedFileUsage StoredFileUsage?
instituteProfile InstituteProfile?

@@index([instituteTypeId])
@@map("tenants")
}
Expand Down Expand Up @@ -1004,7 +1010,8 @@ model Student {
nameEn String? @map("name_en")
dateOfBirth DateTime? @map("date_of_birth") @db.Date
gender Gender?
photoUrl String? @map("photo_url")
/// The student's photo (stored_files, kind STUDENT_PHOTO); replaced files are deleted.
photoFileId String? @map("photo_file_id") @db.Uuid
status StudentStatus @default(ACTIVE)
// Fields required for Bangladesh education board registration.
fatherNameBn String? @map("father_name_bn")
Expand All @@ -1024,6 +1031,7 @@ model Student {

tenant Tenant @relation(fields: [tenantId], references: [id], onDelete: Restrict)
user User? @relation(fields: [userId], references: [id], onDelete: SetNull)
photoFile StoredFile? @relation("StudentPhoto", fields: [tenantId, photoFileId], references: [tenantId, id], onDelete: Restrict, onUpdate: Restrict)
guardians StudentGuardian[]
enrolments Enrolment[]

Expand All @@ -1042,6 +1050,8 @@ model Student {
@@unique([tenantId, id])
@@unique([tenantId, studentCode])
@@unique([tenantId, birthRegistrationNo])
// A file belongs to one student (also the foreign key's index).
@@unique([tenantId, photoFileId])
@@index([tenantId, status], where: raw("deleted_at IS NULL"))
@@index([tenantId, nameEn])
// Trigram indexes for ILIKE '%…%' search (GET /students).
Expand Down Expand Up @@ -3112,3 +3122,105 @@ model StaffAttendanceDay {
@@index([tenantId, date])
@@map("staff_attendance_days")
}

// ───────────────────────────── Files and the institute profile (sprint 1 P2) ─────────────────────────────
// docs/files.md. Only apps/api/src/files/postgres-file-store.ts reads or writes stored_files and
// stored_file_usage (a code scan checks it); callers use the FileStore interface.

enum StoredFileKind {
STUDENT_PHOTO
APPLICANT_PHOTO
LOGO
SIGNATURE
SEAL
DOCUMENT_ASSET

@@map("stored_file_kind")
}

/// An image stored in the database, already re-encoded by the API (never the uploaded bytes).
/// Rows never change (no UPDATE grant): a replaced image is a new row, and the old one is deleted.
model StoredFile {
id String @id @default(uuid(7)) @db.Uuid
tenantId String @map("tenant_id") @db.Uuid
kind StoredFileKind
/// image/jpeg, image/png or image/webp; the CHECK pairs each kind with its formats.
mime String
bytes Bytes
/// = octet_length(bytes); at most the kind's cap (CHECK).
sizeBytes Int @map("size_bytes")
/// Hex SHA-256 of bytes: the ETag.
sha256 String @db.Char(64)
width Int
height Int
createdById String? @map("created_by_id") @db.Uuid
createdAt DateTime @default(now()) @map("created_at") @db.Timestamptz(3)

tenant Tenant @relation(fields: [tenantId], references: [id], onDelete: Restrict, onUpdate: Restrict)
createdBy User? @relation("StoredFileCreatedBy", fields: [createdById], references: [id], onDelete: SetNull, onUpdate: Restrict)

student Student? @relation("StudentPhoto")
profileLogo InstituteProfile? @relation("InstituteProfileLogo")
profileSignature InstituteProfile? @relation("InstituteProfileSignature")
profileSeal InstituteProfile? @relation("InstituteProfileSeal")

@@unique([tenantId, id])
@@index([tenantId, kind])
@@map("stored_files")
}

/// One row per institute once it stores a file: the running total for the per-institute cap
/// (FILE_STORAGE_PER_TENANT_MB), changed with every put and delete under the institute's lock.
model StoredFileUsage {
id String @id @default(uuid(7)) @db.Uuid
tenantId String @unique @map("tenant_id") @db.Uuid
bytesUsed BigInt @default(0) @map("bytes_used")
fileCount Int @default(0) @map("file_count")
createdAt DateTime @default(now()) @map("created_at") @db.Timestamptz(3)
updatedAt DateTime @default(now()) @updatedAt @map("updated_at") @db.Timestamptz(3)

tenant Tenant @relation(fields: [tenantId], references: [id], onDelete: Restrict, onUpdate: Restrict)

@@unique([tenantId, id])
@@map("stored_file_usage")
}

/// The institute's own profile (at most one per institute, created on the first save or image).
/// tenants.name stays the name the platform registered; these are the institute's own words.
model InstituteProfile {
id String @id @default(uuid(7)) @db.Uuid
tenantId String @unique @map("tenant_id") @db.Uuid
nameBn String? @map("name_bn")
nameEn String? @map("name_en")
shortName String? @map("short_name")
/// BANBEIS EIIN: 6 ASCII digits.
eiin String?
addressBn String? @map("address_bn")
addressEn String? @map("address_en")
/// 5-15 ASCII digits with an optional leading + (a Bangladeshi mobile is stored as E.164).
phone String?
email String?
website String?
headTitleBn String? @map("head_title_bn")
headTitleEn String? @map("head_title_en")
headNameBn String? @map("head_name_bn")
headNameEn String? @map("head_name_en")
establishedYear Int? @map("established_year") @db.SmallInt
logoFileId String? @map("logo_file_id") @db.Uuid
headSignatureFileId String? @map("head_signature_file_id") @db.Uuid
sealFileId String? @map("seal_file_id") @db.Uuid
createdAt DateTime @default(now()) @map("created_at") @db.Timestamptz(3)
updatedAt DateTime @default(now()) @updatedAt @map("updated_at") @db.Timestamptz(3)

tenant Tenant @relation(fields: [tenantId], references: [id], onDelete: Restrict, onUpdate: Restrict)
logoFile StoredFile? @relation("InstituteProfileLogo", fields: [tenantId, logoFileId], references: [tenantId, id], onDelete: Restrict, onUpdate: Restrict)
signatureFile StoredFile? @relation("InstituteProfileSignature", fields: [tenantId, headSignatureFileId], references: [tenantId, id], onDelete: Restrict, onUpdate: Restrict)
sealFile StoredFile? @relation("InstituteProfileSeal", fields: [tenantId, sealFileId], references: [tenantId, id], onDelete: Restrict, onUpdate: Restrict)

@@unique([tenantId, id])
// One file is used in one place (also each foreign key's index).
@@unique([tenantId, logoFileId])
@@unique([tenantId, headSignatureFileId])
@@unique([tenantId, sealFileId])
@@map("institute_profiles")
}
Loading