add new dates

This commit is contained in:
amazuecos
2025-04-14 23:36:39 +02:00
parent ebf0a9d5d7
commit 14c5cf493c
11 changed files with 139 additions and 7 deletions

View File

@ -0,0 +1,61 @@
<?php
namespace App\Database\Migrations;
use CodeIgniter\Database\Migration;
use CodeIgniter\Database\RawSql;
class UpdateDateFieldsOrdenTrabajoDates extends Migration
{
protected array $DATES = [
"cosido_at" => [
"type" => "DATE",
"null" => true,
],
"solapa_at" => [
"type" => "DATE",
"null" => true,
],
"grapado_at" => [
"type" => "DATE",
"null" => true,
],
];
protected array $USERS = [
"cosido_user_id" => [
"type" => "INT",
"unsigned" => true,
"constraint" => 10,
"null" => true,
],
"solapa_user_id" => [
"type" => "INT",
"unsigned" => true,
"constraint" => 10,
"null" => true,
],
"grapado_user_id" => [
"type" => "INT",
"unsigned" => true,
"constraint" => 10,
"null" => true,
],
];
public function up()
{
$this->forge->addColumn("orden_trabajo_dates", $this->DATES);
$this->forge->addColumn("orden_trabajo_users", $this->USERS);
foreach ($this->USERS as $key => $value) {
$this->forge->addForeignKey([$key],"users",["id"]);
}
}
public function down()
{
$this->forge->dropColumn("orden_trabajo_dates", array_keys($this->DATES));
$this->forge->dropColumn("orden_trabajo_users", array_keys($this->USERS));
}
}