【问题标题】:Alembic detects changes but produces empty migration with --autogenerateAlembic 检测到更改,但使用 --autogenerate 生成空迁移
【发布时间】:2013-05-25 08:57:19
【问题描述】:

我正在尝试使用 --autogenerate 标志让 alembic 工作自动生成迁移。

当我运行 alembic -n mydbname --autogenerate -m "my message" 时,我会得到类似的信息:

INFO  [alembic.migration] Context impl MySQLImpl.
INFO  [alembic.migration] Will assume non-transactional DDL.
INFO  [alembic.autogenerate] Detected removed table u'some_table'
INFO  [alembic.autogenerate] Detected NULL on column 'table_a.column_a'
INFO  [alembic.autogenerate] Detected added column 'table_b.column_b'
.......

但是当我查看生成的迁移文件时,upgradedowngrade 都只是说pass

发生了什么事?!

【问题讨论】:

    标签: python mysql migration sqlalchemy alembic


    【解决方案1】:

    您是否使用多数据库迁移?如果是这样,他们目前有点错误。解决方案是将 env.py 中的 context.configure 更改为如下所示:

    context.configure(
        connection=rec['connection'],
        upgrade_token="%s_upgrades" % name,
        downgrade_token="%s_downgrades" % name,
        target_metadata=target_metadata.get(name)
    )
    

    (source)

    【讨论】:

      猜你喜欢
      • 2013-03-17
      • 1970-01-01
      • 2019-04-30
      • 2022-11-10
      • 1970-01-01
      • 1970-01-01
      • 2012-06-26
      • 2020-11-05
      • 2013-06-16
      相关资源
      最近更新 更多