mirror of
https://git.imnavajas.es/jjimenez/safekat.git
synced 2025-07-25 22:52:08 +00:00
empezada la estructura de tickets
This commit is contained in:
@ -0,0 +1,80 @@
|
||||
<?php
|
||||
|
||||
namespace App\Database\Migrations;
|
||||
|
||||
use CodeIgniter\Database\Migration;
|
||||
|
||||
class CreateTicketsSystem extends Migration
|
||||
{
|
||||
public function up()
|
||||
{
|
||||
// Tabla de Categorías
|
||||
$this->forge->addField([
|
||||
'id' => ['type' => 'INT', 'constraint' => 11, 'unsigned' => true, 'auto_increment' => true],
|
||||
'nombre' => ['type' => 'VARCHAR', 'constraint' => 100, 'unique' => true],
|
||||
]);
|
||||
$this->forge->addPrimaryKey('id');
|
||||
$this->forge->createTable('categorias');
|
||||
|
||||
// Tabla de Estados
|
||||
$this->forge->addField([
|
||||
'id' => ['type' => 'INT', 'constraint' => 11, 'unsigned' => true, 'auto_increment' => true],
|
||||
'nombre' => ['type' => 'VARCHAR', 'constraint' => 100, 'unique' => true],
|
||||
]);
|
||||
$this->forge->addPrimaryKey('id');
|
||||
$this->forge->createTable('estados');
|
||||
|
||||
// Tabla de Tickets
|
||||
$this->forge->addField([
|
||||
'id' => ['type' => 'INT', 'constraint' => 11, 'unsigned' => true, 'auto_increment' => true],
|
||||
'usuario_id' => ['type' => 'INT', 'constraint' => 11, 'unsigned' => true],
|
||||
'categoria_id' => ['type' => 'INT', 'constraint' => 11, 'unsigned' => true],
|
||||
'estado_id' => ['type' => 'INT', 'constraint' => 11, 'unsigned' => true],
|
||||
'prioridad' => ['type' => 'ENUM', 'constraint' => ['alta', 'media', 'baja'], 'default' => 'media'],
|
||||
'titulo' => ['type' => 'VARCHAR', 'constraint' => 255],
|
||||
'descripcion' => ['type' => 'TEXT'],
|
||||
'created_at' => ['type' => 'DATETIME', 'null' => true],
|
||||
'updated_at' => ['type' => 'DATETIME', 'null' => true],
|
||||
]);
|
||||
$this->forge->addPrimaryKey('id');
|
||||
$this->forge->addForeignKey('usuario_id', 'users', 'id', 'CASCADE', 'CASCADE');
|
||||
$this->forge->addForeignKey('categoria_id', 'categorias', 'id', 'CASCADE', 'CASCADE');
|
||||
$this->forge->addForeignKey('estado_id', 'estados', 'id', 'CASCADE', 'CASCADE');
|
||||
$this->forge->createTable('tickets');
|
||||
|
||||
// Tabla de Respuestas
|
||||
$this->forge->addField([
|
||||
'id' => ['type' => 'INT', 'constraint' => 11, 'unsigned' => true, 'auto_increment' => true],
|
||||
'ticket_id' => ['type' => 'INT', 'constraint' => 11, 'unsigned' => true],
|
||||
'usuario_id' => ['type' => 'INT', 'constraint' => 11, 'unsigned' => true],
|
||||
'mensaje' => ['type' => 'TEXT'],
|
||||
'created_at' => ['type' => 'DATETIME', 'null' => true],
|
||||
]);
|
||||
$this->forge->addPrimaryKey('id');
|
||||
$this->forge->addForeignKey('ticket_id', 'tickets', 'id', 'CASCADE', 'CASCADE');
|
||||
$this->forge->addForeignKey('usuario_id', 'users', 'id', 'CASCADE', 'CASCADE');
|
||||
$this->forge->createTable('respuestas');
|
||||
|
||||
// Tabla de Adjuntos
|
||||
$this->forge->addField([
|
||||
'id' => ['type' => 'INT', 'constraint' => 11, 'unsigned' => true, 'auto_increment' => true],
|
||||
'ticket_id' => ['type' => 'INT', 'constraint' => 11, 'unsigned' => true, 'null' => true],
|
||||
'respuesta_id' => ['type' => 'INT', 'constraint' => 11, 'unsigned' => true, 'null' => true],
|
||||
'archivo' => ['type' => 'VARCHAR', 'constraint' => 255],
|
||||
'created_at' => ['type' => 'DATETIME', 'null' => true],
|
||||
]);
|
||||
$this->forge->addPrimaryKey('id');
|
||||
$this->forge->addForeignKey('ticket_id', 'tickets', 'id', 'CASCADE', 'CASCADE');
|
||||
$this->forge->addForeignKey('respuesta_id', 'respuestas', 'id', 'CASCADE', 'CASCADE');
|
||||
$this->forge->createTable('adjuntos');
|
||||
}
|
||||
|
||||
public function down()
|
||||
{
|
||||
$this->forge->dropTable('adjuntos');
|
||||
$this->forge->dropTable('respuestas');
|
||||
$this->forge->dropTable('tickets');
|
||||
$this->forge->dropTable('categorias');
|
||||
$this->forge->dropTable('estados');
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user