Open vafrcor opened 7 years ago
@vafrcor what are you doing, exactly? Consider writing a test scenario.
@Ocramius
Any suggestion? Thank You
@vafrcor maybe make a gist (using DBAL only) to show what you are doing? We can then discuss a test case strategy starting from there...
ok. I will provide it shortly
@Ocramius : this is my snippet code.
<?php
//# This code used to synchronize MySQL database (Schema 1) into PostgreSQL database (Schema 2)
//# composer require vendors
require __DIR__ . '/vendor/autoload.php';
//# set configurations
$config1 = new \Doctrine\DBAL\Configuration();
$config2 = new \Doctrine\DBAL\Configuration();
$conn1_params = array(
'dbname' => 'db_source',
'user' => 'user',
'password' => 'secret',
'host' => 'localhost',
'driver' => 'pdo_mysql'
);
$conn2_params = array(
'dbname' => 'db_target',
'user' => 'postgres',
'password' => 'secret',
'host' => 'localhost',
'driver' => 'pdo_pgsql'
);
$db_conn1 = \Doctrine\DBAL\DriverManager::getConnection($conn1_params, $config1);
$db_conn2 = \Doctrine\DBAL\DriverManager::getConnection($conn2_params, $config2);
$schema_manager1=$db_conn1->getSchemaManager();
$schema_manager2=$db_conn2->getSchemaManager();
$schema1=$schema_manager1->createSchema();
$schema2=$schema_manager2->createSchema();
//# compare between 2 DB Schema
$comparator=new \Doctrine\DBAL\Schema\Comparator();
$schema_diff = $comparator->compare($schema2, $schema1);
$schema2_update_queries = $schema_diff->toSql($db_conn2->getDatabasePlatform());
//# print out Schema 2 update queries:
echo '<pre>';
print_r(var_export($schema2_update_queries));
echo '</pre>';
//# Problems:
// 1. If MySQL Table contain column which have "Collation", Query Statement not compatible with PostgreSQL standart
// 2. If MySQL Tables contain multiple index with same name (not unqie), Query Statement not compatible with PostgreSQL standart (duplicate index name)
Doctrine\dbal version
2.5
I use
Schema Comparator
to synchronize between 2 database (MySQL into PostgreSQL). The query generator return this SQL Statement:When I run this SQL Statement on PostgreSQL database, there is a problem with
COLLATE "utf8_unicode_ci"
section.The error displayed as below
Any solution for this SQL Generator?