line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package HPC::Runner::Command::Plugin::Logger::Sqlite::Deploy; |
2
|
|
|
|
|
|
|
|
3
|
3
|
|
|
3
|
|
1616
|
use Moose::Role; |
|
3
|
|
|
|
|
7
|
|
|
3
|
|
|
|
|
43
|
|
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
has 'clean_db' => ( |
6
|
|
|
|
|
|
|
is => 'rw', |
7
|
|
|
|
|
|
|
isa => 'Bool', |
8
|
|
|
|
|
|
|
default => 0 |
9
|
|
|
|
|
|
|
); |
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
sub deploy_schema { |
12
|
4
|
|
|
4
|
0
|
10
|
my $self = shift; |
13
|
|
|
|
|
|
|
|
14
|
4
|
100
|
|
|
|
136
|
if ( $self->clean_db ) { |
15
|
2
|
|
|
|
|
6
|
$self->deploy_schema_drop_tables; |
16
|
|
|
|
|
|
|
} |
17
|
4
|
|
|
|
|
274
|
$self->deploy_schema_create_tables; |
18
|
|
|
|
|
|
|
} |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
sub deploy_schema_create_tables { |
21
|
4
|
|
|
4
|
0
|
12
|
my $self = shift; |
22
|
|
|
|
|
|
|
|
23
|
4
|
|
|
|
|
144
|
my $dbh = $self->schema->storage->dbh; |
24
|
|
|
|
|
|
|
###Create Tables |
25
|
|
|
|
|
|
|
|
26
|
4
|
|
|
|
|
2552
|
my $sql = <<EOF; |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
CREATE TABLE IF NOT EXISTS submission ( |
29
|
|
|
|
|
|
|
submission_pi INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, |
30
|
|
|
|
|
|
|
project text, |
31
|
|
|
|
|
|
|
submission_meta text, |
32
|
|
|
|
|
|
|
total_processes integer NOT NULL, |
33
|
|
|
|
|
|
|
total_batches integet NOT NULL, |
34
|
|
|
|
|
|
|
submission_time text NOT NULL |
35
|
|
|
|
|
|
|
); |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
EOF |
38
|
|
|
|
|
|
|
|
39
|
4
|
|
|
|
|
30
|
$dbh->do($sql); |
40
|
|
|
|
|
|
|
|
41
|
4
|
|
|
|
|
77172
|
$sql = <<EOF; |
42
|
|
|
|
|
|
|
CREATE TABLE IF NOT EXISTS jobs ( |
43
|
|
|
|
|
|
|
job_pi INTEGER PRIMARY KEY NOT NULL, |
44
|
|
|
|
|
|
|
submission_fk integer NOT NULL, |
45
|
|
|
|
|
|
|
job_scheduler_id text, |
46
|
|
|
|
|
|
|
start_time text NOT NULL, |
47
|
|
|
|
|
|
|
exit_time text NOT NULL, |
48
|
|
|
|
|
|
|
duration text, |
49
|
|
|
|
|
|
|
jobs_meta text, |
50
|
|
|
|
|
|
|
job_name text, |
51
|
|
|
|
|
|
|
FOREIGN KEY (submission_fk) REFERENCES submission(submission_pi) ON DELETE NO ACTION ON UPDATE NO ACTION |
52
|
|
|
|
|
|
|
); |
53
|
|
|
|
|
|
|
EOF |
54
|
|
|
|
|
|
|
|
55
|
4
|
|
|
|
|
36
|
$dbh->do($sql); |
56
|
|
|
|
|
|
|
|
57
|
4
|
|
|
|
|
25726
|
$sql = <<EOF; |
58
|
|
|
|
|
|
|
CREATE INDEX IF NOT EXISTS jobs_idx_submission_id ON jobs (submission_fk); |
59
|
|
|
|
|
|
|
EOF |
60
|
4
|
|
|
|
|
36
|
$dbh->do($sql); |
61
|
|
|
|
|
|
|
|
62
|
4
|
|
|
|
|
29964
|
$sql = <<EOF; |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
CREATE TABLE IF NOT EXISTS tasks ( |
65
|
|
|
|
|
|
|
task_pi INTEGER PRIMARY KEY NOT NULL, |
66
|
|
|
|
|
|
|
job_fk integer NOT NULL, |
67
|
|
|
|
|
|
|
pid integer NOT NULL, |
68
|
|
|
|
|
|
|
start_time text NOT NULL, |
69
|
|
|
|
|
|
|
exit_time text, |
70
|
|
|
|
|
|
|
duration text, |
71
|
|
|
|
|
|
|
exit_code integer, |
72
|
|
|
|
|
|
|
tasks_meta text, |
73
|
|
|
|
|
|
|
task_tags text, |
74
|
|
|
|
|
|
|
FOREIGN KEY (job_fk) REFERENCES jobs(job_pi) ON DELETE NO ACTION ON UPDATE NO ACTION |
75
|
|
|
|
|
|
|
); |
76
|
|
|
|
|
|
|
EOF |
77
|
|
|
|
|
|
|
|
78
|
4
|
|
|
|
|
118
|
$dbh->do($sql); |
79
|
|
|
|
|
|
|
|
80
|
4
|
|
|
|
|
29014
|
$sql = <<EOF; |
81
|
|
|
|
|
|
|
CREATE INDEX IF NOT EXISTS tasks_idx_job_pi ON tasks (job_fk); |
82
|
|
|
|
|
|
|
EOF |
83
|
|
|
|
|
|
|
|
84
|
4
|
|
|
|
|
46
|
$dbh->do($sql); |
85
|
|
|
|
|
|
|
} |
86
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
sub deploy_schema_drop_tables { |
88
|
2
|
|
|
2
|
0
|
6
|
my $self = shift; |
89
|
|
|
|
|
|
|
|
90
|
2
|
|
|
|
|
76
|
my $dbh = $self->schema->storage->dbh; |
91
|
|
|
|
|
|
|
|
92
|
2
|
50
|
|
|
|
51186
|
print "We are cleaning the db!\n" if $self->clean_db; |
93
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
### Drop Tables |
95
|
2
|
|
|
|
|
12
|
my $sql = <<'EOF'; |
96
|
|
|
|
|
|
|
-- |
97
|
|
|
|
|
|
|
-- Table: submission |
98
|
|
|
|
|
|
|
-- |
99
|
|
|
|
|
|
|
DROP TABLE IF EXISTS submission; |
100
|
|
|
|
|
|
|
EOF |
101
|
|
|
|
|
|
|
|
102
|
2
|
50
|
|
|
|
82
|
$dbh->do($sql) if $self->clean_db; |
103
|
|
|
|
|
|
|
|
104
|
2
|
|
|
|
|
1046
|
$sql = <<EOF; |
105
|
|
|
|
|
|
|
-- |
106
|
|
|
|
|
|
|
-- Table: jobs |
107
|
|
|
|
|
|
|
-- |
108
|
|
|
|
|
|
|
DROP TABLE IF EXISTS jobs; |
109
|
|
|
|
|
|
|
EOF |
110
|
|
|
|
|
|
|
|
111
|
2
|
50
|
|
|
|
80
|
$dbh->do($sql) if $self->clean_db; |
112
|
|
|
|
|
|
|
|
113
|
2
|
|
|
|
|
268
|
$sql = <<EOF; |
114
|
|
|
|
|
|
|
-- |
115
|
|
|
|
|
|
|
-- Table: tasks |
116
|
|
|
|
|
|
|
-- |
117
|
|
|
|
|
|
|
DROP TABLE IF EXISTS tasks; |
118
|
|
|
|
|
|
|
EOF |
119
|
|
|
|
|
|
|
|
120
|
2
|
50
|
|
|
|
78
|
$dbh->do($sql) if $self->clean_db; |
121
|
|
|
|
|
|
|
} |
122
|
|
|
|
|
|
|
|
123
|
|
|
|
|
|
|
1; |