Promociones para cada subdivicion

This commit is contained in:
Juan Pablo Vial
2025-04-03 16:32:40 -03:00
parent b5d6d0acb9
commit 7b2df74e4d
19 changed files with 495 additions and 247 deletions

View File

@ -17,11 +17,15 @@ final class AlterPromotionsRemovePrice extends AbstractMigration
* Remember to call "create()" or "update()" and NOT "save()" when working
* with the Table class.
*/
public function change(): void
public function up(): void
{
$this->table('promotions')
->dropForeignKey('price_id')
->removeColumn('price_id')
->update();
if ($this->table('promotions')->hasColumn('price_id')) {
$this->table('promotions')
->dropForeignKey('price_id')
->removeColumn('price_id')
->update();
}
}
public function down(): void {}
}

View File

@ -17,11 +17,12 @@ final class AlterPromotionsNullDates extends AbstractMigration
* Remember to call "create()" or "update()" and NOT "save()" when working
* with the Table class.
*/
public function change(): void
public function up(): void
{
$this->table('promotions')
->changeColumn('end_date', 'date', ['null' => true])
->changeColumn('valid_until', 'date', ['null' => true])
->update();
}
public function down(): void {}
}

View File

@ -4,7 +4,7 @@ declare(strict_types=1);
use Phinx\Migration\AbstractMigration;
final class CreatePromotionContract extends AbstractMigration
final class CreatePromotionBrokers extends AbstractMigration
{
/**
* Change Method.
@ -19,12 +19,11 @@ final class CreatePromotionContract extends AbstractMigration
*/
public function change(): void
{
$this->table('promotion_contracts')
$this->table('promotion_brokers')
->addColumn('promotion_id', 'integer', ['signed' => false, 'null' => false])
->addColumn('contract_id', 'integer', ['signed' => false, 'null' => false])
->addColumn('created_at', 'datetime', ['null' => false, 'default' => 'CURRENT_TIMESTAMP'])
->addColumn('broker_rut', 'integer', ['signed' => false, 'null' => false])
->addForeignKey('promotion_id', 'promotions', 'id', ['delete' => 'CASCADE', 'update' => 'CASCADE'])
->addForeignKey('contract_id', 'broker_contracts', 'id', ['delete' => 'CASCADE', 'update' => 'CASCADE'])
->addForeignKey('broker_rut', 'brokers', 'rut', ['delete' => 'CASCADE', 'update' => 'CASCADE'])
->create();
}
}

View File

@ -4,7 +4,7 @@ declare(strict_types=1);
use Phinx\Migration\AbstractMigration;
final class CreatePromotionContractUnits extends AbstractMigration
final class CreatePromotionUnitLines extends AbstractMigration
{
/**
* Change Method.
@ -19,13 +19,11 @@ final class CreatePromotionContractUnits extends AbstractMigration
*/
public function change(): void
{
$this->table('promotion_contract_units')
$this->table('promotion_unit_lines')
->addColumn('promotion_id', 'integer', ['signed' => false, 'null' => false])
->addColumn('contract_id', 'integer', ['signed' => false, 'null' => false])
->addColumn('unit_id', 'integer', ['signed' => false, 'null' => false])
->addForeignKey('promotion_id', 'promotions', 'id', ['delete' => 'cascade', 'update' => 'cascade'])
->addForeignKey('contract_id', 'broker_contracts', 'id', ['delete' => 'cascade', 'update' => 'cascade'])
->addForeignKey('unit_id', 'unidad', 'id', ['delete' => 'cascade', 'update' => 'cascade'])
->addColumn('unit_line_id', 'integer', ['signed' => false, 'null' => false])
->addForeignKey('promotion_id', 'promotions', 'id', ['delete' => 'CASCADE', 'update' => 'CASCADE'])
->addForeignKey('unit_line_id', 'proyecto_tipo_unidad', 'id', ['delete' => 'CASCADE', 'update' => 'CASCADE'])
->create();
}
}

View File

@ -0,0 +1,31 @@
<?php
declare(strict_types=1);
use Phinx\Migration\AbstractMigration;
final class CreatePromotionUnitTypes 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('promotion_unit_types')
->addColumn('promotion_id', 'integer', ['signed' => false, 'null' => false])
->addColumn('project_id', 'integer', ['signed' => false, 'null' => false])
->addColumn('unit_type_id', 'integer', ['signed' => false, 'null' => false])
->addForeignKey('promotion_id', 'promotions', 'id', ['delete' => 'CASCADE', 'update' => 'CASCADE'])
->addForeignKey('project_id', 'proyecto', 'id', ['delete' => 'CASCADE', 'update' => 'CASCADE'])
->addForeignKey('unit_type_id', 'tipo_unidad', 'id', ['delete' => 'CASCADE', 'update' => 'CASCADE'])
->create();
}
}