mirror of
https://github.com/hedgedoc/hedgedoc.git
synced 2024-11-24 18:56:32 -05:00
Update revision entity according to the current database scheme.
Signed-off-by: David Mehren <git@herrmehren.de>
This commit is contained in:
parent
0a33d8ef8d
commit
68a0852691
1 changed files with 31 additions and 13 deletions
|
@ -4,47 +4,65 @@ import {
|
||||||
Entity,
|
Entity,
|
||||||
ManyToOne,
|
ManyToOne,
|
||||||
PrimaryGeneratedColumn,
|
PrimaryGeneratedColumn,
|
||||||
UpdateDateColumn,
|
|
||||||
} from 'typeorm';
|
} from 'typeorm';
|
||||||
|
import { JoinTable, ManyToMany } from 'typeorm/index';
|
||||||
import { Note } from '../notes/note.entity';
|
import { Note } from '../notes/note.entity';
|
||||||
|
import { Authorship } from './authorship.entity';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The state of a note at a particular point in time,
|
||||||
|
* with the content at that time and the diff to the previous revision.
|
||||||
|
*
|
||||||
|
*/
|
||||||
@Entity()
|
@Entity()
|
||||||
export class Revision {
|
export class Revision {
|
||||||
//TODO: This is the old schema, we probably want to change it
|
|
||||||
@PrimaryGeneratedColumn('uuid')
|
@PrimaryGeneratedColumn('uuid')
|
||||||
id: string;
|
id: string;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The patch from the previous revision to this one.
|
||||||
|
*/
|
||||||
@Column({
|
@Column({
|
||||||
type: 'text',
|
type: 'text',
|
||||||
})
|
})
|
||||||
patch: string;
|
patch: string;
|
||||||
|
|
||||||
@Column({
|
/**
|
||||||
type: 'text',
|
* The note content at this revision.
|
||||||
})
|
*/
|
||||||
lastContent: string;
|
|
||||||
|
|
||||||
@Column({
|
@Column({
|
||||||
type: 'text',
|
type: 'text',
|
||||||
})
|
})
|
||||||
content: string;
|
content: string;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The length of the note content.
|
||||||
|
*/
|
||||||
@Column()
|
@Column()
|
||||||
length: number;
|
length: number;
|
||||||
|
|
||||||
@Column({ type: 'text' })
|
/**
|
||||||
authorship: string;
|
* Date at which the revision was created.
|
||||||
|
*/
|
||||||
@CreateDateColumn()
|
@CreateDateColumn()
|
||||||
createdAt: Date;
|
createdAt: Date;
|
||||||
|
|
||||||
@UpdateDateColumn()
|
/**
|
||||||
updatedAt: Date;
|
* Note this revision belongs to.
|
||||||
|
*/
|
||||||
@ManyToOne(
|
@ManyToOne(
|
||||||
_ => Note,
|
_ => Note,
|
||||||
note => note.revisions,
|
note => note.revisions,
|
||||||
{ onDelete: 'CASCADE' },
|
{ onDelete: 'CASCADE' },
|
||||||
)
|
)
|
||||||
note: Note;
|
note: Note;
|
||||||
|
/**
|
||||||
|
* All authorship objects which are used in the revision.
|
||||||
|
*/
|
||||||
|
@ManyToMany(
|
||||||
|
_ => Authorship,
|
||||||
|
authorship => authorship.revisions,
|
||||||
|
)
|
||||||
|
@JoinTable()
|
||||||
|
authorships: Authorship[];
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue