line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package UR::Namespace::Command::Show::Schema; |
2
|
1
|
|
|
1
|
|
23
|
use strict; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
25
|
|
3
|
1
|
|
|
1
|
|
4
|
use warnings; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
225
|
|
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
class UR::Namespace::Command::Show::Schema { |
6
|
|
|
|
|
|
|
is => 'Command::V2', |
7
|
|
|
|
|
|
|
has_input => [ |
8
|
|
|
|
|
|
|
class_names => { |
9
|
|
|
|
|
|
|
is => 'Text', |
10
|
|
|
|
|
|
|
is_many => 1, |
11
|
|
|
|
|
|
|
shell_args_position => 1, |
12
|
|
|
|
|
|
|
require_user_verify => 0, |
13
|
|
|
|
|
|
|
doc => 'dump the required database schema changes for a class or classes' |
14
|
|
|
|
|
|
|
}, |
15
|
|
|
|
|
|
|
complete => { |
16
|
|
|
|
|
|
|
is => 'Boolean', |
17
|
|
|
|
|
|
|
default_value => 0, |
18
|
|
|
|
|
|
|
doc => 'when set, dump the complete table creation command not just the required changes', |
19
|
|
|
|
|
|
|
}, |
20
|
|
|
|
|
|
|
], |
21
|
|
|
|
|
|
|
doc => 'database DDL', |
22
|
|
|
|
|
|
|
}; |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
sub execute { |
25
|
0
|
|
|
0
|
|
|
my $self = shift; |
26
|
0
|
|
|
|
|
|
my @class_names = $self->class_names; |
27
|
0
|
|
|
|
|
|
$ENV{UR_DBI_NO_COMMIT} = 1; |
28
|
0
|
|
|
|
|
|
my $t = UR::Context::Transaction->begin; |
29
|
0
|
|
|
|
|
|
$DB::single = 1; |
30
|
0
|
|
|
|
|
|
for my $class_name (@class_names) { |
31
|
0
|
|
|
|
|
|
my $meta = $class_name->__meta__; |
32
|
|
|
|
|
|
|
|
33
|
0
|
|
|
|
|
|
my $class_name = $meta->class_name; |
34
|
0
|
|
|
|
|
|
$self->status_message("-- class $class_name\n"); |
35
|
0
|
|
|
|
|
|
my $ds = $meta->data_source; |
36
|
0
|
|
|
|
|
|
my @schema_objects = $ds->generate_schema_for_class_meta($meta,1); |
37
|
0
|
|
|
|
|
|
my ($tt) = grep { $_->isa("UR::DataSource::RDBMS::Table") } @schema_objects; |
|
0
|
|
|
|
|
|
|
38
|
0
|
|
|
|
|
|
my @ddl = $ds->_resolve_ddl_for_table($tt, all => 1); |
39
|
0
|
0
|
|
|
|
|
if (@ddl) { |
40
|
0
|
|
|
|
|
|
my $ddl = join("\n",@ddl); |
41
|
0
|
|
|
|
|
|
$self->status_message($ddl); |
42
|
|
|
|
|
|
|
} |
43
|
|
|
|
|
|
|
else { |
44
|
0
|
|
|
|
|
|
$self->status_message("-- no changes for $class_name, run with the 'complete' flag for the full table DDL"); |
45
|
|
|
|
|
|
|
} |
46
|
|
|
|
|
|
|
} |
47
|
0
|
|
|
|
|
|
$t->rollback; |
48
|
0
|
|
|
|
|
|
return 1; |
49
|
|
|
|
|
|
|
} |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
1; |
52
|
|
|
|
|
|
|
|