Changeset View
Changeset View
Standalone View
Standalone View
src/database/migrations/2022_07_19_100000_create_stats_table.php
- This file was added.
<?php | |||||
use Illuminate\Support\Facades\Schema; | |||||
use Illuminate\Database\Schema\Blueprint; | |||||
use Illuminate\Database\Migrations\Migration; | |||||
return new class extends Migration | |||||
{ | |||||
/** | |||||
* Run the migrations. | |||||
* | |||||
* @return void | |||||
*/ | |||||
public function up() | |||||
{ | |||||
Schema::create('stats', function (Blueprint $table) { | |||||
$table->bigIncrements('id'); | |||||
$table->unsignedBigInteger('tenant_id')->nullable(); | |||||
$table->integer('type')->unsigned(); | |||||
$table->bigInteger('value'); | |||||
$table->timestamp('created_at')->useCurrent(); | |||||
$table->index(['type', 'created_at', 'tenant_id']); | |||||
$table->index('tenant_id'); | |||||
$table->foreign('tenant_id')->references('id')->on('tenants') | |||||
->onDelete('cascade')->onUpdate('cascade'); | |||||
}); | |||||
} | |||||
/** | |||||
* Reverse the migrations. | |||||
* | |||||
* @return void | |||||
*/ | |||||
public function down() | |||||
{ | |||||
Schema::dropIfExists('stats'); | |||||
} | |||||
}; |