summaryrefslogtreecommitdiff
path: root/util/updates/update_1.22.pl
diff options
context:
space:
mode:
Diffstat (limited to 'util/updates/update_1.22.pl')
-rwxr-xr-xutil/updates/update_1.22.pl28
1 files changed, 28 insertions, 0 deletions
diff --git a/util/updates/update_1.22.pl b/util/updates/update_1.22.pl
new file mode 100755
index 00000000..465c8c40
--- /dev/null
+++ b/util/updates/update_1.22.pl
@@ -0,0 +1,28 @@
+#!/usr/bin/perl
+
+
+# update_1.22.sql must be executed before this script
+
+
+use strict;
+use warnings;
+use DBI;
+
+BEGIN { require '/www/vndb/lib/global.pl' }
+
+my $sql = DBI->connect(@VNDB::DBLOGIN,
+ { PrintError => 1, RaiseError => 1, AutoCommit => 0 });
+
+my $q = $sql->prepare('INSERT INTO relgraph (id, cmap) VALUES(?,?)');
+for (glob "/www/vndb/data/rg/*/*.cmap") {
+ my $id = $1 if /([0-9]+)\.cmap$/;
+ open my $F, '<', $_ or die $!;
+ $q->execute($id, join "\n", <$F>);
+ close $F;
+}
+
+$sql->do('ALTER TABLE vn ADD FOREIGN KEY (rgraph) REFERENCES relgraph (id) DEFERRABLE INITIALLY DEFERRED');
+$sql->commit;
+
+# it's now safe to delete /data/rg
+