Define order of code blocks being added to a migration
In my resource, I need to add a field that is generated automatically by postgres like this:
I also want to add a custom index for that field, so I also added this:
The problem is that ash_postgres will first add the custom index and then the custom statement, meaning that the migration file will fail since postgres can't add a index for a column that is yet to be created inside the table.
My workaround for now is to break this into 2 migrations, I first comment the
custom_indexes
code block and generate a migration, and then I uncomment that block again and generate a new migration.
That's fine, but it would be nicer if I could somehow define the order these code blocks are added to my migration file.2 Replies
Id just suggest editing your migrations after generating them
The migration generator can’t always figure out the proper order for custom things unfortunately
That's fine, I will do that