bugfix/only-one-partner-per-person (#143)
Co-authored-by: Michael Hoennig <michael@hoennig.de> Reviewed-on: https://dev.hostsharing.net/hostsharing/hs.hsadmin.ng/pulls/143 Reviewed-by: Marc Sandlus <marc.sandlus@hostsharing.net>
This commit is contained in:
@@ -29,8 +29,24 @@ create table if not exists hs_office.relation
|
||||
);
|
||||
--//
|
||||
|
||||
-- TODO.impl: unique constraint, to prevent using the same person multiple times as a partner, or better:
|
||||
-- ( anchorUuid, holderUuid, type)
|
||||
|
||||
-- ============================================================================
|
||||
--changeset michael.hoennig:hs-office-relation-unique-constraints endDelimiter:--//
|
||||
-- ----------------------------------------------------------------------------
|
||||
|
||||
CREATE UNIQUE INDEX unique_relation_with_mark
|
||||
ON hs_office.relation (type, anchorUuid, holderUuid, contactUuid, mark)
|
||||
WHERE mark IS NOT NULL;
|
||||
|
||||
CREATE UNIQUE INDEX unique_relation_without_mark
|
||||
ON hs_office.relation (type, anchorUuid, holderUuid, contactUuid)
|
||||
WHERE mark IS NULL;
|
||||
|
||||
CREATE UNIQUE INDEX unique_partner_relation
|
||||
ON hs_office.relation (type, anchorUuid, holderUuid)
|
||||
WHERE mark IS NULL AND type = 'PARTNER';
|
||||
|
||||
--//
|
||||
|
||||
|
||||
-- ============================================================================
|
||||
|
@@ -100,8 +100,8 @@ do language plpgsql $$
|
||||
call hs_office.relation_create_test_data('Third OHG', 'DEBITOR', 'Third OHG', 'third contact');
|
||||
|
||||
call hs_office.relation_create_test_data('Fourth eG', 'PARTNER', 'Hostsharing eG', 'fourth contact');
|
||||
call hs_office.relation_create_test_data('Fouler', 'REPRESENTATIVE', 'Third OHG', 'third contact');
|
||||
call hs_office.relation_create_test_data('Third OHG', 'DEBITOR', 'Third OHG', 'third contact');
|
||||
call hs_office.relation_create_test_data('Fouler', 'REPRESENTATIVE', 'Fourth eG', 'fourth contact');
|
||||
call hs_office.relation_create_test_data('Fourth eG', 'DEBITOR', 'Fourth eG', 'fourth contact');
|
||||
|
||||
call hs_office.relation_create_test_data('Smith', 'PARTNER', 'Hostsharing eG', 'sixth contact');
|
||||
call hs_office.relation_create_test_data('Smith', 'DEBITOR', 'Smith', 'third contact');
|
||||
|
Reference in New Issue
Block a user