Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
simjak opened this issue Aug 24, 2023 · 6 comments
Open

Comments

@simjak
Copy link

simjak commented Aug 24, 2023

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

raise OperationalError(exc)

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

@simjak
Copy link
Author

simjak commented Aug 24, 2023

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

@simjak
Copy link
Author

simjak commented Aug 24, 2023

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

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

@simjak
Copy link
Author

simjak commented Aug 24, 2023

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

@Tradunsky
Copy link
Contributor

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.

@erik-megarad
Copy link
Member

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?

@Tradunsky
Copy link
Contributor

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants