opscale-co / nova-dbml-field
A Laravel Nova field for editing and visualizing DBML schemas.
Package info
github.com/opscale-co/nova-dbml-field
Language:Shell
pkg:composer/opscale-co/nova-dbml-field
Requires
- php: ^8.3
- laravel/nova: ^5.0
Requires (Dev)
- larastan/larastan: ^3.9
- laravel/nova-devtool: ^1.7
- laravel/pint: ^1.18
- mockery/mockery: ^1.6
- opscale-co/strict-rules: ^1.1
- orchestra/testbench-dusk: ^11.1
- pestphp/pest: ^4.6
- pestphp/pest-plugin-laravel: ^4.1
- rector/rector: ^2.4
- rector/rector-laravel: ^2.3
- tightenco/duster: ^3.4
README
At Opscale, weโre passionate about contributing to the open-source community by providing solutions that help businesses scale efficiently. If youโve found our tools helpful, here are a few ways you can show your support:
โญ Star this repository to help others discover our work and be part of our growing community. Every star makes a difference!
๐ฌ Share your experience by leaving a review on Trustpilot or sharing your thoughts on social media. Your feedback helps us improve and grow!
๐ง Send us feedback on what we can improve at feedback@opscale.co. We value your input to make our tools even better for everyone.
๐ Get involved by actively contributing to our open-source repositories. Your participation benefits the entire community and helps push the boundaries of whatโs possible.
๐ผ Hire us if you need custom dashboards, admin panels, internal tools or MVPs tailored to your business. With our expertise, we can help you systematize operations or enhance your existing product. Contact us at hire@opscale.co to discuss your project needs.
Thanks for helping Opscale continue to scale! ๐
Description
DBML is a great way to document a database schema, but inspecting one means jumping out to dbdiagram.io or another external tool every time. This package brings the diagram into your admin panel: upload a .dbml file from any Nova resource and the interactive ER diagram shows up right on the record. Compatible with Nova 5.
Installation
You can install the package in to a Laravel app that uses Nova via composer:
composer require opscale-co/nova-dbml-field
The package will auto-register its service provider.
Back your field with a longText (or text) column on the owning model. The field stores the raw DBML as plain text โ no disk configuration required.
Schema::create('schemas', function (Blueprint $table) { $table->id(); $table->string('name'); $table->longText('dbml')->nullable(); $table->timestamps(); });
Usage
Add the DBML field to any Nova Resource that owns a DBML attribute:
use Laravel\Nova\Fields\ID; use Laravel\Nova\Fields\Text; use Laravel\Nova\Http\Requests\NovaRequest; use Laravel\Nova\Resource; use Opscale\Fields\DBML; class Schema extends Resource { public static $model = \App\Models\Schema::class; public function fields(NovaRequest $request): array { return [ ID::make()->sortable(), Text::make('Name')->rules('required', 'max:255'), DBML::make('Schema', 'dbml')->rules('required'), ]; } }
On Create / Update the field renders Novaโs native file dropzone โ pick a .dbml file, the contents are parsed client-side with @dbml/core and only submitted if they parse cleanly. On Detail / Lens the field renders the full interactive diagram. It is intentionally hidden from Index.
Field behavior
| View | Behavior |
|---|---|
| Create / Update | File upload dropzone (.dbml, .txt). Pre-submit parse validation with @dbml/core. Invalid DBML blocks the submit. |
| Detail / Lens | Interactive VueFlow diagram with pan, zoom, drag, minimap, grid background, auto-layout via dagre. |
| Index | Hidden โ a full diagram inside a table cell adds no decision-making value. |
| API (raw string) | fillAttributeFromRequest transparently accepts a raw DBML string for programmatic callers. |
Under the hood
| Layer | Dependency |
|---|---|
| Parser | @dbml/core โ the official DBML parser. |
| Renderer | @vue-flow/core, @vue-flow/controls, @vue-flow/minimap, @vue-flow/background. |
| Auto-layout | dagre with rankdir: LR. |
All three live behind a one-way pipeline (parser โ graph adapter โ layout โ renderer) โ no step mutates earlier results, results are memoized per DBML string.
Testing
npm run test
Changelog
Please see CHANGELOG for more information on what has changed recently.
Contributing
Please see CONTRIBUTING for details.
Security
If you discover any security related issues, please email development@opscale.co instead of using the issue tracker.
Credits
License
The MIT License (MIT). Please see License File for more information.
