mirror of
https://github.com/omnivore-app/omnivore.git
synced 2026-03-11 08:54:26 +00:00
update entity
This commit is contained in:
parent
966295385a
commit
e74f334db9
3 changed files with 16 additions and 6 deletions
|
|
@ -4,6 +4,8 @@ import {
|
|||
CreateDateColumn,
|
||||
Entity,
|
||||
JoinColumn,
|
||||
JoinTable,
|
||||
ManyToMany,
|
||||
ManyToOne,
|
||||
PrimaryGeneratedColumn,
|
||||
} from 'typeorm'
|
||||
|
|
@ -22,9 +24,15 @@ export class Label extends BaseEntity {
|
|||
@JoinColumn({ name: 'user_id' })
|
||||
user!: User
|
||||
|
||||
@ManyToOne(() => Link)
|
||||
@JoinColumn({ name: 'link_id' })
|
||||
link!: Link
|
||||
@ManyToMany(() => Link, (link) => link.labels)
|
||||
@JoinTable({ name: 'link_labels' })
|
||||
link?: Link
|
||||
|
||||
@Column('text')
|
||||
color!: string
|
||||
|
||||
@Column('text')
|
||||
description?: string
|
||||
|
||||
@CreateDateColumn()
|
||||
createdAt!: Date
|
||||
|
|
|
|||
|
|
@ -15,7 +15,8 @@ import {
|
|||
CreateDateColumn,
|
||||
Entity,
|
||||
JoinColumn,
|
||||
OneToMany,
|
||||
JoinTable,
|
||||
ManyToMany,
|
||||
OneToOne,
|
||||
PrimaryGeneratedColumn,
|
||||
UpdateDateColumn,
|
||||
|
|
@ -62,6 +63,7 @@ export class Link extends BaseEntity {
|
|||
@UpdateDateColumn()
|
||||
updatedAt?: Date
|
||||
|
||||
@OneToMany(() => Label, (label) => label.link)
|
||||
@ManyToMany(() => Label, (label) => label.link)
|
||||
@JoinTable({ name: 'link_labels' })
|
||||
labels?: Label[]
|
||||
}
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@ BEGIN;
|
|||
|
||||
ALTER TABLE omnivore.labels
|
||||
DROP COLUMN link_id,
|
||||
ADD COLUMN color text,
|
||||
ADD COLUMN color text NOT NULL,
|
||||
ADD COLUMN description text,
|
||||
ADD CONSTRAINT label_name_unique UNIQUE (user_id, name);
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue