【laravel5.4】迁移文件的生成、修改、删除

 

建议直接去官方文档查看: https://laravel-china.org/docs/laravel/5.4/migrations#creating-columns

 

1、生成迁移:

主要方式:1、创建空的迁移文件,不指定具体表:php artisan make:migration create_users_table

public function up()
    {
        //
    }

          2、再次创建修改类型的迁移文件(原有新建文件不动),指向已经存在的表,方法体是:php artisan make:migration update_votes_to_users_table --table=testaa

 

public function up()
    {
        Schema::table('testaa', function (Blueprint $table) {    //分别向原来的表插入新的字段

      $table->integer('scope')->nullable()->comment('得分');  
      $table->decimal('money',9,2)->comment('金额');

        });
    }

      3、创建迁移文件的同时,创建数据表:php artisan make:migration create_users_table --create=users

public function up()
    {
        Schema::create('userss', function (Blueprint $table) {
            $table->increments('id');
            $table->timestamps();
        });
    }

 

2、执行迁移:   

 

 3、还原迁移:

4、 

5、 

6、修改已存在的数据表:

 

7、

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值