2 class SQL::Translator::Object::Constraint extends SQL::Translator::Object {
3 use MooseX::Types::Moose qw(ArrayRef Bool HashRef Maybe Str Undef);
4 use MooseX::MultiMethods;
5 use SQL::Translator::Types qw(Column MatchType Table);
23 isa => HashRef[Column],
25 exists_column => 'exists',
27 get_columns => 'values',
30 clear_columns => 'clear',
32 default => sub { my %hash = (); tie %hash, 'Tie::IxHash'; return \%hash },
38 predicate => 'has_type',
52 has 'reference_table' => (
57 has 'reference_columns' => (
61 reference_columns => 'elements',
63 default => sub { [] },
74 around add_column(Column $column) {
75 if ($self->has_type && $self->type eq 'PRIMARY KEY') {
76 $column->is_primary_key(1);
78 $self->$orig($column->name, $column)
81 method is_valid { return $self->has_type && scalar $self->column_ids ? 1 : undef }