The Problem
After years of development, AdonisJS projects often accumulate hundreds of migration files:
- π Slow fresh deployments (running 100+ migrations)
- π Cluttered migration folders
- π Hard to understand current schema
- π§Ή No official way to consolidate like Djangoβs
squashmigrations
The Solution
I built adonis-lucid-migration-squash to solve this!
What it does:
Takes your PostgreSQL schema dump and converts it to a clean, single Knex migration with:
- β Smart enum detection
- β Proper foreign keys & constraints
- β Automated verification
- β Complete up() and down() methods
Quick Start:
# 1. Dump your production schema
pg_dump -s --no-owner --no-acl > schema.sql
# 2. C...
The Problem
After years of development, AdonisJS projects often accumulate hundreds of migration files:
- π Slow fresh deployments (running 100+ migrations)
- π Cluttered migration folders
- π Hard to understand current schema
- π§Ή No official way to consolidate like Djangoβs
squashmigrations
The Solution
I built adonis-lucid-migration-squash to solve this!
What it does:
Takes your PostgreSQL schema dump and converts it to a clean, single Knex migration with:
- β Smart enum detection
- β Proper foreign keys & constraints
- β Automated verification
- β Complete up() and down() methods
Quick Start:
# 1. Dump your production schema
pg_dump -s --no-owner --no-acl > schema.sql
# 2. Convert to Knex migration
python -m pg_to_knex schema.sql baseline_migration.ts
# 3. Archive old migrations, use the baseline!
mv database/migrations/*.ts database/archive/
mv baseline.ts database/migrations/1_baseline.ts
Example Output: Instead of raw SQL, you get clean Knex code:
export async function up(knex: Knex) {
await knex.schema.createTable('users', (table) => {
table.uuid('id').primary()
table.string('email').notNullable().unique()
table.enum('role', ['admin', 'user']).defaultTo('user')
table.timestamps(true, true)
})
}
When to use it?
β Before major version releases β When you have 50+ migrations β Creating a clean foundation β All environments are on the same version
Check it out!
π GitHub Would love to hear feedback from the AdonisJS community! π #adonisjs #nodejs #typescript #database #migrations