Sha256: d7baaca0c74076e0cdad4a596da47314d21aa49d51f5a7a999c5ef5e6412efe1
Contents?: true
Size: 891 Bytes
Versions: 1
Compression:
Stored size: 891 Bytes
Contents
class AddVarietalAliasesTrigger < ActiveRecord::Migration def up execute <<-EOS CREATE OR REPLACE FUNCTION sp_update_varietal_aliases() RETURNS trigger AS $$ begin new.original_tsquery = plainto_tsquery('varietals_alias_search_config', coalesce(new.original,'')); new.substitution_tsquery = plainto_tsquery('varietals_alias_search_config', coalesce(new.substitution,'')); return new; end $$ LANGUAGE plpgsql; EOS execute <<-EOS DROP TRIGGER IF EXISTS trigger_update_varietal_aliases ON varietals; CREATE TRIGGER trigger_update_varietal_aliases BEFORE INSERT OR UPDATE ON varietal_aliases FOR EACH ROW EXECUTE PROCEDURE sp_update_varietal_aliases(); EOS end def down execute "DROP TRIGGER trigger_update_varietal_aliases ON varietal_aliases;" execute "DROP FUNCTION sp_update_varietal_aliases();" end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
search_steroids-0.0.1 | spec/dummy/db/migrate/20130625031608_add_varietal_aliases_trigger.rb |