Hey everyone,
I wanted to contribute something to the cloud sync middleware, which requires changing the database schema (replacing a column, more specifically the boolean "follow_symlink" with the text column "symlink"). I have already found other migration stuff, and I have a migration for the actual data:
However, this does not migrate the actual database schema. I cannot find any existing migrations doing this, nor can I find any documentation on this. The files in
Is there a way to migrate the schema of a table in a datastore or does it get migrated automatically somehow?
Thanks!
I wanted to contribute something to the cloud sync middleware, which requires changing the database schema (replacing a column, more specifically the boolean "follow_symlink" with the text column "symlink"). I have already found other migration stuff, and I have a migration for the actual data:
Code:
async def migrate(middleware): tasks = await middleware.call('datastore.query', 'tasks.cloudsync') for task in tasks: await middleware.call("datastore.update", "tasks.cloudsync", task['id'], { 'symlinks': 'FOLLOW' if task['follow_symlinks'] == True else 'IGNORE' })
However, this does not migrate the actual database schema. I cannot find any existing migrations doing this, nor can I find any documentation on this. The files in
middlewared/plugins/datastore
, which seems to be the source for e.g. the 'datastore.query' call, does contain a schema.py
file. But this file only contains internal functions.Is there a way to migrate the schema of a table in a datastore or does it get migrated automatically somehow?
Thanks!