aerich icon indicating copy to clipboard operation
aerich copied to clipboard

Datamigrations

Open liminspace opened this issue 3 years ago • 4 comments
trafficstars

Is aerich going to support datamigrations? I mean when you can write your migration logic in python, not only SQL. Django and alembic support them, but aerich not :(

liminspace avatar May 16 '22 01:05 liminspace

That'a a good feature, I will consider it

long2ice avatar May 16 '22 01:05 long2ice

@long2ice I see there is a closed issue #148. But looks like it was closed mistakenly. The main idea of that issue was using python code in migrations files, but not executing aerich upgrade command from python code.

I thinks you should reopen that ticket or join it with current one.

And also look at the fork version of the author and his a proof of concept. It looks good to me.

I'd just add a new command aerich datamigration --name "another_change" that would be equivalent to cat template.py > migrations/app/"2_$(date +%Y%m%d%H%M%S)_another_change.py" (from PoC) that creates a new file of data migration using template:

from tortoise.backends.base.client import BaseDBAsyncClient


async def upgrade(conn: BaseDBAsyncClient):
    pass


async def downgrade(conn: BaseDBAsyncClient):
    pass

liminspace avatar Jun 05 '22 22:06 liminspace

Actually, we are trying to migrate from SQLAlchemy and Alembic and we use data migrations very extensively.

GamePad64 avatar Jun 15 '22 17:06 GamePad64