【发布时间】:2020-10-14 23:49:43
【问题描述】:
这是我的代码
Schema::create('employees', function (Blueprint $table) {
$table->id();
$table->string('first_name');
$table->text('second_name');
$table->string('emp_company')->unsigned();
$table->string('email');
$table->string('phone');
$table->timestamps();
$table->foreign('emp_company')->references('company_name')->on('companies');
});
这是我的错误:
SQLSTATE[42000]: 语法错误或访问冲突:1064 您的 SQL 语法有错误;检查与您的 MariaDB 服务器版本相对应的手册,以在第 1 行(SQL:create表 employees (id bigint unsigned not null auto_increment 主键, first_name varchar(255) not null, second_name text not null, emp_company varchar(255) unsigned not null, email varchar(255 ) not null, phone varchar(255) not null, created_at timestamp null, updated_at timestamp null) 默认字符集 utf8mb4 collate 'utf8mb4_unicode_ci')
我坚持这个 .. 寻找 sup 谢谢。
【问题讨论】:
-
字符串不能无符号,只有数字字段
标签: php laravel foreign-keys laravel-7 artisan-migrate