forked from propelorm/Propel2
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added migration tests against real database instances with reverse en…
…gineered prove.
- Loading branch information
Marc J. Schmidt
committed
Aug 18, 2013
1 parent
6f6570a
commit 484bcc8
Showing
10 changed files
with
906 additions
and
1 deletion.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
# $Id$ | ||
# | ||
# This is a project-specific build.properties file. The properties | ||
# in this file override anything set in Propel's top-level build.properties | ||
# file when *this* project is being built. | ||
# | ||
# See top-level build.properties-sample for explanation of configuration | ||
# options. | ||
# | ||
# Because this file is included before the top-level build.properties file, | ||
# you cannot refer to any properties set therein. | ||
|
||
propel.project = migration | ||
propel.database = ##DATABASE_VENDOR## | ||
propel.database.url = ##DATABASE_URL## | ||
propel.mysql.tableType = InnoDB | ||
propel.disableIdentifierQuoting = true | ||
propel.schema.autoPrefix = false | ||
|
||
# For MySQL or Oracle, you also need to specify username & password | ||
propel.database.user = ##DATABASE_USER## | ||
propel.database.password = ##DATABASE_PASSWORD## | ||
|
||
# Note that if you do not wish to specify the database (e.g. if you | ||
# are using multiple databases) you can use the @DB@ token which | ||
# will be replaced with a database at runtime. | ||
# E.g.: propel.database.url = sqlite://localhost/./test/@DB@.db | ||
# This will work for the datadump and the insert-sql tasks. | ||
|
||
# propel.database.createUrl = (doesn't apply for SQLite, since db is auto-created) | ||
|
||
propel.targetPackage = migration |
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,25 @@ | ||
<?xml version="1.0" encoding="ISO-8859-1"?> | ||
<config> | ||
<propel> | ||
<datasources default="migration"> | ||
<datasource id="migration"> | ||
<adapter>##DATABASE_VENDOR##</adapter> | ||
<connection> | ||
<classname>\Propel\Runtime\Connection\DebugPDO</classname> | ||
<dsn>##DATABASE_URL##</dsn> | ||
<user>##DATABASE_USER##</user> | ||
<password>##DATABASE_PASSWORD##</password> | ||
<options> | ||
<option id="ATTR_PERSISTENT">false</option> | ||
</options> | ||
<attributes> | ||
<option id="ATTR_EMULATE_PREPARES">true</option> | ||
</attributes> | ||
<settings> | ||
<setting id="charset">utf8</setting> | ||
</settings> | ||
</connection> | ||
</datasource> | ||
</datasources> | ||
</propel> | ||
</config> |
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,202 @@ | ||
<?php | ||
|
||
|
||
namespace Propel\Tests\Generator\Migration; | ||
|
||
class BaseTest extends MigrationTestCase { | ||
|
||
public function testColumnRequireChange() { | ||
$originXml = ' | ||
<database> | ||
<table name="migration_test_1"> | ||
<column name="id" type="integer" primaryKey="true" autoIncrement="true" /> | ||
<column name="title" required="true" /> | ||
</table> | ||
</database> | ||
'; | ||
|
||
$targetXml = ' | ||
<database> | ||
<table name="migration_test_1"> | ||
<column name="id" type="integer" primaryKey="true" autoIncrement="true" /> | ||
<column name="title" /> | ||
</table> | ||
</database> | ||
'; | ||
|
||
$this->migrateAndTest($originXml, $targetXml); | ||
} | ||
|
||
public function testColumnTypeChangeSimple() { | ||
$originXml = ' | ||
<database> | ||
<table name="migration_test_2"> | ||
<column name="field1" type="VARCHAR" /> | ||
<column name="field2" type="INTEGER" /> | ||
<column name="field3" type="BOOLEAN" /> | ||
</table> | ||
</database> | ||
'; | ||
|
||
$targetXml = ' | ||
<database> | ||
<table name="migration_test_2"> | ||
<column name="field1" type="INTEGER" /> | ||
<column name="field2" type="VARCHAR" /> | ||
<column name="field3" type="VARCHAR" /> | ||
</table> | ||
</database> | ||
'; | ||
$this->migrateAndTest($originXml, $targetXml); | ||
} | ||
|
||
public function testColumnTypeChangeComplex() { | ||
$originXml = ' | ||
<database> | ||
<table name="migration_test_3"> | ||
<column name="field1" type="CHAR" /> | ||
<column name="field2" type="LONGVARCHAR" /> | ||
<column name="field3" type="CLOB" /> | ||
<column name="field4" type="NUMERIC" /> | ||
<column name="field5" type="DECIMAL" /> | ||
<column name="field6" type="TINYINT" /> | ||
<column name="field7" type="SMALLINT" /> | ||
</table> | ||
</database> | ||
'; | ||
|
||
$targetXml = ' | ||
<database> | ||
<table name="migration_test_3"> | ||
<column name="field1" type="LONGVARCHAR" /> | ||
<column name="field4" type="DECIMAL" /> | ||
<column name="field5" type="TINYINT" /> | ||
<column name="field6" type="SMALLINT" /> | ||
<column name="field7" type="NUMERIC" /> | ||
</table> | ||
</database> | ||
'; | ||
$this->migrateAndTest($originXml, $targetXml); | ||
} | ||
|
||
public function testColumnTypeChangeMoreComplex() { | ||
$originXml = ' | ||
<database> | ||
<table name="migration_test_3"> | ||
<column name="field1" type="CHAR" size="5" /> | ||
<column name="field2" type="INTEGER" size="6" /> | ||
<column name="field3" type="BIGINT" /> | ||
<column name="field4" type="REAL" /> | ||
<column name="field5" type="FLOAT" /> | ||
<column name="field6" type="DOUBLE" /> | ||
<column name="field7" type="BINARY" /> | ||
<column name="field8" type="VARBINARY" /> | ||
<column name="field9" type="LONGVARBINARY" /> | ||
<column name="field10" type="BLOB" /> | ||
<column name="field11" type="DATE" /> | ||
<column name="field12" type="TIME" /> | ||
<column name="field13" type="TIMESTAMP" /> | ||
<column name="field14" type="ENUM" /> | ||
</table> | ||
</database> | ||
'; | ||
|
||
$targetXml = ' | ||
<database> | ||
<table name="migration_test_3"> | ||
<column name="field1" type="CHAR" size="5" /> | ||
<column name="field2" type="INTEGER" size="12" /> | ||
<column name="field3" type="REAL" /> | ||
<column name="field4" type="FLOAT" /> | ||
<column name="field5" type="DOUBLE" /> | ||
<column name="field6" type="BIGINT" /> | ||
<column name="field7" type="VARBINARY" /> | ||
<column name="field8" type="LONGVARBINARY" /> | ||
<column name="field9" type="BLOB" /> | ||
<column name="field10" type="BINARY" /> | ||
<column name="field11" type="TIME" /> | ||
<column name="field12" type="TIMESTAMP" /> | ||
<column name="field13" type="DATE" /> | ||
<column name="field14" type="VARCHAR" size="200" /> | ||
</table> | ||
</database> | ||
'; | ||
$this->migrateAndTest($originXml, $targetXml); | ||
} | ||
|
||
/** | ||
* @group test | ||
*/ | ||
public function testColumnChangePrimaryKey() { | ||
$originXml = ' | ||
<database> | ||
<table name="migration_test_5"> | ||
<column name="id" type="integer" primaryKey="true" autoIncrement="true" /> | ||
<column name="title" required="true" /> | ||
</table> | ||
</database> | ||
'; | ||
|
||
$targetXml = ' | ||
<database> | ||
<table name="migration_test_5"> | ||
<column name="id" type="integer" /> | ||
<column name="title" /> | ||
</table> | ||
</database> | ||
'; | ||
|
||
$target2Xml = ' | ||
<database> | ||
<table name="migration_test_5"> | ||
<column name="id" type="integer" primaryKey="true" /> | ||
<column name="title" /> | ||
</table> | ||
</database> | ||
'; | ||
|
||
$target3Xml = ' | ||
<database> | ||
<table name="migration_test_5"> | ||
<column name="id" type="integer" primaryKey="true" autoIncrement="true" /> | ||
<column name="title" /> | ||
</table> | ||
</database> | ||
'; | ||
|
||
$target4Xml = ' | ||
<database> | ||
<table name="migration_test_5"> | ||
<column name="id" type="integer" primaryKey="true" /> | ||
<column name="title" /> | ||
</table> | ||
</database> | ||
'; | ||
|
||
$target5Xml = ' | ||
<database> | ||
<table name="migration_test_5"> | ||
<column name="id" type="varchar" size="200" primaryKey="true" /> | ||
<column name="title" required="true" type="integer" /> | ||
</table> | ||
</database> | ||
'; | ||
$this->applyXmlAndTest($originXml); | ||
$this->applyXmlAndTest($targetXml); | ||
$this->applyXmlAndTest($target2Xml); | ||
$this->applyXmlAndTest($target3Xml); | ||
$this->applyXmlAndTest($target4Xml); | ||
$this->applyXmlAndTest($target5Xml); | ||
} | ||
|
||
} |
Oops, something went wrong.