首页 > laravel 修改了数据库迁移文件,怎么操作才能提交到数据库

laravel 修改了数据库迁移文件,怎么操作才能提交到数据库

Schema::create('vilays', function (Blueprint $table) {
$table->increments('id');
$table->string('name',36)->change();
$table->tinyInteger('user_id')->unsigned();
$table->timestamp('utime');
$table->timestamps();
});

执行php artisan migrate 提示nothing to migrate


创建新的修改或者更新迁移,For Example:

update(or add) name(or user_name, nick_name)_to_users(your_table_name)_table --table=users
建议加上--table=users,会帮我们自动写好指定表的代码,like
 public function up()
    {
        Schema::table('users', function (Blueprint $table) {
            $table->string('name')->change()->after('指定某个字段的后面');
            (如果你是添加操作add)
            $table->string('name');即可 
        });
    }
    最后执行迁移 php artisan migrate

php artisan migrate:rollback,然后修改文件***_create_vilays_table.php,再php artisan migrate

【热门文章】
【热门文章】