I've inherited an old mediawiki installation running 1.12, and would
like to migrate to 1.23.13, since there are packages for that release in
EPEL.
I've dumped the databases on the old PostgreSQL server and loaded them
on the new host, but the upgrade script fails. I added a debugging
statement, so I can see that the failure occurs when the upgrade script
is trying to change the default value of filearchive.fa_id.
# php maintenance/update.php --conf
/var/www/mediawiki123/LocalSettings.php --quick
MediaWiki 1.23.13 Updater
Going to run database updates for wiki_wiki
Depending on the size of your database this may take a while!
...skipping: 'mwuser' table doesn't exist yet.
...skipping: 'mwuser' table doesn't exist yet.
...skipping: 'pagecontent' table doesn't exist yet.
Creating sequence logging_log_id_seq
Creating sequence page_restrictions_pr_id_seq
Creating sequence filearchive_fa_id_seq
Changing 'filearchive.fa_id' default value to
"nextval"('"filearchive_fa_id_seq"'::"regclass")
PHP Fatal error: Call to a member function defaultValue() on a
non-object in
/usr/share/mediawiki123/includes/installer/PostgresUpdater.php on line 711
I've also enabled query loggging in PostgreSQL, and I can see that the
upgrade script runs this query to get info about filearchive.fa_id, but
gets no results, which appears to be the root of the problem.
# psql -h 127.0.0.1 -U wiki_wiki wiki_wiki
Password for user wiki_wiki:
psql (9.2.14)
Type "help" for help.
wiki_wiki=> SELECT /* DatabaseBase::query */ attnotnull, attlen,
conname AS conname,
wiki_wiki-> atthasdef,
wiki_wiki-> adsrc,
wiki_wiki-> COALESCE(condeferred, 'f') AS deferred,
wiki_wiki-> COALESCE(condeferrable, 'f') AS deferrable,
wiki_wiki-> CASE WHEN typname = 'int2' THEN 'smallint'
wiki_wiki-> WHEN typname = 'int4' THEN 'integer'
wiki_wiki-> WHEN typname = 'int8' THEN 'bigint'
wiki_wiki-> WHEN typname = 'bpchar' THEN 'char'
wiki_wiki-> ELSE typname END AS typname
wiki_wiki-> FROM pg_class c
wiki_wiki-> JOIN pg_namespace n ON (n.oid = c.relnamespace)
wiki_wiki-> JOIN pg_attribute a ON (a.attrelid = c.oid)
wiki_wiki-> JOIN pg_type t ON (t.oid = a.atttypid)
wiki_wiki-> LEFT JOIN pg_constraint o ON (o.conrelid = c.oid AND
a.attnum = ANY(o.conkey) AND o.contype = 'f')
wiki_wiki-> LEFT JOIN pg_attrdef d on c.oid=d.adrelid and
a.attnum=d.adnum
wiki_wiki-> WHERE relkind = 'r'
wiki_wiki-> AND nspname='mediawiki'
wiki_wiki-> AND relname='filearchive'
wiki_wiki-> AND attname='fa_id';
attnotnull | attlen | conname | atthasdef | adsrc | deferred |
deferrable | typname
------------+--------+---------+-----------+-------+----------+------------+---------
(0 rows)
However, if I change (pg_namespace.)nspname to "public", then I do get a
result:
wiki_wiki=> SELECT /* DatabaseBase::query */ attnotnull, attlen,
conname AS conname,
wiki_wiki-> atthasdef,
wiki_wiki-> adsrc,
wiki_wiki-> COALESCE(condeferred, 'f') AS deferred,
wiki_wiki-> COALESCE(condeferrable, 'f') AS deferrable,
wiki_wiki-> CASE WHEN typname = 'int2' THEN
'smallint'
wiki_wiki-> WHEN typname = 'int4' THEN 'integer'
wiki_wiki-> WHEN typname = 'int8' THEN 'bigint'
wiki_wiki-> WHEN typname = 'bpchar' THEN 'char'
wiki_wiki-> ELSE typname END AS typname
wiki_wiki-> FROM pg_class c
wiki_wiki-> JOIN pg_namespace n ON (n.oid = c.relnamespace)
wiki_wiki-> JOIN pg_attribute a ON (a.attrelid = c.oid)
wiki_wiki-> JOIN pg_type t ON (t.oid = a.atttypid)
wiki_wiki-> LEFT JOIN pg_constraint o ON (o.conrelid =
c.oid AND a.attnum = ANY(o.conkey) AND o.contype = 'f')
wiki_wiki-> LEFT JOIN pg_attrdef d on c.oid=d.adrelid
and a.attnum=d.adnum
wiki_wiki-> WHERE relkind = 'r'
wiki_wiki-> AND nspname='public'
wiki_wiki-> AND relname='filearchive'
wiki_wiki-> AND attname='fa_id';
attnotnull | attlen | conname | atthasdef | adsrc |
deferred | deferrable | typname
------------+--------+---------+-----------+--------------------------------------------+----------+------------+---------
t | 4 | | t |
nextval('filearchive_fa_id_seq'::regclass) | f | f | integer
(1 row)
I'm guessing that's related to the $wgDBts2schema setting from the old
installation:
https://www.mediawiki.org/wiki/Manual:$wgDBts2schema
...but I'm not sure how to fix it. Do I need to download some
intermediate version of mediawiki and upgrade the database in two stages?