Changed DB to have events behave like polls

This commit is contained in:
ssmucny 2023-04-16 15:25:54 -04:00
parent 4e6a4915d8
commit 8ab1d62444
2 changed files with 13 additions and 16 deletions

View File

@ -1,10 +1,17 @@
import { Entity, Index, Column, PrimaryColumn } from 'typeorm';
import { Entity, Index, Column, PrimaryColumn, OneToOne, JoinColumn } from 'typeorm';
import { id } from '../id.js';
import { Note } from './Note.js';
@Entity()
export class Event {
@PrimaryColumn(id())
public id: string;
public noteId: Note['id'];
@OneToOne(type => Note, {
onDelete: 'CASCADE',
})
@JoinColumn()
public note: Note | null;
@Index()
@Column('timestamp with time zone', {

View File

@ -1,9 +1,8 @@
import { Entity, Index, JoinColumn, Column, PrimaryColumn, ManyToOne, OneToOne } from 'typeorm';
import { Entity, Index, JoinColumn, Column, PrimaryColumn, ManyToOne } from 'typeorm';
import { id } from '../id.js';
import { noteVisibilities } from '../../types.js';
import { User } from './User.js';
import { Channel } from './Channel.js';
import { Event } from './Event.js';
import type { DriveFile } from './DriveFile.js';
@Entity()
@ -54,19 +53,10 @@ export class Note {
})
public threadId: string | null;
@Index()
@Column({
...id(),
nullable: true,
comment: 'The ID of child event',
@Column('boolean', {
default: false,
})
public eventId: Event['id'] | null;
@OneToOne(type => Event, {
onDelete: 'CASCADE',
})
@JoinColumn()
public event: Event | null;
public isEvent: boolean;
// TODO: varcharにしたい
@Column('text', {