Skip to content

Conversation

@joshpencheon
Copy link
Contributor

Issue Summary

FK constraints are mistakenly not being included in SQL structure dumps (rails db:structure:dump).

Issue Details

Due to a bug that I believe was introduced quite a while ago (in #1641, fixing #1625), the DDL describing foreign keys is being discarded in favour of the DDL describing views.

I believe this was missed because the test coverage of the FK dumping tests only the standalone method that does this (#structure_dump_fk_constraints), rather than the main #structure_dump method.

PR Details

This PR ensures that both the view DDL and the foreign key DDL gets included when a structure dump is performed, and adjusts the specs accordingly.

Note on testing

I could only get a limited Oracle enviroment working, but was able to run the appropriate specs:

$ bundle exec rspec spec/active_record/connection_adapters/oracle_enhanced/structure_dump_spec.rb
==> Loading config from /Users/josh/work/forks/oracle-enhanced/spec/spec_config.yaml
==> Running specs with ruby version 2.6.3

==> Effective ActiveRecord version 6.2.0.alpha
..............................*..

Pending: (Failures listed here are expected and do not affect your suite's status)

  1) OracleEnhancedAdapter structure dump schema migrations multi insert is NOT supported should dump schema migrations one version per insert
     # Not supported in this database version
     # ./spec/active_record/connection_adapters/oracle_enhanced/structure_dump_spec.rb:376


Finished in 34.71 seconds (files took 1.16 seconds to load)
33 examples, 0 failures, 1 pending

Many thanks for all the hard work on this gem! 😃

Due to a bug, the SQL describing them was being discarded
@yahonda yahonda merged commit 126346c into rsim:master Jan 12, 2021
@yahonda
Copy link
Collaborator

yahonda commented Jan 12, 2021

Thank you for the pull request.

yahonda added a commit to yahonda/oracle-enhanced that referenced this pull request Jan 12, 2021
…inclusion-bug

Ensure FKs are properly included in structure dumps
yahonda added a commit to yahonda/oracle-enhanced that referenced this pull request Jan 12, 2021
…inclusion-bug

Ensure FKs are properly included in structure dumps
yahonda added a commit that referenced this pull request Jan 12, 2021
Merge pull request #2109 from joshpencheon/fix-fk-structure-dump-incl…
yahonda added a commit that referenced this pull request Jan 12, 2021
Merge pull request #2109 from joshpencheon/fix-fk-structure-dump-incl…
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants