定制 konekt/laravel-migration-compatibility 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

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

konekt/laravel-migration-compatibility

最新稳定版本:1.10.0

Composer 安装命令:

composer require konekt/laravel-migration-compatibility

包简介

Library to help migrations to figure out whether a related field is int or bigInt

README 文档

README

Tests Packagist Stable Version Packagist downloads StyleCI MIT Software License

Laravel 5.8 And The BigInt Problem

As of Laravel 5.8, migration stubs use the bigIncrements method on ID columns by default. Previously, ID columns were created using the increments method.

Foreign key columns must be of the same type. Therefore, a column created using the increments method can not reference a column created using the bigIncrements method.

This small change is a big source of problems for packages that define references to the default Laravel user table.

This package helps to solve this problem by extending Laravel's Blueprint class by a method that can detect the actual referenced field type:

class CreateProfilesTable extends Migration
{
    public function up()
    {
        Schema::create('profiles', function (Blueprint $table) {
            $table->increments('id');

            // Make `user_id` field the same type as the `id` field of the `user` table:
            $table->intOrBigIntBasedOnRelated('user_id', Schema::connection(null), 'users.id');

            //...

            $table->foreign('user_id')
                ->references('id')
                ->on('users');
        });
    }
//...

Installation

composer require konekt/laravel-migration-compatibility

Documentation

For detailed usage and examples go to the Documentation or refer to the markdown files in the docs/ folder of this repo.

For the list of changes read the Changelog.

统计信息

  • 总下载量: 158.07k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 2
  • 依赖项目数: 8
  • 推荐数: 0

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2019-08-18