The schema changes introduced in 0.10.2 introduced a bug where an org
could not be deleted if there was a session for an org scoped user. It
would result in an error like:
scope.(Service).deleteFromRepo: unable to delete scope: \
iam.(Repository).DeleteScope: failed for o_VkNy46KwfS: \
iam.(Repository).delete: db.DoTx: iam.(Repository).delete: \
db.Delete: insert or update on table "session" violates foreign key constraint "target_fkey": integrity violation: error #1003
A worker around would be to first delete all projects in the org, then
finally delete the org.
This fix adds a regression test to the sqltests and updates several
constraints on the session table to be deferrable. Since the org delete
is a single transaction, this allows all of the necessary resources to
be deleted before attempting to enforce these constrains.
See: https://www.postgresql.org/docs/current/sql-set-constraints.html
Blame: 3a28ab614
16 lines
252 B
PL/PgSQL
16 lines
252 B
PL/PgSQL
-- org-delete tests:
|
|
-- deleting an org
|
|
|
|
begin;
|
|
select plan(1);
|
|
|
|
prepare delete_org as
|
|
delete from iam_scope
|
|
where type = 'org'
|
|
and public_id = 'o__foodtruck';
|
|
|
|
select lives_ok('delete_org');
|
|
|
|
select * from finish();
|
|
rollback;
|