扫码关注官方订阅号
使用数据迁移创建了一个表,表里已经有数据了,这个时候想要添加字段,或修改字段,或删除字段,要怎么操作?
走同样的路,发现不同的人生
添加字段
Schema::table('users', function ($table) { $table->string('email'); });
修改字段
Schema::table('users', function ($table) { $table->string('name', 50)->change(); });
重命名字段
Schema::table('users', function ($table) { $table->renameColumn('from', 'to'); });
移除字段
Schema::table('users', function ($table) { $table->dropColumn('votes'); });
微信扫码关注PHP中文网服务号
QQ扫码加入技术交流群
Copyright 2014-2026 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号
PHP学习
技术支持
返回顶部
添加字段
修改字段
重命名字段
移除字段