blib/lib/HPC/Runner/Command/Plugin/Logger/Sqlite/Deploy.pm

filter: Statementstmt 16.6% 5 / 30 Branchbran 0.0% 0 / 10 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 25.0% 1 / 4 Podpod 0.0% 0 / 3 totaltotal 12.7% 6 / 47 SCAR 34.1
CC
6
Cov
12%
deploy_schema_drop_tables
30.0
deploy_schema
6.0
deploy_schema_create_tables
2.0
CRAP 30.1
« blib/lib/HPC/Runner/Command/watch_db.pm ↑ Summary blib/lib/HPC/Runner/Command/execute_array/Plugin/Logger/Sqlite.pm »
1 package HPC::Runner::Command::Plugin::Logger::Sqlite::Deploy;
2  
3 2 ▶use Moose::Role;
Subroutine BEGIN: called CC=1 SCAR=0.0
4  
5 2 has 'clean_db' => (
6 is => 'rw',
7 isa => 'Bool',
8 default => 0
9 );
10  
11 sub deploy_schema {
12 0 ▶ my $self = shift;
Subroutine deploy_schema: not called CC=2 SCAR=17.9
Pod undocumented
13  
14 0 ▶ if ( $self->clean_db ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->clean_db) 0 0 0
15 0 $self->deploy_schema_drop_tables;
16 }
17 0 $self->deploy_schema_create_tables;
18 }
19  
20 sub deploy_schema_create_tables {
21 0 ▶ my $self = shift;
Subroutine deploy_schema_create_tables: not called CC=1 SCAR=6.9
Pod undocumented
22  
23 0 my $dbh = $self->schema->storage->dbh;
24 ###Create Tables
25  
26 0 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 0 $dbh->do($sql);
40  
41 0 $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 0 $dbh->do($sql);
56  
57 0 $sql = <<EOF;
58 CREATE INDEX IF NOT EXISTS jobs_idx_submission_id ON jobs (submission_fk);
59 EOF
60 0 $dbh->do($sql);
61  
62 0 $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 0 $dbh->do($sql);
79  
80 0 $sql = <<EOF;
81 CREATE INDEX IF NOT EXISTS tasks_idx_job_pi ON tasks (job_fk);
82 EOF
83  
84 0 $dbh->do($sql);
85 }
86  
87 sub deploy_schema_drop_tables {
88 0 ▶ my $self = shift;
Subroutine deploy_schema_drop_tables: not called CC=5 SCAR=34.0
Pod undocumented
89  
90 0 my $dbh = $self->schema->storage->dbh;
91  
92 0 ▶ print "We are cleaning the db!\n" if $self->clean_db;
Branch: 1 branch
BranchTrueFalseTotal
if $self->clean_db 0 0 0
93  
94 ### Drop Tables
95 0 my $sql = <<'EOF';
96 --
97 -- Table: submission
98 --
99 DROP TABLE IF EXISTS submission;
100 EOF
101  
102 0 ▶ $dbh->do($sql) if $self->clean_db;
Branch: 1 branch
BranchTrueFalseTotal
if $self->clean_db 0 0 0
103  
104 0 $sql = <<EOF;
105 --
106 -- Table: jobs
107 --
108 DROP TABLE IF EXISTS jobs;
109 EOF
110  
111 0 ▶ $dbh->do($sql) if $self->clean_db;
Branch: 1 branch
BranchTrueFalseTotal
if $self->clean_db 0 0 0
112  
113 0 $sql = <<EOF;
114 --
115 -- Table: tasks
116 --
117 DROP TABLE IF EXISTS tasks;
118 EOF
119  
120 0 ▶ $dbh->do($sql) if $self->clean_db;
Branch: 1 branch
BranchTrueFalseTotal
if $self->clean_db 0 0 0
121 }
122  
123 2 1;
« blib/lib/HPC/Runner/Command/watch_db.pm ↑ Summary blib/lib/HPC/Runner/Command/execute_array/Plugin/Logger/Sqlite.pm »