Skip to content

Commit

Permalink
fix: raise notice to delete dependent fields after workspace reset (#230
Browse files Browse the repository at this point in the history
)

* fix: raise notice to delete dependent fields after workspace reset

* refactor: squish query into one-liner

* fix: dependent field queries not printing the org id (#231)

* fix: dependent field queries not printing the org id

* fix: delete `expense_attributes_deletion_cache` while workspace reset (#232)
  • Loading branch information
1 parent 2e6fde4 commit c8b178f
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions scripts/sql/reset_db.sql
Original file line number Diff line number Diff line change
Expand Up @@ -195,11 +195,24 @@ BEGIN
GET DIAGNOSTICS rcount = ROW_COUNT;
RAISE NOTICE 'Deleted % users', rcount;

DELETE
FROM expense_attributes_deletion_cache
WHERE workspace_id = _workspace_id;
GET DIAGNOSTICS rcount = ROW_COUNT;
RAISE NOTICE 'Deleted % expense_attributes_deletion_cache', rcount;


_org_id := (SELECT org_id FROM workspaces WHERE id = _workspace_id);

DELETE
FROM workspaces w
WHERE w.id = _workspace_id;
GET DIAGNOSTICS rcount = ROW_COUNT;
RAISE NOTICE 'Deleted % workspaces', rcount;

RAISE NOTICE E'\n\n\n\n\n\n\n\n\nSwitch to prod db and run the below queries to delete dependent fields';
RAISE NOTICE E'rollback;begin; delete from platform_schema.dependent_expense_field_mappings where expense_field_id in (select id from platform_schema.expense_fields where org_id =''%'' and type=''DEPENDENT_SELECT''); delete from platform_schema.expense_fields where org_id = ''%'' and type = ''DEPENDENT_SELECT'';\n\n\n\n\n\n\n\n\n\n\n', _org_id, _org_id;

RETURN;
END
$$ LANGUAGE plpgsql;

0 comments on commit c8b178f

Please sign in to comment.