-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Vinzenz Rosenkranz <[email protected]>
- Loading branch information
Showing
8 changed files
with
111 additions
and
10 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
61 changes: 61 additions & 0 deletions
61
database/migrations/2024_12_02_132705_move_entity_type_color.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,61 @@ | ||
<?php | ||
|
||
use App\AvailableLayer; | ||
use App\EntityType; | ||
use Illuminate\Database\Migrations\Migration; | ||
use Illuminate\Database\Schema\Blueprint; | ||
use Illuminate\Support\Facades\Schema; | ||
|
||
return new class extends Migration | ||
{ | ||
/** | ||
* Run the migrations. | ||
*/ | ||
public function up(): void | ||
{ | ||
activity()->disableLogging(); | ||
|
||
Schema::table('entity_types', function (Blueprint $table) { | ||
$table->text('color')->nullable(); | ||
}); | ||
|
||
// migrate existing colors from map plugin table | ||
if(Schema::hasTable('available_layers')) { | ||
$entityTypeLayers = AvailableLayer::has('entity_type')->get(); | ||
|
||
foreach($entityTypeLayers as $entityTypeLayer) { | ||
$color = $entityTypeLayer->color; | ||
$entityTypeLayer->color = null; | ||
$entityTypeLayer->saveQuietly(); | ||
$entityType = EntityType::find($entityTypeLayer->entity_type_id); | ||
$entityType->color = $color; | ||
$entityType->saveQuietly(); | ||
} | ||
} | ||
|
||
activity()->enableLogging(); | ||
} | ||
|
||
/** | ||
* Reverse the migrations. | ||
*/ | ||
public function down(): void | ||
{ | ||
activity()->disableLogging(); | ||
|
||
if(Schema::hasTable('available_layers')) { | ||
$entityTypeLayers = AvailableLayer::has('entity_type')->get(); | ||
|
||
foreach($entityTypeLayers as $entityTypeLayer) { | ||
$entityTypeLayer->color = $entityTypeLayer->entity_type->color; | ||
$entityTypeLayer->saveQuietly(); | ||
} | ||
} | ||
|
||
Schema::table('entity_types', function (Blueprint $table) { | ||
$table->dropColumn('color'); | ||
}); | ||
|
||
activity()->enableLogging(); | ||
} | ||
}; |
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
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