Index: trunk/extensions/EducationProgram/maintenance/deleteEducation.php |
— | — | @@ -0,0 +1,62 @@ |
| 2 | +<?php |
| 3 | + |
| 4 | +/** |
| 5 | + * Maintenance scrtip for deleting all Wikipedia Education Program data. |
| 6 | + * |
| 7 | + * @since 0.1 |
| 8 | + * |
| 9 | + * @file DeleteEducation.php |
| 10 | + * @ingroup EducationProgram |
| 11 | + * |
| 12 | + * @licence GNU GPL v3 or later |
| 13 | + * @author Jeroen De Dauw < jeroendedauw@gmail.com > |
| 14 | + */ |
| 15 | + |
| 16 | +$basePath = getenv( 'MW_INSTALL_PATH' ) !== false ? getenv( 'MW_INSTALL_PATH' ) : dirname( __FILE__ ) . '/../../..'; |
| 17 | + |
| 18 | +require_once $basePath . '/maintenance/Maintenance.php'; |
| 19 | + |
| 20 | +class DeleteEducation extends Maintenance { |
| 21 | + |
| 22 | + public function __construct() { |
| 23 | + $this->mDescription = 'Delete the Wikipedia Education Program data'; |
| 24 | + |
| 25 | + parent::__construct(); |
| 26 | + } |
| 27 | + |
| 28 | + public function execute() { |
| 29 | + echo "Are you really really sure you want to delete all EP date?? If so, type YES\n"; |
| 30 | + |
| 31 | + if ( $this->readconsole() !== 'YES' ) { |
| 32 | + return; |
| 33 | + } |
| 34 | + |
| 35 | + $tables = array( |
| 36 | + 'orgs', |
| 37 | + 'courses', |
| 38 | + 'students', |
| 39 | + 'users_per_course', |
| 40 | + 'instructors', |
| 41 | + 'oas', |
| 42 | + 'cas', |
| 43 | + 'articles', |
| 44 | + 'revisions', |
| 45 | + ); |
| 46 | + |
| 47 | + $dbw = wfGetDB( DB_MASTER ); |
| 48 | + |
| 49 | + foreach ( $tables as $table ) { |
| 50 | + $name = "ep_$table"; |
| 51 | + |
| 52 | + echo "Truncating table $name..."; |
| 53 | + |
| 54 | + $dbw->query( 'TRUNCATE TABLE ' . $dbw->tableName( $name ) ); |
| 55 | + |
| 56 | + echo "done!\n"; |
| 57 | + } |
| 58 | + } |
| 59 | + |
| 60 | +} |
| 61 | + |
| 62 | +$maintClass = 'DeleteEducation'; |
| 63 | +require_once( RUN_MAINTENANCE_IF_MAIN ); |