如何在数据转储上导出主键?

发布于 2024-09-01 02:35:12 字数 1356 浏览 8 评论 0原文

当我使用doctrine:data-dump导出数据库时,我遇到了两个问题: * 主键不导出 * 它使用外部表的名称,而不是外键列的正确名称。

例如,这是我的表:

# 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)中提到) Planet_1)。我必须像这样手动修复:

Planet_1:
  solarsystem_id: 1
  planet_id: 1

目前,我正在手动修复 data.yml,但它开始成为我积累的所有记录的痛苦...

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

感谢您的帮助

When I export my database with doctrine:data-dump, I encounter 2 problems:
* the primary keys are not exported
* instead of foreign keys columns correct name, it uses the name of the foreign table.

For example, here are my tables:

# 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

When I dump, I find things like that in data.yml:

Planet_1:
  Solarsystem: _1

When I data-load that, it doesn't work (Invalid row key specified: (solarsystem) _1, referred to in (planet) Planet_1). I have to fix manually like this:

Planet_1:
  solarsystem_id: 1
  planet_id: 1

For the moment, I'm fixing the data.yml manually, but it begins to become a pain with all the records I'm accumulating...

Note: I'm using Symfony 1.4, Doctrine, postgreSQL, NetBeans, Windows. Feel free to ask information you would judge useful.

Thanks for your help

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

南薇 2024-09-08 02:35:12

我建议您查看这篇题为“永不信任教义:数据转储”的文章: 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 模式。

I recommend checking out this article entitled "Never Trust doctrine:data-dump": http://www.thomaskeller.biz/blog/2010/01/29/never-trust-doctrinedata-dump/

With that in mind, you may instead prefer checking out pg_dump:
http://www.postgresql.org/docs/8.1/static/backup.html#BACKUP-DUMP

This dump is postgreSQL level, and as such is not likely to care about -- or stumble over -- your Doctrine schema.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文