summaryrefslogtreecommitdiff
path: root/packages/backend/src/models/PromoNote.ts
blob: ae27adec9ef70133e1426f3b567e4361a73f93f5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
/*
 * SPDX-FileCopyrightText: syuilo and misskey-project
 * SPDX-License-Identifier: AGPL-3.0-only
 */

import { PrimaryColumn, Entity, Index, JoinColumn, Column, OneToOne } from 'typeorm';
import { id } from './util/id.js';
import { MiNote } from './Note.js';
import type { MiUser } from './User.js';

@Entity('promo_note')
export class MiPromoNote {
	@PrimaryColumn(id())
	public noteId: MiNote['id'];

	@OneToOne(type => MiNote, {
		onDelete: 'CASCADE',
	})
	@JoinColumn()
	public note: MiNote | null;

	@Column('timestamp with time zone')
	public expiresAt: Date;

	//#region Denormalized fields
	@Index()
	@Column({
		...id(),
		comment: '[Denormalized]',
	})
	public userId: MiUser['id'];
	//#endregion
}