gabrielrcosta1 / laravel-schema
Laravel package to generate migrations from a schema.db definition file.
v1.0.01
2025-06-07 23:07 UTC
Requires
- php: ^8.2
- illuminate/support: ^11.0 || ^12.0
Requires (Dev)
- laravel/pint: ^1.22
README
๐งช This package is currently under development. Features, APIs and behavior may change at any time.
Generate Laravel migration files based on a simple DSL (domain-specific language) written in a single file: schema.db
.
๐ฆ Installation
Then run:
composer require gabrielrcosta1/laravel-schema
๐ What It Does
- Adds Artisan commands:
schema:create
schema:migrate
schema:reset
- Lets you define your database tables in a single DSL file
- Generates Laravel-compatible migration files into
database/migrations
- Tracks schema changes and generates only incremental migrations
- Supports full or table-specific reset
- Lets you run
php artisan migrate
as usual
๐ Usage
1. Generate the schema file
php artisan schema:create
This will create the file:
/your-laravel-project/database/schema.db
With default content for:
posts
2. Define your schema (example)
Edit database/schema.db
like this:
table posts { id primary title string body text published_at timestamp nullable user_id foreign:users.id timestamps softDeletes }
3. Generate migration files
php artisan schema:migrate
This will:
- Parse
schema.db
- Compare with previous schema
- Generate new migrations:
- full table migrations
- incremental
add_
/remove_
migrations
4. Apply the migrations
php artisan migrate
5. Reset generated migrations
If you want to delete generated migrations and schema cache:
Reset everything:
php artisan schema:reset --all
Reset only one table:
php artisan schema:reset
# You will be prompted for the table name
This deletes:
- The migration files related to the selected table(s)
- The schema cache files (.json and .hash)
โ Commands Summary
Command | Description |
---|---|
schema:create |
Create schema.db with default tables |
schema:migrate |
Generate migrations from schema (full or incremental) |
schema:reset |
Delete generated migrations and cache (--all or specific) |
php artisan migrate |
Apply the generated migrations |
โ ๏ธ Status
This package is in development.
Use at your own risk in production environments.
Contributions, ideas, and issues are welcome.
๐ License
MIT โ ยฉ Gabriel R. Costa