zoukankan      html  css  js  c++  java
  • laraval migration 新增字段或者修改字段的方法

    1.进入项目根目录执行artisan命令生成migration文件,可以指定--table和--path参数,会在对应目录下生成migration文件。

    php artisan make:migration alter_table_his_decisions  --table=his_decisions --path=database/migrations/ca/

    2.在migration文件中的up方法中新增或者修改字段

        /**
         * Run the migrations.
         *
         * @return void
         */
        public function up()
        {
            Schema::table('his_decisions', function (Blueprint $table) {
                $table->string('primary_refuse_reason')->default('')->comment('拒绝主原因');
                $table->string('secondary_refuse_reason')->default('')->comment('拒绝子原因');
            });
        }
    
        /**
         * Reverse the migrations.
         *
         * @return void
         */
        public function down()
        {
            Schema::table('his_decisions', function (Blueprint $table) {
                $table->drop_column('primary_refuse_reason');
                $table->drop_column('secondary_refuse_reason');
            });
        }

    3.执行artisan命令来使变更生效,可以指定path参数到目录级别

    php artisan migrate --path=database/migrations/ca/ 

    ps:

    一个很好用的参数来查看artisan命令可以跟哪些参数,比如想知道迁移命令后接的参数

    php artisan migrate --help
  • 相关阅读:
    poj3273Monthly Expense
    poj2516Minimum Cost
    poj1201Intervals(差分约束)
    poj3122Pie
    poj3258River Hopscotch
    hdu3308LCIS(线段树区间合并)
    CF1178F2 Long Colorful Strip
    CF906C Party
    [NOI2002]贪吃的九头龙
    CF1178F1 Short Colorful Strip
  • 原文地址:https://www.cnblogs.com/zjj-php/p/8244288.html
Copyright © 2011-2022 走看看