m240625_222117_nivel_municipio.php 1.0 KB

123456789101112131415161718192021222324252627
  1. <?php
  2. use yii\db\Migration;
  3. class m240625_222117_nivel_municipio extends Migration {
  4. public function safeUp() {
  5. $this->createTable('NivelMunicipio', [
  6. "id" => $this->string(36),
  7. "idMunicipio" => $this->string(36),
  8. "idNivel" => $this->string(36),
  9. "creado" => $this->timestamp()->append('with time zone'),
  10. "modificado" => $this->timestamp()->append('with time zone'),
  11. "eliminado" => $this->timestamp()->append('with time zone'),
  12. ]);
  13. $this->addPrimaryKey('NivelMunicipioPK', 'NivelMunicipio', 'id');
  14. $this->addForeignKey('NivelMunicipioMunicipioFK', 'NivelMunicipio', 'idMunicipio', 'Municipio', 'id');
  15. $this->addForeignKey('NivelMunicipioNivelFK', 'NivelMunicipio', 'idNivel', 'Nivel', 'id');
  16. }
  17. public function safeDown() {
  18. $this->dropForeignKey('NivelMunicipioNivelFK', 'NivelMunicipio');
  19. $this->dropForeignKey('NivelMunicipioMunicipioFK', 'NivelMunicipio');
  20. $this->dropPrimaryKey('NivelMunicipioPK', 'NivelMunicipio');
  21. $this->dropTable('NivelMunicipio');
  22. }
  23. }