mirror of
https://github.com/omnivore-app/omnivore.git
synced 2026-03-11 08:54:26 +00:00
Add unique constraint on user_id and group_id to group_membership table
This commit is contained in:
parent
ce49287444
commit
27d9e8464d
3 changed files with 20 additions and 0 deletions
|
|
@ -6,6 +6,7 @@ import {
|
|||
ManyToOne,
|
||||
OneToOne,
|
||||
PrimaryGeneratedColumn,
|
||||
Unique,
|
||||
UpdateDateColumn,
|
||||
} from 'typeorm'
|
||||
|
||||
|
|
@ -14,6 +15,7 @@ import { Group } from './group'
|
|||
import { Invite } from './invite'
|
||||
|
||||
@Entity()
|
||||
@Unique('group_membership_unique', ['user', 'group'])
|
||||
export class GroupMembership {
|
||||
@PrimaryGeneratedColumn('uuid')
|
||||
id!: string
|
||||
|
|
|
|||
|
|
@ -0,0 +1,9 @@
|
|||
-- Type: DO
|
||||
-- Name: add_unique_constraint_in_group_membership
|
||||
-- Description: Add unique constraint in group_membership table
|
||||
|
||||
BEGIN;
|
||||
|
||||
ALTER TABLE omnivore.group_membership ADD CONSTRAINT group_membership_unique UNIQUE (group_id, user_id);
|
||||
|
||||
COMMIT;
|
||||
|
|
@ -0,0 +1,9 @@
|
|||
-- Type: UNDO
|
||||
-- Name: add_unique_constraint_in_group_membership
|
||||
-- Description: Add unique constraint in group_membership table
|
||||
|
||||
BEGIN;
|
||||
|
||||
ALTER TABLE omnivore.group_membership DROP CONSTRAINT IF EXISTS group_membership_unique;
|
||||
|
||||
COMMIT;
|
||||
Loading…
Reference in a new issue