12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364 |
- <?php
- use yii\db\Migration;
- /**
- * Class m240515_224734_estado_municipio
- */
- class m240515_224734_estado_municipio extends Migration {
- /**
- * {@inheritdoc}
- */
- public function safeUp() {
- $this->createTable("Estado", [
- "id" => $this->string(36),
- "nombre" => $this->string(100),
- "abreviacion" => $this->string(16),
- "creado" => $this->timestamp(),
- "modificado" => $this->timestamp(),
- "eliminado" => $this->timestamp(),
- ]);
- $this->addPrimaryKey("EstadoPK", "Estado", "id");
- $this->createTable("Municipio", [
- "id" => $this->string(36),
- "nombre" => $this->string(100),
- "idEstado" => $this->string(36),
- "creado" => $this->timestamp(),
- "modificado" => $this->timestamp(),
- "eliminado" => $this->timestamp(),
- ]);
- $this->addPrimaryKey("MunicipioPK", "Municipio", "id");
- $this->addForeignKey("MunicipioEstadoIdFK", "Municipio", "idEstado", "Estado", "id");
- }
- /**
- * {@inheritdoc}
- */
- public function safeDown() {
- $this->dropForeignKey("MunicipioEstadoIdFK", "Municipio");
- $this->dropPrimaryKey("EstadoPK", "Estado");
- $this->dropPrimaryKey("MunicipioPK", "Municipio");
- $this->dropTable("Municipio");
- $this->dropTable("Estado");
- }
- /*
- // Use up()/down() to run migration code without a transaction.
- public function up()
- {
- }
- public function down()
- {
- echo "m240515_224734_estado_municipio cannot be reverted.\n";
- return false;
- }
- */
- }
|