Handy script to manually run a single sql patch file, with all the necessary options...
[lhc/web/wiklou.git] / maintenance / patchSql.php
1 <?php
2
3 // Manually run an SQL patch outside of the general updaters.
4 // This ensures that the DB options (charset, prefix, engine) are correctly set.
5
6 require_once 'commandLine.inc';
7 require_once "$IP/maintenance/updaters.inc";
8
9 if( $args ) {
10 foreach( $args as $arg ) {
11 $files = array(
12 $arg,
13 archive( $arg ),
14 archive( "patch-$arg.sql" ),
15 );
16 foreach( $files as $file ) {
17 if( file_exists( $file ) ) {
18 echo "$file ...\n";
19 dbsource( $file );
20 continue 2;
21 }
22 }
23 echo "Could not find $arg\n";
24 }
25 echo "done.\n";
26 } else {
27 echo "Run an SQL file into the DB, replacing prefix and charset vars.\n";
28 echo "Usage:\n";
29 echo " php maintenance/patchSql.php file1.sql file2.sql ...\n";
30 echo "\n";
31 echo "Paths in maintenance/archive are automatically expanded if a local file isn't found.\n";
32 }