Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ability to filter list of tables to migrate #70

Open
wants to merge 9 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
3 changes: 3 additions & 0 deletions README.md
Expand Up @@ -34,6 +34,9 @@ However, if you're not into Node.js, you can still use old and proven FromMySqlT
<li>
Ability to transfer only a data (in case of an existing database).
</li>
<li>
Ability to transfer list of tables.
</li>
</ul>

<h3>SYSTEM REQUIREMENTS</h3>
Expand Down
13 changes: 12 additions & 1 deletion migration/FromMySqlToPostgreSql/FromMySqlToPostgreSql.php
Expand Up @@ -67,6 +67,13 @@ class FromMySqlToPostgreSql
*/
private $strSourceConString;

/**
* MySql list of tables.
*
* @var string
*/
private $tablesList;

/**
* PostgreSql connection string.
*
Expand Down Expand Up @@ -233,6 +240,7 @@ public function __construct(array $arrConfig)
$this->floatDataChunkSize = $this->floatDataChunkSize < 1 ? 1 : $this->floatDataChunkSize;
$this->strSourceConString = $arrConfig['source'];
$this->strTargetConString = $arrConfig['target'];
$this->tablesList = $arrConfig['tablesList'];
$this->mysql = null;
$this->pgsql = null;
$this->strMySqlDbName = $this->extractDbName($this->strSourceConString);
Expand Down Expand Up @@ -401,7 +409,10 @@ private function loadStructureToMigrate()

foreach ($arrResult as $arrRow) {
if ('BASE TABLE' == $arrRow['Table_type']) {
$this->arrTablesToMigrate[] = $arrRow;
//echo 'table = ' . $arrRow['Tables_in_' . $this->strMySqlDbName];
if($this->tablesList==null || array_search($arrRow['Tables_in_' . $this->strMySqlDbName], $this->tablesList)!=false){
$this->arrTablesToMigrate[] = $arrRow;
}
} elseif ('VIEW' == $arrRow['Table_type']) {
$this->arrViewsToMigrate[] = $arrRow;
}
Expand Down
5 changes: 5 additions & 0 deletions sample_config.json
Expand Up @@ -6,6 +6,11 @@
],
"source" : "mysql:host=localhost;port=3306;charset=UTF8;dbname=your_db_name,your_user_name,your_password",

"tablesList_description": [
"List of tables to migrate. Can be empty for migrate all tables."
],
"tablesList": "",

"target_description" : [
"Connection string to your PostgreSql database",
"Please ensure, that you have defined your connection string properly.",
Expand Down