use MooseX::Declare;
-class SQL::Translator::Object::Constraint {
- use MooseX::Types::Moose qw(ArrayRef Bool HashRef Maybe Str);
+class SQL::Translator::Object::Constraint extends SQL::Translator::Object {
+ use MooseX::Types::Moose qw(ArrayRef Bool HashRef Maybe Str Undef);
use MooseX::AttributeHelpers;
- use SQL::Translator::Types qw(Column);
- extends 'SQL::Translator::Object';
+ use SQL::Translator::Types qw(Column Table);
+
+ has 'table' => (
+ is => 'rw',
+ isa => Table,
+ required => 1,
+ weak_ref => 1,
+ );
has 'name' => (
is => 'rw',
keys => 'column_ids',
values => 'get_columns',
get => 'get_column',
- },
- curries => {
- set => {
- add_column => sub {
- my ($self, $body, $column) = @_;
- $self->$body($column->name, $column);
- }
- }
+ set => 'add_column',
},
default => sub { my %hash = (); tie %hash, 'Tie::IxHash'; return \%hash },
);
isa => Str,
);
- has 'options' => (
+ has 'reference_table' => (
+ isa => Maybe[Str],
is => 'rw',
- isa => ArrayRef,
- auto_deref => 1
);
- has 'extra' => (
- is => 'rw',
- isa => HashRef,
- auto_deref => 1,
+ has 'reference_columns' => (
+ isa => ArrayRef | Undef,
+ is => 'rw',
+ auto_deref => 1
);
- method get_fields { return $self->get_columns }
- method fields { return $self->column_ids }
- method field_names { return $self->column_ids }
+ around add_column(Column $column) { $self->$orig($column->name, $column) }
+
+ method get_fields { $self->get_columns }
+ method fields { $self->column_ids }
+ method field_names { $self->column_ids }
+
+ method reference_fields { $self->reference_columns }
method match_type { }
}