Migraciones

This commit is contained in:
Juan Pablo Vial
2024-11-28 11:37:26 -03:00
parent dafabdbbdb
commit 57fc6fa46e
11 changed files with 214 additions and 872 deletions

View File

@ -0,0 +1,29 @@
<?php
declare(strict_types=1);
use Phinx\Migration\AbstractMigration;
final class CreateTipoAgente extends AbstractMigration
{
/**
* Change Method.
*
* Write your reversible migrations using this method.
*
* More information on writing migrations is available here:
* https://book.cakephp.org/phinx/0/en/migrations.html#the-change-method
*
* Remember to call "create()" or "update()" and NOT "save()" when working
* with the Table class.
*/
public function change(): void
{
$this->table('tipo_agente')
->addColumn('descripcion', 'string', ['limit' => 100, 'null' => false])
->addColumn('icono', 'string', ['limit' => 50, 'null' => true])
->addColumn('color', 'string', ['limit' => 6, 'null' => true])
->addColumn('bgcolor', 'string', ['limit' => 6, 'null' => true])
->create();
}
}

View File

@ -7,93 +7,9 @@ class Incoviba17303572256733fad3df01b extends Phinx\Migration\AbstractMigration
public function change()
{
$this->execute('SET unique_checks=0; SET foreign_key_checks=0;');
$this->execute("ALTER DATABASE CHARACTER SET 'utf8mb3';");
$this->execute("ALTER DATABASE COLLATE='utf8mb3_general_ci';");
$this->table('tipo_estado_cierre', [
'id' => false,
'primary_key' => ['id'],
'engine' => 'InnoDB',
'encoding' => 'utf8mb4',
'collation' => 'utf8mb4_general_ci',
'comment' => '',
'row_format' => 'DYNAMIC',
])
->addColumn('id', 'integer', [
'null' => false,
'limit' => 10,
'signed' => false,
'identity' => true,
])
->addColumn('descripcion', 'string', [
'null' => false,
'limit' => 50,
'collation' => 'utf8mb4_general_ci',
'encoding' => 'utf8mb4',
'after' => 'id',
])
->addColumn('vigente', 'integer', [
'null' => false,
'default' => '0',
'limit' => 1,
'signed' => false,
'after' => 'descripcion',
])
->create();
$this->table('logins', [
'id' => false,
'primary_key' => ['id'],
'engine' => 'InnoDB',
'encoding' => 'utf8mb4',
'collation' => 'utf8mb4_general_ci',
'comment' => '',
'row_format' => 'DYNAMIC',
])
->addColumn('id', 'integer', [
'null' => false,
'limit' => 10,
'signed' => false,
'identity' => true,
])
->addColumn('user_id', 'integer', [
'null' => false,
'limit' => 10,
'signed' => false,
'after' => 'id',
])
->addColumn('time', 'datetime', [
'null' => false,
'after' => 'user_id',
])
->addColumn('selector', 'string', [
'null' => false,
'limit' => 255,
'collation' => 'utf8mb4_general_ci',
'encoding' => 'utf8mb4',
'after' => 'time',
])
->addColumn('token', 'string', [
'null' => false,
'limit' => 255,
'collation' => 'utf8mb4_general_ci',
'encoding' => 'utf8mb4',
'after' => 'selector',
])
->addColumn('status', 'integer', [
'null' => false,
'default' => '1',
'limit' => 1,
'after' => 'token',
])
->addIndex(['user_id'], [
'name' => 'fk_logins_users',
'unique' => false,
])
->addForeignKey('user_id', 'users', 'id', [
'constraint' => 'fk_logins_users',
'update' => 'RESTRICT',
'delete' => 'RESTRICT',
])
->create();
$this->execute("ALTER DATABASE CHARACTER SET 'utf8mb4';");
$this->execute("ALTER DATABASE COLLATE='utf8mb4_general_ci';");
$this->table('propiedad_unidad', [
'id' => false,
'primary_key' => ['id'],
@ -152,113 +68,7 @@ class Incoviba17303572256733fad3df01b extends Phinx\Migration\AbstractMigration
'delete' => 'CASCADE',
])
->create();
$this->table('agente', [
'id' => false,
'primary_key' => ['id'],
'engine' => 'InnoDB',
'encoding' => 'utf8mb4',
'collation' => 'utf8mb4_general_ci',
'comment' => '',
'row_format' => 'DYNAMIC',
])
->addColumn('id', 'integer', [
'null' => false,
'limit' => 10,
'signed' => false,
'identity' => true,
])
->addColumn('tipo', 'integer', [
'null' => true,
'default' => null,
'limit' => MysqlAdapter::INT_REGULAR,
'after' => 'id',
])
->addColumn('rut', 'integer', [
'null' => true,
'default' => null,
'limit' => MysqlAdapter::INT_REGULAR,
'after' => 'tipo',
])
->addColumn('descripcion', 'string', [
'null' => true,
'default' => null,
'limit' => 100,
'collation' => 'utf8mb4_general_ci',
'encoding' => 'utf8mb4',
'after' => 'rut',
])
->addColumn('representante', 'string', [
'null' => true,
'default' => null,
'limit' => 100,
'collation' => 'utf8mb4_general_ci',
'encoding' => 'utf8mb4',
'after' => 'descripcion',
])
->addColumn('telefono', 'integer', [
'null' => true,
'default' => null,
'limit' => MysqlAdapter::INT_REGULAR,
'after' => 'representante',
])
->addColumn('correo', 'string', [
'null' => true,
'default' => null,
'limit' => 50,
'collation' => 'utf8mb4_general_ci',
'encoding' => 'utf8mb4',
'after' => 'telefono',
])
->addColumn('direccion', 'integer', [
'null' => true,
'default' => null,
'limit' => MysqlAdapter::INT_REGULAR,
'after' => 'correo',
])
->addColumn('giro', 'text', [
'null' => true,
'default' => null,
'limit' => MysqlAdapter::TEXT_MEDIUM,
'collation' => 'utf8mb4_general_ci',
'encoding' => 'utf8mb4',
'after' => 'direccion',
])
->addColumn('abreviacion', 'string', [
'null' => true,
'default' => null,
'limit' => 20,
'collation' => 'utf8mb4_general_ci',
'encoding' => 'utf8mb4',
'after' => 'giro',
])
->addIndex(['tipo'], [
'name' => 'idx_tipo',
'unique' => false,
])
->create();
$this->table('tipo_estado_proyecto_agente', [
'id' => false,
'primary_key' => ['id'],
'engine' => 'InnoDB',
'encoding' => 'utf8mb4',
'collation' => 'utf8mb4_general_ci',
'comment' => '',
'row_format' => 'DYNAMIC',
])
->addColumn('id', 'integer', [
'null' => false,
'limit' => 10,
'signed' => false,
'identity' => true,
])
->addColumn('descripcion', 'string', [
'null' => false,
'limit' => 255,
'collation' => 'utf8mb4_general_ci',
'encoding' => 'utf8mb4',
'after' => 'id',
])
->create();
$this->table('unidad', [
'id' => false,
'primary_key' => ['id'],
@ -1449,7 +1259,7 @@ class Incoviba17303572256733fad3df01b extends Phinx\Migration\AbstractMigration
])
->addColumn('fecha_banco', 'date', [
'null' => false,
'default' => '0000-00-00',
'default' => 0,
'after' => 'fecha',
])
->addColumn('duracion', 'integer', [

View File

@ -0,0 +1,13 @@
<?php
use Phinx\Db\Adapter\MysqlAdapter;
class CreateTipoEstadoCierre extends Phinx\Migration\AbstractMigration
{
public function change(): void
{
$this->table('tipo_estado_cierre')
->addColumn('descripcion', 'string', ['limit' => 50, 'null' => false])
->create();
}
}

View File

@ -0,0 +1,21 @@
<?php
use Phinx\Migration\AbstractMigration;
class CreateAgente extends AbstractMigration
{
public function change(): void
{
$this->table('agente')
->addColumn('tipo', 'integer', ['null' => true, 'default' => null])
->addColumn('rut', 'integer', ['null' => true, 'default' => null])
->addColumn('descripcion', 'string', ['null' => true, 'default' => null, 'limit' => 100])
->addColumn('representante', 'string', ['null' => true, 'default' => null, 'limit' => 100])
->addColumn('telefono', 'integer', ['null' => true, 'default' => null])
->addColumn('correo', 'string', ['null' => true, 'default' => null, 'limit' => 100])
->addColumn('direccion', 'string', ['null' => true, 'default' => null, 'limit' => 100])
->addColumn('giro', 'text', ['null' => true, 'default' => null])
->addColumn('abreviacion', 'text', ['null' => true, 'default' => null, 'limit' => 20])
->create();
}
}

View File

@ -0,0 +1,15 @@
<?php
use Phinx\Migration\AbstractMigration;
class CreateTipoEstadoProyectoAgente extends AbstractMigration
{
public function change(): void
{
$this->table('tipo_estado_proyecto_agente')
->addColumn('descripcion', 'string', ['limit' => 50, 'null' => false])
->addColumn('vigente', 'integer', ['null' => false, 'default' => 0, 'limit' => 1, 'signed' => false])
->create();
}
}

View File

@ -0,0 +1,19 @@
<?php
use Phinx\Db\Adapter\MysqlAdapter;
class CreateLogins extends \Phinx\Migration\AbstractMigration
{
public function change(): void
{
$this->table('logins')
->addColumn('user_id', 'integer', ['null' => false, 'limit' => 10, 'signed' => false])
->addColumn('time', 'datetime', ['null' => false])
->addColumn('selector', 'string', ['null' => false, 'limit' => 255, 'collation' => 'utf8mb4_general_ci', 'encoding' => 'utf8mb4'])
->addColumn('token', 'string', ['null' => false, 'limit' => 255, 'collation' => 'utf8mb4_general_ci', 'encoding' => 'utf8mb4'])
->addColumn('status', 'integer', ['null' => false, 'default' => '1', 'limit' => 1])
->addIndex(['user_id'], ['name' => 'fk_logins_users', 'unique' => false])
->addForeignKey('user_id', 'users', 'id', ['constraint' => 'fk_logins_users', 'update' => 'CASCADE', 'delete' => 'CASCADE'])
->create();
}
}

View File

@ -0,0 +1,31 @@
<?php
declare(strict_types=1);
use Phinx\Migration\AbstractMigration;
final class CreateTipoCobro extends AbstractMigration
{
/**
* Change Method.
*
* Write your reversible migrations using this method.
*
* More information on writing migrations is available here:
* https://book.cakephp.org/phinx/0/en/migrations.html#the-change-method
*
* Remember to call "create()" or "update()" and NOT "save()" when working
* with the Table class.
*/
public function change(): void
{
$this->table('tipo_cobro')
->addColumn('descripcion', 'string', ['limit' => 100, 'null' => false])
->addColumn('monto_base', 'string', ['limit' => 100, 'null' => true])
->addColumn('modificador', 'string', ['limit' => 100, 'null' => true])
->addColumn('monto_neto', 'string', ['limit' => 100, 'null' => true])
->addColumn('operacion', 'integer', ['null' => true])
->addColumn('mod', 'float', ['null' => true])
->create();
}
}

View File

@ -0,0 +1,28 @@
<?php
declare(strict_types=1);
use Phinx\Migration\AbstractMigration;
final class CreateTipoElemento extends AbstractMigration
{
/**
* Change Method.
*
* Write your reversible migrations using this method.
*
* More information on writing migrations is available here:
* https://book.cakephp.org/phinx/0/en/migrations.html#the-change-method
*
* Remember to call "create()" or "update()" and NOT "save()" when working
* with the Table class.
*/
public function change(): void
{
$this->table('tipo_elemento')
->addColumn('descripcion', 'string', ['limit' => 50, 'null' => false])
->addColumn('abreviacion', 'string', ['limit' => 50, 'null' => false])
->addColumn('orden', 'integer', ['null' => false, 'unsigned' => true])
->create();
}
}

View File

@ -0,0 +1,26 @@
<?php
declare(strict_types=1);
use Phinx\Migration\AbstractMigration;
final class CreateTipoEstadoCobro extends AbstractMigration
{
/**
* Change Method.
*
* Write your reversible migrations using this method.
*
* More information on writing migrations is available here:
* https://book.cakephp.org/phinx/0/en/migrations.html#the-change-method
*
* Remember to call "create()" or "update()" and NOT "save()" when working
* with the Table class.
*/
public function change(): void
{
$this->table('tipo_estado_cobro')
->addColumn('descripcion', 'string', ['limit' => 20])
->create();
}
}

View File

@ -0,0 +1,27 @@
<?php
declare(strict_types=1);
use Phinx\Migration\AbstractMigration;
final class CreateTipoEstadoPago extends AbstractMigration
{
/**
* Change Method.
*
* Write your reversible migrations using this method.
*
* More information on writing migrations is available here:
* https://book.cakephp.org/phinx/0/en/migrations.html#the-change-method
*
* Remember to call "create()" or "update()" and NOT "save()" when working
* with the Table class.
*/
public function change(): void
{
$this->table('tipo_estado_pago')
->addColumn('descripcion', 'string', ['limit' => 20, 'null' => false])
->addColumn('active', 'integer', ['limit' => 1, 'default' => 0])
->create();
}
}