Autogenerating creates an empty migration file continually #957
Answered
by
CaselIT
ehdgua01
asked this question in
Usage Questions
-
Is it is a bug or an intended thing? I defined the from sqlalchemy.dialects import mysql
@as_declarative()
class Base:
__table_args__: tuple = (
{
"mysql_engine": "InnoDB",
"mysql_charset": "utf8mb4",
},
)
id = sa.Column(sa.BigInteger, autoincrement=True, primary_key=True)
@declarative_mixin
class TimestampMixin:
created_at = sa.Column(mysql.DATETIME(fsp=6), default=get_aware_now_datetime)
updated_at = sa.Column(mysql.DATETIME(fsp=6), default=get_aware_now_datetime, onupdate=get_aware_now_datetime)
class Service(TimestampMixin, Base):
__tablename__ = "service"
name = sa.Column(sa.String(length=64), unique=True) And, I ran below commands poetry run alembic revision --autogenerate -m first
poetry run alembic upgrade head
poetry run alembic revision --autogenerate -m second Finally, two migrations were created, but the second migration was empty. 79fce76005dc_first.py"""20211025_160438
Revision ID: 79fce76005dc
Revises:
Create Date: 2021-10-25 16:04:39.440165
"""
from alembic import op
import sqlalchemy as sa
from sqlalchemy.dialects import mysql
# revision identifiers, used by Alembic.
revision = '79fce76005dc'
down_revision = None
branch_labels = None
depends_on = None
def upgrade():
# ### commands auto generated by Alembic - please adjust! ###
op.create_table('service',
sa.Column('id', sa.BigInteger(), autoincrement=True, nullable=False),
sa.Column('created_at', mysql.DATETIME(fsp=6), nullable=True),
sa.Column('updated_at', mysql.DATETIME(fsp=6), nullable=True),
sa.Column('name', sa.String(length=64), nullable=True),
sa.PrimaryKeyConstraint('id'),
sa.UniqueConstraint('name'),
mysql_charset='utf8mb4',
mysql_engine='InnoDB'
)
# ### end Alembic commands ###
def downgrade():
# ### commands auto generated by Alembic - please adjust! ###
op.drop_table('service')
# ### end Alembic commands ### 9fc474e7b3fc_second.py"""20211025_160447
Revision ID: 9fc474e7b3fc
Revises: 79fce76005dc
Create Date: 2021-10-25 16:04:48.255282
"""
from alembic import op
import sqlalchemy as sa
# revision identifiers, used by Alembic.
revision = '9fc474e7b3fc'
down_revision = '79fce76005dc'
branch_labels = None
depends_on = None
def upgrade():
# ### commands auto generated by Alembic - please adjust! ###
pass
# ### end Alembic commands ###
def downgrade():
# ### commands auto generated by Alembic - please adjust! ###
pass
# ### end Alembic commands ### Unfortunately, empty migration was created continually when executing the above commands |
Beta Was this translation helpful? Give feedback.
Answered by
CaselIT
Oct 25, 2021
Replies: 1 comment 1 reply
-
Hi, If autogenerate does not detect any change an empty migration is created. |
Beta Was this translation helpful? Give feedback.
1 reply
Answer selected by
ehdgua01
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hi,
If autogenerate does not detect any change an empty migration is created.
This is to be expected, the command is
alembic revision
that will by default create an empty revision to be filled by the user.