aboutsummaryrefslogtreecommitdiffstats
path: root/bin
diff options
context:
space:
mode:
Diffstat (limited to 'bin')
-rwxr-xr-xbin/fiksgatami/load-norwegian-contacts4
-rwxr-xr-xbin/fixmystreet.com/import-categories2
-rwxr-xr-xbin/fixmystreet.com/load-contacts2
-rwxr-xr-xbin/send-comments4
-rwxr-xr-xbin/update-schema11
5 files changed, 15 insertions, 8 deletions
diff --git a/bin/fiksgatami/load-norwegian-contacts b/bin/fiksgatami/load-norwegian-contacts
index b73778848..ed382d6fc 100755
--- a/bin/fiksgatami/load-norwegian-contacts
+++ b/bin/fiksgatami/load-norwegian-contacts
@@ -54,13 +54,13 @@ while (<FP>) {
$categories = $defcategories;
}
# dbh()->do("INSERT INTO contacts (area_id, email, editor, whenedited, note, confirmed, deleted)
-# VALUES (?, ?, 'import', ms_current_timestamp(), 'Initial import', 'false', 'false')",
+# VALUES (?, ?, 'import', current_timestamp, 'Initial import', 'false', 'false')",
# {}, $id, $email);
# } else {
for my $category (split(/,\s*/, $categories)) {
print " Category '$category'\n";
dbh()->do("INSERT INTO contacts (area_id, email, category, editor, whenedited, note, confirmed, deleted)
- VALUES (?, ?, ?, 'import', ms_current_timestamp(), 'Initial import', 'true', 'false')",
+ VALUES (?, ?, ?, 'import', current_timestamp, 'Initial import', 'true', 'false')",
{}, $id, $email, $category);
}
# }
diff --git a/bin/fixmystreet.com/import-categories b/bin/fixmystreet.com/import-categories
index e9008b93f..fe4c2e027 100755
--- a/bin/fixmystreet.com/import-categories
+++ b/bin/fixmystreet.com/import-categories
@@ -70,7 +70,7 @@ sub add_categories {
dbh()->do("insert into contacts
(area_id, category, email, editor, whenedited, note, confirmed, deleted)
values
- (?, ?, ?, 'import', ms_current_timestamp(), 'Initial copy', ?, 'f')", {},
+ (?, ?, ?, 'import', current_timestamp, 'Initial copy', ?, 'f')", {},
$id, $_, $email, ($confirmed ? 1 : 0)
);
}
diff --git a/bin/fixmystreet.com/load-contacts b/bin/fixmystreet.com/load-contacts
index b18699db1..78bb77e8f 100755
--- a/bin/fixmystreet.com/load-contacts
+++ b/bin/fixmystreet.com/load-contacts
@@ -42,7 +42,7 @@ while (<FP>) {
s/\r?\n//g;
my ($id, $email) = split /,/;
dbh()->do("INSERT INTO contacts (area_id, email, editor, whenedited, note)
- VALUES (?, ?, 'import', ms_current_timestamp(), 'Initial import')",
+ VALUES (?, ?, 'import', current_timestamp, 'Initial import')",
{}, $id, $email);
}
dbh()->commit();
diff --git a/bin/send-comments b/bin/send-comments
index fabf2b633..fbbd57891 100755
--- a/bin/send-comments
+++ b/bin/send-comments
@@ -130,12 +130,12 @@ while ( my $body = $bodies->next ) {
if ( $id ) {
$comment->update( {
external_id => $id,
- whensent => \'ms_current_timestamp()',
+ whensent => \'current_timestamp',
} );
} else {
$comment->update( {
send_fail_count => $comment->send_fail_count + 1,
- send_fail_timestamp => \'ms_current_timestamp()',
+ send_fail_timestamp => \'current_timestamp',
send_fail_reason => 'Failed to post over Open311',
} );
}
diff --git a/bin/update-schema b/bin/update-schema
index ce193f29c..57d1d8ad3 100755
--- a/bin/update-schema
+++ b/bin/update-schema
@@ -95,8 +95,8 @@ sub get_statements {
next if /^--/; # Ignore comments
$s .= $_;
# Functions may have semicolons within them
- $in_function = 1 if /create function/i;
- $in_function = 0 if /language 'plpgsql'/i;
+ $in_function = 1 if /create (or replace )?function/i;
+ $in_function = 0 if /language (sql|'plpgsql')/i;
if ($s =~ /;/ && !$in_function) {
push @statements, $s;
$s = '';
@@ -195,6 +195,8 @@ else {
# By querying the database schema, we can see where we're currently at
# (assuming schema change files are never half-applied, which should be the case)
sub get_db_version {
+ return '0034' if ! function_exists('ms_current_timestamp');
+ return '0033' if ! function_exists('angle_between');
return '0032' if table_exists('moderation_original_data');
return '0031' if column_exists('body', 'external_url');
return '0030' if ! constraint_exists('admin_log_action_check');
@@ -254,3 +256,8 @@ sub constraint_exists {
return dbh()->selectrow_array('select count(*) from pg_constraint where conname = ?', {}, $constraint);
}
+# Returns true if a function exists
+sub function_exists {
+ my $fn = shift;
+ return dbh()->selectrow_array('select count(*) from pg_proc where proname = ?', {}, $fn);
+}