2

当我用学说导出我的数据库时:数据转储,我遇到了两个问题: * 没有导出主键 * 代替外键列的正确名称,它使用外部表的名称。

例如,这是我的表:

# schema.yml
Planet:
  connection: doctrine
  tableName: planet
  columns:
    planet_id:
      type: integer(4)
      fixed: false
      unsigned: false
      primary: true
      sequence: planet_planet_id
    solarsystem_id:
      type: integer(4)
      fixed: false
      unsigned: false
      notnull: false
      primary: false
  # some columns...
  relations:
    Solarsystem:
      local: solarsystem_id
      foreign: solarsystem_id
      type: one
  # other relations...

Solarsystem:
  connection: doctrine
  tableName: solarsystem
  columns:
    solarsystem_id:
      type: integer(4)
      fixed: false
      unsigned: false
      primary: true
      sequence: solarsystem_solarsystem_id
    # other columns...
  relations:
    Planet:
      local: solarsystem_id
      foreign: solarsystem_id
      type: many
    # other relations

当我转储时,我会在 data.yml 中找到类似的内容:

Planet_1:
  Solarsystem: _1

当我加载数据时,它不起作用(指定的行键无效:(solarsystem)_1,在(行星)Planet_1 中引用)。我必须像这样手动修复:

Planet_1:
  solarsystem_id: 1
  planet_id: 1

目前,我正在手动修复 data.yml,但是我积累的所有记录开始变得很痛苦......

注意:我使用的是 Symfony 1.4、Doctrine、postgreSQL、NetBeans、Windows。随意询问您认为有用的信息。

谢谢你的帮助

4

1 回答 1

1

我建议查看这篇题为“从不信任原则:数据转储”的文章:http ://www.thomaskeller.biz/blog/2010/01/29/never-trust-doctrinedata-dump/

考虑到这一点,您可能更喜欢查看 pg_dump: http ://www.postgresql.org/docs/8.1/static/backup.html#BACKUP-DUMP

这个转储是 postgreSQL 级别的,因此不太可能关心——或者偶然发现——你的 Doctrine 模式。

于 2011-01-13T07:23:39.310 回答