コード例 #1
0
ファイル: AlterField.php プロジェクト: eddmash/powerorm
 /**
  * Does the actual field alteration.
  *
  * @param SchemaEditor $schemaEditor
  * @param ProjectState $fromState
  * @param ProjectState $toState
  *
  * @since 1.1.0
  *
  * @author Eddilbert Macharia (http://eddmash.com) <*****@*****.**>
  */
 private function _alterField($schemaEditor, $fromState, $toState)
 {
     $toModel = $toState->getRegistry()->getModel($this->modelName);
     if ($this->allowMigrateModel($schemaEditor->connection, $toModel)) {
         $fromModel = $fromState->getRegistry()->getModel($this->modelName);
         $fromField = $fromModel->meta->getField($this->name);
         $toField = $toModel->meta->getField($this->name);
         if (false === $this->preserveDefault) {
             $toField->default = $this->field->default;
         }
         $schemaEditor->alterField($fromModel, $fromField, $toField);
         if (false === $this->preserveDefault) {
             $toField->default = NOT_PROVIDED;
         }
     }
 }