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屋!
查看全文