mirror of https://github.com/hashicorp/boundary
parent
903039e885
commit
7c483e3c51
@ -0,0 +1,25 @@
|
||||
-- Copyright (c) HashiCorp, Inc.
|
||||
-- SPDX-License-Identifier: BUSL-1.1
|
||||
|
||||
begin;
|
||||
|
||||
-- replaces constraints from internal/db/schema/migrations/postgres/82/01_storage_policies.up.sql
|
||||
alter table policy
|
||||
drop constraint policy_scope_id_fkey;
|
||||
alter table policy
|
||||
add constraint policy_scope_id_fkey
|
||||
foreign key (scope_id)
|
||||
references iam_scope(public_id)
|
||||
on delete cascade
|
||||
on update cascade;
|
||||
|
||||
alter table policy_storage_policy
|
||||
drop constraint policy_storage_policy_scope_id_fkey;
|
||||
alter table policy_storage_policy
|
||||
add constraint policy_storage_policy_scope_id_fkey
|
||||
foreign key (scope_id)
|
||||
references iam_scope(public_id)
|
||||
on delete cascade
|
||||
on update cascade;
|
||||
|
||||
commit;
|
||||
@ -0,0 +1,30 @@
|
||||
-- Copyright (c) HashiCorp, Inc.
|
||||
-- SPDX-License-Identifier: BUSL-1.1
|
||||
|
||||
begin;
|
||||
|
||||
select plan(6);
|
||||
|
||||
-- create a storage policy
|
||||
prepare insert_policy as
|
||||
insert into policy_storage_policy
|
||||
(public_id, scope_id, retain_for_days, delete_after_days)
|
||||
values
|
||||
('pst_test1234', 'o__foodtruck', 1, 0);
|
||||
select lives_ok('insert_policy');
|
||||
|
||||
select is(count(*), 1::bigint) from policy_storage_policy where public_id = 'pst_test1234';
|
||||
select is(count(*), 1::bigint) from policy where public_id = 'pst_test1234';
|
||||
|
||||
-- deleting org should also delete the storage policy creating in that org
|
||||
prepare delete_org as
|
||||
delete from iam_scope
|
||||
where type = 'org'
|
||||
and public_id = 'o__foodtruck';
|
||||
|
||||
select lives_ok('delete_org');
|
||||
|
||||
select is(count(*), 0::bigint) from policy_storage_policy where public_id = 'pst_test1234';
|
||||
select is(count(*), 0::bigint) from policy where public_id = 'pst_test1234';
|
||||
|
||||
rollback;
|
||||
Loading…
Reference in new issue