g4t / schema-designer
Visual database schema designer for Laravel — renders your schema from migration files as an interactive ERD and generates migrations for every change made in the UI.
Requires
- php: ^8.0
- laravel/framework: ^8.83|^9.0|^10.0|^11.0|^12.0|^13.0
README
g4t Schema Designer
A visual database schema designer for Laravel, driven entirely by migration files — no database introspection required.
The package replays every migration's up() method against a capturing schema builder swapped in behind the Schema facade. Blueprints are recorded instead of executed and folded into an in-memory model of your final schema — rendered as an interactive ERD. Every change you make in the UI (create / edit / drop a table) generates a real migration file, shown to you for review before it is written.
Installation
composer require g4t/schema-designer
The service provider is auto-discovered. Open the designer at:
http://your-app.test/schema-designer
Features
- ERD canvas — tables as draggable cards, foreign keys as curved colored edges, pan/zoom, auto-layout, fit-to-view, and a live filter. Card positions persist across sessions.
- Create tables — column editor with all common Blueprint types, length/precision/enum values, nullable/unsigned/default/
useCurrentmodifiers, composite indexes, and foreign keys withonDelete/onUpdate. Quick-add buttons forid,uuid,timestamps, and soft deletes. - Edit tables — the designer diffs your changes against the parsed schema and generates an update migration:
renameColumn,->change(),dropColumn, index and FK adds/drops — ordered correctly (FK/index drops before column drops) with a best-effortdown(). - Drop tables — generates a
dropIfExistsmigration whosedown()fully recreates the table from the current parsed definition. - Migration awareness — tables whose source migrations haven't run yet get a pending badge, and you can run
php artisan migrateright from the UI. - Safe parsing — raw
DB::statement()/ query-builder calls inside migrations run in the connection's pretend mode, so parsing never touches your database. Files that fail to parse are surfaced as warnings, never fatal.
Compatibility
| Laravel | 8.x, 9.x, 10.x, 11.x, 12.x, 13.x |
| PHP | ^8.0 |
| Databases | Driver-agnostic — parsing happens at the Blueprint level, so MySQL, PostgreSQL, SQLite, and SQL Server projects all work the same. |
Configuration
php artisan vendor:publish --tag=schema-designer-config
| Key | Default | Purpose |
|---|---|---|
enabled |
null |
null → available everywhere except production. Override with SCHEMA_DESIGNER_ENABLED=true/false. |
path |
schema-designer |
Route prefix. |
middleware |
['web'] |
Add auth etc. to protect the UI. |
migrations_path |
database_path('migrations') |
Where migrations are read from and written to. |
layout_file |
storage/app/schema-designer/layout.json |
Canvas positions. |
How parsing works
- Migration files are loaded in order (both anonymous-class and classic named-class styles).
- The
Schemafacade root is swapped for aCapturingSchemaBuilder; eachSchema::create/table/drop/renamecall produces a Blueprint that is recorded, not executed. - Introspection calls inside migrations (
Schema::hasTable(),hasColumn(), …) are answered from the aggregated state, so conditional migrations behave exactly as they would against a fully migrated database. SchemaAggregatorfolds columns,->change()s, renames, drops, indexes, and foreign keys into the final schema model.
Known limits
- Raw SQL (
DB::statement('ALTER TABLE …')) can't be interpreted structurally — the statement is safely ignored and the file is listed under parse warnings when it affects schema. Schema::connection('other')->…calls bypass the capture and are not represented.- Generated
down()methods for edits are best-effort reconstructions.
Security
The UI writes files into your migrations directory and can run php artisan migrate. It is disabled in production by default — if you enable it there, put real auth middleware in front of it.
License
MIT