Skip to content

High performance self-hosted photo and video management solution.

1.3 KB
Raw Blame
import {
  Column,
  CreateDateColumn,
  DeleteDateColumn,
  ForeignKeyColumn,
  type Generated,
  PrimaryGeneratedColumn,
  Table,
  Timestamp,
  UpdateDateColumn,
} from '@immich/sql-tools';
import { UpdateIdColumn, UpdatedAtTrigger } from 'src/decorators.js';
import { NotificationLevel, NotificationType } from 'src/enum.js';
import { UserTable } from 'src/schema/tables/user.table.js';

@Table('notification')
@UpdatedAtTrigger('notification_updatedAt')
export class NotificationTable {
  @PrimaryGeneratedColumn()
  id!: Generated<string>;

  @CreateDateColumn()
  createdAt!: Generated<Timestamp>;

  @UpdateDateColumn()
  updatedAt!: Generated<Timestamp>;

  @DeleteDateColumn()
  deletedAt!: Timestamp | null;

  @UpdateIdColumn({ index: true })
  updateId!: Generated<string>;

  @ForeignKeyColumn(() => UserTable, { onDelete: 'CASCADE', onUpdate: 'CASCADE', nullable: true })
  userId!: string;

  @Column({ default: NotificationLevel.Info })
  level!: Generated<NotificationLevel>;

  @Column({ default: NotificationLevel.Info })
  type!: Generated<NotificationType>;

  @Column({ type: 'jsonb', nullable: true })
  data!: unknown | null;

  @Column()
  title!: string;

  @Column({ type: 'text', nullable: true })
  description!: string | null;

  @Column({ type: 'timestamp with time zone', nullable: true })
  readAt!: Timestamp | null;
}