]> jfr.im git - irc/freenode/gms.git/commitdiff
Add script to update uuid references in other fixtures.
authorErrietta Kostala <redacted>
Sat, 28 May 2016 21:43:38 +0000 (22:43 +0100)
committerErrietta Kostala <redacted>
Sat, 28 May 2016 21:43:38 +0000 (22:43 +0100)
bin/update_other_tables.pl [new file with mode: 0755]

diff --git a/bin/update_other_tables.pl b/bin/update_other_tables.pl
new file mode 100755 (executable)
index 0000000..25086b2
--- /dev/null
@@ -0,0 +1,20 @@
+#!/usr/bin/env perl
+
+# Don't even ask, thank mst.
+# Run like this: ls t/etc/**/**/*.fix  | grep -v accounts | perl bin/update_other_tables.pl
+
+use Data::Munge qw(replace mapval list2re);
+use IO::All;
+use Data::Dumper;
+
+my @dirs = qw(approved_group basic_db new_db pending_changes staff three_contacts three_groups);
+
+foreach my $dir (@dirs) {
+    my @accounts = map do($_), glob("t/etc/$dir/accounts/*.fix");
+    my %id_map = map +($_->{uuid} => $_->{id}), @accounts;
+
+    foreach my $file (mapval { chomp } <STDIN>) {
+        my $data = io->file($file)->all;
+        io->file($file)->print(replace($data, list2re(keys %id_map), sub { $id_map{$_[0]} }));
+    }
+}