This week I rebuilt GraceSoft Desk, a small accounting and project tool I run my own business on, on a fresh Laravel 13 + Livewire 4 codebase. The new app started from our internal boilerplate, so the features went quickly. Moving six months of real records out of the old app took longer, and taught me more.

Here's how the importer works, then what broke when it met production.

The importer's ground rules

php artisan desk:import-legacy reads the old database and writes the new one. A second command, desk:verify-legacy-import, checks the result independently. The rules:

  • Read-only, twice over. The legacy connection sets the session read-only, and a beforeExecuting hook throws on anything that isn't a read. If the session setting fails silently, the guard still holds.
  • Exact copies. Original UUIDs, codes, timestamps and deleted_at are kept, so links and history still make sense.
  • Secrets re-encrypted. Values encrypted under the old APP_KEY are decrypted with LEGACY_APP_KEY and re-encrypted under the new key.
  • Documents hash-checked. Every receipt is copied from the old bucket and compared by hash.
  • Idempotent, with a dry run. --dry-run runs every step inside a transaction and rolls it back. A real run can be repeated: it finishes unfinished work and creates no duplicates.
$connection->beforeExecuting(function (string $query) { if (! self::isRead($query)) { throw new LegacyConnectionIsReadOnly('The legacy Desk database is read only.'); } }); 

isRead() strips leading comments and allows only SELECT, WITH, SHOW, EXPLAIN, DESCRIBE and read-only PRAGMA.

1. Production's schema was older than the code

I built the importer against the old app's latest migrations. Production was running an earlier release: no clients, invoices or billing tables, and fewer columns on services, projects and Git tables. The first dry run stopped at services.

Fix: the importer checks which tables and columns exist. Missing tables are skipped with a warning, and missing columns take the new schema's defaults. Verification only counts what was imported.

Lesson: test against a snapshot of production, not your own repo's head.

2. 33 receipts were "missing"

For part of one day in June, the old app saved files under documents/ but recorded their paths without the prefix. The bucket policy only allows reads under documents/ and answers 403, not 404, everywhere else. So 33 receipts looked lost.

Fix: try the recorded path, then the same path under documents/, and treat a 403 as "not here".

$candidates = str_starts_with($path, 'documents/') ? [$path] : [$path, 'documents/'.$path]; 

A deleted document whose file is already gone now imports as deleted with a note. A missing file for a live document still fails verification.

3. The cloud database only accepts SSL

On Laravel Cloud the import stopped with "SSL is required". The legacy connection now takes a CA bundle from LEGACY_DB_SSL_CA, then the app's own MYSQL_ATTR_SSL_CA, then the server's standard bundle. Local setups without a bundle are unchanged.

4. A 33-character name in a 32-character column

Laravel Cloud names a bucket's disk after the bucket: gracesoft_footing_desk_production, 33 characters. documents.disk was varchar(32). Uploads and the import both failed with "Data too long for column 'disk'". The column is now 100 characters.

5. MySQL's 64-character index names

Laravel's generated name for a unique index on project_repositories was 68 characters. MySQL refuses anything over 64. My tests run on SQLite, which doesn't care, so CI was green while the MySQL migration failed. I gave the index an explicit name and added a schema test that checks every index name's length.

6. Livewire uploads that live in a bucket

On Laravel Cloud, Livewire stores temporary uploads in object storage. Two problems followed:

  • CSP. The browser uploads straight to a pre-signed bucket URL, which connect-src 'self' blocked. The bucket origin is now added to connect-src only when the upload disk is S3.
  • getRealPath() returned a bucket key, not a file, so opening the CSV threw a 500. A small LocalUpload::path() helper streams remote uploads to a temp file and removes it when the request ends. Imports, reconciliation, avatars, branding and document hashing all use it.

7. wire:click="commit" never reached my method

Livewire 4 maps some bare action names to its own magic actions: commit becomes $commit, upload becomes $upload. My Import button only re-rendered, and the document form never submitted. I renamed them to confirmImport and uploadDocument. A test now reads Livewire's alias list from its bundled JS and fails if any view calls an action with one of those names.

8. Categories that don't map one-to-one

The new app ships an expanded starter set of categories. --map-categories points each old category at a new one, and a few rules move the transactions a category-level map gets wrong, such as courses, phone plans and equipment filed under general expenses. The run prints every move, and verification confirms each transaction landed in its mapped category.

9. Output for a tired human

The first version reported table names and file paths. The person reading it at cutover is me, late at night. Now the output says "Documents and receipts" instead of documents, names deleted files instead of showing paths, and explains what was saved if a step fails. One example: if copying files fails after the data is saved, it says so, and tells you that re-running finishes the job without duplicates. The import also checks that storage is set up before it saves anything.

Choices I'd make again

  • Don't carry two-factor secrets across. Users enrol again. It's one extra step and a cleaner security story.
  • Make optional steps explicit. --skip-git leaves Git connections out on purpose and lists each repository to reconnect, so verification doesn't fail on something I chose to skip.
  • Rehearse until it's boring. The runbook asks for two clean runs in a row on a production snapshot before the real cutover.

Every bug above came from data or infrastructure my local setup didn't have. If you're migrating real data, test against the real thing as early as you can.

 `