@@ -27,6 +27,12 @@ sub process_functions
27
27
my $name = $1 ;
28
28
push @functions , $name ;
29
29
}
30
+ # Functions created by the previous versions of SIR
31
+ push @functions , qw(
32
+ search_link_attribute_type_insert
33
+ search_link_attribute_type_update
34
+ search_link_attribute_type_delete
35
+ ) ;
30
36
@functions = sort (@functions );
31
37
32
38
my @aggregates ;
@@ -39,11 +45,11 @@ sub process_functions
39
45
print OUT " -- Automatically generated, do not edit.\n " ;
40
46
print OUT " \\ unset ON_ERROR_STOP\n\n " ;
41
47
foreach my $func (@functions ) {
42
- print OUT " DROP FUNCTION $func ;\n " ;
48
+ print OUT " DROP FUNCTION IF EXISTS $func ;\n " ;
43
49
}
44
50
foreach my $agg (@aggregates ) {
45
51
my ($name , $type ) = @$agg ;
46
- print OUT " DROP AGGREGATE $name ($type );\n " ;
52
+ print OUT " DROP AGGREGATE IF EXISTS $name ($type );\n " ;
47
53
}
48
54
close OUT;
49
55
}
@@ -67,12 +73,22 @@ sub process_triggers
67
73
while ($create_triggers_sql =~ m / CREATE (?:CONSTRAINT )?TRIGGER\s +"?([a-z0-9_]+)"?\s +.*?\s +ON\s +"?([a-z0-9_\. ]+)"?.*?;/ gsi ) {
68
74
push @triggers , [$1 , $2 ];
69
75
}
76
+ # Triggers created by the previous versions of SIR
77
+ push @triggers , (
78
+ [' search_release_packaging_insert' , ' musicbrainz.release_packaging' ],
79
+ [' search_release_packaging_update' , ' musicbrainz.release_packaging' ],
80
+ [' search_release_packaging_delete' , ' musicbrainz.release_packaging' ],
81
+ [' search_link_attribute_type_insert' , ' musicbrainz.link_attribute_type' ],
82
+ [' search_link_attribute_type_update' , ' musicbrainz.link_attribute_type' ],
83
+ [' search_link_attribute_type_delete' , ' musicbrainz.link_attribute_type' ]
84
+ );
85
+ @triggers = sort (@triggers );
70
86
71
87
open OUT, " >$dir /$outfile " ;
72
88
print OUT " -- Automatically generated, do not edit.\n " ;
73
89
print OUT " \\ unset ON_ERROR_STOP\n\n " ;
74
90
foreach my $trigger (@triggers ) {
75
- print OUT " DROP TRIGGER $trigger ->[0] ON $trigger ->[1];\n " ;
91
+ print OUT " DROP TRIGGER IF EXISTS $trigger ->[0] ON $trigger ->[1];\n " ;
76
92
}
77
93
close OUT;
78
94
}
0 commit comments