Skip to content

Commit

Permalink
Merge "tests: Add structure test for abstract schema"
Browse files Browse the repository at this point in the history
  • Loading branch information
jenkins-bot authored and Gerrit Code Review committed Dec 17, 2024
2 parents fe6fead + 0dea180 commit 4a5258e
Show file tree
Hide file tree
Showing 27 changed files with 174 additions and 57 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
<?php

declare( strict_types=1 );

namespace Wikibase\Client\Tests\Integration;

use MediaWiki\Tests\Structure\AbstractSchemaTestBase;

/**
* @group Wikibase
* @coversNothing
* @license GPL-2.0-or-later
*/
class WikibaseClientSchemaTest extends AbstractSchemaTestBase {
protected static function getSchemasDirectory(): string {
return __DIR__ . '/../../../sql/abstract/';
}

protected static function getSchemaChangesDirectory(): string {
return __DIR__ . '/../../../sql/abstractSchemaChanges/';
}

protected static function getSchemaSQLDirs(): array {
return [
'mysql' => __DIR__ . '/../../../sql/mysql/',
'sqlite' => __DIR__ . '/../../../sql/sqlite',
'postgres' => __DIR__ . '/../../../sql/postgres',
];
}

protected static function getSchemaChangesSQLDirs(): array {
return [
'mysql' => __DIR__ . '/../../../sql/mysql/archives',
'sqlite' => __DIR__ . '/../../../sql/sqlite/archives',
'postgres' => __DIR__ . '/../../../sql/postgres/archives',
];
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
-- This file is automatically generated using maintenance/generateSchemaChangeSql.php.
-- Source: extensions/Wikibase/repo/sql/abstractSchemaChanges/patch-wb_changes-change_object_id-index.json
-- Source: repo/sql/abstractSchemaChanges/patch-wb_changes-change_object_id-index.json
-- Do not modify this file directly.
-- See https://www.mediawiki.org/wiki/Manual:Schema_changes
CREATE INDEX change_object_id ON /*_*/wb_changes (change_object_id);
CREATE INDEX change_object_id ON /*_*/wb_changes (change_object_id);
8 changes: 4 additions & 4 deletions repo/sql/mysql/archives/patch-wb_id_counters-unique-to-pk.sql
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
-- This file is automatically generated using maintenance/generateSchemaChangeSql.php.
-- Source: extensions/Wikibase/repo/sql/abstractSchemaChanges/patch-wb_id_counters-unique-to-pk.json
-- Source: repo/sql/abstractSchemaChanges/patch-wb_id_counters-unique-to-pk.json
-- Do not modify this file directly.
-- See https://www.mediawiki.org/wiki/Manual:Schema_changes
DROP INDEX wb_id_counters_type ON /*_*/wb_id_counters;
ALTER TABLE /*_*/wb_id_counters
ADD PRIMARY KEY (id_type);
DROP INDEX wb_id_counters_type ON /*_*/wb_id_counters;
ALTER TABLE /*_*/wb_id_counters
ADD PRIMARY KEY (id_type);
2 changes: 1 addition & 1 deletion repo/sql/mysql/term_store.sql
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
-- This file is automatically generated using maintenance/generateSchemaSql.php.
-- Source: extensions/Wikibase/repo/sql/abstract/term_store.json
-- Source: repo/sql/abstract/term_store.json
-- Do not modify this file directly.
-- See https://www.mediawiki.org/wiki/Manual:Schema_changes
CREATE TABLE /*_*/wbt_item_terms (
Expand Down
2 changes: 1 addition & 1 deletion repo/sql/mysql/wb_changes.sql
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
-- This file is automatically generated using maintenance/generateSchemaSql.php.
-- Source: extensions/Wikibase/repo/sql/abstract/wb_changes.json
-- Source: repo/sql/abstract/wb_changes.json
-- Do not modify this file directly.
-- See https://www.mediawiki.org/wiki/Manual:Schema_changes
CREATE TABLE /*_*/wb_changes (
Expand Down
2 changes: 1 addition & 1 deletion repo/sql/mysql/wb_changes_subscription.sql
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
-- This file is automatically generated using maintenance/generateSchemaSql.php.
-- Source: extensions/Wikibase/repo/sql/abstract/wb_changes_subscription.json
-- Source: repo/sql/abstract/wb_changes_subscription.json
-- Do not modify this file directly.
-- See https://www.mediawiki.org/wiki/Manual:Schema_changes
CREATE TABLE /*_*/wb_changes_subscription (
Expand Down
2 changes: 1 addition & 1 deletion repo/sql/mysql/wb_id_counters.sql
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
-- This file is automatically generated using maintenance/generateSchemaSql.php.
-- Source: extensions/Wikibase/repo/sql/abstract/wb_id_counters.json
-- Source: repo/sql/abstract/wb_id_counters.json
-- Do not modify this file directly.
-- See https://www.mediawiki.org/wiki/Manual:Schema_changes
CREATE TABLE /*_*/wb_id_counters (
Expand Down
2 changes: 1 addition & 1 deletion repo/sql/mysql/wb_items_per_site.sql
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
-- This file is automatically generated using maintenance/generateSchemaSql.php.
-- Source: extensions/Wikibase/repo/sql/abstract/wb_items_per_site.json
-- Source: repo/sql/abstract/wb_items_per_site.json
-- Do not modify this file directly.
-- See https://www.mediawiki.org/wiki/Manual:Schema_changes
CREATE TABLE /*_*/wb_items_per_site (
Expand Down
2 changes: 1 addition & 1 deletion repo/sql/mysql/wb_property_info.sql
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
-- This file is automatically generated using maintenance/generateSchemaSql.php.
-- Source: extensions/Wikibase/repo/sql/abstract/wb_property_info.json
-- Source: repo/sql/abstract/wb_property_info.json
-- Do not modify this file directly.
-- See https://www.mediawiki.org/wiki/Manual:Schema_changes
CREATE TABLE /*_*/wb_property_info (
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
-- This file is automatically generated using maintenance/generateSchemaChangeSql.php.
-- Source: extensions/Wikibase/repo/sql/abstractSchemaChanges/patch-wb_changes-change_object_id-index.json
-- Source: repo/sql/abstractSchemaChanges/patch-wb_changes-change_object_id-index.json
-- Do not modify this file directly.
-- See https://www.mediawiki.org/wiki/Manual:Schema_changes
CREATE INDEX change_object_id ON wb_changes (change_object_id);
CREATE INDEX change_object_id ON wb_changes (change_object_id);
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
-- Source: repo/sql/abstractSchemaChanges/patch-wb_changes-change_timestamp.json
-- Do not modify this file directly.
-- See https://www.mediawiki.org/wiki/Manual:Schema_changes
ALTER TABLE wb_changes ALTER change_time TYPE TIMESTAMPTZ;
ALTER TABLE wb_changes ALTER change_time
DROP DEFAULT;
ALTER TABLE wb_changes ALTER change_time TYPE TIMESTAMPTZ;
ALTER TABLE wb_changes
ALTER change_time TYPE TIMESTAMPTZ;
ALTER TABLE wb_changes
ALTER change_time TYPE TIMESTAMPTZ;
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
-- This file is automatically generated using maintenance/generateSchemaChangeSql.php.
-- Source: extensions/Wikibase/repo/sql/abstractSchemaChanges/patch-wb_id_counters-unique-to-pk.json
-- Source: repo/sql/abstractSchemaChanges/patch-wb_id_counters-unique-to-pk.json
-- Do not modify this file directly.
-- See https://www.mediawiki.org/wiki/Manual:Schema_changes
DROP INDEX wb_id_counters_type;
ALTER TABLE wb_id_counters
ADD PRIMARY KEY (id_type);
DROP INDEX wb_id_counters_type;
ALTER TABLE wb_id_counters
ADD PRIMARY KEY (id_type);
2 changes: 1 addition & 1 deletion repo/sql/postgres/term_store.sql
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
-- This file is automatically generated using maintenance/generateSchemaSql.php.
-- Source: extensions/Wikibase/repo/sql/abstract/term_store.json
-- Source: repo/sql/abstract/term_store.json
-- Do not modify this file directly.
-- See https://www.mediawiki.org/wiki/Manual:Schema_changes
CREATE TABLE wbt_item_terms (
Expand Down
2 changes: 1 addition & 1 deletion repo/sql/postgres/wb_changes.sql
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
-- This file is automatically generated using maintenance/generateSchemaSql.php.
-- Source: extensions/Wikibase/repo/sql/abstract/wb_changes.json
-- Source: repo/sql/abstract/wb_changes.json
-- Do not modify this file directly.
-- See https://www.mediawiki.org/wiki/Manual:Schema_changes
CREATE TABLE wb_changes (
Expand Down
2 changes: 1 addition & 1 deletion repo/sql/postgres/wb_changes_subscription.sql
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
-- This file is automatically generated using maintenance/generateSchemaSql.php.
-- Source: extensions/Wikibase/repo/sql/abstract/wb_changes_subscription.json
-- Source: repo/sql/abstract/wb_changes_subscription.json
-- Do not modify this file directly.
-- See https://www.mediawiki.org/wiki/Manual:Schema_changes
CREATE TABLE wb_changes_subscription (
Expand Down
2 changes: 1 addition & 1 deletion repo/sql/postgres/wb_id_counters.sql
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
-- This file is automatically generated using maintenance/generateSchemaSql.php.
-- Source: extensions/Wikibase/repo/sql/abstract/wb_id_counters.json
-- Source: repo/sql/abstract/wb_id_counters.json
-- Do not modify this file directly.
-- See https://www.mediawiki.org/wiki/Manual:Schema_changes
CREATE TABLE wb_id_counters (
Expand Down
2 changes: 1 addition & 1 deletion repo/sql/postgres/wb_items_per_site.sql
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
-- This file is automatically generated using maintenance/generateSchemaSql.php.
-- Source: extensions/Wikibase/repo/sql/abstract/wb_items_per_site.json
-- Source: repo/sql/abstract/wb_items_per_site.json
-- Do not modify this file directly.
-- See https://www.mediawiki.org/wiki/Manual:Schema_changes
CREATE TABLE wb_items_per_site (
Expand Down
2 changes: 1 addition & 1 deletion repo/sql/postgres/wb_property_info.sql
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
-- This file is automatically generated using maintenance/generateSchemaSql.php.
-- Source: extensions/Wikibase/repo/sql/abstract/wb_property_info.json
-- Source: repo/sql/abstract/wb_property_info.json
-- Do not modify this file directly.
-- See https://www.mediawiki.org/wiki/Manual:Schema_changes
CREATE TABLE wb_property_info (
Expand Down
Original file line number Diff line number Diff line change
@@ -1,18 +1,48 @@
-- This file is automatically generated using maintenance/generateSchemaChangeSql.php.
-- Source: extensions/Wikibase/repo/sql/abstractSchemaChanges/patch-wb_changes-change_object_id-index.json
-- Source: repo/sql/abstractSchemaChanges/patch-wb_changes-change_object_id-index.json
-- Do not modify this file directly.
-- See https://www.mediawiki.org/wiki/Manual:Schema_changes
DROP INDEX wb_changes_change_time;
DROP INDEX wb_changes_change_revision_id;
CREATE TEMPORARY TABLE /*_*/__temp__wb_changes AS
SELECT change_id, change_type, change_time, change_object_id, change_revision_id, change_user_id, change_info
FROM /*_*/wb_changes;
DROP TABLE /*_*/wb_changes;
CREATE TABLE /*_*/wb_changes ( change_id INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, change_type VARCHAR(25) NOT NULL, change_time BLOB NOT NULL, change_object_id BLOB NOT NULL, change_revision_id INTEGER UNSIGNED NOT NULL, change_user_id INTEGER UNSIGNED NOT NULL, change_info BLOB NOT NULL );
INSERT INTO /*_*/wb_changes ( change_id, change_type, change_time, change_object_id, change_revision_id, change_user_id, change_info )
SELECT change_id, change_type, change_time, change_object_id, change_revision_id, change_user_id, change_info
FROM /*_*/__temp__wb_changes;
DROP TABLE /*_*/__temp__wb_changes;
CREATE INDEX wb_changes_change_time ON /*_*/wb_changes (change_time);
CREATE INDEX wb_changes_change_revision_id ON /*_*/wb_changes (change_revision_id);
CREATE INDEX change_object_id ON /*_*/wb_changes (change_object_id);
SELECT
change_id,
change_type,
change_time,
change_object_id,
change_revision_id,
change_user_id,
change_info
FROM /*_*/wb_changes;
DROP TABLE /*_*/wb_changes;


CREATE TABLE /*_*/wb_changes (
change_id INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL,
change_type VARCHAR(25) NOT NULL,
change_time BLOB NOT NULL,
change_object_id BLOB NOT NULL,
change_revision_id INTEGER UNSIGNED NOT NULL,
change_user_id INTEGER UNSIGNED NOT NULL,
change_info BLOB NOT NULL
);
INSERT INTO /*_*/wb_changes (
change_id, change_type, change_time,
change_object_id, change_revision_id,
change_user_id, change_info
)
SELECT
change_id,
change_type,
change_time,
change_object_id,
change_revision_id,
change_user_id,
change_info
FROM
/*_*/__temp__wb_changes;
DROP TABLE /*_*/__temp__wb_changes;

CREATE INDEX wb_changes_change_time ON /*_*/wb_changes (change_time);

CREATE INDEX wb_changes_change_revision_id ON /*_*/wb_changes (change_revision_id);

CREATE INDEX change_object_id ON /*_*/wb_changes (change_object_id);
29 changes: 20 additions & 9 deletions repo/sql/sqlite/archives/patch-wb_id_counters-unique-to-pk.sql
Original file line number Diff line number Diff line change
@@ -1,13 +1,24 @@
-- This file is automatically generated using maintenance/generateSchemaChangeSql.php.
-- Source: extensions/Wikibase/repo/sql/abstractSchemaChanges/patch-wb_id_counters-unique-to-pk.json
-- Source: repo/sql/abstractSchemaChanges/patch-wb_id_counters-unique-to-pk.json
-- Do not modify this file directly.
-- See https://www.mediawiki.org/wiki/Manual:Schema_changes
CREATE TEMPORARY TABLE /*_*/__temp__wb_id_counters AS
SELECT id_value, id_type
FROM /*_*/wb_id_counters;
DROP TABLE /*_*/wb_id_counters;
CREATE TABLE /*_*/wb_id_counters ( id_type BLOB NOT NULL, id_value INTEGER UNSIGNED NOT NULL, PRIMARY KEY(id_type) );
INSERT INTO /*_*/wb_id_counters (id_value, id_type)
SELECT id_value, id_type
FROM /*_*/__temp__wb_id_counters;
DROP TABLE /*_*/__temp__wb_id_counters;
SELECT
id_value,
id_type
FROM /*_*/wb_id_counters;
DROP TABLE /*_*/wb_id_counters;


CREATE TABLE /*_*/wb_id_counters (
id_type BLOB NOT NULL,
id_value INTEGER UNSIGNED NOT NULL,
PRIMARY KEY(id_type)
);
INSERT INTO /*_*/wb_id_counters (id_value, id_type)
SELECT
id_value,
id_type
FROM
/*_*/__temp__wb_id_counters;
DROP TABLE /*_*/__temp__wb_id_counters;
2 changes: 1 addition & 1 deletion repo/sql/sqlite/term_store.sql
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
-- This file is automatically generated using maintenance/generateSchemaSql.php.
-- Source: extensions/Wikibase/repo/sql/abstract/term_store.json
-- Source: repo/sql/abstract/term_store.json
-- Do not modify this file directly.
-- See https://www.mediawiki.org/wiki/Manual:Schema_changes
CREATE TABLE /*_*/wbt_item_terms (
Expand Down
2 changes: 1 addition & 1 deletion repo/sql/sqlite/wb_changes.sql
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
-- This file is automatically generated using maintenance/generateSchemaSql.php.
-- Source: extensions/Wikibase/repo/sql/abstract/wb_changes.json
-- Source: repo/sql/abstract/wb_changes.json
-- Do not modify this file directly.
-- See https://www.mediawiki.org/wiki/Manual:Schema_changes
CREATE TABLE /*_*/wb_changes (
Expand Down
2 changes: 1 addition & 1 deletion repo/sql/sqlite/wb_changes_subscription.sql
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
-- This file is automatically generated using maintenance/generateSchemaSql.php.
-- Source: extensions/Wikibase/repo/sql/abstract/wb_changes_subscription.json
-- Source: repo/sql/abstract/wb_changes_subscription.json
-- Do not modify this file directly.
-- See https://www.mediawiki.org/wiki/Manual:Schema_changes
CREATE TABLE /*_*/wb_changes_subscription (
Expand Down
2 changes: 1 addition & 1 deletion repo/sql/sqlite/wb_id_counters.sql
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
-- This file is automatically generated using maintenance/generateSchemaSql.php.
-- Source: extensions/Wikibase/repo/sql/abstract/wb_id_counters.json
-- Source: repo/sql/abstract/wb_id_counters.json
-- Do not modify this file directly.
-- See https://www.mediawiki.org/wiki/Manual:Schema_changes
CREATE TABLE /*_*/wb_id_counters (
Expand Down
2 changes: 1 addition & 1 deletion repo/sql/sqlite/wb_items_per_site.sql
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
-- This file is automatically generated using maintenance/generateSchemaSql.php.
-- Source: extensions/Wikibase/repo/sql/abstract/wb_items_per_site.json
-- Source: repo/sql/abstract/wb_items_per_site.json
-- Do not modify this file directly.
-- See https://www.mediawiki.org/wiki/Manual:Schema_changes
CREATE TABLE /*_*/wb_items_per_site (
Expand Down
2 changes: 1 addition & 1 deletion repo/sql/sqlite/wb_property_info.sql
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
-- This file is automatically generated using maintenance/generateSchemaSql.php.
-- Source: extensions/Wikibase/repo/sql/abstract/wb_property_info.json
-- Source: repo/sql/abstract/wb_property_info.json
-- Do not modify this file directly.
-- See https://www.mediawiki.org/wiki/Manual:Schema_changes
CREATE TABLE /*_*/wb_property_info (
Expand Down
38 changes: 38 additions & 0 deletions repo/tests/phpunit/includes/WikibaseRepoSchemaTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
<?php

declare( strict_types=1 );

namespace Wikibase\Repo\Tests;

use MediaWiki\Tests\Structure\AbstractSchemaTestBase;

/**
* @group Wikibase
* @coversNothing
* @license GPL-2.0-or-later
*/
class WikibaseRepoSchemaTest extends AbstractSchemaTestBase {
protected static function getSchemasDirectory(): string {
return __DIR__ . '/../../../sql/abstract/';
}

protected static function getSchemaChangesDirectory(): string {
return __DIR__ . '/../../../sql/abstractSchemaChanges/';
}

protected static function getSchemaSQLDirs(): array {
return [
'mysql' => __DIR__ . '/../../../sql/mysql/',
'sqlite' => __DIR__ . '/../../../sql/sqlite',
'postgres' => __DIR__ . '/../../../sql/postgres',
];
}

protected static function getSchemaChangesSQLDirs(): array {
return [
'mysql' => __DIR__ . '/../../../sql/mysql/archives',
'sqlite' => __DIR__ . '/../../../sql/sqlite/archives',
'postgres' => __DIR__ . '/../../../sql/postgres/archives',
];
}
}

0 comments on commit 4a5258e

Please sign in to comment.