summaryrefslogtreecommitdiff
path: root/src/models/entities
diff options
context:
space:
mode:
authorsyuilo <Syuilotan@yahoo.co.jp>2020-02-18 08:41:32 +0900
committersyuilo <Syuilotan@yahoo.co.jp>2020-02-18 08:41:32 +0900
commita54de07260c3555d0230492970448604ffb9d586 (patch)
tree0650c5de48af1cd5b5945da6a3dff6093ceaefd1 /src/models/entities
parentFix type (diff)
downloadmisskey-a54de07260c3555d0230492970448604ffb9d586.tar.gz
misskey-a54de07260c3555d0230492970448604ffb9d586.tar.bz2
misskey-a54de07260c3555d0230492970448604ffb9d586.zip
Resolve #5963
Diffstat (limited to 'src/models/entities')
-rw-r--r--src/models/entities/promo-note.ts28
-rw-r--r--src/models/entities/promo-read.ts35
2 files changed, 63 insertions, 0 deletions
diff --git a/src/models/entities/promo-note.ts b/src/models/entities/promo-note.ts
new file mode 100644
index 0000000000..474f1cb235
--- /dev/null
+++ b/src/models/entities/promo-note.ts
@@ -0,0 +1,28 @@
+import { PrimaryColumn, Entity, Index, JoinColumn, Column, OneToOne } from 'typeorm';
+import { Note } from './note';
+import { User } from './user';
+import { id } from '../id';
+
+@Entity()
+export class PromoNote {
+ @PrimaryColumn(id())
+ public noteId: Note['id'];
+
+ @OneToOne(type => Note, {
+ onDelete: 'CASCADE'
+ })
+ @JoinColumn()
+ public note: Note | null;
+
+ @Column('timestamp with time zone')
+ public expiresAt: Date;
+
+ //#region Denormalized fields
+ @Index()
+ @Column({
+ ...id(),
+ comment: '[Denormalized]'
+ })
+ public userId: User['id'];
+ //#endregion
+}
diff --git a/src/models/entities/promo-read.ts b/src/models/entities/promo-read.ts
new file mode 100644
index 0000000000..2e0977b6b5
--- /dev/null
+++ b/src/models/entities/promo-read.ts
@@ -0,0 +1,35 @@
+import { PrimaryColumn, Entity, Index, JoinColumn, Column, ManyToOne } from 'typeorm';
+import { Note } from './note';
+import { User } from './user';
+import { id } from '../id';
+
+@Entity()
+@Index(['userId', 'noteId'], { unique: true })
+export class PromoRead {
+ @PrimaryColumn(id())
+ public id: string;
+
+ @Column('timestamp with time zone', {
+ comment: 'The created date of the PromoRead.'
+ })
+ public createdAt: Date;
+
+ @Index()
+ @Column(id())
+ public userId: User['id'];
+
+ @ManyToOne(type => User, {
+ onDelete: 'CASCADE'
+ })
+ @JoinColumn()
+ public user: User | null;
+
+ @Column(id())
+ public noteId: Note['id'];
+
+ @ManyToOne(type => Note, {
+ onDelete: 'CASCADE'
+ })
+ @JoinColumn()
+ public note: Note | null;
+}