php-如何仅更新表并使用Laravel添加新行?
作者:互联网
在数据库表中如下所示;
public function up()
{
Schema::create('current_adresses', function (Blueprint $table) {
$table->engine = 'InnoDB';
$table->increments('id');
$table->string('current_name',50)->nullable();
$table->string('current_surname',50)->nullable();
$table->string('telephone',25)->nullable();
$table->timestamps();
});
}
我想做如下
public function up()
{
Schema::create('current_adresses', function (Blueprint $table) {
$table->engine = 'InnoDB';
$table->increments('id');
$table->string('current_name',50)->nullable();
$table->string('current_surname',50)->nullable();
$table->string('gsm',25)->nullable();
$table->string('telephone',25)->nullable();
$table->timestamps();
});
}
我如何不刷新即可更新新列(gsm列)(php artisan migration:refresh)
解决方法:
添加新的迁移-
public function up()
{
Schema::table('current_adresses', function($table) {
$table->string('gsm',25)->nullable();
});
}
public function down()
{
Schema::table('current_adresses', function($table) {
$table->dropColumn('gsm');
});
}
请参阅this链接以获得更好的理解.
标签:laravel-5,database-migration,php 来源: https://codeday.me/bug/20191025/1928426.html