<?php

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

/**
 * Migration auto-generated by Sequel Pro Laravel Export
 * @see https://github.com/cviebrock/sequel-pro-laravel-export
 */
class CreateAccountLogsTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('account_logs', function (Blueprint $table) {
            $table->increments('id');
            $table->unsignedInteger('from_id')->comment('来源对象id');
            $table->string('from_name', 100)->nullable()->comment('来源对象名称');
            $table->string('op', 20)->comment('操作，charge：冲值，support：消耗，withdraw：提现');
            $table->string('from_type', 20)->comment('操作类型，1、余额，2、梦想币，3、现金');
            $table->unsignedInteger('from_amount')->comment('操作金额from');
            $table->string('to_type', 20)->comment('操作类型，1、余额，2、梦想币，3、现金');
            $table->unsignedInteger('to_id')->comment('目标对象id');
            $table->string('to_name', 100)->nullable()->comment('来源目标对象名称');
            $table->unsignedInteger('to_amount')->comment('操作金额to');
            $table->nullableTimestamps();

            $table->index(['from_id'], 'idx_from');
            $table->index(['to_id'], 'idx_to');
            $table->index('from_type', 'idx_from_type');
            $table->index('to_type', 'idx_to_type');
            $table->index('created_at', 'idx_created_at');



        });
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::dropIfExists('account_logs');
    }
}
