source: xas-model/trunk/lib/XAS/Apps/Database/Schema.pm @ ec669f7d855f211d1a774ab3048a0a59d4356f13

Revision ec669f7d855f211d1a774ab3048a0a59d4356f13, 2.7 KB checked in by Kevin L. Esteb <kevin@…>, 6 years ago (diff)

Corrected documentation

  • Property mode set to 100644
Line 
1package XAS::Apps::Database::Schema;
2
3use XAS::Model::Schema;
4use XAS::Model::Database;
5
6use XAS::Class
7  debug     => 0,
8  version   => '0.02',
9  base      => 'XAS::Lib::App',
10  accessors => 'dbtype revision directory database db schema',
11;
12
13# ----------------------------------------------------------------------
14# Public Methods
15# ----------------------------------------------------------------------
16
17sub setup {
18    my $self = shift;
19
20    my $schema = $self->schema;
21    my $database = $self->database;
22
23    XAS::Model::Database->schemas($schema);
24    $self->{db} = XAS::Model::Schema->opendb($database);
25
26}
27
28sub main {
29    my $self = shift;
30
31    $self->setup();
32
33    $self->log->info('starting up');
34
35    $self->db->create_ddl_dir(
36        [$self->dbtype],
37        $self->revision,
38        $self->directory,
39    );
40
41    $self->log->info('shutting down');
42
43}
44
45sub options {
46    my $self = shift;
47
48    $self->{dbtype}    = 'SQLite';
49    $self->{revision}  = '0.01';
50    $self->{directory} = './sql/';
51    $self->{database}  = 'testing';
52    $self->{schema}    = 'XAS::Model::Database::Testing';
53
54    return {
55        'dbtype=s'    => \$self->{dbtype},
56        'revision=s'  => \$self->{revision},
57        'directory=s' => \$self->{directory},
58        'database=s'  => \$self->{database},
59        'schema=s'    => \$self->{schema},
60    };
61
62}
63
64# ----------------------------------------------------------------------
65# Private Methods
66# ----------------------------------------------------------------------
67
681;
69
70__END__
71
72=head1 NAME
73
74XAS::Apps::Database::Schema - Create a database schema
75
76=head1 SYNOPSIS
77
78 use XAS::Apps::Database::Schema;
79
80 my $app = XAS::Apps::Database::Schema->new();
81
82 exit $app->run();
83
84=head1 DESCRIPTION
85
86This module will create a schema for the XAS database. It inherits from
87L<XAS::Lib::App|XAS::Lib::App>. Please see that module for additional documentation.
88
89=head1 OPTIONS
90
91This modules provides these additional cli options.
92
93=head2 --dbtype
94
95The type of database. This can be one of the following:
96
97 PostgreSQL
98 SQLite
99 MySQL
100
101Or any other L<SQL::Translator|https://metacpan.org/pod/SQL::Translator> database name.
102
103=head2 --revision
104
105The revision for this schema. Defaults to "0.01".
106
107=head2 --directory
108
109The directory to write the schema into. Defaults to "./sql.".
110
111=head1 SEE ALSO
112
113=over 4
114
115=item bin/xas-create-schema
116
117=item L<XAS|XAS>
118
119=back
120
121=head1 AUTHOR
122
123Kevin L. Esteb, E<lt>kevin@kesteb.usE<gt>
124
125=head1 COPYRIGHT AND LICENSE
126
127Copyright (C) 2012 by Kevin L. Esteb
128
129This library is free software; you can redistribute it and/or modify
130it under the same terms as Perl itself, either Perl version 5.8.8 or,
131at your option, any later version of Perl 5 you may have available.
132
133=cut
Note: See TracBrowser for help on using the repository browser.