Why am I getting this error?
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'?
I ran flask db migrate
to try to push updates to my tables. I noticed that my FIRST versions file was being edited. I was expecting a new file to be created. This is some of the contents of the first file.
"""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"),
)
with op.batch_alter_table("refresh_token_blocklist", schema=None) as batch_op:
batch_op.create_index(
batch_op.f("ix_refresh_token_blocklist_jti"), ["jti"], unique=False
)
# ### end Alembic commands ###
def downgrade():
# ### commands auto generated by Alembic - please adjust! ###
with op.batch_alter_table("refresh_token_blocklist", schema=None) as batch_op:
batch_op.drop_index(batch_op.f("ix_refresh_token_blocklist_jti"))
op.drop_table("refresh_token_blocklist")
# ### end Alembic commands ###
Second file
"""empty message
Revision ID: fbaa8bda9a8b
Revises:
Create Date: 2023-04-23 01:07:46.538734
"""
from alembic import op
import sqlalchemy as sa
# revision identifiers, used by Alembic.
revision = "fbaa8bda9a8b"
down_revision = None
branch_labels = None
depends_on = None
def upgrade():
# ### commands auto generated by Alembic - please adjust! ###
op.create_table(
"property",
sa.Column("id", sa.UUID(), nullable=False),
sa.Column("created_at", sa.DateTime(), nullable=False),
sa.Column("updated_at", sa.DateTime(), nullable=False),
sa.PrimaryKeyConstraint("id"),
)
op.create_table(
"user",
sa.Column("id", sa.UUID(), nullable=False),
sa.Column("first_name", sa.String(length=128), nullable=False),
sa.Column("last_name", sa.String(length=128), nullable=False),
sa.Column("email", sa.String(length=128), nullable=False),
sa.Column("password_hash", sa.String(length=128), nullable=True),
sa.Column("phone_number", sa.String(length=10), nullable=True),
sa.Column("created_at", sa.DateTime(), nullable=False),
sa.Column("updated_at", sa.DateTime(), nullable=False),
sa.PrimaryKeyConstraint("id"),
)
with op.batch_alter_table("user", schema=None) as batch_op:
batch_op.create_index(batch_op.f("ix_user_email"), ["email"], unique=True)
op.create_table(
"review",
sa.Column("id", sa.UUID(), nullable=False),
sa.Column("user_id", sa.UUID(), nullable=True),
sa.Column("rating", sa.Integer(), nullable=True),
sa.Column("comment", sa.Text(), nullable=True),
sa.Column("created_at", sa.DateTime(), nullable=False),
sa.Column("updated_at", sa.DateTime(), nullable=False),
sa.ForeignKeyConstraint(
["user_id"],
["user.id"],
),
sa.PrimaryKeyConstraint("id"),
)
# ### end Alembic commands ###
def downgrade():
# ### commands auto generated by Alembic - please adjust! ###
op.drop_table("review")
with op.batch_alter_table("user", schema=None) as batch_op:
batch_op.drop_index(batch_op.f("ix_user_email"))
op.drop_table("user")
op.drop_table("property")
# ### end Alembic commands ###
I'm using
flask = "^2.2.3"
flask-sqlalchemy = "^3.0.3"
flask-migrate = "^4.0.4"