https://authzed.com logo
Is there a way to dump relationships
w

williamdclt

03/16/2023, 2:20 PM
Is there a way to dump relationships from spicedb, that could then be re-imported with
zed import
? Whether using Zed, the SpiceDB binary or anything else. Would be tremendously useful for me to skip a whole bunch of data import
If not, would this work (postgres datastore):
sql
SELECT
  CASE
    WHEN userset_relation = '...' THEN
      CONCAT("namespace", ':', object_id, '#', relation, '@', userset_namespace, ':', userset_object_id)
    ELSE
      CONCAT("namespace", ':', object_id, '#', relation, '@', userset_namespace, ':', userset_object_id, '#', userset_relation)
  END
FROM relation_tuple
WHERE deleted_xid = '9223372036854775807'::xid8;
Would this WHERE condition do what I want? I don't necessarily need perfectly up-to-date relations (it'd be outdated in seconds anyway), just vaguely up-to-date. Performance isn't really a concern, I'd run it on a copy of the live database
c

corkrean

03/16/2023, 2:47 PM
At a quick glance, that looks like it would work, but I don't have an active DB instance to test on. I've also create a Github issue for an export command. https://github.com/authzed/spicedb/issues/1208
And yes, you are correct that there is no command to export in the format that import expects.