redis-om-python icon indicating copy to clipboard operation
redis-om-python copied to clipboard

How to use the migrate CLI tool?

Open jetxr opened this issue 1 year ago • 5 comments

The docs refer to running migrations with CLI. What's the command to run the migrate from CLI?

jetxr avatar Oct 06 '22 10:10 jetxr

Okay, the binary is simply called migrate. Can't get the migrations to run though, it just silently exits with no output.

Tried to pass the module with the --module switch, but it fails with an ModuleNotFoundError: No module named 'source' error

jetxr avatar Oct 06 '22 13:10 jetxr

Hi thanks for checking out the library - the (definitely recommended, definitely easiest) way to do migrations is with the Migrator.run() from within a script.

There is the migrate.py file but I don't have any experience using it and didn't actually know it existed until now - I'll check it out to see but if you don't have to use CLI - I'd highly recommend the Migrator.run() command.

sav-norem avatar Oct 11 '22 13:10 sav-norem

Hi All,

I am facing the below error when I am trying to run migrations on a remote redis server. Here is the error, please help me out.

ERROR: Traceback (most recent call last): File "/usr/local/lib/python3.10/site-packages/starlette/routing.py", line 645, in lifespan async with self.lifespan_context(app): File "/usr/local/lib/python3.10/site-packages/starlette/routing.py", line 540, in aenter await self._router.startup() File "/usr/local/lib/python3.10/site-packages/starlette/routing.py", line 622, in startup await handler() File "/usr/share/pyscripts/ServerApi/./serverapi.py", line 48, in startup_event Migrator(redis).run() File "/usr/local/lib/python3.10/site-packages/redis_om/model/migrations/migrator.py", line 163, in run self.detect_migrations() File "/usr/local/lib/python3.10/site-packages/redis_om/model/migrations/migrator.py", line 101, in detect_migrations import_submodules(self.module) File "/usr/local/lib/python3.10/site-packages/redis_om/model/migrations/migrator.py", line 25, in import_submodules root_module = importlib.import_module(root_module_name) File "/usr/local/lib/python3.10/importlib/init.py", line 117, in import_module if name.startswith('.'): AttributeError: 'Redis' object has no attribute 'startswith'

chakri622 avatar Oct 28 '22 18:10 chakri622