m241016_185927_Tabla_Gasto_y_Pagos_creacion.php 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. <?php
  2. use yii\db\Migration;
  3. /**
  4. * Class m241016_185927_Tabla_Gasto_y_Pagos_creacion
  5. */
  6. class m241016_185927_Tabla_Gasto_y_Pagos_creacion extends Migration
  7. {
  8. /**
  9. * {@inheritdoc}
  10. */
  11. public function safeUp()
  12. {
  13. $this->createTable('Gasto', [
  14. "id" => $this->string(36),
  15. "idObra" => $this->string(36),
  16. "idConceptoObra" => $this->string(36),
  17. "cantidad" => $this->integer(),
  18. "descripcion" => $this->string(100),
  19. "fechaCompra" => $this->timestamp()->append(" with time zone"),
  20. "creado" => $this->timestamp()->append(" with time zone"),
  21. "modificado" => $this->timestamp()->append(" with time zone"),
  22. "eliminado" => $this->timestamp()->append(" with time zone"),
  23. ]);
  24. $this->addForeignKey("GastoObraFK", "Gasto", "idObra", "Obra", "id");
  25. $this->addForeignKey("GastoConceptoFK", "Gasto", "idConceptoObra", "ConceptoObra", "id");
  26. $this->addPrimaryKey('GastoPK', 'Gasto', 'id');
  27. $this->createTable('Pago', [
  28. "id" => $this->string(36),
  29. "idObra" => $this->string(36),
  30. "idConceptoObra" => $this->string(36),
  31. "cantidad" => $this->integer(),
  32. "descripcion" => $this->string(100),
  33. "fechaPago" => $this->timestamp()->append(" with time zone"),
  34. "creado" => $this->timestamp()->append(" with time zone"),
  35. "modificado" => $this->timestamp()->append(" with time zone"),
  36. "eliminado" => $this->timestamp()->append(" with time zone"),
  37. ]);
  38. $this->addForeignKey("PagoObraFK", "Pago", "idObra", "Obra", "id");
  39. $this->addForeignKey("PagoConceptoFK", "Pago", "idConceptoObra", "ConceptoObra", "id");
  40. $this->addPrimaryKey('PagoPK', 'Pago', 'id');
  41. }
  42. /**
  43. * {@inheritdoc}
  44. */
  45. public function safeDown()
  46. {
  47. $this->dropForeignKey("GastoObra", "Gasto");
  48. $this->dropForeignKey("GastoConcepto", "Gasto");
  49. $this->dropTable('Gasto');
  50. $this->dropForeignKey("PagoObra", "Pago");
  51. $this->dropForeignKey("PagoConcepto", "Pago");
  52. $this->dropTable('Pago');
  53. }
  54. /*
  55. // Use up()/down() to run migration code without a transaction.
  56. public function up()
  57. {
  58. }
  59. public function down()
  60. {
  61. echo "m241016_185927_Tabla_Gasto_y_Pagos_creacion cannot be reverted.\n";
  62. return false;
  63. }
  64. */
  65. }