mirror of
https://github.com/hedgedoc/hedgedoc.git
synced 2024-11-24 18:56:32 -05:00
RevisionEntity: Change primary key type from UUID to number
The precision of sqlites datetime() timestamp is only one second (see https://www.sqlite.org/lang_datefunc.html). Therefore we could not order revisions of one note that were created in the same second. To remedy this, the primary key was changed to a monotonically increasing number, which solves the ordering problem. Signed-off-by: David Mehren <git@herrmehren.de>
This commit is contained in:
parent
1abb472621
commit
d462a571d8
5 changed files with 10 additions and 9 deletions
|
@ -58,7 +58,7 @@ entity "Session" as seesion {
|
||||||
|
|
||||||
|
|
||||||
entity "Revision" {
|
entity "Revision" {
|
||||||
*id : uuid <<generated>>
|
*id : number <<generated>>
|
||||||
--
|
--
|
||||||
*noteId : uuid <<FK Note>>
|
*noteId : uuid <<FK Note>>
|
||||||
*content : text
|
*content : text
|
||||||
|
@ -78,7 +78,7 @@ entity "Authorship" {
|
||||||
}
|
}
|
||||||
|
|
||||||
entity "RevisionAuthorship" {
|
entity "RevisionAuthorship" {
|
||||||
*revisionId : uuid <<FK Revision>>
|
*revisionId : number <<FK Revision>>
|
||||||
*authorshipId : uuid <<FK Authorship>>
|
*authorshipId : uuid <<FK Authorship>>
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -2,7 +2,7 @@ import { IsDate, IsNumber, IsString } from 'class-validator';
|
||||||
import { Revision } from './revision.entity';
|
import { Revision } from './revision.entity';
|
||||||
|
|
||||||
export class RevisionMetadataDto {
|
export class RevisionMetadataDto {
|
||||||
@IsString()
|
@IsNumber()
|
||||||
id: Revision['id'];
|
id: Revision['id'];
|
||||||
|
|
||||||
@IsDate()
|
@IsDate()
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
import { IsString } from 'class-validator';
|
import { IsNumber, IsString } from 'class-validator';
|
||||||
import { Revision } from './revision.entity';
|
import { Revision } from './revision.entity';
|
||||||
|
|
||||||
export class RevisionDto {
|
export class RevisionDto {
|
||||||
@IsString()
|
@IsNumber()
|
||||||
id: Revision['id'];
|
id: Revision['id'];
|
||||||
@IsString()
|
@IsString()
|
||||||
content: string;
|
content: string;
|
||||||
|
|
|
@ -16,8 +16,8 @@ import { Authorship } from './authorship.entity';
|
||||||
*/
|
*/
|
||||||
@Entity()
|
@Entity()
|
||||||
export class Revision {
|
export class Revision {
|
||||||
@PrimaryGeneratedColumn('uuid')
|
@PrimaryGeneratedColumn()
|
||||||
id: string;
|
id: number;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The patch from the previous revision to this one.
|
* The patch from the previous revision to this one.
|
||||||
|
|
|
@ -16,14 +16,14 @@ export class RevisionsService {
|
||||||
this.logger.warn('Using hardcoded data!');
|
this.logger.warn('Using hardcoded data!');
|
||||||
return [
|
return [
|
||||||
{
|
{
|
||||||
id: 'some-uuid',
|
id: 42,
|
||||||
updatedAt: new Date(),
|
updatedAt: new Date(),
|
||||||
length: 42,
|
length: 42,
|
||||||
},
|
},
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
getNoteRevision(noteIdOrAlias: string, revisionId: string): RevisionDto {
|
getNoteRevision(noteIdOrAlias: string, revisionId: number): RevisionDto {
|
||||||
this.logger.warn('Using hardcoded data!');
|
this.logger.warn('Using hardcoded data!');
|
||||||
return {
|
return {
|
||||||
id: revisionId,
|
id: revisionId,
|
||||||
|
@ -39,6 +39,7 @@ export class RevisionsService {
|
||||||
},
|
},
|
||||||
order: {
|
order: {
|
||||||
createdAt: 'DESC',
|
createdAt: 'DESC',
|
||||||
|
id: 'DESC',
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue