Example: a system to migrate from
"SupplierBook 2", an invented approved-supplier register (a small Flask application with a PostgreSQL schema), as a
stand-in for the system you want to replace. It is the fixture of lib/adopt/adopt.test.ts and the worked example of
the migration assistant; the application itself is not meant to run.
| File | What the assistant makes of it |
|---|---|
db/schema.sql |
The data model: 12 tables, of which 5 become record types |
db/seed.sql |
Invented data; loaded into a scratch SQLite file to try the export and the rehearsal |
app/main.py, requirements.txt |
What the old system does: approval by quality, its own passwords, e-mail, uploads, an Excel report |
env.example |
The settings to carry over, by name |
Three rows are wrong on purpose (a supplier that is still pending, a material that belongs to it, a material without a name), so the rehearsal has something to report.
Try it:
node -e 'const {DatabaseSync}=require("node:sqlite");const fs=require("fs");fs.mkdirSync("scratch",{recursive:true});fs.rmSync("scratch/supplierbook.sqlite",{force:true});const d=new DatabaseSync("scratch/supplierbook.sqlite");for(const f of ["schema","seed"])d.exec(fs.readFileSync(`examples/legacy-app/db/${f}.sql`,"utf8"))'
npm run migrate -- plan examples/legacy-app --system "SupplierBook 2" --db sqlite:scratch/supplierbook.sqlite --dir scratch/supplierbook
npm run migrate -- extract --dir scratch/supplierbook --from sqlite:scratch/supplierbook.sqlite
npm run migrate -- rehearse --dir scratch/supplierbook