1 package SQL::Translator::Object::Table;
2 use namespace::autoclean;
4 use MooseX::Types::Moose qw(HashRef Str);
5 use MooseX::AttributeHelpers;
6 use SQL::Translator::Types qw(Column Constraint Index Schema Sequence);
7 use SQL::Translator::Object::Schema;
9 extends 'SQL::Translator::Object';
18 metaclass => 'Collection::Hash',
20 isa => HashRef[Column],
22 exists => 'exists_column',
29 my ($self, $body, $column) = @_;
30 $self->$body($column->name, $column);
34 default => sub { my %hash = (); tie %hash, 'Tie::IxHash'; return \%hash },
38 metaclass => 'Collection::Hash',
40 isa => HashRef[Index],
42 exists => 'exists_index',
49 my ($self, $body, $index) = @_;
50 $self->$body($index->name, $index);
54 default => sub { {} },
57 has 'constraints' => (
58 metaclass => 'Collection::Hash',
60 isa => HashRef[Constraint],
62 exists => 'exists_constraint',
63 keys => 'constraint_ids',
64 get => 'get_constraint',
68 add_constraint => sub {
69 my ($self, $body, $constraint) = @_;
70 $self->$body($constraint->name, $constraint);
74 default => sub { {} },
78 metaclass => 'Collection::Hash',
80 isa => HashRef[Sequence],
82 exists => 'exists_sequence',
83 keys => 'sequence_ids',
84 get => 'get_sequence',
89 my ($self, $body, $sequence) = @_;
90 $self->$body($sequence->name, $sequence);
94 default => sub { {} },
97 __PACKAGE__->meta->make_immutable;