Files
safekat/ci4/app/Database/Migrations/2024-11-30-160000_TareasServicioTable.php
2024-12-10 07:35:25 +01:00

69 lines
1.9 KiB
PHP

<?php
namespace App\Database\Migrations;
use CodeIgniter\Database\Migration;
use CodeIgniter\Database\RawSql;
class ServicioClienteTareas extends Migration
{
protected array $COLUMNS = [
"id" => [
"type" => "INT",
"unsigned" => true,
"auto_increment" => true
],
"servicio_cliente_id" => [
"type" => "INT",
"unsigned" => true,
"comment" => "Servicio cliente asociado"
],
"tarifa_acabado_id" => [
"type" => "INT",
"unsigned" => true,
"null" => true,
"comment" => "Tarifa de acabado asociada a servicio"
],
"tarifa_manipulado_id" => [
"type" => "INT",
"unsigned" => true,
"null" => true,
"comment" => "Tarifa de manipulado asociada a servicio",
]
];
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('servicio_cliente_id','servicios_cliente','id');
$this->forge->addForeignKey('tarifa_acabado_id','lg_tarifa_acabado','id');
$this->forge->addForeignKey('tarifa_manipulado_id','lg_tarifa_manipulado','id');
$this->forge->createTable("servicio_cliente_tareas", true);
}
public function down()
{
$this->forge->dropTable("servicio_cliente_tareas");
}
}