Migraciones
This commit is contained in:
@ -2,454 +2,13 @@
|
||||
|
||||
use Phinx\Db\Adapter\MysqlAdapter;
|
||||
|
||||
class Incoviba2287310996733f7d5ac59c extends Phinx\Migration\AbstractMigration
|
||||
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('movimientos_auxiliares', [
|
||||
'id' => false,
|
||||
'primary_key' => ['id'],
|
||||
'engine' => 'InnoDB',
|
||||
'encoding' => 'utf8mb3',
|
||||
'collation' => 'utf8mb3_general_ci',
|
||||
'comment' => '',
|
||||
'row_format' => 'DYNAMIC',
|
||||
])
|
||||
->addColumn('id', 'integer', [
|
||||
'null' => false,
|
||||
'limit' => 10,
|
||||
'signed' => false,
|
||||
'identity' => true,
|
||||
])
|
||||
->addColumn('movimiento_id', 'integer', [
|
||||
'null' => false,
|
||||
'limit' => 10,
|
||||
'signed' => false,
|
||||
'after' => 'id',
|
||||
])
|
||||
->addColumn('cargo', 'integer', [
|
||||
'null' => true,
|
||||
'default' => null,
|
||||
'limit' => 10,
|
||||
'signed' => false,
|
||||
'after' => 'movimiento_id',
|
||||
])
|
||||
->addColumn('abono', 'integer', [
|
||||
'null' => true,
|
||||
'default' => null,
|
||||
'limit' => 10,
|
||||
'signed' => false,
|
||||
'after' => 'cargo',
|
||||
])
|
||||
->addIndex(['movimiento_id'], [
|
||||
'name' => 'movimiento_id',
|
||||
'unique' => false,
|
||||
])
|
||||
->addForeignKey('movimiento_id', 'movimientos', 'id', [
|
||||
'constraint' => 'movimientos_auxiliares_ibfk_2',
|
||||
'update' => 'CASCADE',
|
||||
'delete' => 'CASCADE',
|
||||
])
|
||||
->create();
|
||||
$this->table('datos_personas', [
|
||||
'id' => false,
|
||||
'primary_key' => ['persona_rut'],
|
||||
'engine' => 'InnoDB',
|
||||
'encoding' => 'utf8mb3',
|
||||
'collation' => 'utf8mb3_general_ci',
|
||||
'comment' => '',
|
||||
'row_format' => 'DYNAMIC',
|
||||
])
|
||||
->addColumn('persona_rut', 'integer', [
|
||||
'null' => false,
|
||||
'limit' => 10,
|
||||
'signed' => false,
|
||||
])
|
||||
->addColumn('direccion_id', 'integer', [
|
||||
'null' => true,
|
||||
'default' => null,
|
||||
'limit' => 10,
|
||||
'signed' => false,
|
||||
'after' => 'persona_rut',
|
||||
])
|
||||
->addColumn('telefono', 'integer', [
|
||||
'null' => true,
|
||||
'default' => null,
|
||||
'limit' => 10,
|
||||
'signed' => false,
|
||||
'after' => 'direccion_id',
|
||||
])
|
||||
->addColumn('email', 'string', [
|
||||
'null' => true,
|
||||
'default' => null,
|
||||
'limit' => 100,
|
||||
'collation' => 'utf8mb3_general_ci',
|
||||
'encoding' => 'utf8mb3',
|
||||
'after' => 'telefono',
|
||||
])
|
||||
->addColumn('sexo', 'enum', [
|
||||
'null' => true,
|
||||
'default' => null,
|
||||
'limit' => 2,
|
||||
'values' => ['M', 'F', 'NA'],
|
||||
'after' => 'email',
|
||||
])
|
||||
->addColumn('fecha_nacimiento', 'date', [
|
||||
'null' => true,
|
||||
'default' => null,
|
||||
'after' => 'sexo',
|
||||
])
|
||||
->addColumn('estado_civil', 'enum', [
|
||||
'null' => true,
|
||||
'default' => null,
|
||||
'limit' => 10,
|
||||
'values' => ['casado', 'soltero', 'divorciado'],
|
||||
'after' => 'fecha_nacimiento',
|
||||
])
|
||||
->addColumn('nacionalidad', 'string', [
|
||||
'null' => true,
|
||||
'default' => null,
|
||||
'limit' => 100,
|
||||
'collation' => 'utf8mb3_general_ci',
|
||||
'encoding' => 'utf8mb3',
|
||||
'after' => 'estado_civil',
|
||||
])
|
||||
->addColumn('profesion', 'string', [
|
||||
'null' => true,
|
||||
'default' => null,
|
||||
'limit' => 100,
|
||||
'collation' => 'utf8mb3_general_ci',
|
||||
'encoding' => 'utf8mb3',
|
||||
'after' => 'nacionalidad',
|
||||
])
|
||||
->addIndex(['direccion_id'], [
|
||||
'name' => 'direccion_id',
|
||||
'unique' => false,
|
||||
])
|
||||
->addIndex(['telefono'], [
|
||||
'name' => 'telefono',
|
||||
'unique' => false,
|
||||
])
|
||||
->addForeignKey('direccion_id', 'direccion', 'id', [
|
||||
'constraint' => 'datos_personas_ibfk_4',
|
||||
'update' => 'SET_NULL',
|
||||
'delete' => 'SET_NULL',
|
||||
])
|
||||
->addForeignKey('persona_rut', 'personas', 'rut', [
|
||||
'constraint' => 'datos_personas_ibfk_7',
|
||||
'update' => 'CASCADE',
|
||||
'delete' => 'CASCADE',
|
||||
])
|
||||
->create();
|
||||
$this->table('personas', [
|
||||
'id' => false,
|
||||
'primary_key' => ['rut'],
|
||||
'engine' => 'InnoDB',
|
||||
'encoding' => 'utf8mb3',
|
||||
'collation' => 'utf8mb3_general_ci',
|
||||
'comment' => '',
|
||||
'row_format' => 'DYNAMIC',
|
||||
])
|
||||
->addColumn('rut', 'integer', [
|
||||
'null' => false,
|
||||
'limit' => 10,
|
||||
'signed' => false,
|
||||
])
|
||||
->addColumn('digito', 'char', [
|
||||
'null' => false,
|
||||
'limit' => 1,
|
||||
'collation' => 'utf8mb3_general_ci',
|
||||
'encoding' => 'utf8mb3',
|
||||
'after' => 'rut',
|
||||
])
|
||||
->addColumn('nombres', 'string', [
|
||||
'null' => false,
|
||||
'limit' => 100,
|
||||
'collation' => 'utf8mb3_general_ci',
|
||||
'encoding' => 'utf8mb3',
|
||||
'after' => 'digito',
|
||||
])
|
||||
->addColumn('apellido_paterno', 'string', [
|
||||
'null' => false,
|
||||
'limit' => 100,
|
||||
'collation' => 'utf8mb3_general_ci',
|
||||
'encoding' => 'utf8mb3',
|
||||
'after' => 'nombres',
|
||||
])
|
||||
->addColumn('apellido_materno', 'string', [
|
||||
'null' => false,
|
||||
'limit' => 100,
|
||||
'collation' => 'utf8mb3_general_ci',
|
||||
'encoding' => 'utf8mb3',
|
||||
'after' => 'apellido_paterno',
|
||||
])
|
||||
->create();
|
||||
$this->table('tipos_estados_facturas', [
|
||||
'id' => false,
|
||||
'primary_key' => ['id'],
|
||||
'engine' => 'InnoDB',
|
||||
'encoding' => 'utf8mb3',
|
||||
'collation' => 'utf8mb3_general_ci',
|
||||
'comment' => '',
|
||||
'row_format' => 'DYNAMIC',
|
||||
])
|
||||
->addColumn('id', 'integer', [
|
||||
'null' => false,
|
||||
'limit' => 10,
|
||||
'signed' => false,
|
||||
'identity' => true,
|
||||
])
|
||||
->addColumn('descripcion', 'string', [
|
||||
'null' => false,
|
||||
'limit' => 100,
|
||||
'collation' => 'utf8mb3_general_ci',
|
||||
'encoding' => 'utf8mb3',
|
||||
'after' => 'id',
|
||||
])
|
||||
->create();
|
||||
$this->table('estados_facturas', [
|
||||
'id' => false,
|
||||
'primary_key' => ['id'],
|
||||
'engine' => 'InnoDB',
|
||||
'encoding' => 'utf8mb3',
|
||||
'collation' => 'utf8mb3_general_ci',
|
||||
'comment' => '',
|
||||
'row_format' => 'DYNAMIC',
|
||||
])
|
||||
->addColumn('id', 'integer', [
|
||||
'null' => false,
|
||||
'limit' => 10,
|
||||
'signed' => false,
|
||||
'identity' => true,
|
||||
])
|
||||
->addColumn('factura_id', 'integer', [
|
||||
'null' => false,
|
||||
'limit' => 10,
|
||||
'signed' => false,
|
||||
'after' => 'id',
|
||||
])
|
||||
->addColumn('fecha', 'date', [
|
||||
'null' => false,
|
||||
'after' => 'factura_id',
|
||||
])
|
||||
->addColumn('tipo_id', 'integer', [
|
||||
'null' => false,
|
||||
'limit' => 10,
|
||||
'signed' => false,
|
||||
'after' => 'fecha',
|
||||
])
|
||||
->addIndex(['factura_id'], [
|
||||
'name' => 'factura_id',
|
||||
'unique' => false,
|
||||
])
|
||||
->addIndex(['tipo_id'], [
|
||||
'name' => 'tipo_id',
|
||||
'unique' => false,
|
||||
])
|
||||
->addForeignKey('factura_id', 'facturas', 'id', [
|
||||
'constraint' => 'estados_facturas_ibfk_3',
|
||||
'update' => 'CASCADE',
|
||||
'delete' => 'CASCADE',
|
||||
])
|
||||
->addForeignKey('tipo_id', 'tipos_estados_facturas', 'id', [
|
||||
'constraint' => 'estados_facturas_ibfk_4',
|
||||
'update' => 'CASCADE',
|
||||
'delete' => 'CASCADE',
|
||||
])
|
||||
->create();
|
||||
$this->table('sociedades', [
|
||||
'id' => false,
|
||||
'primary_key' => ['rut'],
|
||||
'engine' => 'InnoDB',
|
||||
'encoding' => 'utf8mb3',
|
||||
'collation' => 'utf8mb3_general_ci',
|
||||
'comment' => '',
|
||||
'row_format' => 'DYNAMIC',
|
||||
])
|
||||
->addColumn('rut', 'integer', [
|
||||
'null' => false,
|
||||
'limit' => 10,
|
||||
'signed' => false,
|
||||
])
|
||||
->addColumn('digito', 'char', [
|
||||
'null' => false,
|
||||
'limit' => 1,
|
||||
'collation' => 'utf8mb3_general_ci',
|
||||
'encoding' => 'utf8mb3',
|
||||
'after' => 'rut',
|
||||
])
|
||||
->addColumn('nombre', 'string', [
|
||||
'null' => false,
|
||||
'limit' => 100,
|
||||
'collation' => 'utf8mb3_general_ci',
|
||||
'encoding' => 'utf8mb3',
|
||||
'after' => 'digito',
|
||||
])
|
||||
->addColumn('razon', 'text', [
|
||||
'null' => false,
|
||||
'limit' => 65535,
|
||||
'collation' => 'utf8mb3_general_ci',
|
||||
'encoding' => 'utf8mb3',
|
||||
'after' => 'nombre',
|
||||
])
|
||||
->addColumn('tipo_sociedad_id', 'integer', [
|
||||
'null' => false,
|
||||
'limit' => 10,
|
||||
'signed' => false,
|
||||
'after' => 'razon',
|
||||
])
|
||||
->addColumn('contacto_rut', 'integer', [
|
||||
'null' => false,
|
||||
'limit' => 10,
|
||||
'signed' => false,
|
||||
'after' => 'tipo_sociedad_id',
|
||||
])
|
||||
->addIndex(['tipo_sociedad_id'], [
|
||||
'name' => 'tipo_sociedad_id',
|
||||
'unique' => false,
|
||||
])
|
||||
->addIndex(['contacto_rut'], [
|
||||
'name' => 'representante_rut',
|
||||
'unique' => false,
|
||||
])
|
||||
->addForeignKey('tipo_sociedad_id', 'tipo_sociedad', 'id', [
|
||||
'constraint' => 'sociedades_ibfk_1',
|
||||
'update' => 'RESTRICT',
|
||||
'delete' => 'CASCADE',
|
||||
])
|
||||
->addForeignKey('contacto_rut', 'personas', 'rut', [
|
||||
'constraint' => 'sociedades_ibfk_2',
|
||||
'update' => 'RESTRICT',
|
||||
'delete' => 'CASCADE',
|
||||
])
|
||||
->create();
|
||||
$this->table('proveedores', [
|
||||
'id' => false,
|
||||
'primary_key' => ['id'],
|
||||
'engine' => 'InnoDB',
|
||||
'encoding' => 'utf8mb3',
|
||||
'collation' => 'utf8mb3_general_ci',
|
||||
'comment' => '',
|
||||
'row_format' => 'DYNAMIC',
|
||||
])
|
||||
->addColumn('id', 'integer', [
|
||||
'null' => false,
|
||||
'limit' => 10,
|
||||
'signed' => false,
|
||||
'identity' => true,
|
||||
])
|
||||
->addColumn('inmobiliaria_rut', 'integer', [
|
||||
'null' => false,
|
||||
'limit' => 8,
|
||||
'signed' => false,
|
||||
'after' => 'id',
|
||||
])
|
||||
->addColumn('sociedad_rut', 'integer', [
|
||||
'null' => false,
|
||||
'limit' => 10,
|
||||
'signed' => false,
|
||||
'after' => 'inmobiliaria_rut',
|
||||
])
|
||||
->addIndex(['inmobiliaria_rut'], [
|
||||
'name' => 'inmobiliaria_rut',
|
||||
'unique' => false,
|
||||
])
|
||||
->addIndex(['sociedad_rut'], [
|
||||
'name' => 'sociedad_rut',
|
||||
'unique' => false,
|
||||
])
|
||||
->addForeignKey('inmobiliaria_rut', 'inmobiliaria', 'rut', [
|
||||
'constraint' => 'proveedores_ibfk_1',
|
||||
'update' => 'RESTRICT',
|
||||
'delete' => 'CASCADE',
|
||||
])
|
||||
->addForeignKey('sociedad_rut', 'sociedades', 'rut', [
|
||||
'constraint' => 'proveedores_ibfk_2',
|
||||
'update' => 'RESTRICT',
|
||||
'delete' => 'CASCADE',
|
||||
])
|
||||
->create();
|
||||
$this->table('auxiliar_detalles', [
|
||||
'id' => false,
|
||||
'engine' => 'InnoDB',
|
||||
'encoding' => 'utf8mb3',
|
||||
'collation' => 'utf8mb3_general_ci',
|
||||
'comment' => '',
|
||||
'row_format' => 'DYNAMIC',
|
||||
])
|
||||
->addColumn('auxiliar_id', 'integer', [
|
||||
'null' => false,
|
||||
'limit' => 10,
|
||||
'signed' => false,
|
||||
])
|
||||
->addColumn('centro_costo_id', 'integer', [
|
||||
'null' => true,
|
||||
'default' => null,
|
||||
'limit' => 10,
|
||||
'signed' => false,
|
||||
'after' => 'auxiliar_id',
|
||||
])
|
||||
->addColumn('rut', 'integer', [
|
||||
'null' => true,
|
||||
'default' => null,
|
||||
'limit' => 8,
|
||||
'signed' => false,
|
||||
'after' => 'centro_costo_id',
|
||||
])
|
||||
->addColumn('digito', 'char', [
|
||||
'null' => true,
|
||||
'default' => null,
|
||||
'limit' => 1,
|
||||
'collation' => 'utf8mb3_general_ci',
|
||||
'encoding' => 'utf8mb3',
|
||||
'after' => 'rut',
|
||||
])
|
||||
->addColumn('nombre', 'string', [
|
||||
'null' => true,
|
||||
'default' => null,
|
||||
'limit' => 255,
|
||||
'collation' => 'utf8mb3_general_ci',
|
||||
'encoding' => 'utf8mb3',
|
||||
'after' => 'digito',
|
||||
])
|
||||
->addColumn('categoria', 'string', [
|
||||
'null' => true,
|
||||
'default' => null,
|
||||
'limit' => 100,
|
||||
'collation' => 'utf8mb3_general_ci',
|
||||
'encoding' => 'utf8mb3',
|
||||
'after' => 'nombre',
|
||||
])
|
||||
->addColumn('detalle', 'text', [
|
||||
'null' => true,
|
||||
'default' => null,
|
||||
'limit' => 65535,
|
||||
'collation' => 'utf8mb3_general_ci',
|
||||
'encoding' => 'utf8mb3',
|
||||
'after' => 'categoria',
|
||||
])
|
||||
->addIndex(['auxiliar_id'], [
|
||||
'name' => 'auxiliar_id',
|
||||
'unique' => false,
|
||||
])
|
||||
->addIndex(['centro_costo_id'], [
|
||||
'name' => 'centro_costo_id',
|
||||
'unique' => false,
|
||||
])
|
||||
->addForeignKey('auxiliar_id', 'movimientos_auxiliares', 'id', [
|
||||
'constraint' => 'auxiliar_detalles_ibfk_3',
|
||||
'update' => 'CASCADE',
|
||||
'delete' => 'CASCADE',
|
||||
])
|
||||
->addForeignKey('centro_costo_id', 'centros_costos', 'id', [
|
||||
'constraint' => 'auxiliar_detalles_ibfk_5',
|
||||
'update' => 'CASCADE',
|
||||
'delete' => 'SET_NULL',
|
||||
])
|
||||
->create();
|
||||
$this->table('tipo_estado_cierre', [
|
||||
'id' => false,
|
||||
'primary_key' => ['id'],
|
@ -0,0 +1,30 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
use Phinx\Migration\AbstractMigration;
|
||||
|
||||
final class CreatePersonas 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('personas', ['id' => false, 'primary_key' => ['rut', 'digito']])
|
||||
->addColumn('rut', 'integer', ['identity' => true, 'signed' => false, 'null' => false])
|
||||
->addColumn('digito', 'string', ['limit' => 1, 'null' => false])
|
||||
->addColumn('nombres', 'string', ['limit' => 255, 'null' => false])
|
||||
->addColumn('apellido_paterno', 'string', ['limit' => 255, 'null' => false])
|
||||
->addColumn('apellido_materno', 'string', ['limit' => 255, 'null' => false])
|
||||
->create();
|
||||
}
|
||||
}
|
@ -0,0 +1,31 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
use Phinx\Migration\AbstractMigration;
|
||||
|
||||
final class CreateProveedores 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('proveedores', ['id' => false, 'primary_key' => ['rut', 'digito']])
|
||||
->addColumn('rut', 'integer', ['identity' => true, 'signed' => false, 'null' => false])
|
||||
->addColumn('digito', 'string', ['limit' => 1, 'null' => false])
|
||||
->addColumn('nombre', 'string', ['limit' => 255, 'null' => false])
|
||||
->addColumn('razon', 'string', ['limit' => 255, 'null' => true])
|
||||
->addColumn('contacto_rut', 'integer', ['signed' => false, 'null' => true])
|
||||
->addForeignKey('contacto_rut', 'personas', ['rut'], ['delete' => 'CASCADE', 'update' => 'CASCADE'])
|
||||
->create();
|
||||
}
|
||||
}
|
@ -0,0 +1,31 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
use Phinx\Migration\AbstractMigration;
|
||||
|
||||
final class CreateDatosProveedores 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('datos_proveedores')
|
||||
->addColumn('proveedor_rut', 'integer', ['signed' => false, 'null' => false])
|
||||
->addForeignKey('proveedor_rut', 'proveedores', ['rut'], ['delete' => 'CASCADE', 'update' => 'CASCADE'])
|
||||
->addColumn('direccion_id', 'integer', ['signed' => false, 'null' => true])
|
||||
->addForeignKey('direccion_id', 'direccion', ['id'], ['delete' => 'CASCADE', 'update' => 'CASCADE'])
|
||||
->addColumn('telefono', 'string', ['limit' => 255, 'null' => true])
|
||||
->addColumn('giro', 'string', ['limit' => 255, 'null' => true])
|
||||
->create();
|
||||
}
|
||||
}
|
@ -0,0 +1,36 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
use Phinx\Migration\AbstractMigration;
|
||||
|
||||
final class CreateDatosPersonas 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('datos_personas')
|
||||
->addColumn('persona_rut', 'integer', ['signed' => false, 'null' => false])
|
||||
->addForeignKey('persona_rut', 'personas', ['rut'], ['delete' => 'CASCADE', 'update' => 'CASCADE'])
|
||||
->addColumn('direccion_id', 'integer', ['signed' => false, 'null' => true])
|
||||
->addForeignKey('direccion_id', 'direccion', ['id'], ['delete' => 'CASCADE', 'update' => 'CASCADE'])
|
||||
->addColumn('telefono', 'string', ['limit' => 255, 'null' => true])
|
||||
->addColumn('email', 'string', ['limit' => 255, 'null' => true])
|
||||
->addColumn('fecha_nacimiento', 'datetime', ['null' => true])
|
||||
->addColumn('sexo', 'string', ['limit' => 255, 'null' => true])
|
||||
->addColumn('estado_civil', 'string', ['limit' => 255, 'null' => true])
|
||||
->addColumn('nacionalidad', 'string', ['limit' => 255, 'null' => true])
|
||||
->addColumn('ocupacion', 'string', ['limit' => 255, 'null' => true])
|
||||
->create();
|
||||
}
|
||||
}
|
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user