public function toModel(&$registry)
    {
        $metaData = $this->getMeta();
        $extends = $this->extends;

        $className = $this->name;

        // if we are loading migrations from disk we need to namespace different
        // so that we can be able to compare the two states. this way we avoid
        // possibility of loading the same state information about an app
        // i.e. we might end up always loading the state of the apps based on
        // whats currently shown the models
        if ($this->fromDisk) {
            $className = sprintf(
                '%s\\%s',
                Model::FAKENAMESPACE,
                $className
            );
            if ($extends) {
                $extends = sprintf(
                    '%s\\%s',
                    Model::FAKENAMESPACE,
                    $extends
                );
            }
        }

        $model = $this->createInstance(
            $className,
            $extends,
            ['registry' => $registry]
        );
        $fields = [];
        foreach ($this->fields as $name => $field) {
            $fields[$name] = $field->deepClone();
        }

        $model->setupClassInfo($fields, ['meta' => $metaData, 'registry' => $registry]);

        return $model;
    }