Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added foregin_key to the allowed validation options for managing columns and tables in migration #4

Closed

Conversation

soartec-lab
Copy link
Owner

@soartec-lab soartec-lab commented Jun 16, 2023

Motivation / Background

This Pull Request has been created because raise an error when adding columns in a new migration if foregin_key is included.

Detail

This Pull Request changes fix an error when adding columns in a new migration if foregin_key is included.
The error occurs in cases where foregin_key is specified such as add_reference in an old migration definition. For example, the bellow:

class ChangeTableUsers < ActiveRecord::Migration[6.0]
  def change
    add_reference :users, :posts, foregin_key: true
  end
end

#=> eval error: Unknown key: :foregin_key. Valid keys are: :limit, :precision, :scale, :default, :null, :collation, :comment, :primary_key, :if_exists, :if_not_exists, :auto_increment, :charset, :as, :size, :unsigned, :first, :after, :type, :stored

An error is generated if an option other than the allowed option is entered. The foregin_key is not included in the allowed options, but it is necessary, so it was added.

Also, add_reference is now compatible with lower versions.

Additional information

Checklist

Before submitting the PR make sure the following are checked:

  • This Pull Request is related to one change. Changes that are unrelated should be opened in separate PRs.
  • Commit message has a detailed description of what changed and why. If this PR fixes a related issue include it in the commit message. Ex: [Fix #issue-number]
  • Tests are added or updated if you fix a bug or add a feature.
  • CHANGELOG files are updated for the changed libraries if there is a behavior change or additional feature. Minor bug fixes and documentation changes should not be included.

@soartec-lab soartec-lab force-pushed the fix/added-foregin_key-to-allowed-migration-options branch from 857b605 to ac74887 Compare June 16, 2023 07:15
@soartec-lab soartec-lab deleted the fix/added-foregin_key-to-allowed-migration-options branch June 19, 2023 01:07
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.

1 participant