2021_05_04_140851_create_limits_table.php 1.08 KB
<?php

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

class CreateLimitsTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('limits', function (Blueprint $table) {
            $table->id();
            $table->bigInteger('token')->unsigned();
            $table->string('service', 128);
            $table->string('method', 128);
            $table->integer('spent')->unsigned();
            $table->integer('current')->unsigned();
            $table->integer('day')->unsigned();
            $table->boolean('reserved');
            $table->timestamps();

            $table->foreign('token')->references('id')->on('tokens');
        });

        Schema::table('tokens', function (Blueprint $table) {
            $table->integer('limit')->default(0);
        });
    }

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