chronomodel icon indicating copy to clipboard operation
chronomodel copied to clipboard

`add/remove_foreign_key` do not work on temporal tables

Open tagliala opened this issue 2 years ago • 2 comments

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

tagliala avatar Jul 24 '22 10:07 tagliala

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

tagliala avatar Sep 29 '22 09:09 tagliala

Is there currently any other way of adding a reference to a temporal: true-table aside from dropping and recreating the table?

Zyndoras avatar Jan 13 '23 12:01 Zyndoras