add PrimaryKey and ForeignKey classes
[dbsrgits/SQL-Translator-2.0-ish.git] / lib / SQL / Translator / Object / Schema.pm
CommitLineData
c5051351 1package SQL::Translator::Object::Schema;
abb2c327 2use namespace::autoclean;
c5051351 3use Moose;
7aa485df 4use MooseX::Types::Moose qw(HashRef Maybe Str);
e157d782 5use MooseX::AttributeHelpers;
c0e05758 6use SQL::Translator::Types qw(Procedure Table View);
cc73c25e 7extends 'SQL::Translator::Object';
c5051351 8
109263d0 9has 'name' => (
44547961 10 is => 'rw',
11 isa => Maybe[Str],
12 required => 1,
13 default => ''
109263d0 14);
15
16has 'tables' => (
44547961 17 metaclass => 'Collection::Hash',
18 is => 'rw',
19 isa => HashRef[Table],
20 provides => {
21 exists => 'exists_table',
22 keys => 'table_ids',
23 get => 'get_table',
24 },
25 curries => {
26 set => {
27 add_table => sub {
28 my ($self, $body, $table) = @_;
29 $self->$body($table->name, $table);
30 }
31 }
32 },
33 default => sub { {} },
109263d0 34);
35
36has 'views' => (
44547961 37 metaclass => 'Collection::Hash',
38 is => 'rw',
39 isa => HashRef[View],
40 provides => {
41 exists => 'exists_view',
42 keys => 'view_ids',
43 get => 'get_view',
44 },
45 curries => {
46 set => {
47 add_view => sub {
48 my ($self, $body, $view) = @_;
49 $self->$body($view->name, $view);
50 }
51 }
52 },
53 default => sub { {} },
109263d0 54);
55
56has 'procedures' => (
44547961 57 metaclass => 'Collection::Hash',
58 is => 'rw',
59 isa => HashRef[Procedure],
60 provides => {
61 exists => 'exists_procedure',
62 keys => 'procedure_ids',
63 get => 'get_procedure',
64 },
65 curries => {
66 set => {
67 add_procedure => sub {
68 my ($self, $body, $procedure) = @_;
69 $self->$body($procedure->name, $procedure);
70 }
71 }
72 },
73 default => sub { {} },
109263d0 74);
c5051351 75
b27b9d16 76__PACKAGE__->meta->make_immutable;
7aa485df 77
c5051351 781;