2 class SQL::Translator::Object::Table {
3 use MooseX::Types::Moose qw(ArrayRef Bool HashRef Maybe Str);
4 use MooseX::AttributeHelpers;
5 use SQL::Translator::Types qw(Column Constraint Index Schema Sequence);
6 use SQL::Translator::Object::Schema;
7 extends 'SQL::Translator::Object';
16 metaclass => 'Collection::Hash',
18 isa => HashRef[Column],
20 exists => 'exists_column',
22 values => 'get_columns',
26 default => sub { my %hash = (); tie %hash, 'Tie::IxHash'; return \%hash },
30 metaclass => 'Collection::Hash',
32 isa => HashRef[Index],
34 exists => 'exists_index',
36 values => 'get_indices',
40 default => sub { my %hash = (); tie %hash, 'Tie::IxHash'; return \%hash },
43 has 'constraints' => (
44 metaclass => 'Collection::Hash',
46 isa => HashRef[Constraint],
48 exists => 'exists_constraint',
49 keys => 'constraint_ids',
50 values => 'get_constraints',
51 get => 'get_constraint',
52 set => 'add_constraint',
54 default => sub { my %hash = (); tie %hash, 'Tie::IxHash'; return \%hash },
58 metaclass => 'Collection::Hash',
60 isa => HashRef[Sequence],
62 exists => 'exists_sequence',
63 keys => 'sequence_ids',
64 values => 'get_sequences',
65 get => 'get_sequence',
66 set => 'add_sequence',
68 default => sub { my %hash = (); tie %hash, 'Tie::IxHash'; return \%hash },
88 around add_column(Column $column) { $self->$orig($column->name, $column) }
89 around add_index(Index $index) { $self->$orig($index->name, $index) }
90 around add_constraint(Constraint $constraint) { $self->$orig($constraint->name, $constraint) }
91 around add_sequence(Sequence $sequence) { $self->$orig($sequence->name, $sequence) }
93 method get_fields { return $self->get_columns }
94 method fields { return $self->column_ids }
95 method primary_key(Str $column) {
96 $self->get_column($column)->is_primary_key(1);