我有两个成员输入它的播放器和场地我如何才能更好地创建表格?也许玩家与user_id或合并users表和players?但是那张venues桌子呢?
1 回答
0
migrate:make您可以使用Artisan CLI 上的命令创建新的迁移。使用特定名称以避免与现有模型冲突
php artisan make:migration add_type_to_users_table --table=users
然后,您需要使用 Schema::table() 方法(因为您正在访问现有表,而不是创建新表)。您可以添加这样的列:
public function up()
{
Schema::table('users', function($table) {
$table->enum('type', ['player', 'venue'])->after('email');
});
}
并且不要忘记添加回滚选项:
public function down()
{
Schema::table('users', function($table) {
$table->dropColumn('type');
});
}
然后你可以运行你的迁移:
php artisan migrate
于 2020-02-09T18:18:29.363 回答