Example #1
0
 /**
  *  Content to be added for the down migration
  *
  * @param bool $tableCreated
  * @param string $tableName
  * @return string
  */
 private function migrationDownContents($tableCreated, $tableName)
 {
     $removedProperties = $this->model->getPropertiesToRemove();
     $functionContents = "";
     if (!$tableCreated) {
         $functionContents = "\t\tSchema::dropIfExists('" . $tableName . "');\n";
     } else {
         if (!empty($this->columnsAdded)) {
             $functionContents = $this->removePropertiesFromTable($tableName);
         } else {
             if (!empty($removedProperties)) {
                 $functionContents = $this->addPropertiesToTable($tableName, $removedProperties);
             }
         }
         $removedRelationships = $this->model->getRelationshipsToRemove();
         if (!empty($removedRelationships)) {
             $functionContents = $this->rollbackForRemovedProperties($removedRelationships, $tableName);
         }
     }
     return $functionContents;
 }