chronomodel
chronomodel copied to clipboard
`add/remove_foreign_key` do not work on temporal tables
add_foreign_key :countries, :regions
== 20220724104350 AddRegionFkConstraints: migrating ===========================
-- add_foreign_key(:countries, :regions)
rails aborted!
StandardError: An error has occurred, this and all later migrations canceled:
PG::WrongObjectType: ERROR: "countries" is not a table or foreign table
Unfortunately
def add_foreign_key(table_name, *)
return super unless is_chrono?(table_name)
on_temporal_schema { super }
end
will not work in this case because if you want to add a foreign key between a temporal table and a normal table, on_temporal_schema
will assume that both tables are temporal, but this cannot be true, so this requires some kind of custom logic that I cannot figure out at the moment
Is there currently any other way of adding a reference to a temporal: true
-table aside from dropping and recreating the table?