From: moltar <moltar@moltar.net> Date: Tue, 14 May 2013 21:11:37 +0000 (-0400) Subject: Should have removed constraint, not index. Duh. X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=HEAD;p=dbsrgits%2FDBIx-Class-Tree.git Should have removed constraint, not index. Duh. --- diff --git a/lib/DBIx/Class/Tree/AdjacencyList.pm b/lib/DBIx/Class/Tree/AdjacencyList.pm index 4925416..a77eeda 100644 --- a/lib/DBIx/Class/Tree/AdjacencyList.pm +++ b/lib/DBIx/Class/Tree/AdjacencyList.pm @@ -368,15 +368,16 @@ __END__ If you are using L<DBIx::Class::Schema/deploy> methods either directly or via L<DBIx::Class::DeploymentHandler> or L<DBIx::Migration>, you -will need the following L<SQL::Translator> hook to remove the index -from C<parent_column>. +will need the following L<SQL::Translator> hook to remove the constraint +from C<parent_column>, otherwise you will not be able to user 0 (zero) as +a value. sub sqlt_deploy_hook { my ($self, $sqlt_table) = @_; - foreach my $index ($sqlt_table->get_indices) { - if ($index->fields->[0] eq $self->parent_column) { - $sqlt_table->drop_index($index->name); + foreach my $constraint ($sqlt_table->get_constraints) { + if ($constraint->field_names->[0] eq $self->parent_column) { + $sqlt_table->drop_constraint($constraint->name); last; } }