Browse Source

Add migration fix for course_code column that shouldn't have been there in the first place

Yannick Warnier 7 years ago
parent
commit
98eb722933
1 changed files with 38 additions and 0 deletions
  1. 38 0
      app/Migrations/Schema/V111/Version20170522120000.php

+ 38 - 0
app/Migrations/Schema/V111/Version20170522120000.php

@@ -0,0 +1,38 @@
+<?php
+/* For licensing terms, see /license.txt */
+
+namespace Application\Migrations\Schema\V111;
+
+use Application\Migrations\AbstractMigrationChamilo;
+use Doctrine\DBAL\Schema\Schema;
+
+/**
+ * Class Version20170522120000
+ * Remove track_e_attempt.course_code which is deleted between 1.9 and 1.10
+ * but somehow still existed in the 1.10 entity (and it is not deleted from 
+ * 1.10 to 1.11)
+ * @package Application\Migrations\Schema\V111
+ */
+class Version20170522120000 extends AbstractMigrationChamilo
+{
+    /**
+     * @param Schema $schema
+     */
+    public function up(Schema $schema)
+    {
+        $trackEAttempt = $schema->getTable('track_e_attempt');
+
+        if ($trackEAttempt->hasColumn('course_code')) {
+            $this->addSql("ALTER TABLE track_e_attempt DROP COLUMN course_code");
+        }
+    }
+
+    /**
+     * Down does not do anything in this case because the field shouldn't
+     * have been there in the first place
+     * @param Schema $schema
+     */
+    public function down(Schema $schema)
+    {
+    }
+}