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
  • 相关阅读:
    python Database Poll for SQL SERVER
    SQLAlchemy表操作和增删改查
    flask动态url规则
    flask配置管理
    一个Flask运行分析
    Function Set in OPEN CASCADE
    Happy New Year 2016
    Apply Newton Method to Find Extrema in OPEN CASCADE
    OPEN CASCADE Multiple Variable Function
    OPEN CASCADE Gauss Least Square
  • 原文地址:https://www.cnblogs.com/zjj-php/p/8244288.html
Copyright © 2011-2022 走看看