Files
oficial/app/resources/database/migrations/20141101080009_create_centros_costos.php
aldarien 307f2ac7d7 feature/cierres (#25)
Varios cambios

Co-authored-by: Juan Pablo Vial <jpvialb@incoviba.cl>
Reviewed-on: #25
2025-07-22 13:18:00 +00:00

25 lines
1.2 KiB
PHP

<?php
use Phinx\Db\Adapter\MysqlAdapter;
class CreateCentrosCostos extends Phinx\Migration\AbstractMigration
{
public function change(): void
{
$this->execute('SET unique_checks=0; SET foreign_key_checks=0;');
$this->execute("ALTER DATABASE CHARACTER SET 'utf8mb4';");
$this->execute("ALTER DATABASE COLLATE='utf8mb4_general_ci';");
$this->table('centros_costos')
->addColumn('tipo_centro_id', 'integer', ['length' => 10, 'null' => false, 'signed' => false])
->addColumn('categoria_id', 'integer', ['length' => 10, 'null' => false, 'signed' => false])
->addColumn('tipo_cuenta_id', 'integer', ['length' => 10, 'default' => null, 'null' => true, 'signed' => false])
->addColumn('cuenta_contable', 'string', ['length' => 100, 'null' => false])
->addColumn('descripcion', 'text', ['null' => false, 'limit' => MysqlAdapter::TEXT_MEDIUM])
->addForeignKey('tipo_centro_id', 'tipos_centros_costos', 'id', ['delete' => 'cascade', 'update' => 'cascade'])
->addForeignKey('categoria_id', 'categorias_centros_costos', 'id', ['delete' => 'cascade', 'update' => 'cascade'])
->create();
$this->execute('SET unique_checks=1; SET foreign_key_checks=1;');
}
}