I am using a postgres function to enforce the uniqueness of a set of
'restriction_ids' stored as a postgres array on a 'dietary profile'. The
migration file that sets this up is as follows:
Sequel.migration do
change do
create_function(
:sort_array,
"select array_agg(n) from (select n from unnest($1) as t(n) order by
n) as a;",
returns: 'integer[]',
args: ['integer[]'],
behavior: :immutable
)
alter_table :dietary_profiles do
add_index Sequel.function(:sort_array, :restriction_ids), unique: true
end
end
end
When I run the migration, everything is fine and code exhibits the desired
behaviour.
However, the schema.rb file that has been dumped out by the migration
doesn't include the 'sort_array' function, or the index on the
dietary_profiles table. If I try to recreate my database state from this
dump, I therefore don't get the function or index that I created.
I've taken a look at the code
<https://github.com/jeremyevans/sequel/blob/master/lib/sequel/extensions/schema_dumper.rb>responsible
for doing the dumps and it is appears that functions aren't considered.
1. Is there some other way of creating a database dump that will export
the functions?
2. If not, is there a reason that this isn't a good idea?
3. If not, where would be the best place to put code that would support
function exporting (if I wanted to try getting it working)?
Many thanks,
Tom
--
You received this message because you are subscribed to the Google Groups
"sequel-talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/sequel-talk.
For more options, visit https://groups.google.com/d/optout.