beebot icon indicating copy to clipboard operation
beebot copied to clipboard

tortoise.exceptions.OperationalError: relation "body" does not exist

Open simjak opened this issue 1 year ago • 6 comments

INFO 09:00:38.380 decomposer.py:58- [

raise OperationalError(exc)

tortoise.exceptions.OperationalError: relation "body" does not exist

simjak avatar Aug 24 '23 06:08 simjak

I needed to run migrations, didn't find in the docs

simjak avatar Aug 24 '23 06:08 simjak

missing migrations ```python cli.py DEBUG:asyncio:Using selector: KqueueSelector What would you like me to do?

test Initializing database Found migrations: MigrationList([])```

simjak avatar Aug 24 '23 06:08 simjak

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```

simjak avatar Aug 24 '23 06:08 simjak

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.

Tradunsky avatar Sep 05 '23 05:09 Tradunsky

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?

erik-megarad avatar Sep 06 '23 19:09 erik-megarad

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.

Tradunsky avatar Sep 06 '23 20:09 Tradunsky