Browse Source

FD3-515 composer

Espinoza Guillermo 7 năm trước cách đây
mục cha
commit
be6df6c085
2 tập tin đã thay đổi với 34 bổ sung34 xóa
  1. 32 34
      app/DoctrineMigrations/Version20180221174411.php
  2. 2 0
      composer.json

+ 32 - 34
app/DoctrineMigrations/Version20180221174411.php

@@ -16,46 +16,44 @@ class Version20180221174411 extends MigrationsBase
      */
     public function up(Schema $schema)
     {
-	
-        $this->abortIf($this->connection->getDatabasePlatform()->getName() != 'mysql', 'Migration can only be executed safely on \'mysql\'.');
 
+        $this->abortIf($this->connection->getDatabasePlatform()->getName() != 'mysql', 'Migration can only be executed safely on \'mysql\'.');
 
-	if (!$schema->hasTable('service_port') == true) {
-		$this->addSql('CREATE TABLE service_port (id INT AUTO_INCREMENT NOT NULL, olt_id BIGINT DEFAULT NULL, onu_id INT DEFAULT NULL, number INT DEFAULT 0 NOT NULL, gemport INT DEFAULT 0 NOT NULL, vlan INT DEFAULT 0 NOT NULL, type VARCHAR(255) NOT NULL, INDEX IDX_8DD2E92069FFAD89 (olt_id), INDEX IDX_8DD2E920AB83998C (onu_id), UNIQUE INDEX sp_unique (olt_id, number), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci ENGINE = InnoDB');
-		$this->addSql('ALTER TABLE service_port ADD CONSTRAINT FK_8DD2E92069FFAD89 FOREIGN KEY (olt_id) REFERENCES olt (id)');
-		$this->addSql('ALTER TABLE service_port ADD CONSTRAINT FK_8DD2E920AB83998C FOREIGN KEY (onu_id) REFERENCES onu (id)');
-		$this->addSql('ALTER TABLE olt CHANGE execute_snmp execute_snmp BOOLEAN DEFAULT TRUE');
-		$this->addSql('ALTER TABLE olt_audit CHANGE execute_snmp execute_snmp BOOLEAN DEFAULT TRUE');
-	}
 
-	$result = $this->connection->query("select o.id id, o.olt_id, nap_id, pon_serial_number, position, slot, link, ot.name FROM onu o JOIN nap n ON (n.id = o.nap_id) JOIN olt t ON (t.id = o.olt_id) JOIN oltmodel ot ON(t.model_id = ot.id) WHERE  o.deleted_at IS NULL AND ot.name LIKE 'Huawei MA5608T';");
+    if (!$schema->hasTable('service_port') == true) {
+        $this->addSql('CREATE TABLE service_port (id INT AUTO_INCREMENT NOT NULL, olt_id BIGINT DEFAULT NULL, onu_id INT DEFAULT NULL, number INT DEFAULT 0 NOT NULL, gemport INT DEFAULT 0 NOT NULL, vlan INT DEFAULT 0 NOT NULL, type VARCHAR(255) NOT NULL, INDEX IDX_8DD2E92069FFAD89 (olt_id), INDEX IDX_8DD2E920AB83998C (onu_id), UNIQUE INDEX sp_unique (olt_id, number), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci ENGINE = InnoDB');
+        $this->addSql('ALTER TABLE service_port ADD CONSTRAINT FK_8DD2E92069FFAD89 FOREIGN KEY (olt_id) REFERENCES olt (id)');
+        $this->addSql('ALTER TABLE service_port ADD CONSTRAINT FK_8DD2E920AB83998C FOREIGN KEY (onu_id) REFERENCES onu (id)');
+        $this->addSql('ALTER TABLE olt CHANGE execute_snmp execute_snmp BOOLEAN DEFAULT TRUE');
+        $this->addSql('ALTER TABLE olt_audit CHANGE execute_snmp execute_snmp BOOLEAN DEFAULT TRUE');
+    }
 
-	$i = 0;
-	$vlangemport_config = array('voip' => array('gemport' => 0, 'vlan' => 13), 'data' => array('gemport' => 1, 'vlan' => 10));
-	while($rtr = $result->fetch()){
-		$i++;
-		$pon_serial_number = $rtr['pon_serial_number'];
-		$slot = $rtr['slot'];
-		$link = $rtr['link'];
-		$position = $rtr['position'];
-		$olt_id = $rtr['olt_id'];
-		$onu_id = $rtr['id'];
-		$service_port = array(
-			//{% set service_port_data =  "1" ~  slot  ~  link  ~  ("%02d" | format(onu)) %}
-			"data" => "1" .  $slot  . $link  . sprintf ("%02d",  $position),
+    $result = $this->connection->query("select o.id id, o.olt_id, nap_id, pon_serial_number, position, slot, link, ot.name FROM onu o JOIN nap n ON (n.id = o.nap_id) JOIN olt t ON (t.id = o.olt_id) JOIN oltmodel ot ON(t.model_id = ot.id) WHERE  o.deleted_at IS NULL AND ot.name LIKE 'Huawei MA5608T';");
 
-			//{% set service_port_voip =  "2" ~  slot  ~  link  ~  ("%02d" | format(onu)) %}
-			"voip" => "2" .  $slot  . $link  . sprintf ("%02d",  $position),
-		);
-		foreach($service_port as $type => $number){
-			$gemport = $vlangemport_config[$type]['gemport'];
-			$vlan = $vlangemport_config[$type]['vlan'];
-			$sql = "REPLACE INTO service_port (olt_id, onu_id, number, type, gemport, vlan) VALUES ($olt_id, $onu_id, $number, '$type', $gemport, $vlan);";
-			$this->addSql($sql);
-		}
-	}
+    $i = 0;
+    $vlangemport_config = array('voip' => array('gemport' => 0, 'vlan' => 13), 'data' => array('gemport' => 1, 'vlan' => 10));
+    while($rtr = $result->fetch()){
+        $i++;
+        $pon_serial_number = $rtr['pon_serial_number'];
+        $slot = $rtr['slot'];
+        $link = $rtr['link'];
+        $position = $rtr['position'];
+        $olt_id = $rtr['olt_id'];
+        $onu_id = $rtr['id'];
+        $service_port = array(
+            //{% set service_port_data =  "1" ~  slot  ~  link  ~  ("%02d" | format(onu)) %}
+            "data" => "1" .  $slot  . $link  . sprintf ("%02d",  $position),
 
-	$this->executeYaml(__DIR__ . "/Templates20180221174411", "template-action-2018-02-26.yml");
+            //{% set service_port_voip =  "2" ~  slot  ~  link  ~  ("%02d" | format(onu)) %}
+            "voip" => "2" .  $slot  . $link  . sprintf ("%02d",  $position),
+        );
+        foreach($service_port as $type => $number){
+            $gemport = $vlangemport_config[$type]['gemport'];
+            $vlan = $vlangemport_config[$type]['vlan'];
+            $sql = "REPLACE INTO service_port (olt_id, onu_id, number, type, gemport, vlan) VALUES ($olt_id, $onu_id, $number, '$type', $gemport, $vlan);";
+            $this->addSql($sql);
+        }
+    }
 
     }
 

+ 2 - 0
composer.json

@@ -194,6 +194,7 @@
         ],
         "mkdir-dir-cache-sessions-logs": "mkdir -p var/cache var/logs var/sessions",
         "chmod-dir-cache-sessions-logs": "chmod 777 -R var/cache var/logs var/sessions",
+        "doctrine-migrations-down": "php bin/console doctrine:migrations:migrate --no-interaction first -vvv",
         "doctrine-migrations": "php bin/console doctrine:migrations:migrate --no-interaction -vvv",
         "doctrine-update": "php bin/console doctrine:schema:update --force",
         "auto-increment": "php bin/console baseadmin:autoincrement",
@@ -204,6 +205,7 @@
             "@chmod-dir-cache-sessions-logs",
             "@doctrine-update",
             "@auto-increment",
+            "@doctrine-migrations-down",
             "@doctrine-migrations"
         ],
         "post-update-cmd": [