Skip to content

Commit

Permalink
Merge pull request #73 from kdambekalns/bugfix/72-migration-character…
Browse files Browse the repository at this point in the history
…-set-name

BUGFIX: Stable check for used character set in migration
  • Loading branch information
kdambekalns committed Jun 8, 2020
2 parents 636a987 + b2ad7a1 commit a3060e8
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions Migrations/Mysql/Version20141111161429.php
Expand Up @@ -37,8 +37,12 @@ public function up(Schema $schema) {
return; // Nothing to do here
}

$columnCharSets = $this->connection->executeQuery("SELECT character_set_name FROM information_schema.`COLUMNS` WHERE table_schema IN (SELECT DATABASE()) AND table_name = '${tableName}' AND column_name = 'persistence_object_identifier'")->fetch();
$charSet = $columnCharSets['CHARACTER_SET_NAME'];
// the column name can come out of the query as upper or lower case
// (see https://github.com/neos/neos-googleanalytics/pull/70 and
// https://github.com/neos/neos-googleanalytics/issues/72 for details)
// - thus the AS is added.
$columnCharSets = $this->connection->executeQuery("SELECT character_set_name AS charsetname FROM information_schema.`COLUMNS` WHERE table_schema IN (SELECT DATABASE()) AND table_name = '${tableName}' AND column_name = 'persistence_object_identifier'")->fetch();
$charSet = $columnCharSets['charsetname'];

$this->addSql("CREATE TABLE typo3_neos_googleanalytics_domain_model_siteconfiguration (persistence_object_identifier VARCHAR(40) NOT NULL, site VARCHAR(40) DEFAULT NULL, profileid VARCHAR(255) NOT NULL, INDEX IDX_D675F674694309E4 (site), PRIMARY KEY(persistence_object_identifier)) DEFAULT CHARACTER SET ${charSet} COLLATE ${charSet}_unicode_ci ENGINE = InnoDB");
$this->addSql("ALTER TABLE typo3_neos_googleanalytics_domain_model_siteconfiguration ADD CONSTRAINT FK_D675F674694309E4 FOREIGN KEY (site) REFERENCES ${tableName} (persistence_object_identifier) ON DELETE CASCADE");
Expand Down

0 comments on commit a3060e8

Please sign in to comment.