我的数据库中有一个用户表:
$table->increments('id');
$table->string('fullName');
$table->string('email')->unique();
$table->string('password', 50);
$table->enum('role',['boss','employee','customer'])->default('customer');
$table->rememberToken();
$table->timestamps();
我需要将“角色”列类型更改为“文本”,然后在 Laravel 中运行新的迁移。如果我不想对以前的数据产生影响,最好的方法是什么。
最佳答案
你可以尝试:
现在只需按原样更改数据库模式:
$table->increments('id');
$table->string('fullName');
$table->string('email')->unique();
$table->string('password', 50);
$table->string('role');
$table->rememberToken();
$table->timestamps();
基本上,您将角色值复制到(临时)列并重命名。至少它是安全的,不会花费很多时间。
https://stackoverflow.com/questions/38290815/