Name error when using a custom type imported from another file. #1517
-
Describe the bug Expected behavior To Reproduce """empty message
Revision ID: abd06113edc0
Revises: 4d3e79e25c52
Create Date: 2024-08-07 02:04:27.676951
"""
from alembic import op
import sqlalchemy as sa
from sqlalchemy.dialects import mysql
# revision identifiers, used by Alembic.
revision = 'abd06113edc0'
down_revision = '4d3e79e25c52'
branch_labels = None
depends_on = None
def upgrade():
# ### commands auto generated by Alembic - please adjust! ###
with op.batch_alter_table('encryption_keys', schema=None) as batch_op:
batch_op.alter_column('encrypted_key',
existing_type=mysql.VARCHAR(length=94),
type_=resources.db_models.custom_types.app_master_key_encrypted.AppMasterKeyEncrypted(length=95),
existing_nullable=False)
# ### end Alembic commands ###
def downgrade():
# ### commands auto generated by Alembic - please adjust! ###
with op.batch_alter_table('encryption_keys', schema=None) as batch_op:
batch_op.alter_column('encrypted_key',
existing_type=resources.db_models.custom_types.app_master_key_encrypted.AppMasterKeyEncrypted(length=95),
type_=mysql.VARCHAR(length=94),
existing_nullable=False)
# ### end Alembic commands ### from resources.db_models.custom_types.app_master_key_encrypted import \
AppMasterKeyEncrypted
class EncryptionKeyModel(db.Model):
__tablename__ = 'encryption_keys'
uuid = db.Column(db.String(36), primary_key=True)
encrypted_key = db.Column(AppMasterKeyEncrypted(94), nullable=False) Error
Versions.
|
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
hi - check out the docs at https://alembic.sqlalchemy.org/en/latest/autogenerate.html#controlling-the-module-prefix. you want to add the imports you need for all your custom types to |
Beta Was this translation helpful? Give feedback.
hi -
check out the docs at https://alembic.sqlalchemy.org/en/latest/autogenerate.html#controlling-the-module-prefix. you want to add the imports you need for all your custom types to
script.py.mako
and then set user_module_prefix appropriately