在Laravel迁移中添加独特的索引
如何在Laravel迁移文件中为SQL Server设置唯一索引?
我已经尝试了以下内容,但对于SQL Server 2017来说,我没有运气:
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::table('participants', function (Blueprint $table) {
$table->string('sheet',50)->index('sheet')->unique()->nullable()->comment('...');
});
}
如果我只是尝试使用unique(),那就不起作用吗
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::table('participants', function (Blueprint $table) {
$table->unique('sheet',50)->nullable()->comment('...');
});
}
?
How to set a unique index for SQL Server in a Laravel migration file?
I have tried the following but no luck for SQL Server 2017:
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::table('participants', function (Blueprint $table) {
$table->string('sheet',50)->index('sheet')->unique()->nullable()->comment('...');
});
}
If I simply try with unique(), it doesn't work either
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::table('participants', function (Blueprint $table) {
$table->unique('sheet',50)->nullable()->comment('...');
});
}
Any ideas?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论