php - laravel 修改了数据库迁移文件,怎么操作才能提交到数据库
阿神
阿神 2017-04-10 15:42:09
[PHP讨论组]

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

阿神
阿神

闭关修行中......

全部回复(2)
巴扎黑

php artisan migrate:rollback,然后修改文件***_create_vilays_table.php,再php artisan 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
热门教程
更多>
最新下载
更多>
网站特效
网站源码
网站素材
前端模板
关于我们 免责申明 意见反馈 讲师合作 广告合作 最新更新 English
php中文网:公益在线php培训,帮助PHP学习者快速成长!
关注服务号 技术交流群
PHP中文网订阅号
每天精选资源文章推送
PHP中文网APP
随时随地碎片化学习

Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号