mirror of
https://github.com/phpbb/phpbb.git
synced 2025-06-08 04:18:52 +00:00
[ticket/17415] Move install step of Q&A to migration
PHPBB-17415
This commit is contained in:
parent
e84e9cace4
commit
ae9f97b7e2
2 changed files with 89 additions and 50 deletions
|
@ -336,56 +336,6 @@ class qa
|
||||||
*/
|
*/
|
||||||
function install()
|
function install()
|
||||||
{
|
{
|
||||||
global $phpbb_container;
|
|
||||||
|
|
||||||
$db_tool = $phpbb_container->get('dbal.tools');
|
|
||||||
$schemas = array(
|
|
||||||
$this->table_captcha_questions => array (
|
|
||||||
'COLUMNS' => array(
|
|
||||||
'question_id' => array('UINT', null, 'auto_increment'),
|
|
||||||
'strict' => array('BOOL', 0),
|
|
||||||
'lang_id' => array('UINT', 0),
|
|
||||||
'lang_iso' => array('VCHAR:30', ''),
|
|
||||||
'question_text' => array('TEXT_UNI', ''),
|
|
||||||
),
|
|
||||||
'PRIMARY_KEY' => 'question_id',
|
|
||||||
'KEYS' => array(
|
|
||||||
'lang' => array('INDEX', 'lang_iso'),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
$this->table_captcha_answers => array (
|
|
||||||
'COLUMNS' => array(
|
|
||||||
'question_id' => array('UINT', 0),
|
|
||||||
'answer_text' => array('STEXT_UNI', ''),
|
|
||||||
),
|
|
||||||
'KEYS' => array(
|
|
||||||
'qid' => array('INDEX', 'question_id'),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
$this->table_qa_confirm => array (
|
|
||||||
'COLUMNS' => array(
|
|
||||||
'session_id' => array('CHAR:32', ''),
|
|
||||||
'confirm_id' => array('CHAR:32', ''),
|
|
||||||
'lang_iso' => array('VCHAR:30', ''),
|
|
||||||
'question_id' => array('UINT', 0),
|
|
||||||
'attempts' => array('UINT', 0),
|
|
||||||
'confirm_type' => array('USINT', 0),
|
|
||||||
),
|
|
||||||
'KEYS' => array(
|
|
||||||
'session_id' => array('INDEX', 'session_id'),
|
|
||||||
'lookup' => array('INDEX', array('confirm_id', 'session_id', 'lang_iso')),
|
|
||||||
),
|
|
||||||
'PRIMARY_KEY' => 'confirm_id',
|
|
||||||
),
|
|
||||||
);
|
|
||||||
|
|
||||||
foreach ($schemas as $table => $schema)
|
|
||||||
{
|
|
||||||
if (!$db_tool->sql_table_exists($table))
|
|
||||||
{
|
|
||||||
$db_tool->sql_create_table($table, $schema);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
89
phpBB/phpbb/db/migration/data/v400/qa_captcha.php
Normal file
89
phpBB/phpbb/db/migration/data/v400/qa_captcha.php
Normal file
|
@ -0,0 +1,89 @@
|
||||||
|
<?php
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* This file is part of the phpBB Forum Software package.
|
||||||
|
*
|
||||||
|
* @copyright (c) phpBB Limited <https://www.phpbb.com>
|
||||||
|
* @license GNU General Public License, version 2 (GPL-2.0)
|
||||||
|
*
|
||||||
|
* For full copyright and license information, please see
|
||||||
|
* the docs/CREDITS.txt file.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace phpbb\db\migration\data\v400;
|
||||||
|
|
||||||
|
use phpbb\db\migration\migration;
|
||||||
|
|
||||||
|
class qa_captcha extends migration
|
||||||
|
{
|
||||||
|
public function effectively_installed(): bool
|
||||||
|
{
|
||||||
|
return $this->db_tools->sql_table_exists($this->tables['captcha_qa_questions'])
|
||||||
|
&& $this->db_tools->sql_table_exists($this->tables['captcha_qa_answers'])
|
||||||
|
&& $this->db_tools->sql_table_exists($this->tables['captcha_qa_confirm']);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function depends_on(): array
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
'\phpbb\db\migration\data\v400\dev',
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
public function update_schema(): array
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
'add_tables' => [
|
||||||
|
$this->tables['captcha_qa_questions'] => [
|
||||||
|
'COLUMNS' => [
|
||||||
|
'question_id' => ['UINT', null, 'auto_increment'],
|
||||||
|
'strict' => ['BOOL', 0],
|
||||||
|
'lang_id' => ['UINT', 0],
|
||||||
|
'lang_iso' => ['VCHAR:30', ''],
|
||||||
|
'question_text' => ['TEXT_UNI', ''],
|
||||||
|
],
|
||||||
|
'PRIMARY_KEY' => 'question_id',
|
||||||
|
'KEYS' => [
|
||||||
|
'lang' => ['INDEX', 'lang_iso'],
|
||||||
|
],
|
||||||
|
],
|
||||||
|
$this->tables['captcha_qa_answers'] => [
|
||||||
|
'COLUMNS' => [
|
||||||
|
'question_id' => ['UINT', 0],
|
||||||
|
'answer_text' => ['STEXT_UNI', ''],
|
||||||
|
],
|
||||||
|
'KEYS' => [
|
||||||
|
'qid' => ['INDEX', 'question_id'],
|
||||||
|
],
|
||||||
|
],
|
||||||
|
$this->tables['captcha_qa_confirm'] => [
|
||||||
|
'COLUMNS' => [
|
||||||
|
'session_id' => ['CHAR:32', ''],
|
||||||
|
'confirm_id' => ['CHAR:32', ''],
|
||||||
|
'lang_iso' => ['VCHAR:30', ''],
|
||||||
|
'question_id' => ['UINT', 0],
|
||||||
|
'attempts' => ['UINT', 0],
|
||||||
|
'confirm_type' => ['USINT', 0],
|
||||||
|
],
|
||||||
|
'KEYS' => [
|
||||||
|
'session_id' => ['INDEX', 'session_id'],
|
||||||
|
'lookup' => ['INDEX', ['confirm_id', 'session_id', 'lang_iso']],
|
||||||
|
],
|
||||||
|
'PRIMARY_KEY' => 'confirm_id',
|
||||||
|
],
|
||||||
|
],
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
public function revert_schema(): array
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
'drop_tables' => [
|
||||||
|
$this->tables['captcha_qa_questions'],
|
||||||
|
$this->tables['captcha_qa_answers'],
|
||||||
|
$this->tables['captcha_qa_confirm']
|
||||||
|
],
|
||||||
|
];
|
||||||
|
}
|
||||||
|
}
|
Loading…
Add table
Reference in a new issue