|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace OroCRM\Bundle\MagentoBundle\Migrations\Schema\v1_41; |
|
4
|
|
|
|
|
5
|
|
|
use Doctrine\DBAL\Schema\Schema; |
|
6
|
|
|
|
|
7
|
|
|
use Oro\Bundle\MigrationBundle\Migration\Migration; |
|
8
|
|
|
use Oro\Bundle\MigrationBundle\Migration\ParametrizedSqlMigrationQuery; |
|
9
|
|
|
use Oro\Bundle\MigrationBundle\Migration\QueryBag; |
|
10
|
|
|
|
|
11
|
|
|
class AddSyncDates implements Migration |
|
12
|
|
|
{ |
|
13
|
|
|
/** |
|
14
|
|
|
* {@inheritdoc} |
|
15
|
|
|
*/ |
|
16
|
|
|
public function up(Schema $schema, QueryBag $queries) |
|
17
|
|
|
{ |
|
18
|
|
|
$table = $schema->getTable('orocrm_magento_order'); |
|
19
|
|
|
$table->addColumn('imported_at', 'datetime', ['notnull' => false, 'comment' => '(DC2Type:datetime)']); |
|
20
|
|
|
$table->addColumn('synced_at', 'datetime', ['notnull' => false, 'comment' => '(DC2Type:datetime)']); |
|
21
|
|
|
|
|
22
|
|
|
$updateDates = 'UPDATE orocrm_magento_order SET imported_at = created_at, synced_at = updated_at'; |
|
23
|
|
|
$updateDatesQuery = new ParametrizedSqlMigrationQuery(); |
|
24
|
|
|
$updateDatesQuery->addSql($updateDates); |
|
25
|
|
|
$queries->addPostQuery($updateDatesQuery); |
|
26
|
|
|
|
|
27
|
|
|
$table = $schema->getTable('orocrm_magento_customer'); |
|
28
|
|
|
$table->addColumn('imported_at', 'datetime', ['notnull' => false, 'comment' => '(DC2Type:datetime)']); |
|
29
|
|
|
$table->addColumn('synced_at', 'datetime', ['notnull' => false, 'comment' => '(DC2Type:datetime)']); |
|
30
|
|
|
|
|
31
|
|
|
$updateDates = 'UPDATE orocrm_magento_customer SET imported_at = created_at, synced_at = updated_at'; |
|
32
|
|
|
$updateDatesQuery = new ParametrizedSqlMigrationQuery(); |
|
33
|
|
|
$updateDatesQuery->addSql($updateDates); |
|
34
|
|
|
$queries->addPostQuery($updateDatesQuery); |
|
35
|
|
|
|
|
36
|
|
|
$table = $schema->getTable('orocrm_magento_cart'); |
|
37
|
|
|
$table->addColumn('imported_at', 'datetime', ['notnull' => false, 'comment' => '(DC2Type:datetime)']); |
|
38
|
|
|
$table->addColumn('synced_at', 'datetime', ['notnull' => false, 'comment' => '(DC2Type:datetime)']); |
|
39
|
|
|
|
|
40
|
|
|
$updateDates = 'UPDATE orocrm_magento_cart SET imported_at = createdat, synced_at = updatedat'; |
|
41
|
|
|
$updateDatesQuery = new ParametrizedSqlMigrationQuery(); |
|
42
|
|
|
$updateDatesQuery->addSql($updateDates); |
|
43
|
|
|
$queries->addPostQuery($updateDatesQuery); |
|
44
|
|
|
} |
|
45
|
|
|
} |
|
46
|
|
|
|