Immigrant

screenshot of Immigrant

Foreign key migration generator for Rails

Overview

Immigrant is a powerful tool for Rails developers that streamlines the process of managing foreign keys within your database schemas. For those experienced with Rails applications, it can be cumbersome to add foreign keys to an established app, especially when missing associations can lead to potential data integrity issues. With Immigrant, the process becomes effortless, allowing you to ensure that your models are properly linked without the headache of manually checking every association.

This gem provides a migration generator that quickly identifies any missing foreign keys based on the associations defined in your models. It’s an essential tool that not only saves time but also reduces the likelihood of errors that can arise during migration efforts.

Features

  • Effortless Foreign Key Management: Automatically detects and adds any missing foreign keys based on existing model associations, making migrations a breeze.
  • Migration Generator: Creates a migration named AddKeys that includes add_foreign_key statements only for keys that are missing, ensuring existing keys remain untouched.
  • Rake Task for Continuous Integration: Incorporate a handy rake task into your CI setup with rake immigrant:check_keys, which alerts you to any missing foreign keys, improving your development workflow.
  • Configurable Ignored Keys: Use Immigrant.ignore_keys to specify keys to ignore during migration generation and rake checking, especially useful for associations that span multiple databases.
  • Robust Error Handling: Highlights potential issues before running migrations, ensuring that orphaned records do not cause failures.
  • Compatibility with Older Versions: Works seamlessly with Rails applications pre-4.2, requiring only the addition of the Foreigner gem for those setups.
  • Initial Configuration: Simple initializer file set up to manage ignored keys quickly and effectively for your specific application needs.