-
-
Notifications
You must be signed in to change notification settings - Fork 25
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
#94 - Fixed engine and another table options declaration
- Loading branch information
Showing
8 changed files
with
157 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
<?php | ||
|
||
use Phalcon\Db\Column; | ||
use Phalcon\Db\Index; | ||
use Phalcon\Migrations\Mvc\Model\Migration; | ||
|
||
class MemoryTableMigration_100 extends Migration | ||
{ | ||
/** | ||
* Define the table structure | ||
* | ||
* @return void | ||
* @throws \Phalcon\Db\Exception | ||
*/ | ||
public function morph() | ||
{ | ||
$this->morphTable('memory_table', [ | ||
'columns' => [ | ||
new Column( | ||
'id', | ||
[ | ||
'type' => Column::TYPE_INTEGER, | ||
'notNull' => true, | ||
'autoIncrement' => true, | ||
'size' => 11, | ||
'first' => true | ||
] | ||
), | ||
], | ||
'indexes' => [ | ||
new Index('PRIMARY', ['id'], 'PRIMARY') | ||
], | ||
'options' => [ | ||
'TABLE_TYPE' => 'BASE TABLE', | ||
'ENGINE' => 'MEMORY', | ||
'TABLE_COLLATION' => 'latin1_swedish_ci' | ||
], | ||
]); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,89 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Phalcon\Migrations\Tests\Mysql; | ||
|
||
use MysqlTester; | ||
use Phalcon\Db\Column; | ||
use Phalcon\Db\Exception; | ||
use Phalcon\Db\Index; | ||
use Phalcon\Migrations\Migrations; | ||
|
||
/** | ||
* @see https://github.com/phalcon/migrations/issues/94 | ||
*/ | ||
final class Issue94Cest | ||
{ | ||
/** | ||
* @param MysqlTester $I | ||
* @throws Exception | ||
*/ | ||
public function testIssue94(MysqlTester $I): void | ||
{ | ||
$I->wantToTest('Issue #94 - Engine "MEMORY"'); | ||
|
||
ob_start(); | ||
Migrations::run([ | ||
'migrationsDir' => codecept_data_dir('issues/94'), | ||
'config' => $I->getMigrationsConfig(), | ||
'migrationsInDb' => true, | ||
]); | ||
ob_clean(); | ||
|
||
$options = $I->getPhalconDb()->tableOptions('memory_table'); | ||
|
||
$I->assertSame('MEMORY', $options['engine']); | ||
} | ||
|
||
/** | ||
* @param MysqlTester $I | ||
* @throws Exception | ||
*/ | ||
public function testGenerateIssue94(MysqlTester $I): void | ||
{ | ||
$I->wantToTest('Issue #94 - Correct options generation case (uppercase)'); | ||
|
||
$engine = 'MyISAM'; | ||
$tableName = 'options_uppercase'; | ||
$migrationsDir = codecept_output_dir(__FUNCTION__); | ||
|
||
$I->getPhalconDb()->createTable($tableName, '', [ | ||
'columns' => [ | ||
new Column('id', [ | ||
'type' => Column::TYPE_INTEGER, | ||
'size' => 20, | ||
'notNull' => true, | ||
'autoIncrement' => true, | ||
]), | ||
], | ||
'indexes' => [ | ||
new Index('PRIMARY', ['id'], 'PRIMARY') | ||
], | ||
'options' => [ | ||
'TABLE_TYPE' => 'BASE TABLE', | ||
'ENGINE' => $engine, | ||
'TABLE_COLLATION' => 'utf8mb4_general_ci', | ||
], | ||
]); | ||
|
||
/** | ||
* Generate | Drop | Run | ||
*/ | ||
ob_start(); | ||
Migrations::generate([ | ||
'migrationsDir' => $migrationsDir, | ||
'config' => $I->getMigrationsConfig(), | ||
'tableName' => $tableName, | ||
]); | ||
$I->getPhalconDb()->dropTable($tableName); | ||
Migrations::run([ | ||
'migrationsDir' => $migrationsDir, | ||
'config' => $I->getMigrationsConfig(), | ||
'migrationsInDb' => true, | ||
]); | ||
ob_clean(); | ||
|
||
$I->assertSame($engine, $I->getPhalconDb()->tableOptions($tableName)['engine']); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters