laravel迁移将列添加到现有表中
php artisan make:migration add_paid_to_users_table --table=users
public function up()
{
Schema::table('users', function($table) {
$table->integer('paid');
});
}
public function down()
{
Schema::table('users', function($table) {
$table->dropColumn('paid');
});
}
php artisan migrate
在laravel迁移中添加列
php artisan make:migration add_paid_to_users_table --table=users
在迁移中向现有表添加新列
// for Laravel 5+
php artisan make:migration add_email_to_users_table --table=users
public function up()
{
Schema::table('users', function($table) {
$table->integer('email');
});
}
public function down()
{
Schema::table('users', function($table) {
$table->dropColumn('email');
});
}
php artisan migrate
laravel迁移后添加列
Schema::table('users', function ($table) {
$table->string('email')->after('id')->nullable();
});
php artisan查看上次迁移
php artisan migrate:status