Files
Test-Laravel-Eloquent-Basics/database/migrations/2021_11_16_085542_create_stats_table.php
T
2021-11-16 11:02:41 +02:00

36 lines
769 B
PHP

<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class CreateStatsTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('stats', function (Blueprint $table) {
$table->id();
$table->integer('users_count')->default(0);
$table->integer('projects_count')->default(0);
$table->timestamps();
});
\App\Models\Stat::create(['users_count' => 0, 'projects_count' => 0]);
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::dropIfExists('stats');
}
}