Sqlalchemy:类型geoalchemy2不存在

时间:2016-08-27 20:12:02

标签: python postgresql flask sqlalchemy

我正在尝试在postgresql数据库上运行迁移,我正在使用python flask。出现以下错误:

  

类型“几何”不存在

迁移是:

    """empty message

Revision ID: a9d0c3e2ac85
Revises: 06493ef33fab
Create Date: 2016-08-28 01:00:41.022063

"""

# revision identifiers, used by Alembic.
revision = 'a9d0c3e2ac85'
down_revision = '06493ef33fab'

from alembic import op
import sqlalchemy as sa
import geoalchemy2


def upgrade():
    ### commands auto generated by Alembic - please adjust! ###
    op.add_column('location', sa.Column('coordinates', geoalchemy2.types.Geometry(geometry_type='POINT'), nullable=True))
    ### end Alembic commands ###


def downgrade():
    ### commands auto generated by Alembic - please adjust! ###
    op.drop_column('location', 'coordinates')
    ### end Alembic commands ###

我的架构是这样的:

import enum
from .extensions import db
from sqlalchemy import func
from sqlalchemy.ext.declarative import declared_attr
from geoalchemy2 import Geometry

class Location(db.Model, Entity):
name = db.Column(db.String(30))
coordinates = db.Column(Geometry('POINT'))

0 个答案:

没有答案