1. Michael Bayer
  2. alembic
  3. Issues


Issue #79 duplicate

autogenerate for ondelete/onupdate

Robert Kopaczewski
created an issue

Autogenerate currently doesn't pick up changes in (or new) columns with ondelete/onupdate.

e.g. modified_at = Column(DateTime(), onupdate=datetime.now) will be translated to: sa.Column('modified_at', sa.DateTime(), nullable=True),

Same for ForeignKeys with ondelete/onupdate.

Comments (4)

  1. Michael Bayer repo owner

    Column(.., onupdate=) is a Python-side only default generation function and does not apply to database migrations.

    As for foreign keys, onupdate/ondelete have an entirely different meaning, that of the cascade behavior of the FK. Auto-detection of changes in foreign keys is not supported right now, see the last section in https://alembic.readthedocs.org/en/latest/tutorial.html#auto-generating-migrations "Autogenerate can’t currently, but will eventually detect:".

  2. Log in to comment