gabrielrcosta1/laravel-schema 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

gabrielrcosta1/laravel-schema

最新稳定版本:v1.0.01

Composer 安装命令:

composer require gabrielrcosta1/laravel-schema

包简介

Laravel package to generate migrations from a schema.db definition file.

README 文档

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

统计信息

  • 总下载量: 5
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 6
  • 点击次数: 0
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 6
  • Watchers: 0
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2025-06-10