SQLalchemy migrate 对之前版本文件进行修改

问题描述 投票:0回答:0

为什么我会收到这个错误?

  File "/Users/user1/Development/projects/zen/zen_api/zen_api/migrations/versions/ab4404d743ac_.py", line 24, in upgrade
    sa.Column("expires_at", sa.NullType(), nullable=False),
                            ^^^^^^^^^^^
AttributeError: module 'sqlalchemy' has no attribute 'NullType'. Did you mean: 'TupleType'?

我运行

flask db migrate
尝试将更新推送到我的表。我注意到正在编辑我的第一个版本文件。我期待创建一个新文件。这是第一个文件的一些内容。

"""empty message

Revision ID: ab4404d743ac
Revises: fbaa8bda9a8b
Create Date: 2023-04-26 00:00:29.089871

"""
from alembic import op
import sqlalchemy as sa

# revision identifiers, used by Alembic.
revision = "ab4404d743ac"
down_revision = "fbaa8bda9a8b"
branch_labels = None
depends_on = None


def upgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.create_table(
        "refresh_token_blocklist",
        sa.Column("jti", sa.UUID(), nullable=False),
        sa.Column("expires_at", sa.NullType(), nullable=False),
        sa.Column("refresh_token", sa.NullType(), nullable=False),
        sa.Column("created_at", sa.DateTime(), nullable=False),
        sa.PrimaryKeyConstraint("jti"),
    )

我在用

flask = "^2.2.3"
flask-sqlalchemy = "^3.0.3"
flask-migrate = "^4.0.4"
flask flask-sqlalchemy flask-migrate
© www.soinside.com 2019 - 2024. All rights reserved.