DGe*_*Geo 7 php migration primary-key laravel artisan
我必须更改数据库中的表,以便primary key不是标准increments.
这是迁移,
public function up()
{
Schema::create('settings', function (Blueprint $table) {
$table->text('code', 30)->primary();
$table->timestamps();
$table->text('name');
$table->text('comment');
});
}
Run Code Online (Sandbox Code Playgroud)
但是,MySQL一直在回来,
语法错误或访问冲突:1170 BLOB/TEXT列'代码'在密钥规范中使用而没有密钥长度(SQL:alter table
settingsadd primary keysettings_code_primary(code)
我已经尝试将法线increments id留在那里并在不同的迁移中修改表格,但同样的事情发生了.
我做错了什么想法?
Laveral Version 5.4.23
San*_*esh 15
将其更改为字符串.
$table->string('code', 30)->primary();
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
17201 次 |
| 最近记录: |