1
0
mirror of https://github.com/phpbb/phpbb.git synced 2025-07-30 21:40:43 +02:00

[ticket/12643] Properly handle changing columns on tables with constraints

PHPBB3-12643
This commit is contained in:
Patrick Webster
2014-06-15 14:52:05 -05:00
parent e6a8df7f7e
commit 754e36e378
2 changed files with 30 additions and 1 deletions

View File

@@ -239,6 +239,24 @@ class phpbb_dbal_db_tools_test extends phpbb_database_test_case
$this->assertFalse($this->tools->sql_column_exists('prefix_table_name', 'c_bug_12012'));
}
public function test_column_change_with_composite_primary()
{
// Remove the old primary key
$this->assertTrue($this->tools->sql_column_remove('prefix_table_name', 'c_id'));
$this->assertTrue($this->tools->sql_column_add('prefix_table_name', 'c_id', array('UINT', 0)));
// Create a composite key
$this->assertTrue($this->tools->sql_create_primary_key('prefix_table_name', array('c_id', 'c_uint')));
// Create column
$this->assertFalse($this->tools->sql_column_exists('prefix_table_name', 'c_bug_12643'));
$this->assertTrue($this->tools->sql_column_add('prefix_table_name', 'c_bug_12643', array('DECIMAL', 0)));
$this->assertTrue($this->tools->sql_column_exists('prefix_table_name', 'c_bug_12643'));
// Change type from int to string
$this->assertTrue($this->tools->sql_column_change('prefix_table_name', 'c_bug_12643', array('VCHAR:100', '')));
}
public function test_column_remove()
{
$this->assertTrue($this->tools->sql_column_exists('prefix_table_name', 'c_int_size'));