Previously a889deb tried to create a Gem::Version out of a module rather than the full version string, causing: ArgumentError: Malformed version number string ActiveRecord::VERSION This fixes broken tests (https://travis-ci.org/matthuhiggins/foreigner/builds/56370433) and db:migrate on Rails 3.2.
When using Foreigner on Rails 4.1.9 and trying to run `schema::load` Foreigner has not been initialized yet so this methods don't exist. This change was introduced by the following Rails commit: * (rails/rails@5d6bb89) So in order to ensure Foreigner has been initialized and methods are present for `schema::load` to work correctly, we include `Foreigner.load` inside the `schema.rb` file before any of the foreign key methods. Also: * Introduce Foreigner::Helper to store class level helpers * Simplify the way to determine which version of ActiveRecord is using
When a foreign key has no ON DELETE or additional options, and is followed by a comma (i.e. the first of many), then the trailing comma was incorrectly parsed as a constraint option. This caused 'options: ","' to appear in schema.rb.
basically any valid db-specific thing that you can already specify via `options: "..."` will be preserved on the way back out. for mysql that's: * `ON UPDATE <action>` for postgres that's: * `ON UPDATE <action>` * `ON DELETE SET DEFAULT` (doesn't map to a `:dependent` value) * `DEFERRABLE` (`NOT DEFERRABLE` is the default) * `INITIALLY DEFERRED` (`INITIALLY IMMEDIATE` is the default) * `NOT VALID` postgres' `MATCH <type>` is not supported, but that's already problematic for `:options` since it is incompatible with `:dependent` (due to where it appears in the statement), so ¯\_(ツ)_/¯