简体   繁体   English

如何处理不区分大小写的文件系统上的学说更新(?)

[英]how to deal with doctrine updates on case insensitive file systems(?)

I have an issue with doctrine updates. 我对学说的更新有疑问。 When a new table is added the table name defaults to the class name (with upper case) 'class Foo', table created is 'Foo'. 添加新表时,表名默认为类名(大写)“ Foo类”,创建的表为“ Foo”。 If you change Foo, such as add or delete a property, upon update, the table is renamed to 'foo'. 如果在更新时更改Foo(例如添加或删除属性),则表将重命名为“ foo”。

There is a bug filed against this issue: http://www.doctrine-project.org/jira/browse/DBAL-598 针对该问题存在一个错误: http : //www.doctrine-project.org/jira/browse/DBAL-598

The issue is when I export and post the db to a linux based system (when exported from mac-os), I have to hand edit the export file to fix the db tables. 问题是当我导出数据库并将其发布到基于linux的系统(从mac-os导出)时,我必须手动编辑导出文件以修复数据库表。

Specifically my question is, has anyone come up with a reasonably automated way of cleaning up the table names? 具体来说,我的问题是,是否有人想出一种合理的自动化方式来清理表名?

Simply define the table name in lower-case in the entity definition, eg: 只需在实体定义中以小写形式定义表名,例如:

YAML: YAML:

# Doctrine.Tests.ORM.Mapping.User.dcm.yml
Doctrine\Tests\ORM\Mapping\User:
    type: entity
    table: cms_users

XML: XML:

// Doctrine.Tests.ORM.Mapping.User.dcm.xml
<?xml version="1.0" encoding="UTF-8"?>
<doctrine-mapping xmlns="http://doctrine-project.org/schemas/orm/doctrine-mapping"
      xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
      xsi:schemaLocation="http://doctrine-project.org/schemas/orm/doctrine-mapping
                          http://www.doctrine-project.org/schemas/orm/doctrine-mapping.xsd">

    <entity name="Doctrine\Tests\ORM\Mapping\User" table="cms_users">

Annotation: 注解:

<?php
/**
 * @Entity
 * @Table(name="user")
 */
class User { }

That way you ensure that there's no problem whatsoever during a schema update on different filesystems. 这样,您可以确保在不同文件系统上进行模式更新期间没有任何问题。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM