Browse Source

FD3-295 migración link y slot para ONU

Guillermo Espinoza 7 years ago
parent
commit
f40e0a6a44
2 changed files with 40 additions and 2 deletions
  1. 34 0
      app/DoctrineMigrations/Version20171107185545.php
  2. 6 2
      src/FTTHBundle/Entity/ONU.php

+ 34 - 0
app/DoctrineMigrations/Version20171107185545.php

@@ -0,0 +1,34 @@
+<?php
+
+namespace Application\Migrations;
+
+use Doctrine\DBAL\Migrations\AbstractMigration;
+use Doctrine\DBAL\Schema\Schema;
+
+/**
+ * Auto-generated Migration: Please modify to your needs!
+ */
+class Version20171107185545 extends AbstractMigration
+{
+    /**
+     * @param Schema $schema
+     */
+    public function up(Schema $schema)
+    {
+        $this->addsql(
+            "UPDATE onu AS o 
+            JOIN nap AS n ON o.nap_id = n.id
+            SET o.link = JSON_EXTRACT(n.extra_data, '$.link'), o.slot = JSON_EXTRACT(n.extra_data, '$.slot')
+            WHERE o.link=0 AND o.slot=0;"
+        );
+    }
+
+    /**
+     * @param Schema $schema
+     */
+    public function down(Schema $schema)
+    {
+        // this down() migration is auto-generated, please modify it to your needs
+
+    }
+}

+ 6 - 2
src/FTTHBundle/Entity/ONU.php

@@ -150,14 +150,18 @@ class ONU implements DeviceInterface, TenancyIdTraitInterface, LocationInterface
     /**
      * @var int
      * 
-     * @ORM\Column(type="integer", nullable=true)
+     * @ORM\Column(type="integer", options={"default": "0"})
+     * 
+     * @Assert\NotNull
      */
     protected $slot;
     
     /**
      * @var int
      * 
-     * @ORM\Column(type="integer", nullable=true)
+     * @ORM\Column(type="integer", options={"default": "0"})
+     * 
+     * @Assert\NotNull
      */
     protected $link;