laravel-shift / blueprint

A code generation tool for Laravel developers.
MIT License
2.82k stars 270 forks source link

Use `foreignId` for consistency #653

Closed jasonmccreary closed 9 months ago

jasonmccreary commented 9 months ago

It seems recent code uses foreignId when setting the column data type for many and polymorphic relationship foreign keys. However, the standard belongsTo relationship still uses unsignedBigInteger as the data type. For consistency within Blueprint and to align with whatever data type Laravel uses for "id" columns foreignId is now used.

Given the following draft file:

models:
    Post:
        author_id: id

Before:

Schema::create('posts', function (Blueprint $table) {
    $table->unsignedBigInteger('author_id');
}

After:

Schema::create('posts', function (Blueprint $table) {
    $table->foreignId('author_id');
}