zoukankan      html  css  js  c++  java
  • 【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、

  • 相关阅读:
    dup/dup2函数
    read/write函数
    lseek函数
    流程控制
    vim普通模式
    vim实用技巧1
    python源代码解读
    python变量命名规则
    python之字符串2
    Docker系列文章
  • 原文地址:https://www.cnblogs.com/xuzhengzong/p/8848447.html
Copyright © 2011-2022 走看看