From ba7c5f88edc45439d7ce344200c16b87d1e0f61a Mon Sep 17 00:00:00 2001 From: Greg Sabino Mullane Date: Tue, 25 Jul 2006 00:28:03 +0000 Subject: [PATCH] Allow for renamed tables. --- maintenance/postgres/compare_schemas.pl | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/maintenance/postgres/compare_schemas.pl b/maintenance/postgres/compare_schemas.pl index 56670af1c6..22e8c1524a 100644 --- a/maintenance/postgres/compare_schemas.pl +++ b/maintenance/postgres/compare_schemas.pl @@ -120,8 +120,14 @@ my %ok; while () { next unless /^(\w+)\s*:\s*([^#]+)/; my ($name,$val) = ($1,$2); + if ($name eq 'RENAME') { + die "Invalid rename\n" unless $val =~ /(\w+)\s+(\w+)/; + $ok{OLD}{$1} = $2; + $ok{NEW}{$2} = $1; + next; + } for (split(/\s+/ => $val)) { - $ok{$name}{$_}=1; + $ok{$name}{$_} = 0; } } @@ -131,9 +137,10 @@ for my $t (sort keys %old) { print "Table not in $new: $t\n"; next; } - next if exists $ok{OLD}{$t}; + next if exists $ok{OLD}{$t} and !$ok{OLD}{$t}; + my $newt = exists $ok{OLD}{$t} ? $ok{OLD}{$t} : $t; my $oldcol = $old{$t}{column}; - my $newcol = $new{$t}{column}; + my $newcol = $new{$newt}{column}; for my $c (keys %$oldcol) { if (!exists $newcol->{$c}) { print "Column $t.$c not in new\n"; @@ -159,7 +166,7 @@ __DATA__ ## Known exceptions OLD: searchindex ## We use tsearch2 directly on the page table instead OLD: archive ## This is a view due to the char(14) timestamp hack -OLD: user text ## Reserved words, so we use something else -NEW: mwuser pagecontent ## This is what we use +RENAME: user mwuser ## Reserved word causing lots of problems +RENAME: text pagecontent ## Reserved word NEW: archive2 ## The real archive table NEW: mediawiki_version ## Just us, for now -- 2.20.1