mirror of
https://git.imnavajas.es/jjimenez/safekat.git
synced 2025-07-25 22:52:08 +00:00
105 lines
2.7 KiB
PHP
105 lines
2.7 KiB
PHP
<?php
|
|
|
|
namespace App\Database\Migrations;
|
|
|
|
use CodeIgniter\Database\Migration;
|
|
use CodeIgniter\Database\RawSql;
|
|
|
|
class OrdenTrabajoTable extends Migration
|
|
{
|
|
protected array $COLUMNS = [
|
|
"id" => [
|
|
"type" => "INT",
|
|
"unsigned" => true,
|
|
"auto_increment" => true
|
|
],
|
|
"pedido_id" => [
|
|
"type" => "INT",
|
|
"unsigned" => true,
|
|
"constraint" => 16,
|
|
"comment" => "Pedido original asociado",
|
|
],
|
|
"user_created_id" => [
|
|
"type" => "INT",
|
|
"unsigned" => true,
|
|
"constraint" => 10,
|
|
"comment" => "Usuario que ha pasado el pedido a producción",
|
|
],
|
|
|
|
"user_updated_id" => [
|
|
"type" => "INT",
|
|
"unsigned" => true,
|
|
"constraint" => 10,
|
|
"comment" => "Usuario que ha actualizado la orden de trabajo",
|
|
|
|
],
|
|
"total_tirada" => [
|
|
"type" => "DOUBLE",
|
|
"null" => true
|
|
],
|
|
"total_precio" => [
|
|
"type" => "DOUBLE",
|
|
"null" => true
|
|
],
|
|
"tipo_entrada" => [
|
|
"type" => "ENUM",
|
|
"constraint" => ["in", "out"],
|
|
"default" => "out",
|
|
"comment" => "Tipo de entrada"
|
|
],
|
|
|
|
"progreso" => [
|
|
"type" => "DOUBLE",
|
|
"default" => 0.00,
|
|
"comment" => "Progreso de 0 a 100"
|
|
],
|
|
|
|
"estado" => [
|
|
"type" => "ENUM",
|
|
"constraint" => ["I","F","P","E"],
|
|
"default" => "I",
|
|
"comment" => "I => INICIADO, F => FINALIZADO, P => PROGRESO , E => ERROR"
|
|
],
|
|
|
|
"comentarios" => [
|
|
"type" => "TEXT",
|
|
"null" => true,
|
|
"default" => null,
|
|
"comment" => "Comentarios orden de trabajo"
|
|
]
|
|
];
|
|
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("pedido_id","pedidos","id");
|
|
$this->forge->addForeignKey("user_created_id","users","id");
|
|
$this->forge->addForeignKey("user_updated_id","users","id");
|
|
|
|
$this->forge->createTable("ordenes_trabajo", true);
|
|
}
|
|
|
|
public function down()
|
|
{
|
|
$this->forge->dropTable("ordenes_trabajo");
|
|
}
|
|
}
|