php - Doctrine migrations table collation -
trying find way programatically create tables collation, can't seem find way how properly. using "doctrine/doctrine-migrations-bundle": "2.1.*@dev" , symfony 2.3,
i set in config.yml:
# doctrine configuration doctrine: dbal: driver: "%database_driver%" host: "%database_host%" port: "%database_port%" dbname: "%database_name%" user: "%database_user%" password: "%database_password%" charset: latin1 orm: auto_generate_proxy_classes: "%kernel.debug%" entity_managers: default: auto_mapping: true doctrine_migrations: dir_name: %kernel.root_dir%/../src/cf/escritoriobundle/migrations namespace: mynamespace\migrations table_name: migrations name: application migrations
it creates database latin1 charset , latin1_swedish_ci default collation, when run doctrine:database:create
tool. run migrations, , tables utf8_general_ci
looked $schema->createtable()
function, cannot find way pass collation need that. proper workaround here?
well, thats kind of ugly, way have found generate after tables set of migrations altered table , converted encoding. migration up()
, down()
functions looked like:
...... /** * @param schema $schema */ public function up(schema $schema) { // up() migration auto-generated, please modify needs $this->addsql("alter table mytable convert character set latin1 collate latin1_general_ci"); } /** * @param schema $schema */ public function down(schema $schema) { // down() migration auto-generated, please modify needs $this->addsql("alter table mytable convert character set utf8 collate utf8_general_ci"); }
Comments
Post a Comment