Skip to content

Commit 6da35de

Browse files
author
Benny Burkert
committed
feat: WIP prepare db migration
1 parent 4a131c7 commit 6da35de

File tree

6 files changed

+129
-11
lines changed

6 files changed

+129
-11
lines changed

backend/package-lock.json

Lines changed: 117 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

backend/src/controllers/prompts/dtos/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { ApiProperty } from '@nestjs/swagger';
22
import { IsArray, IsDefined, IsEnum, IsOptional, IsString } from 'class-validator';
3-
import { VisibilityType } from 'src/domain/prompt/interfaces';
3+
import { VisibilityType } from 'src/domain/prompt';
44

55
export class CreatePromptCategoryDto {
66
@ApiProperty({

backend/src/domain/database/entities/index.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,3 +11,5 @@ export * from './setting';
1111
export * from './usage';
1212
export * from './user';
1313
export * from './user-group';
14+
export * from './prompt';
15+
export * from './prompt-category';

backend/src/domain/database/entities/prompt-category.ts

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,10 @@
1-
import { Column, Entity, PrimaryGeneratedColumn } from 'typeorm';
1+
import { Column, Entity, PrimaryColumn } from 'typeorm';
2+
import { VisibilityType } from 'src/domain/prompt';
23
import { schema } from '../typeorm.helper';
3-
import { VisibilityType } from 'src/domain/prompt/interfaces';
44

55
@Entity({ name: 'prompt-categories', schema })
66
export class PromptCategoryEntity {
7-
@PrimaryGeneratedColumn()
8-
id!: string;
9-
10-
@Column({ nullable: true })
7+
@PrimaryColumn()
118
label!: string;
129

1310
@Column()

backend/src/domain/database/entities/prompt.ts

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
import { Column, Entity, OneToMany, PrimaryGeneratedColumn } from 'typeorm';
1+
import { Column, Entity, JoinTable, ManyToMany, PrimaryGeneratedColumn } from 'typeorm';
2+
import { VisibilityType } from 'src/domain/prompt';
23
import { schema } from '../typeorm.helper';
3-
import { VisibilityType } from 'src/domain/prompt/interfaces';
44
import { PromptCategoryEntity } from './prompt-category';
55

66
@Entity({ name: 'prompts', schema })
@@ -17,8 +17,9 @@ export class PromptEntity {
1717
@Column({ nullable: false })
1818
content!: string;
1919

20-
@OneToMany(() => PromptEntity, (prompt) => prompt.categories)
21-
categories?: [string];
20+
@ManyToMany(() => PromptCategoryEntity)
21+
@JoinTable()
22+
categories?: PromptCategoryEntity[];
2223

2324
@Column()
2425
visibility!: VisibilityType;

backend/src/domain/prompt/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export * from './interfaces';

0 commit comments

Comments
 (0)