mirror of
https://github.com/phpbb/phpbb.git
synced 2025-08-01 14:30:32 +02:00
[ticket/11880] Break up schema changes in the migrator
PHPBB3-11880
This commit is contained in:
33
tests/dbal/migration/schema.php
Normal file
33
tests/dbal/migration/schema.php
Normal file
@@ -0,0 +1,33 @@
|
||||
<?php
|
||||
/**
|
||||
*
|
||||
* @package testing
|
||||
* @copyright (c) 2014 phpBB Group
|
||||
* @license http://opensource.org/licenses/gpl-license.php GNU Public License
|
||||
*
|
||||
*/
|
||||
|
||||
class phpbb_dbal_migration_schema extends \phpbb\db\migration\migration
|
||||
{
|
||||
function update_schema()
|
||||
{
|
||||
return array(
|
||||
'add_columns' => array(
|
||||
$this->table_prefix . 'config' => array(
|
||||
'test_column1' => array('BOOL', 1),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
function revert_schema()
|
||||
{
|
||||
return array(
|
||||
'drop_columns' => array(
|
||||
$this->table_prefix . 'config' => array(
|
||||
'test_column1',
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
@@ -16,6 +16,7 @@ require_once dirname(__FILE__) . '/migration/revert.php';
|
||||
require_once dirname(__FILE__) . '/migration/revert_with_dependency.php';
|
||||
require_once dirname(__FILE__) . '/migration/fail.php';
|
||||
require_once dirname(__FILE__) . '/migration/installed.php';
|
||||
require_once dirname(__FILE__) . '/migration/schema.php';
|
||||
|
||||
class phpbb_dbal_migrator_test extends phpbb_database_test_case
|
||||
{
|
||||
@@ -267,4 +268,23 @@ class phpbb_dbal_migrator_test extends phpbb_database_test_case
|
||||
$this->fail('Installed test failed');
|
||||
}
|
||||
}
|
||||
|
||||
public function test_schema()
|
||||
{
|
||||
$this->migrator->set_migrations(array('phpbb_dbal_migration_schema'));
|
||||
|
||||
while (!$this->migrator->finished())
|
||||
{
|
||||
$this->migrator->update();
|
||||
}
|
||||
|
||||
$this->assertTrue($this->db_tools->sql_column_exists('phpbb_config', 'test_column1'));
|
||||
|
||||
while ($this->migrator->migration_state('phpbb_dbal_migration_schema'))
|
||||
{
|
||||
$this->migrator->revert('phpbb_dbal_migration_schema');
|
||||
}
|
||||
|
||||
$this->assertFalse($this->db_tools->sql_column_exists('phpbb_config', 'test_column1'));
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user