|
@@ -3,54 +3,27 @@
|
|
|
use yii\db\Migration;
|
|
|
|
|
|
/**
|
|
|
- * Class m240813_184024_actualizacion_de_Vehiculo
|
|
|
+ * Class m240813_184024_actualizacion_de_Vehiculo, PERO ES LA CREACIÓN DE LA TABLA "Color"
|
|
|
*/
|
|
|
-class m240813_184024_actualizacion_de_Vehiculo extends Migration
|
|
|
-{
|
|
|
- /**
|
|
|
- * {@inheritdoc}
|
|
|
- */
|
|
|
- public function safeUp()
|
|
|
- {
|
|
|
- $this->renameColumn('Vehiculo', 'color', 'idColor');
|
|
|
- $this->renameColumn('Vehiculo', 'tipo', 'idTipo');
|
|
|
- $this->renameColumn('Vehiculo', 'marca', 'idMarca');
|
|
|
-
|
|
|
- // Agregar la llave foránea a "idTipo" que hace referencia a la columna "id" en la tabla "related_table"
|
|
|
- $this->addForeignKey("VehiculoColorFK", "Vehiculo", "idColor", "Color", "id");
|
|
|
- $this->addForeignKey("VehiculoTipoFK", "Vehiculo", "idTipo", "TipoAuto", "id");
|
|
|
- $this->addForeignKey("VehiculoMarcaFK", "Vehiculo", "idMarca", "Marca", "id");
|
|
|
-
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * {@inheritdoc}
|
|
|
- */
|
|
|
- public function safeDown()
|
|
|
- {
|
|
|
- $this->dropForeignKey('VehiculoColorFK', 'Vehiculo');
|
|
|
- $this->dropForeignKey('VehiculoTipoFK', 'Vehiculo');
|
|
|
- $this->dropForeignKey('VehiculoMarcaFK', 'Vehiculo');
|
|
|
- // Renombrar la columna "idTipo" de vuelta a "tipo"
|
|
|
- $this->renameColumn('Vehiculo', 'idTipo', 'tipo');
|
|
|
- $this->renameColumn('Vehiculo', 'idMarca', 'marca');
|
|
|
- $this->renameColumn('Vehiculo', 'idColor', 'color');
|
|
|
-
|
|
|
-
|
|
|
- }
|
|
|
-
|
|
|
- /*
|
|
|
- // Use up()/down() to run migration code without a transaction.
|
|
|
- public function up()
|
|
|
- {
|
|
|
-
|
|
|
- }
|
|
|
-
|
|
|
- public function down()
|
|
|
- {
|
|
|
- echo "m240813_184024_actualizacion_de_Vehiculo cannot be reverted.\n";
|
|
|
-
|
|
|
- return false;
|
|
|
- }
|
|
|
- */
|
|
|
+class m240813_184024_actualizacion_de_Vehiculo extends Migration {
|
|
|
+ public function safeUp() {
|
|
|
+ $this->createTable('Color', [
|
|
|
+ "id" => $this->string(36),
|
|
|
+ "clave" => $this->string(100)->notNull(),
|
|
|
+ "color" => $this->string(100)->notNull(),
|
|
|
+ "descripcion" => $this->string(100),
|
|
|
+ "creado" => $this->timestamp()->append(" with time zone"),
|
|
|
+ "modificado" => $this->timestamp()->append(" with time zone"),
|
|
|
+ "eliminado" => $this->timestamp()->append(" with time zone"),
|
|
|
+ ]);
|
|
|
+
|
|
|
+ $this->addPrimaryKey('ColorPK', 'Color', 'id');
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * {@inheritdoc}
|
|
|
+ */
|
|
|
+ public function safeDown() {
|
|
|
+ $this->dropTable("Color");
|
|
|
+ }
|
|
|
}
|