| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package Daje::Database::Migrator; |
|
2
|
1
|
|
|
1
|
|
343203
|
use Mojo::Base -base, -signatures; |
|
|
1
|
|
|
|
|
10090
|
|
|
|
1
|
|
|
|
|
8
|
|
|
3
|
1
|
|
|
1
|
|
2246
|
use v5.40; |
|
|
1
|
|
|
|
|
4
|
|
|
4
|
|
|
|
|
|
|
|
|
5
|
1
|
|
|
1
|
|
512
|
use Mojo::Loader qw(load_class); |
|
|
1
|
|
|
|
|
254554
|
|
|
|
1
|
|
|
|
|
939
|
|
|
6
|
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
# NAME |
|
8
|
|
|
|
|
|
|
# ==== |
|
9
|
|
|
|
|
|
|
# |
|
10
|
|
|
|
|
|
|
# Daje::Database::Migrator - It's the database migrate plugin for Daje::Workflow |
|
11
|
|
|
|
|
|
|
# |
|
12
|
|
|
|
|
|
|
# SYNOPSIS |
|
13
|
|
|
|
|
|
|
# ======== |
|
14
|
|
|
|
|
|
|
# |
|
15
|
|
|
|
|
|
|
# use Daje::Database::Migrator; |
|
16
|
|
|
|
|
|
|
# |
|
17
|
|
|
|
|
|
|
# push @{$migrations}, {class => 'Daje::Workflow::Database', name => 'workflow', migration => 2}; |
|
18
|
|
|
|
|
|
|
# |
|
19
|
|
|
|
|
|
|
# push @{$migrations}, {file => '/home/user/schema/users.sql', name => 'users'}; |
|
20
|
|
|
|
|
|
|
# |
|
21
|
|
|
|
|
|
|
# Daje::Database::Migrator->new( |
|
22
|
|
|
|
|
|
|
# pg => $pg, |
|
23
|
|
|
|
|
|
|
# migrations => $migrations, |
|
24
|
|
|
|
|
|
|
# )->migrate(); |
|
25
|
|
|
|
|
|
|
# |
|
26
|
|
|
|
|
|
|
# DESCRIPTION |
|
27
|
|
|
|
|
|
|
# =========== |
|
28
|
|
|
|
|
|
|
# |
|
29
|
|
|
|
|
|
|
# Daje::Database::Migrator is the Database migrate plugin for Daje |
|
30
|
|
|
|
|
|
|
# |
|
31
|
|
|
|
|
|
|
# LICENSE |
|
32
|
|
|
|
|
|
|
# ======= |
|
33
|
|
|
|
|
|
|
# |
|
34
|
|
|
|
|
|
|
# Copyright (C) janeskil1525. |
|
35
|
|
|
|
|
|
|
# |
|
36
|
|
|
|
|
|
|
# This library is free software; you can redistribute it and/or modify |
|
37
|
|
|
|
|
|
|
# it under the same terms as Perl itself. |
|
38
|
|
|
|
|
|
|
# |
|
39
|
|
|
|
|
|
|
# AUTHOR |
|
40
|
|
|
|
|
|
|
# ====== |
|
41
|
|
|
|
|
|
|
# |
|
42
|
|
|
|
|
|
|
# janeskil1525 Ejaneskil1525@gmail.comE |
|
43
|
|
|
|
|
|
|
# |
|
44
|
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
our $VERSION = "1.05"; |
|
46
|
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
has 'pg'; |
|
48
|
|
|
|
|
|
|
has 'migrations'; |
|
49
|
|
|
|
|
|
|
|
|
50
|
0
|
|
|
0
|
1
|
|
sub migrate($self) { |
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
|
|
52
|
0
|
|
|
|
|
|
my $length = scalar @{$self->migrations}; |
|
|
0
|
|
|
|
|
|
|
|
53
|
0
|
|
|
|
|
|
for (my $i = 0; $i < $length; $i++) { |
|
54
|
0
|
0
|
|
|
|
|
if (exists @{$self->migrations}[$i]->{class}) { |
|
|
0
|
0
|
|
|
|
|
|
|
55
|
0
|
|
|
|
|
|
try { |
|
56
|
0
|
|
|
|
|
|
my $cl = load_class @{$self->migrations}[$i]->{class}; |
|
|
0
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
$self->pg->migrations->name( |
|
58
|
0
|
|
|
|
|
|
@{$self->migrations}[$i]->{name} |
|
59
|
|
|
|
|
|
|
)->from_data( |
|
60
|
0
|
|
|
|
|
|
@{$self->migrations}[$i]->{class}, |
|
61
|
0
|
|
|
|
|
|
@{$self->migrations}[$i]->{name} |
|
62
|
|
|
|
|
|
|
)->migrate( |
|
63
|
0
|
|
|
|
|
|
@{$self->migrations}[$i]->{migration} |
|
64
|
0
|
|
|
|
|
|
); |
|
65
|
|
|
|
|
|
|
} |
|
66
|
|
|
|
|
|
|
catch($e) { |
|
67
|
0
|
|
|
|
|
|
say $e; |
|
68
|
0
|
|
|
|
|
|
say @{$self->migrations}[$i]->{class}; |
|
|
0
|
|
|
|
|
|
|
|
69
|
0
|
|
|
|
|
|
say @{$self->migrations}[$i]->{name}; |
|
|
0
|
|
|
|
|
|
|
|
70
|
0
|
|
|
|
|
|
say @{$self->migrations}[$i]->{migration}; |
|
|
0
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
} |
|
72
|
|
|
|
|
|
|
} |
|
73
|
0
|
|
|
|
|
|
elsif (exists @{$self->migrations}[$i]->{file}) { |
|
74
|
|
|
|
|
|
|
$self->pg->migrations->name( |
|
75
|
0
|
|
|
|
|
|
@{$self->migrations}[$i]->{name} |
|
76
|
|
|
|
|
|
|
)->from_file( |
|
77
|
0
|
|
|
|
|
|
@{$self->migrations}[$i]->{file} |
|
78
|
|
|
|
|
|
|
)->migrate( |
|
79
|
0
|
|
|
|
|
|
@{$self->migrations}[$i]->{migration} |
|
80
|
0
|
|
|
|
|
|
); |
|
81
|
|
|
|
|
|
|
} |
|
82
|
|
|
|
|
|
|
} |
|
83
|
|
|
|
|
|
|
|
|
84
|
0
|
|
|
|
|
|
return 1; |
|
85
|
|
|
|
|
|
|
} |
|
86
|
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
1; |
|
89
|
|
|
|
|
|
|
__END__ |