each other via UPDATE before a DELETE is emitted. The flag should
be placed on just *one* of the relationships, preferably the
many-to-one side. Below we illustrate
-a complete example, including two :class:`.ForeignKey` constructs, one which
-specifies :paramref:`~.ForeignKey.use_alter` to help with emitting CREATE TABLE statements::
+a complete example, including two :class:`.ForeignKey` constructs::
from sqlalchemy import Integer, ForeignKey, Column
from sqlalchemy.ext.declarative import declarative_base
widget_id = Column(Integer, primary_key=True)
favorite_entry_id = Column(Integer,
ForeignKey('entry.entry_id',
- use_alter=True,
name="fk_favorite_entry"))
name = Column(String(50))
ForeignKeyConstraint(
["widget_id", "favorite_entry_id"],
["entry.widget_id", "entry.entry_id"],
- name="fk_favorite_entry", use_alter=True
+ name="fk_favorite_entry"
),
)
or pre-deassociate one of the foreign key constrained values.
The ``post_update`` flag described at :ref:`post_update` can resolve
this cycle.
- * In a :meth:`.MetaData.create_all`, :meth:`.MetaData.drop_all`,
- :attr:`.MetaData.sorted_tables` operation, two :class:`.ForeignKey`
+ * In a :attr:`.MetaData.sorted_tables` operation, two :class:`.ForeignKey`
or :class:`.ForeignKeyConstraint` objects mutually refer to each
other. Apply the ``use_alter=True`` flag to one or both,
see :ref:`use_alter`.