mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/OATHAuth
synced 2024-09-23 10:23:23 +00:00
Make SQLite compatible patches
Bug: T264492 Change-Id: I622b177015740ca5f6f625250efa3d4ad71be448
This commit is contained in:
parent
c5e31de93a
commit
9952cf8ee6
23
sql/sqlite/patch-add_generic_fields.sql
Normal file
23
sql/sqlite/patch-add_generic_fields.sql
Normal file
|
@ -0,0 +1,23 @@
|
|||
CREATE TABLE /*_*/oathauth_users_tmp (
|
||||
-- User ID
|
||||
id int not null primary key,
|
||||
|
||||
-- Secret key
|
||||
secret text NULL DEFAULT NULL,
|
||||
|
||||
-- Scratch tokens
|
||||
scratch_tokens blob NULL DEFAULT NULL,
|
||||
|
||||
-- Module user has selected
|
||||
module text not null,
|
||||
|
||||
-- Data
|
||||
data blob null
|
||||
);
|
||||
|
||||
INSERT INTO /*_*/oathauth_users_tmp (id, secret, scratch_tokens, module, data)
|
||||
SELECT id, secret, scratch_tokens, '', null FROM /*_*/oathauth_users;
|
||||
|
||||
DROP TABLE /*_*/oathauth_users;
|
||||
|
||||
ALTER TABLE /*_*/oathauth_users_tmp RENAME TO /*_*/oathauth_users;
|
17
sql/sqlite/patch-remove_module_specific_fields.sql
Normal file
17
sql/sqlite/patch-remove_module_specific_fields.sql
Normal file
|
@ -0,0 +1,17 @@
|
|||
CREATE TABLE /*_*/oathauth_users_tmp (
|
||||
-- User ID
|
||||
id int not null primary key,
|
||||
|
||||
-- Module user has selected
|
||||
module text not null,
|
||||
|
||||
-- Data
|
||||
data blob null
|
||||
);
|
||||
|
||||
INSERT INTO /*_*/oathauth_users_tmp (id, module, data)
|
||||
SELECT id, module, data FROM /*_*/oathauth_users;
|
||||
|
||||
DROP TABLE /*_*/oathauth_users;
|
||||
|
||||
ALTER TABLE /*_*/oathauth_users_tmp RENAME TO /*_*/oathauth_users;
|
|
@ -40,7 +40,8 @@ class UpdateTables {
|
|||
}
|
||||
|
||||
protected function execute() {
|
||||
switch ( $this->updater->getDB()->getType() ) {
|
||||
$type = $this->updater->getDB()->getType();
|
||||
switch ( $type ) {
|
||||
case 'mysql':
|
||||
case 'sqlite':
|
||||
$this->updater->addExtensionTable( 'oathauth_users', "{$this->base}/sql/mysql/tables.sql" );
|
||||
|
@ -50,10 +51,11 @@ class UpdateTables {
|
|||
'secret_reset',
|
||||
"{$this->base}/sql/mysql/patch-remove_reset.sql"
|
||||
);
|
||||
|
||||
$this->updater->addExtensionField(
|
||||
'oathauth_users',
|
||||
'module',
|
||||
"{$this->base}/sql/mysql/patch-add_generic_fields.sql"
|
||||
"{$this->base}/sql/{$type}/patch-add_generic_fields.sql"
|
||||
);
|
||||
|
||||
$this->updater->addExtensionUpdate(
|
||||
|
@ -62,7 +64,7 @@ class UpdateTables {
|
|||
$this->updater->dropExtensionField(
|
||||
'oathauth_users',
|
||||
'secret',
|
||||
"{$this->base}/sql/mysql/patch-remove_module_specific_fields.sql"
|
||||
"{$this->base}/sql/{$type}/patch-remove_module_specific_fields.sql"
|
||||
);
|
||||
|
||||
$this->updater->addExtensionUpdate(
|
||||
|
|
Loading…
Reference in a new issue