You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
As I understand it this would hold a lock on the users table.
I couldn't find a way to detect this with a custom check. This monkey patch seems to work but I'm wondering if this should make it's way into Strong Migrations itself or if there's a better way to achieve it.
# Prevent foreign keys being defined with t.references e.g.# t.references :x, foreign_key: true# t.references :x, foreign_key: {}classActiveRecord::ConnectionAdapters::ReferenceDefinitionalias_method:__add_to__,:add_todefadd_to(table)ifforeign_keyraiseArgumentErrorend__add_to__(table)endend# Prevent foreign keys being defined within column definitions e.g.# t.bigint :x_id, foreign_key: true# t.bigint :x_id, foreign_key: {}classActiveRecord::ConnectionAdapters::TableDefinitionalias_method:__column__,:columndefcolumn(name,type,index: nil, **options)ifoptions[:foreign_key]raiseArgumentErrorend__column__(name,type,index: index, **options)endend
Thanks! 🙏
The text was updated successfully, but these errors were encountered:
It doesn't appear like adding foreign keys within
create_table
are detected as unsafe. e.g.As I understand it this would hold a lock on the users table.
I couldn't find a way to detect this with a custom check. This monkey patch seems to work but I'm wondering if this should make it's way into Strong Migrations itself or if there's a better way to achieve it.
Thanks! 🙏
The text was updated successfully, but these errors were encountered: