Laravel迁移以更改表名称 [英] Laravel Migration to change table name
本文介绍了Laravel迁移以更改表名称的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想在Laravel中更改我的两个表名,所以我必须手动更改表名,还是可以通过迁移来实现.
I want to change my two table name in the Laravel, so do I have to manually change the table name or it can be possible through migration.
推荐答案
要更改表名,可以执行以下操作:
To change a table name, you can do this:
Schema::rename($currentTableName, $newTableName);
您可以使用drop
或dropIfExists
方法删除现有表:
You can use the drop
or dropIfExists
methods to remove an existing table:
Schema::drop('users');
Schema::dropIfExists('users');
只需将其添加到迁移中,它就可以正常工作.
Just add that to a migration and it should work.
这篇关于Laravel迁移以更改表名称的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文