Skip to content

Commit

Permalink
add DB migration to drop style column
Browse files Browse the repository at this point in the history
  • Loading branch information
FO-nTTaX committed May 7, 2024
1 parent ef5d858 commit d64d777
Show file tree
Hide file tree
Showing 5 changed files with 32 additions and 13 deletions.
6 changes: 5 additions & 1 deletion extension.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "NetworkNotice",
"version": "3.2.1",
"version": "3.3.0",
"author": [
"Tephus",
"[https://fo-nttax.de Alex Winkler]"
Expand All @@ -26,10 +26,14 @@
"HookHandlers": {
"Main": {
"class": "\\Liquipedia\\Extension\\NetworkNotice\\Hooks\\MainHookHandler"
},
"Schema": {
"class": "\\Liquipedia\\Extension\\NetworkNotice\\Hooks\\SchemaHookHandler"
}
},
"Hooks": {
"BeforePageDisplay": "Main",
"LoadExtensionSchemaUpdates": "Schema",
"LPExtensionMenu": [
"Liquipedia\\Extension\\NetworkNotice\\Hooks\\LegacyHooks::onLPExtensionMenu"
],
Expand Down
2 changes: 1 addition & 1 deletion resources/scripts/ext.networknotice.Notice.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
const items = localStorage.getItem( LOCAL_STORAGE_KEY );
try {
return items ? JSON.parse( items ) : [];
} catch( e ) {
} catch ( e ) {
return [ ];
}
}
Expand Down
1 change: 1 addition & 0 deletions sql/3_3_0.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
ALTER TABLE `networknotice` DROP `style`;
11 changes: 0 additions & 11 deletions networknotice.sql → sql/networknotice.sql
Original file line number Diff line number Diff line change
@@ -1,23 +1,12 @@
SET SQL_MODE = "NO_AUTO_VALUE_ON_ZERO";
SET time_zone = "+00:00";


-- --------------------------------------------------------
-- Table structure for table `networknotice`
--

CREATE TABLE IF NOT EXISTS `networknotice` (
`notice_id` int(11) NOT NULL AUTO_INCREMENT,
`label` tinyblob NOT NULL,
`wiki` blob NOT NULL,
`namespace` tinyblob NOT NULL,
`notice_text` blob NOT NULL,
`style` tinyblob NOT NULL,
`category` blob NOT NULL,
`prefix` blob NOT NULL,
`action` blob NOT NULL,
`disabled` tinyint(1) NOT NULL DEFAULT '0',
PRIMARY KEY (`notice_id`)
) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=binary;


25 changes: 25 additions & 0 deletions src/Hooks/SchemaHookHandler.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<?php

namespace Liquipedia\Extension\NetworkNotice\Hooks;

use DatabaseUpdater;
use MediaWiki\Installer\Hook\LoadExtensionSchemaUpdatesHook;
use MediaWiki\MediaWikiServices;

class SchemaHookHandler implements LoadExtensionSchemaUpdatesHook {

/**
* @param DatabaseUpdater $updater
*/
public function onLoadExtensionSchemaUpdates( $updater ) {
$config = MediaWikiServices::getInstance()->getMainConfig();
$db = $updater->getDB();
if ( !$db->tableExists( $config->get( 'DBname' ) . '.networknotice', __METHOD__ ) ) {
$updater->addExtensionTable( 'networknotice', __DIR__ . '/../../sql/networknotice.sql' );
}
if ( $db->fieldExists( $config->get( 'DBname' ) . '.networknotice', 'style' ) ) {
$updater->dropExtensionField( 'networknotice', 'style', __DIR__ . '/../../sql/3_3_0.sql' );
}
}

}

0 comments on commit d64d777

Please sign in to comment.