feat(notification): add entity

This commit is contained in:
avicenan
2026-05-04 15:38:50 +07:00
parent 71a0a1efbe
commit eefd8f21a9
2 changed files with 89 additions and 0 deletions

View File

@ -0,0 +1,88 @@
import {
Entity,
PrimaryGeneratedColumn,
Column,
ManyToOne,
JoinColumn,
CreateDateColumn,
Index,
} from "typeorm";
import { User } from "./users";
@Index("idx_notification_recipient_id", ["recipient_id"])
@Index("idx_notification_sender_id", ["sender_id"])
@Entity("notifications")
export class Notification {
@PrimaryGeneratedColumn("uuid")
id: string;
@ManyToOne(() => User, { nullable: false, onDelete: "CASCADE" })
@JoinColumn({ name: "recipient_id" })
recipient: User;
@Column({
nullable: false,
length: 64,
})
type: string;
@Column({
type: "text",
nullable: false,
})
message: string;
@Column({
type: "jsonb",
nullable: true,
})
data: Record<string, unknown> | null;
@ManyToOne(() => User, { nullable: true, onDelete: "SET NULL" })
@JoinColumn({ name: "sender_id" })
sender: User | null;
@Column({
type: "boolean",
default: false,
})
is_read: boolean;
@Column({
type: "timestamp",
nullable: true,
})
read_at: Date | null;
@Column({
type: "varchar",
length: 10,
nullable: true,
})
priority: string | null;
@Column({
type: "text",
nullable: true,
})
action_url: string | null;
@Column({
type: "timestamp",
nullable: true,
})
expires_at: Date | null;
@Column({
type: "uuid",
nullable: true,
})
batch_id: string | null;
@CreateDateColumn()
created_at: Date;
@Column({ nullable: true, length: 256 })
created_by: string;
}

View File

@ -53,6 +53,7 @@ export * from "../entity/subdistrict";
export * from "../entity/ward"; export * from "../entity/ward";
export * from "../entity/responsible_party_consent"; export * from "../entity/responsible_party_consent";
export * from "../entity/foster_care_history"; export * from "../entity/foster_care_history";
export * from "../entity/notification";
export * from "../types/public"; export * from "../types/public";
export * from "../types/action"; export * from "../types/action";