JeroenDeDauw/Maps — pull request #31 by Mwmaps (2014-05-08 21:39:59+00:00)
Title: Maps pull request from Jeroen De Dauw (talk)‎15:15, 28 April 2014

/**
* This will setup database tables for layer functionality.
*
* @since 3.0
*
* @global type $wgDBtype
* @param DatabaseUpdater $updater
*
* @return true
*/
public static function onLoadExtensionSchemaUpdates( DatabaseUpdater $updater ) {
global $wgDBtype;

switch( $wgDBtype ) {
case 'mysql':
case 'sqlite':
$sqlPath = dirname( __FILE__ ) . '/schema/MapsLayers.sql';
break;
case 'postgres':
$sqlPath = dirname( __FILE__ ) . '/schema/MapsLayers-postgres.sql';
break;
/** @ToDo: Support for other SQL **/
}
$updater->addExtensionTable( 'maps_layers', $sqlPath );

return true;
}

::::::::::::::
MapsLayers-postgres.sql
::::::::::::::
BEGIN;

CREATE TABLE maps_layers (
layer_page_id INTEGER NOT NULL REFERENCES page(page_id) ON DELETE CASCADE,
layer_name VARCHAR(64) DEFAULT NULL,
layer_type VARCHAR(32) NOT NULL,
layer_data TEXT NOT NULL
) /*$wgDBTableOptions*/;

COMMIT;