浏览代码

on delete cascade solo para la db

Luciano Andrade 7 年之前
父节点
当前提交
14229606c7
共有 1 个文件被更改,包括 36 次插入0 次删除
  1. 36 0
      app/DoctrineMigrations/Version20180326154629.php

+ 36 - 0
app/DoctrineMigrations/Version20180326154629.php

@@ -0,0 +1,36 @@
+<?php
+
+namespace Application\Migrations;
+
+use Doctrine\DBAL\Migrations\AbstractMigration;
+use Doctrine\DBAL\Schema\Schema;
+
+/**
+ * Auto-generated Migration: Please modify to your needs!
+ */
+class Version20180326154629 extends AbstractMigration
+{
+    /**
+     * @param Schema $schema
+     */
+    public function up(Schema $schema)
+    {
+        // this up() migration is auto-generated, please modify it to your needs
+        $this->abortIf($this->connection->getDatabasePlatform()->getName() != 'mysql', 'Migration can only be executed safely on \'mysql\'.');
+
+	$this->addSql('ALTER TABLE `service_port` DROP FOREIGN KEY `FK_8DD2E92069FFAD89`; 
+			ALTER TABLE `service_port` ADD CONSTRAINT `FK_8DD2E92069FFAD89` FOREIGN KEY (`olt_id`) REFERENCES `olt`(`id`) ON DELETE SET NULL ON UPDATE RESTRICT; 
+			ALTER TABLE `service_port` DROP FOREIGN KEY `FK_8DD2E920AB83998C`; ALTER TABLE `service_port` ADD CONSTRAINT `FK_8DD2E920AB83998C` FOREIGN KEY (`onu_id`) REFERENCES `onu`(`id`) ON DELETE CASCADE ON UPDATE RESTRICT;
+	');
+    }
+
+    /**
+     * @param Schema $schema
+     */
+    public function down(Schema $schema)
+    {
+        // this down() migration is auto-generated, please modify it to your needs
+        $this->abortIf($this->connection->getDatabasePlatform()->getName() != 'mysql', 'Migration can only be executed safely on \'mysql\'.');
+
+    }
+}