+ foreach ($nullchanges as $nc) {
+ $fi = $wgDatabase->fieldInfo($nc[0], $nc[1]);
+ if (is_null($fi)) {
+ wfOut( "... error: expected column $nc[0].$nc[1] to exist\n" );
+ exit(1);
+ }
+ if ($fi->nullable()) {
+ ## It's NULL - does it need to be NOT NULL?
+ if ('NOT NULL' === $nc[2]) {
+ wfOut( "Changing \"$nc[0].$nc[1]\" to not allow NULLs\n" );
+ $wgDatabase->query( "ALTER TABLE $nc[0] ALTER $nc[1] SET NOT NULL" );
+ }
+ else {
+ wfOut( "... column \"$nc[0].$nc[1]\" is already set as NULL\n" );
+ }
+ }
+ else {
+ ## It's NOT NULL - does it need to be NULL?
+ if ('NULL' === $nc[2]) {
+ wfOut( "Changing \"$nc[0].$nc[1]\" to allow NULLs\n" );
+ $wgDatabase->query( "ALTER TABLE $nc[0] ALTER $nc[1] DROP NOT NULL" );
+ }
+ else {
+ wfOut( "... column \"$nc[0].$nc[1]\" is already set as NOT NULL\n" );
+ }
+ }
+ }
+