public function createModel($model)
    {
        $schema = new Schema();

        $tableDef = $schema->createTable($model->getMeta()->getDbTable());
        // this assumes fields set_from_name has been invoked
        $primaryKeyFields = [];
        $unique_fields = [];
        $indexes = [];
        /** @var $field Field */
        /** @var $field ForeignKey */
        foreach ($model->getMeta()->localFields as $fname => $field) {
            $colName = $field->getColumnName();
            $type = $field->dbType($this->connection);
            // if we don't have a type skip
            if (empty($type)) {
                continue;
            }
            if ($field->primaryKey) {
                $primaryKeyFields[] = $model->getMeta()->primaryKey->getColumnName();
            } elseif ($field->isUnique()) {
                $unique_fields[] = $colName;
            } elseif ($field->dbIndex) {
                $indexes[] = $colName;
            }
            $tableDef->addColumn($colName, $type, $this->getDoctrineColumnOptions($field));
            if ($field->isRelation && $field->relation && $field->dbConstraint) {
                $relField = $field->getRelatedField();
                $tableDef->addForeignKeyConstraint(
                    $relField->scopeModel->getMeta()->getDbTable(),
                    [$field->getColumnName()],
                    [$relField->getColumnName()]
                );
            }
        }
        // create the primary key
        $tableDef->setPrimaryKey($primaryKeyFields);
        // add index constraint
        if (!empty($indexes)) {
            $tableDef->addIndex($indexes);
        }
        // add unique constraint
        if (!empty($unique_fields)) {
            $tableDef->addUniqueIndex($unique_fields);
        }
        $this->createTable($tableDef);
        // many to many
        /** @var $relationField ManyToManyField */
        foreach ($model->getMeta()->localManyToMany as $name => $relationField) {
            if ($relationField->manyToMany && $relationField->relation->through->getMeta()->autoCreated) {
                $this->createModel($relationField->relation->through);
            }
        }
    }