Lukabratzee
Lukabratzee

Reputation: 147

How to generate data in an Alembic migration i.e --autogenerate

I can successfully generate a database model, however I can't seem to figure out how to populate the database with data.

I believe the error lies in the command I used to autogenerate

alembic -x data=true upgrade head

does not produce any data, though after looking at my generated file, there is nothing in data_upgrade() or data_downgrade().

The command I am using to generate an auto migration is

alembic revision --autogenerate -m "migration_objective"

This then upgrades head to what is expected, but with no data in any of the tables.

Am I missing an option flag? I can't seem to find documentation on additional flags to use at this stage.

Upvotes: 0

Views: 1580

Answers (1)

badger0053
badger0053

Reputation: 1209

Alembic AutoGenerate will not detect data changes.

You'll need to pull the data out of the database to something like a CSV file which you can then parse and insert to the database during your upgrade

Upvotes: 1

Related Questions