beebot
beebot copied to clipboard
tortoise.exceptions.OperationalError: relation "body" does not exist
INFO 09:00:38.380 decomposer.py:58- [
raise OperationalError(exc)
tortoise.exceptions.OperationalError: relation "body" does not exist
I needed to run migrations, didn't find in the docs
missing migrations ```python cli.py DEBUG:asyncio:Using selector: KqueueSelector What would you like me to do?
test Initializing database Found migrations: MigrationList([])```
all good, I need to run from the root:
DEBUG:asyncio:Using selector: KqueueSelector
What would you like me to do?
> test
Initializing database
Found migrations: MigrationList([<Migration '20230717_01_initial_schema' from migrations/20230717_01_initial_schema.sql>])
INFO 09:19:35.787 base.py:504- Applying 20230717_01_initial_schema
INFO 09:19:35.808 migrations.py:402- - applying step 0
INFO 09:19:35.869 migrations.py:402- - applying step 1
INFO 09:19:35.926 migrations.py:402- - applying step 2
INFO 09:19:35.951 migrations.py:402- - applying step 3
INFO 09:19:35.983 migrations.py:402- - applying step 4
INFO 09:19:36.014 migrations.py:402- - applying step 5
INFO 09:19:36.049 migrations.py:402- - applying step 6
INFO 09:19:36.097 migrations.py:402- - applying step 7
INFO 09:19:36.126 migrations.py:402- - applying step 8
INFO 09:19:36.134 migrations.py:402- - applying step 9
INFO 09:19:36.142 migrations.py:402- - applying step 10
INFO 09:19:36.188 base.py:534- Marking 20230717_01_initial_schema applied```
In my case it was that migrations relative path, expected to be from the repo root, but was cli file path as IDE generated it.
migrations = read_migrations("migrations") # this path is relative to working directory
Setting the working directory path to the repo root solved the problem for me.
Setting the working directory path to the repo root solved the problem for me.
Was this setting in your IDE? Can you tell me more about how you fixed it?
Yes, I use Jet Brains IDE, the working directory path:
This is the path from which python start its path reference.
This can be fixed by looking up migrations
directory relative to the script file instead of relative to the working directory path. I would be happy to open up a PR if you would like.