laravel 通过迁移文件改变数据表某字段类型

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/tclzsn7456/article/details/88887865
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::table('free_resources', function (Blueprint $table) {
            DB::statement("ALTER TABLE free_resources CHANGE COLUMN type type  VARCHAR(255)  DEFAULT '' comment '资料类型' ");

        });
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::table('free_resources', function (Blueprint $table) {
            $table->dropColumn('type');
        });
    }

猜你喜欢

转载自blog.csdn.net/tclzsn7456/article/details/88887865