On Sep 24, 2:35 am, cult hero <[email protected]> wrote:
> This works like a charm. Thanks.
>
> How do I incorporate these into a migration?
I do not have a Sequel example to hand, but for ActiveRecord
migrations I do this:
class HllPgFnIdentInsert < ActiveRecord::Migration
def self.up
if /.*PostgreSQL.*/i =~ ActiveRecord::Base.connection.class.to_s
# First, define trigger function to insert identifier for aliases
sql_string = <<-'SQLEND'
CREATE OR REPLACE FUNCTION hll_pg_fn_ident_insert()
. . .
SQLEND
puts sql_string
execute sql_string
end # if
end #up
def self.down
if /.*PostgreSQL.*/i =~ ActiveRecord::Base.connection.class.to_s
sql_string = <<-'SQLEND'
DROP FUNCTION hll_pg_fn_ident_insert();
SQLEND
puts sql_string
execute sql_string
end
end #down
The puts is just for confidence checking when running migrations.
--
You received this message because you are subscribed to the Google Groups
"sequel-talk" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/sequel-talk?hl=en.