Skip to content

Commit

Permalink
Fix planet histories table
Browse files Browse the repository at this point in the history
  • Loading branch information
Kejax committed Mar 30, 2024
1 parent 03f3b3c commit 2920e09
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 2 deletions.
4 changes: 2 additions & 2 deletions app/Models/PlanetHistory.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ class PlanetHistory extends Model
{
use HasFactory;

public $timestamps = true;

protected $table = 'planet_histories';

protected $fillable = [
Expand All @@ -18,7 +20,5 @@ class PlanetHistory extends Model
'health',
'regenPerSecond',
'players',
'created_at',
'updated_at'
];
}
30 changes: 30 additions & 0 deletions database/migrations/2024_03_30_203231_fix_planet_histories.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
<?php

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

return new class extends Migration
{
/**
* Run the migrations.
*/
public function up(): void
{
Schema::table('planet_histories', function (Blueprint $table) {
$table->timestamp('created_at')->default(DB::raw('current_timestamp()'))->change();
$table->timestamp('updated_at')->default(DB::raw('current_timestamp()'))->change();
});
}

/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::table('planet_histories', function (Blueprint $table) {
$table->timestamp('created_at')->useCurrentOnUpdate()->change();
});
}
};

0 comments on commit 2920e09

Please sign in to comment.