-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* [TM-1503] add migrations to create tables historic criteria * [TM-1503] delete and create site and historic * [TM-1503] lint
- Loading branch information
1 parent
655d47d
commit cc4d1ae
Showing
6 changed files
with
145 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
<?php | ||
|
||
namespace App\Models\V2\Sites; | ||
|
||
use App\Models\Traits\HasUuid; | ||
use Illuminate\Database\Eloquent\Model; | ||
|
||
class CriteriaSiteHistoric extends Model | ||
{ | ||
use HasUuid; | ||
|
||
/** | ||
* The table associated with the model. | ||
* | ||
* @var string | ||
*/ | ||
protected $table = 'criteria_site_historic'; | ||
|
||
/** | ||
* The attributes that are mass assignable. | ||
* | ||
* @var array | ||
*/ | ||
protected $fillable = [ | ||
'criteria_id', | ||
'polygon_id', | ||
'valid', | ||
'extra_info', | ||
]; | ||
|
||
/** | ||
* The attributes that should be mutated to dates. | ||
* | ||
* @var array | ||
*/ | ||
protected $dates = [ | ||
'deleted_at', | ||
'date_created', | ||
]; | ||
|
||
public function scopeForCriteria($query, $criteriaId) | ||
{ | ||
return $query->where('criteria_id', $criteriaId)->latest(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
32 changes: 32 additions & 0 deletions
32
database/migrations/2024_11_22_161557_remove_softdeletes_from_criteria_site.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
<?php | ||
|
||
use Illuminate\Database\Migrations\Migration; | ||
use Illuminate\Database\Schema\Blueprint; | ||
use Illuminate\Support\Facades\Schema; | ||
|
||
class RemoveSoftDeletesFromCriteriaSite extends Migration | ||
{ | ||
/** | ||
* Run the migrations. | ||
* | ||
* @return void | ||
*/ | ||
public function up() | ||
{ | ||
Schema::table('criteria_site', function (Blueprint $table) { | ||
$table->dropSoftDeletes(); | ||
}); | ||
} | ||
|
||
/** | ||
* Reverse the migrations. | ||
* | ||
* @return void | ||
*/ | ||
public function down() | ||
{ | ||
Schema::table('criteria_site', function (Blueprint $table) { | ||
$table->softDeletes(); | ||
}); | ||
} | ||
} |
36 changes: 36 additions & 0 deletions
36
database/migrations/2024_11_22_161611_create_criteria_site_historic_table.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
<?php | ||
|
||
use Illuminate\Database\Migrations\Migration; | ||
use Illuminate\Database\Schema\Blueprint; | ||
use Illuminate\Support\Facades\Schema; | ||
|
||
class CreateCriteriaSiteHistoricTable extends Migration | ||
{ | ||
/** | ||
* Run the migrations. | ||
* | ||
* @return void | ||
*/ | ||
public function up() | ||
{ | ||
Schema::create('criteria_site_historic', function (Blueprint $table) { | ||
$table->id(); | ||
$table->uuid('uuid')->unique(); | ||
$table->integer('criteria_id')->nullable(); | ||
$table->string('polygon_id')->nullable(); | ||
$table->integer('valid')->nullable(); | ||
$table->json('extra_info')->nullable(); | ||
$table->timestamps(); | ||
}); | ||
} | ||
|
||
/** | ||
* Reverse the migrations. | ||
* | ||
* @return void | ||
*/ | ||
public function down() | ||
{ | ||
Schema::dropIfExists('criteria_site_historic'); | ||
} | ||
} |