Files
safekat/ci4/app/Database/Migrations/2024-11-30-170001_OrdenTrabajoTareasTable.php
2025-04-21 12:55:45 +02:00

148 lines
5.3 KiB
PHP
Executable File

<?php
namespace App\Database\Migrations;
use CodeIgniter\Database\Migration;
use CodeIgniter\Database\RawSql;
class OrdenTrabajoTareasTable extends Migration
{
protected array $COLUMNS = [
"id" => [
"type" => "INT",
"unsigned" => true,
"auto_increment" => true
],
"orden_trabajo_id" => [
"type" => "INT",
"unsigned" => true,
"constraint" => 10,
"comment" => "Orden de trabajo a la que pertenece esta tarea",
],
"presupuesto_linea_id" => [
"type" => "INT",
"unsigned" => true,
"constraint" => 10,
"null" => true,
"comment" => "Presupuesto linea asociada a esta tarea. Puede ser NULL porque se podría añadir una tarea manual",
],
"presupuesto_acabado_id" => [
"type" => "INT",
"unsigned" => true,
"constraint" => 10,
"null" => true,
"comment" => "Presupuesto linea asociada a esta tarea. Puede ser NULL porque se podría añadir una tarea manual",
],
"presupuesto_preimpresion_id" => [
"type" => "INT",
"unsigned" => true,
"constraint" => 10,
"null" => true,
"comment" => "Presupuesto linea asociada a esta tarea. Puede ser NULL porque se podría añadir una tarea manual",
],
"presupuesto_encuadernado_id" => [
"type" => "INT",
"unsigned" => true,
"constraint" => 10,
"null" => true,
"comment" => "Presupuesto linea asociada a esta tarea. Puede ser NULL porque se podría añadir una tarea manual",
],
"presupuesto_manipulado_id" => [
"type" => "INT",
"unsigned" => true,
"constraint" => 10,
"null" => true,
"comment" => "Presupuesto linea asociada a esta tarea. Puede ser NULL porque se podría añadir una tarea manual",
],
"presupuesto_extra_id" => [
"type" => "INT",
"unsigned" => true,
"constraint" => 10,
"null" => true,
"comment" => "Presupuesto linea asociada a esta tarea. Puede ser NULL porque se podría añadir una tarea manual",
],
"nombre" => [
"type" => "VARCHAR",
"constraint" => 255,
"comment" => "Nombre de la tarea",
],
"orden" => [
"type" => "INT",
"unsigned" => true,
"comment" => "Orden de ejecución del tarea. Por defecto el orden será la de la máquina asociada a la línea de presupuesto."
],
"maquina_id" =>
[
"type" => "INT",
"unsigned" => true,
"constraint" => 10,
"null" => true,
"comment" => "Máquina asociada a la tarea. Por defecto será la asociada a la linea de presupuesto"
],
"imposicion_id" => [
"type" => "INT",
"null" => true,
"constraint" => 11,
"default" => null,
"comment" => "Imposicion aplicada a la tarea. Default null"
],
"tiempo_estimado" => [
"type" => "DOUBLE",
"default" => 0.00,
"null" => true,
"comment" => "Tiempo ejecución estimado de la tarea en minutos",
],
"tiempo_real" => [
"type" => "DOUBLE",
"default" => 0.00,
"null" => true,
"comment" => "Tiempo ejecución real de la tarea",
],
"comment" => [
"type" => "TEXT",
"null" => true,
"comment" => "Comentario sobre la tarea",
]
];
public function up()
{
$this->forge->addField($this->COLUMNS);
$currenttime = new RawSql("CURRENT_TIMESTAMP");
$this->forge->addField([
"created_at" => [
"type" => "TIMESTAMP",
"default" => $currenttime,
],
"updated_at" => [
"type" => "TIMESTAMP",
"null" => true,
],
"deleted_at" => [
"type" => "TIMESTAMP",
"null" => true,
],
]);
$this->forge->addPrimaryKey("id");
$this->forge->addForeignKey("orden_trabajo_id","ordenes_trabajo","id","CASCADE","CASCADE");
$this->forge->addForeignKey("presupuesto_linea_id","presupuesto_linea","id");
$this->forge->addForeignKey("presupuesto_acabado_id","presupuesto_acabados","id");
$this->forge->addForeignKey("presupuesto_encuadernado_id","presupuesto_encuadernaciones","id");
$this->forge->addForeignKey("presupuesto_manipulado_id","presupuesto_manipulados","id");
$this->forge->addForeignKey("presupuesto_preimpresion_id","presupuesto_preimpresiones","id");
$this->forge->addForeignKey("presupuesto_extra_id","presupuesto_serviciosExtra","id");
$this->forge->addForeignKey("imposicion_id","lg_imposiciones","id");
$this->forge->addForeignKey("maquina_id","lg_maquinas","id");
$this->forge->createTable("orden_trabajo_tareas");
}
public function down()
{
$this->forge->dropTable("orden_trabajo_tareas",true);
}
}