unique constraint for registry_item - fixes #1121
we remove all duplicate items from the registry, keeping the most-recently updated one (which presumably is the one that the users expect to be used) then we use `upsert` instead of the more complicated previous logic, which was subject to races
This commit is contained in:
parent
a4c0ef824c
commit
3aa5ec713c
3 changed files with 32 additions and 29 deletions
|
|
@ -7,8 +7,8 @@ import { PrimaryColumn, Entity, Index, JoinColumn, Column, ManyToOne } from 'typ
|
|||
import { id } from './util/id.js';
|
||||
import { MiUser } from './User.js';
|
||||
|
||||
// TODO: 同じdomain、同じscope、同じkeyのレコードは二つ以上存在しないように制約付けたい
|
||||
@Entity('registry_item')
|
||||
@Index(['userId', 'key', 'scope', 'domain'], { unique: true })
|
||||
export class MiRegistryItem {
|
||||
@PrimaryColumn(id())
|
||||
public id: string;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue