yuhal/laravel-sync-database
Composer 安装命令:
composer require yuhal/laravel-sync-database
包简介
Laravel tool helps to sync databases without refreshing the migration
README 文档
README
If you don't want to create migration files manually during the development of laravel project. It can help you Automatically create and update the migration file corresponding to the table structure in the database。 In addition, it can be used in combination with laravel sync migration to realize bidirectional synchronization of database and migrated files.
License
The MIT License (MIT). Please see License File for more information.
介绍
使用 laravel 框架的小伙伴,这将会是你的福音!推荐使用 yuhal/laravel-sync-database,可以帮助您高效开发哦,欢迎 star OR fork!如果您不想在开发laravel项目时手动创建迁移文件。它可以帮助您自动创建和更新数据库中表结构对应的迁移文件。此外,它还可以与早期同步迁移结合使用,实现数据库和迁移文件的双向同步。
安装
- 通过 composer 创建项目
$ composer create-project --prefer-dist laravel/laravel blog
- 进入 blog 目录
$ cd blog
- 复制 .env.example 配置文件,命名为 .env
$ cp .env.example .env
- 修改 .env
# 项目地址
APP_URL=http://blog.com
# mysql数据库连接
DB_CONNECTION=mysql
DB_HOST=127.0.0.1
DB_PORT=3306
DB_DATABASE=blog
DB_USERNAME=root
DB_PASSWORD=root
- composer 设置国内镜像
$ composer config -g repo.packagist composer https://mirrors.aliyun.com/composer
- composer 安装依赖包
$ composer install
$ composer require kitloong/laravel-migrations-generator=5.0.1
$ composer require awssat/laravel-sync-migration
$ composer require yuhal/laravel-sync-database
同步
- 首次执行迁移
$ php artisan migrate
Migration table created successfully.
Migrating: 2014_10_12_000000_create_users_table
Migrated: 2014_10_12_000000_create_users_table (19.90ms)
Migrating: 2014_10_12_100000_create_password_resets_table
Migrated: 2014_10_12_100000_create_password_resets_table (15.12ms)
Migrating: 2019_08_19_000000_create_failed_jobs_table
Migrated: 2019_08_19_000000_create_failed_jobs_table (16.40ms)
Migrating: 2019_12_14_000001_create_personal_access_tokens_table
Migrated: 2019_12_14_000001_create_personal_access_tokens_table (23.22ms)
- users 迁移文件新增 phone 字段
table->string('phone')->unique();
- 迁移文件同步数据库
$ php artisan migrate:sync
New column users->phone was created
- users 数据库表重命名 phone 字段为 mobile
通过执行 SQL 或 数据库可视化工具更改。
- 数据库同步迁移文件
$ php artisan database:sync
/Users/hai/env/docker/laradock/blog/database/migrations/2014_10_12_000000_create_users_table.php
Add migration column: mobile
Delete migration column: phone
提示
数据库和迁移文件的双向同步,不仅支持字段的增删改,也支持数据表的增删改。
yuhal/laravel-sync-database 适用场景与选型建议
yuhal/laravel-sync-database 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 104 次下载、GitHub Stars 达 0, 最近一次更新时间为 2021 年 12 月 22 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「database」 「package」 「php」 「mysql」 「sync」 「migration」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 yuhal/laravel-sync-database 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 yuhal/laravel-sync-database 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 yuhal/laravel-sync-database 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
Dibi is Database Abstraction Library for PHP
Store your language lines in the database, yaml or other sources
A package for automatically encrypting and decrypting Eloquent attributes in Laravel 5.5+, based on configuration settings.
A PSR-7 compatible library for making CRUD API endpoints
Simple ASCII output of array data
统计信息
- 总下载量: 104
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 3
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2021-12-22