Skip to content
| Marketplace
Sign in
Visual Studio Code>Visualization>DBML for LaravelNew to Visual Studio Code? Get it now.
DBML for Laravel

DBML for Laravel

Tadeáš Ditte

|
1 install
| (0) | Free
Generate a DBML schema file from your Laravel migrations.
Installation
Launch VS Code Quick Open (Ctrl+P), paste the following command, and press enter.
Copied to clipboard
More Info

DBML for Laravel

A VS Code extension that reads your Laravel migrations and writes a DBML schema file into a folder you choose, ready to paste into dbdiagram.io or render with @dbml/cli.

It does not connect to your database and does not run PHP. It reads the migration files themselves, so it works on a fresh checkout with nothing installed.

Commands

Open the Command Palette (Ctrl+Shift+P / Cmd+Shift+P):

Command What it does
DBML for Laravel: Generate DBML File Writes the DBML to the folder in dbmlForLaravel.outputFolder.
DBML for Laravel: Generate DBML File To Folder... Asks for a folder, writes there, and offers to remember it as this project's default.
DBML for Laravel: Preview DBML (unsaved) Opens the DBML in a scratch editor without writing a file.

Settings

Setting Default Meaning
dbmlForLaravel.migrationsPath database/migrations Where the migrations are. Relative to the workspace folder, or absolute. Sub-folders are included.
dbmlForLaravel.outputFolder dbml Folder the file is written to. Created if missing.
dbmlForLaravel.outputFileName schema.dbml Name of the generated file.
dbmlForLaravel.generateOnSave false Regenerate whenever a migration file is saved.
dbmlForLaravel.openAfterGenerate false Open the file after writing it.
dbmlForLaravel.projectName workspace folder name Name in the DBML Project block.
dbmlForLaravel.databaseType MySQL database_type in the Project block.
dbmlForLaravel.excludeTables ["migrations"] Tables to leave out. * wildcards work, e.g. cache_*.
dbmlForLaravel.inferRelationships false Also add refs for *_id columns with no explicit foreign key, when a table of the matching name exists.
dbmlForLaravel.includeIndexes true Emit indexes { } blocks.
dbmlForLaravel.enumStyle inline inline writes enum() values on the column; block declares a named Enum block and uses it as the column type.
dbmlForLaravel.includeTableGroups false Group tables by the migration that created them.
dbmlForLaravel.sortTables migration migration keeps creation order; alphabetical sorts by name.
dbmlForLaravel.noteSource true Add the generated-at header comment.

All settings are per-workspace-folder, so a multi-root workspace can point each project at its own output folder.

How it reads your migrations

Migrations are sorted by file name, which, with Laravel's timestamp prefix, is the order Laravel runs them, and then replayed in order. That matters: the output is the final state of the schema, not a dump of the first Schema::create it finds.

  • Schema::create() / Schema::table() / Schema::drop() / Schema::rename(), including behind Schema::connection('x')->… and inside if blocks.
  • Only the up() method is read. down() is ignored.
  • Class-based migrations, anonymous-class migrations, function () {} closures and fn () => … arrow closures.
  • Columns added, retyped with ->change(), renamed with renameColumn() or removed with dropColumn() by a later migration, plus dropTimestamps(), dropSoftDeletes(), dropMorphs() and dropConstrainedForeignId().
  • Column types and lengths, including unsigned* variants, decimal, float, char, uuid, ulid, json, jsonb, vector, the spatial types, and the helpers id(), timestamps(), softDeletes(), rememberToken() and the morphs() family.
  • Modifiers: nullable(), default() (including DB::raw()), unsigned(), unique(), index(), primary(), comment(), useCurrent(), storedAs(), virtualAs(). Positional and named arguments both work.
  • enum() columns keep their allowed values on the column, as status "enum('alive','dead','unknown')". Set dbmlForLaravel.enumStyle to block to get a separate Enum {table}_{column} block instead. When the values cannot be read from the migration (enum('status', Status::values())), the column is written as a plain "enum" and the reason is reported.
  • Indexes, composite indexes and composite primary keys, fullText() and spatialIndex() (noted, since DBML has no keyword for them).
  • Foreign keys from constrained(), foreign()->references()->on(), onDelete() / onUpdate() and the cascadeOnDelete() / nullOnDelete() / restrictOnDelete() shorthands. constrained() with no argument resolves the table the way Laravel does, pluralising the column name with the _id suffix removed.
  • foreignIdFor(User::class) resolves to user_id on users.

Anything it cannot make sense of is skipped and logged to the DBML for Laravel output channel rather than silently dropped. Refs pointing at a table that is not in the output, because it was excluded, or lives outside the migrations, are dropped and logged, since dbdiagram.io rejects a ref to an unknown table.

What it cannot do

The migrations are read as text, not executed. Columns created by code the generator cannot see — a raw DB::statement('ALTER TABLE …'), a loop over a config array, a trait or helper method that defines columns — will be missing. Those statements are reported in the output channel.

Standalone CLI

The same generator runs outside VS Code, which is handy in CI:

npx dbml-for-laravel database/migrations dbml schema.dbml

Options: --infer, --no-indexes, --sort, --no-header, --enum-blocks.

Development

npm install
npm run compile
npm test          # 28 unit tests

npm test relies on the shell expanding out/test/*.test.js, so on Windows run node --test against the compiled files directly.

Press F5 to launch an Extension Development Host; it opens the examples/ project, which contains migrations covering most of the Blueprint surface. To build a .vsix:

npm run package

@vscode/vsce needs Node 22 or newer, though the extension itself runs on the older Node that VS Code bundles.

Releasing

.github/workflows/ci.yml type-checks, tests on Node 20 and 22, and uploads a .vsix artifact for every push and pull request.

.github/workflows/publish.yml handles releases with release-please. Versions are never bumped by hand: every push to main updates a standing "chore(main): release x.y.z" pull request that accumulates the changes. Merging that PR bumps package.json, writes CHANGELOG.md, tags the commit, and the second job then packages the extension, attaches the .vsix to the GitHub release, and publishes it.

So the whole release flow is: merge the release PR.

Because the version comes from the commit messages, they have to follow Conventional Commits:

Commit Effect while below 1.0.0
fix: handle fullText on a single column patch — 0.1.0 to 0.1.1
feat: read Schema::rename minor — 0.1.0 to 0.2.0
feat!: drop the inferRelationships setting minor, flagged as breaking (bump-minor-pre-major)
chore:, test:, docs: no release on their own

Anything that is not a conventional commit is simply left out of the changelog. release-please-config.json holds the section names and bump rules, and .release-please-manifest.json records the version release-please believes is current — keep it in step with package.json if you ever edit a version by hand.

workflow_dispatch on the same workflow has a publish checkbox, for shipping the current main without going through a release PR.

Open VSX (optional)

VSCodium, Cursor, Windsurf and Gitpod use Open VSX rather than the Microsoft Marketplace. Create a namespace and token there, add the token as an OPEN_VSX_TOKEN repository secret, and the publish workflow picks it up automatically. Without the secret that step is skipped.

Syntax highlighting

VS Code has no built-in DBML grammar. Install any DBML extension from the Marketplace if you want the generated file coloured.

License

AGPL 3.0

Notice

This project is NOT endorsed by Laravel nor DBML

  • Contact us
  • Jobs
  • Privacy
  • Manage cookies
  • Terms of use
  • Trademarks
  • Your Privacy Choices
  • Consumer Health Privacy
© 2026 Microsoft