2022_03_28_122608_alter_user_profiles_table.php 1.17 KB
<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

class AlterUserProfilesTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::table('user_profiles', function (Blueprint $table) {

            $table->unsignedInteger('user_id')->after('id')->comment('用户id');

            $table->unsignedTinyInteger('is_vip')->after('unionid')->default('0')->comment('是否会员');

            $table->timestamp('create_vip_time')->after('is_vip')->nullable()->comment('会员创建时间');

            $table->timestamp('expire_vip_time')->after('create_vip_time')->nullable()->comment('会员失效时间');

            $table->unsignedInteger('buy_number')->default(0)->comment('购买次数')->change();
            $table->decimal('buy_amount')->default(0.00)->comment('消费金额')->change();
        });
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::dropColumns('user_profiles', ['is_vip','create_vip_time','expire_vip_time']);
    }
}