Organizing Migrations #2490
-
|
Hi there. In the example below, wich migration runs first? |
Beta Was this translation helpful? Give feedback.
Replies: 4 comments
-
|
This is pretty easy to test - just try it out: With a folder structure like: it ran in the following order: so yes, it will run all migrations in folder "A" before folder "B" |
Beta Was this translation helpful? Give feedback.
-
|
Hey @scal-lider! 👋 We are using a deep natural sort. In other terms, your folders and files are run in your expected order. 👍 |
Beta Was this translation helpful? Give feedback.
-
|
So I have to search "natural sort" 😅 When compare a string with a number, it uses a string comparation: Based on the @e-e's test, the sort also count the folder's name: |
Beta Was this translation helpful? Give feedback.
-
|
Hey! I just built a tool that might help with this: adonis-lucid-migration-squash Instead of organizing migrations into folders, you can consolidate/squash them into a single baseline migration (similar to Django's What it does:
Quick example: # Dump your schema
pg_dump -s --no-owner --no-acl > schema.sql
# Convert to Knex migration
python -m pg_to_knex schema.sql baseline_migration.ts
# Done! Clean baseline migration with verification |
Beta Was this translation helpful? Give feedback.
This is pretty easy to test - just try it out:
With a folder structure like:
it ran in the following order:
so yes, it will run all migrations in folder "A" before folder "B"