[英]String as Primary Key in Laravel migration
我不得不更改數據庫中的一個表,以便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');
});
}
然而,MySQL 不斷返回,
語法錯誤或訪問沖突:1170 BLOB/TEXT 列“代碼”在沒有鍵長度的鍵規范中使用(SQL:alter table
settings
add primary keysettings_code_primary
(code
)
我嘗試將正常的increments
id
保留在那里並在不同的遷移中修改表,但同樣的事情發生了。
關於我做錯了什么的任何想法?
Laveral Version 5.4.23
將其更改為字符串。
$table->string('code', 30)->primary();
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.