Selaa lähdekoodia

Creacion de la migracion para cambiar los datos de Unidad de medida y Partida con posibilidad de nulos

Jogibeda 7 kuukautta sitten
vanhempi
commit
5e79989cc1

+ 2 - 2
migrations/m240925_184940_Creacion_tablas_Partida_Unidad_Medida.php

@@ -14,8 +14,8 @@ class m240925_184940_Creacion_tablas_Partida_Unidad_Medida extends Migration
     {
         $this->createTable('Partida', [
             "id" => $this->string(36),
-            "nombre" => $this->string(100)->notNull(),
-            "descripcion" => $this->string(100)->notNull(),
+            "nombre" => $this->string(100),
+            "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"),

+ 47 - 0
migrations/m240926_211958_Ajuste_campos_partida_unidad_de_medida.php

@@ -0,0 +1,47 @@
+<?php
+
+use yii\db\Migration;
+
+/**
+ * Class m240926_211958_Ajuste_campos_partida_unidad_de_medida
+ */
+class m240926_211958_Ajuste_campos_partida_unidad_de_medida extends Migration
+{
+    /**
+     * {@inheritdoc}
+     */
+    public function safeUp()
+    { 
+        $this->alterColumn('UnidadMedida', 'nombre', $this->string(100)->null());
+        $this->alterColumn('UnidadMedida', 'descripcion', $this->string(100)->null());
+        $this->alterColumn('Partida', 'nombre', $this->string(100)->null());
+        $this->alterColumn('Partida', 'descripcion', $this->string(100)->null());
+
+    }
+
+    /**
+     * {@inheritdoc}
+     */
+    public function safeDown()
+    {
+        $this->alterColumn('UnidadMedida', 'nombre', $this->string(100)->notNull());
+        $this->alterColumn('UnidadMedida', 'descripcion', $this->string(100)->notNull());
+        $this->alterColumn('Partida', 'nombre', $this->string(100)->notNull());
+        $this->alterColumn('Partida', 'descripcion', $this->string(100)->notNull());
+    }
+
+    /*
+    // Use up()/down() to run migration code without a transaction.
+    public function up()
+    {
+
+    }
+
+    public function down()
+    {
+        echo "m240926_211958_Ajuste_campos_partida_unidad_de_medida cannot be reverted.\n";
+
+        return false;
+    }
+    */
+}