public function down(Schema $schema)
{
$this->abortIf($this->connection->getDatabasePlatform()->getName() != "postgresql");
$select = $this->connection->query("SELECT * FROM typo3_typo3cr_domain_model_nodedata");
$nodeData = array();
while ($result = $select->fetch()) {
$properties = json_decode($result['properties'], true);
$dimensionvalues = json_decode($result['dimensionvalues'], true);
$accessroles = json_decode($result['accessroles'], true);
$nodeData[] = array('persistence_object_identifier' => $result['persistence_object_identifier'], 'properties' => serialize($properties), 'dimensionvalues' => serialize($dimensionvalues), 'accessroles' => serialize($accessroles));
}
$this->connection->exec('BEGIN;');
$this->connection->exec("ALTER TABLE typo3_typo3cr_domain_model_nodedata ADD COLUMN aproperties BYTEA;");
$this->connection->exec("ALTER TABLE typo3_typo3cr_domain_model_nodedata ADD COLUMN adimensionvalues BYTEA");
$this->connection->exec("ALTER TABLE typo3_typo3cr_domain_model_nodedata ADD COLUMN aaccessroles BYTEA");
$update = $this->connection->prepare('UPDATE typo3_typo3cr_domain_model_nodedata SET aproperties = :properties, adimensionvalues = :dimensionvalues, aaccessroles = :accessroles WHERE persistence_object_identifier = :persistence_object_identifier');
foreach ($nodeData as $node) {
$update->execute($node);
}
$this->connection->exec('COMMIT;');
$this->connection->exec("ALTER TABLE typo3_typo3cr_domain_model_nodedata DROP COLUMN properties;");
$this->connection->exec("ALTER TABLE typo3_typo3cr_domain_model_nodedata DROP COLUMN dimensionvalues;");
$this->connection->exec("ALTER TABLE typo3_typo3cr_domain_model_nodedata DROP COLUMN accessroles;");
$this->connection->exec("ALTER TABLE typo3_typo3cr_domain_model_nodedata RENAME aproperties TO properties;");
$this->connection->exec("COMMENT ON COLUMN typo3_typo3cr_domain_model_nodedata.properties IS '(DC2Type:objectarray)';");
$this->connection->exec("ALTER TABLE typo3_typo3cr_domain_model_nodedata RENAME adimensionvalues TO dimensionvalues;");
$this->connection->exec("COMMENT ON COLUMN typo3_typo3cr_domain_model_nodedata.dimensionvalues IS '(DC2Type:objectarray)';");
$this->connection->exec("ALTER TABLE typo3_typo3cr_domain_model_nodedata RENAME aaccessroles TO accessroles;");
$this->connection->exec("COMMENT ON COLUMN typo3_typo3cr_domain_model_nodedata.accessroles IS '(DC2Type:objectarray)';");
}