migrate laravel campo text code example
Example 1: laravel migation error
use Illuminate\Support\Facades\Schema;
public function boot()
{
Schema::defaultStringLength(191);
}
Example 2: laravel migration constrained
Schema::table('posts', function (Blueprint $table) {
$table->foreignId('user_id')->constrained();
});
/* The foreignId method is an alias for unsignedBigInteger while the
* constrained method will use conventions to determine the table and
* column name being referenced. If your table name does not match
* Laravel's conventions, you may specify the table name by passing it
* as an argument to the constrained method:
*/
Schema::table('posts', function (Blueprint $table) {
$table->foreignId('user_id')->constrained('users');
});