Convert to abstract schema

Bug: T361920
Change-Id: I28f450a4f5c4e1784b4e7e8c8e1fa694bfac4d14
这个提交包含在:
Reedy 2024-04-26 18:11:25 +01:00
父节点 75cb81c2e6
当前提交 bb40f4f232
共有 6 个文件被更改,包括 84 次插入18 次删除

查看文件

@ -165,9 +165,21 @@ class GlobalUserrightsHooks {
*/
public static function onLoadExtensionSchemaUpdates( DatabaseUpdater $updater ) {
$dir = __DIR__;
$updater->addExtensionTable( 'global_user_groups', $dir . '/../sql/global_user_groups.sql' );
$dir .= '/../db_patches';
$dbType = $updater->getDB()->getType();
$dir = dirname( __DIR__ ) . '/sql/';
$updater->addExtensionTable(
'global_user_groups',
"$dir/$dbType/tables-generated.sql"
);
$dir = dirname( __DIR__ ) . '/db_patches';
if ( $dbType === 'postgres' ) {
// Currently no schema changes with postgres, bail out
return;
}
// Update the table with the new definitions
// This ensures backwards compatibility

查看文件

@ -1,16 +0,0 @@
-- Additional table for the GlobalUserrights extension
-- To be added to $wgSharedDB
CREATE TABLE /*_*/global_user_groups (
-- Key to user_id
gug_user int unsigned NOT NULL default 0,
-- Group name
gug_group varbinary(255) NOT NULL default '',
-- Expiry date
gug_expiry varbinary(14) NULL default NULL,
PRIMARY KEY (gug_user, gug_group)
) /*$wgDBTableOptions*/;
CREATE INDEX /*i*/gug_group ON /*_*/global_user_groups (gug_group);
CREATE INDEX /*i*/gug_expiry ON /*_*/global_user_groups (gug_expiry);

查看文件

@ -0,0 +1,12 @@
-- This file is automatically generated using maintenance/generateSchemaSql.php.
-- Source: /var/www/wiki/mediawiki/extensions/GlobalUserrights/sql/tables.json
-- Do not modify this file directly.
-- See https://www.mediawiki.org/wiki/Manual:Schema_changes
CREATE TABLE /*_*/global_user_groups (
gug_user BIGINT UNSIGNED NOT NULL,
gug_group VARBINARY(255) DEFAULT '' NOT NULL,
gug_expiry BINARY(14) NOT NULL,
INDEX gug_group (gug_group),
INDEX gug_expiry (gug_expiry),
PRIMARY KEY(gug_user, gug_group)
) /*$wgDBTableOptions*/;

查看文件

@ -0,0 +1,14 @@
-- This file is automatically generated using maintenance/generateSchemaSql.php.
-- Source: /var/www/wiki/mediawiki/extensions/GlobalUserrights/sql/tables.json
-- Do not modify this file directly.
-- See https://www.mediawiki.org/wiki/Manual:Schema_changes
CREATE TABLE global_user_groups (
gug_user BIGINT NOT NULL,
gug_group TEXT DEFAULT '' NOT NULL,
gug_expiry TIMESTAMPTZ NOT NULL,
PRIMARY KEY(gug_user, gug_group)
);
CREATE INDEX gug_group ON global_user_groups (gug_group);
CREATE INDEX gug_expiry ON global_user_groups (gug_expiry);

查看文件

@ -0,0 +1,14 @@
-- This file is automatically generated using maintenance/generateSchemaSql.php.
-- Source: /var/www/wiki/mediawiki/extensions/GlobalUserrights/sql/tables.json
-- Do not modify this file directly.
-- See https://www.mediawiki.org/wiki/Manual:Schema_changes
CREATE TABLE /*_*/global_user_groups (
gug_user BIGINT UNSIGNED NOT NULL,
gug_group BLOB DEFAULT '' NOT NULL,
gug_expiry BLOB NOT NULL,
PRIMARY KEY(gug_user, gug_group)
);
CREATE INDEX gug_group ON /*_*/global_user_groups (gug_group);
CREATE INDEX gug_expiry ON /*_*/global_user_groups (gug_expiry);

30
sql/tables.json 普通文件
查看文件

@ -0,0 +1,30 @@
[
{
"name": "global_user_groups",
"columns": [
{
"name": "gug_user",
"comment": "Key to user_id",
"type": "bigint",
"options": { "unsigned": true, "notnull": true, "autoincrement": false }
},
{
"name": "gug_group",
"comment": "Group name",
"type": "binary",
"options": { "length": 255, "default": "", "notnull": false }
},
{
"name": "gug_expiry",
"comment": "Text username or IP address",
"type": "mwtimestamp",
"options": { "notnull": true }
}
],
"indexes": [
{ "name": "gug_group", "columns": [ "gug_group" ], "unique": false },
{ "name": "gug_expiry", "columns": [ "gug_expiry" ], "unique": false }
],
"pk": [ "gug_user", "gug_group" ]
}
]