I've tried to run aerich upgrade as shown in the docs, but the migrations, although marked as executed in the database, were not actually applied. After a bit of digging I found out that this is due to the change of these lines of code:
be changed so that the generated migration script contains the query execution
be reverted.
In either case it would be useful to have some sort of a test checking whether the migration is applied (IDK, maybe mocking the execute_query() call and looking for its calls).
I would provide a PR, but I don't know which approach do you prefer.
EDIT As a workaround you can add this to your code to run migrations:
async def upgrade(db: BaseDBAsyncClient) -> List[str]:
queries = [
"""ALTER TABLE "items" ADD "read_counter" INT NOT NULL DEFAULT 0"""
]
for query in queries:
await db.execute_query(query)
return queries
This could also be added to the template as another solution.
Applicable for version
0.6.4
I've tried to run
aerich upgrade
as shown in the docs, but the migrations, although marked as executed in the database, were not actually applied. After a bit of digging I found out that this is due to the change of these lines of code:In commit https://github.com/tortoise/aerich/commit/e9b76bdd35cb34e25a2271709fc08c6c06a28032
Code which I used for testing: https://github.com/gonczor/fastapi-aerich
So this should either:
execute_query()
call and looking for its calls).I would provide a PR, but I don't know which approach do you prefer.
EDIT As a workaround you can add this to your code to run migrations:
This could also be added to the template as another solution.