youling66
08/28/2023, 7:52 AMspicedb migrate xxx as if I used in my dev env, since it's a brand new spicedb instance with no schema and relationships in it. it doesn't need migrate anything. Besides, I only have spicedb executable in docker container, which just panic and exited immediately as it, so I can't prompt this migrate cmd.
https://cdn.discordapp.com/attachments/844600078948630559/1145626923897200720/image.png▾
vroldanbet
08/28/2023, 8:18 AMspicedb migrate always needs to be run, it's what creates the database schema. The fact you haven't done any WriteSchema calls does not matter here - the database tables need to be there or else SpiceDB won't come up healthy. SpiceDB does not create tables based on your API calls, it just writes to it. The database schema is always the same and independent of the SpiceDB schema written.
Here is a working example of a docker compose with SpiceDB and Postgres that runs `spicedb migrate`:
https://github.com/authzed/examples/blob/main/datastores/postgres.ymlyouling66
08/28/2023, 9:41 AMspicedb migrate . And in this case this command doesn't migrate but only initiate database.
what should I do if I wanna use this spicedb migrate command to migrate data from an already-existed spicedb instance to a new datastore? Can I migrate relationships and schema from memdb or other datastore to a new one?vroldanbet
08/28/2023, 9:46 AMspicedb migrate. It's a command that's in place to create all database tables, and if there is ever a change to the that database schema, it handles it to. For example, when Caveats feature was introduced, you'd typically see a introduce_caveats database migration for all datastores that creates the corresponding table.
It's not for migrating from one SpiceDB instance to another.
What you are describing is conceptually different from database migration (term that usually refers to schema migration / data migration, which are DDL / DML statements applied to your database). If you want to move your data from one SpiceDB instance to another, there is a new experimental API you can use for this called BulkExport and `BulkImport`:
https://buf.build/authzed/api/docs/main:authzed.api.v1#authzed.api.v1.ExperimentalService.BulkExportRelationships
https://buf.build/authzed/api/docs/main:authzed.api.v1#authzed.api.v1.ExperimentalService.BulkImportRelationshipsyouling66
11/02/2023, 7:08 AMvroldanbet
11/02/2023, 7:10 AMyouling66
11/02/2023, 7:25 AM