tortoise / aerich

A database migrations tool for TortoiseORM, ready to production.
https://github.com/tortoise/aerich
Apache License 2.0
804 stars 90 forks source link

Initialise an existing project in a new environment #309

Open ShipraShalini opened 1 year ago

ShipraShalini commented 1 year ago

I am trying to initialise aerich for an existing project which has configuration files and many migration files, in a new environment with a fresh db.

aerich init-db --safe true throws Inited models already, or delete migrations/models and try again. but the aerich table is not created.

aerich heads says No available heads, try migrate first

aerich upgrade says No upgrade items found

I don't want to run aerich migrate as the migration files are version controlled.

How can I achieve running all migrations (including the aerich table) in a new environment?

Similar to #267

alexf-bond commented 1 year ago

What about creating the aerich table manually via sql ddl and then runnning aerich upgrade?

henryfool91 commented 11 months ago

+1, rn i'm keep clean db dump with aerich table only in my git repo as a workaround

georges-g commented 6 months ago

I had the same problem, trying to initialize a duplicate db with aerich init-db but it did not work:

Inited my_app already, or delete migrations/my_app and try again.

I just had to run aerich upgrade on the duplicate database instead, to create the tables, and it works well now. No need for manual creation in my case.

Make sure you have properly run aerich init and aerich init-db on the original database beforehand though.