📌  相关文章
📜  在现有表中添加列 - PHP 代码示例

📅  最后修改于: 2022-03-11 14:53:56.232000             🧑  作者: Mango

代码示例1
php artisan make:migration add_paid_to_users_table --table=users

//You then need to use the Schema::table() method (as you're accessing an existing table, not creating a new one). And you can add a column like this:

public function up()
{
    Schema::table('users', function($table) {
        $table->integer('paid');
    });
}
//and don't forget to add the rollback option:

public function down()
{
    Schema::table('users', function($table) {
        $table->dropColumn('paid');
    });
}
//Then you can run your migrations:

php artisan migrate