Monday, February 22, 2016

Put Your Finger on Triggers in Rails with HairTrigger

Configuration Icon. Vector Illustration" width="300" height="300" class="size-medium wp-image-125265" />

HairTrigger enables Ruby on Rails applications to create and manage database triggers in a concise and database agnostic way. Without it, implementing database triggers in a Rails application would require database specific knowledge on creating stored procedures with desired SQL statements to do database operations.

In this article, you will be given a short introduction to database triggers, along with a comparison between using Active Record callbacks and database triggers. This article will also explain the key points of implementing database triggers using HairTrigger. For complete information of the HairTrigger API, please refer to the official documentation.

To have a good starting point, you will be provided a use case of implementing database triggers using HairTrigger. The use case demonstrates a denormalization strategy that requires implementing database triggers to aggregate and synchronize data between tables. The full source code of the implementation is available on Github as a reference.

Continue reading %Put Your Finger on Triggers in Rails with HairTrigger%


by Hendra Uzia via SitePoint

No comments:

Post a Comment