added new features for asset mgmt

This commit is contained in:
Luca Haid
2025-06-26 15:23:57 +02:00
parent 97f8a625e4
commit b0d7d4aeeb
10 changed files with 159 additions and 27 deletions
@@ -0,0 +1,30 @@
<?php
declare(strict_types=1);
use Phinx\Migration\AbstractMigration;
final class AddDescriptionToAssetManagement extends AbstractMigration
{
/**
* Adds the 'description' column to the 'AssetManagement' table.
*/
public function up(): void
{
$table = $this->table('AssetManagement');
$table->addColumn('description', 'text', [
'null' => true,
'after' => 'name',
]);
$table->update();
}
/**
* Removes the 'description' column from the 'AssetManagement' table.
*/
public function down(): void
{
$table = $this->table('AssetManagement');
$table->removeColumn('description');
$table->update();
}
}
@@ -0,0 +1,36 @@
<?php
declare(strict_types=1);
use Phinx\Migration\AbstractMigration;
final class ModifyBorrowReasonInAssetManagementJournal extends AbstractMigration
{
/**
* Changes the 'borrowReason' column to be nullable, adds a comment, and sets its position.
*/
public function up(): void
{
$table = $this->table('AssetManagementJournal');
$table->changeColumn('borrowReason', 'text', [
'null' => true,
'comment' => 'Reason for borrowing the asset',
'after' => 'returnDate',
]);
$table->update();
}
/**
* Reverts the 'borrowReason' column to its previous state (not nullable and without a comment).
*/
public function down(): void
{
// Reverting the changes made in the up() method.
// This assumes the column was NOT NULL and had no comment previously.
$table = $this->table('AssetManagementJournal');
$table->changeColumn('borrowReason', 'text', [
'null' => false,
'comment' => 'Reason for borrowing the asset', // Set comment back to empty
]);
$table->update();
}
}
@@ -0,0 +1,30 @@
<?php /** @noinspection ALL */
declare(strict_types=1);
use Phinx\Migration\AbstractMigration;
final class WorkerPermissionAddCanAssetAdmin extends AbstractMigration {
public function up(): void {
if ($this->getEnvironment() == "thetool") {
$table = $this->table("WorkerPermission");
$table->addColumn("canAssetAdmin", "enum", ["null" => false, "values" => 'false,true', "default" => "false", "after" => "canSuperexpert"]);
$table->update();
}
if ($this->getEnvironment() == "addressdb") {
}
}
public function down(): void {
if ($this->getEnvironment() == "thetool") {
$table = $this->table("WorkerPermission");
$table->removeColumn("canAssetAdmin");
$table->save();
}
if ($this->getEnvironment() == "addressdb") {
}
}
}