has 'type' => (
is => 'rw',
isa => Str,
+ predicate => 'has_type',
+ required => 1,
);
has 'deferrable' => (
traits => ['Array'],
handles => {
reference_columns => 'elements',
+ add_reference_column => 'push',
},
default => sub { [] },
+ required => 1,
);
has 'match_type' => (
default => ''
);
- around add_column(Column $column) { $self->$orig($column->name, $column) }
+ has 'on_delete' => ( is => 'rw', required => 0);
+ has 'on_update' => ( is => 'rw', required => 0);
+
+ around add_column(Column $column) {
+ if ($self->has_type && $self->type eq 'PRIMARY KEY') {
+ $column->is_primary_key(1);
+ }
+ $self->$orig($column->name, $column)
+ }
+
+ method is_valid { return $self->has_type && scalar $self->column_ids ? 1 : undef }
}