This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- Courtesy | |
-- http://shuber.io/porting-activerecord-counter-cache-behavior-to-postgres/ | |
-- Counter-cache implementation for foreign-key of type UUID | |
CREATE FUNCTION increment_counter(table_name text, column_name text, id integer, step integer) | |
RETURNS VOID AS $$ | |
DECLARE | |
table_name text := quote_ident(table_name); | |
column_name text := quote_ident(column_name); |