Hi Jeremy,

thanks for hte response; yes, that workaround is perfectly fine, and I can
live with that.

David


On Thu, Oct 10, 2013 at 5:27 PM, Jeremy Evans <[email protected]>wrote:

> On Thursday, October 10, 2013 4:12:08 PM UTC-7, David Lutterkort wrote:
>>
>> Hi,
>>
>> in my DB schema I previously created a constraint using
>> constraint_validations using
>>
>> Sequel.migration do
>>   up do
>>     create_table :repos do
>>       validate do
>>         format URL_RX, :url, :name => "url_is_simple"
>>   end; end; end; end
>>
>> I now need to modify the schema so that it allows NULL's for url. I am
>> not sure what the right way using constraint_validations is. My attempt was
>> to drop and recreate the constraint:
>>
>> Sequel.migration do
>>   up do
>>     alter_table :repos do
>>       validate do
>>         drop 'url_is_simple'
>>         format URL_RX, :url, :name => "url_is_simple", :allow_nil => true
>>   end; end; end; end
>>
>> After migrating, the repos table has the correct constraint;
>> unfortunately, the url_is_simple validation is missing from
>> sequel_constraint_validations. Is there another way to achieve this ?
>>
>
> Drops are currently processed after all other constraint validation
> statements, so most likely what it is doing is adding the new format with
> the same name, then dropping it.  You could run it with an SQL logger to
> check that.
>
> I can probably change the code so that drops are processed before the
> other queries, allowing your code to work (I'll try to do that before the
> next release if it doesn't cause problems).  In the meantime, use a
> separate after_table block for the drop:
>
>
> alter_table :repos do
>   validate do
>     drop 'url_is_simple'
>   end
> end
>
> alter_table :repos do
>   validate do
>     format URL_RX, :url, :name => "url_is_simple", :allow_nil => true
>   end
> end
>
> Thanks,
> Jeremy
>
> --
> 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/groups/opt_out.
>

-- 
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/groups/opt_out.

Reply via email to