您可以与 Symfony 建立关系(使用 Doctrine)吗?

发布于 2024-10-19 17:08:07 字数 4643 浏览 5 评论 0原文

目前,如果我执行以下操作,它只会生成 schema.yml:

./symfony 学说:构建模式

但这并不会生成关系。

我是否必须手动将它们添加到 schema.yml 中,还是有办法生成它们?如果我必须手动输入它,那么下次我执行 doctrine:build-schema(用新表刷新架构等)时它们不会被覆盖吗?

这是 schema.yml:

Companies:
  connection: doctrine
  tableName: companies
  columns:
    company_id:
      type: integer(4)
      fixed: false
      unsigned: false
      primary: true
      autoincrement: true
    company_name:
      type: string(100)
      fixed: false
          unsigned: false
      primary: false
      notnull: true
      autoincrement: false
    company_logo:
      type: string(100)
      fixed: false
      unsigned: false
      primary: false
      notnull: true
      autoincrement: false
    company_date_added:
      type: timestamp(25)
      fixed: false
      unsigned: false
      primary: false
      notnull: true
      autoincrement: false
Credentials:
  connection: doctrine
  tableName: credentials
  columns:
    credential_id:
      type: integer(4)
      fixed: false
      unsigned: false
      primary: true
      autoincrement: true
    credential_name:
      type: string(100)
      fixed: false
      unsigned: false
      primary: false
      notnull: true
      autoincrement: false
    company_id:
      type: integer(4)
      fixed: false
      unsigned: false
      primary: false
      notnull: true
      autoincrement: false
    credential_date_added:
      type: timestamp(25)
      fixed: false
      unsigned: false
      primary: false
      default: '0000-00-00 00:00:00'
      notnull: true
      autoincrement: false
Groups:
  connection: doctrine
  tableName: groups
  columns:
    group_id:
      type: integer(4)
      fixed: false
      unsigned: false
      primary: true
      autoincrement: true
    group_name:
      type: string(100)
      fixed: false
      unsigned: false
      primary: false
      notnull: true
      autoincrement: false
    company_id:
      type: integer(4)
      fixed: false
      unsigned: false
      primary: false
      notnull: true
      autoincrement: false
    group_date_added:
      type: timestamp(25)
      fixed: false
      unsigned: false
      primary: false
      default: '0000-00-00 00:00:00'
      notnull: true
      autoincrement: false
GroupsCredentials:
  connection: doctrine
  tableName: groups_credentials
  columns:
    group_credential_id:
      type: integer(4)
      fixed: false
      unsigned: false
      primary: true
      autoincrement: true
    group_id:
      type: integer(4)
      fixed: false
      unsigned: false
      primary: false
      notnull: true
      autoincrement: false
    credential_id:
      type: integer(4)
      fixed: false
      unsigned: false
      primary: false
      notnull: true
      autoincrement: false
    group_credential_date_added:
      type: integer(4)
      fixed: false
      unsigned: false
      primary: false
      notnull: true
      autoincrement: false
Users:
  connection: doctrine
  tableName: users
  columns:
    user_id:
      type: integer(4)
      fixed: false
      unsigned: false
      primary: true
      autoincrement: true
    user_username:
      type: string(100)
      fixed: false
      unsigned: false
      primary: false
      notnull: true
      autoincrement: false
    user_password:
      type: string(100)
      fixed: false
      unsigned: false
      primary: false
      notnull: true
      autoincrement: false
    user_email:
      type: string(100)
      fixed: false
      unsigned: false
      primary: false
      notnull: true
      autoincrement: false
    company_id:
      type: integer(4)
      fixed: false
      unsigned: false
      primary: false
      notnull: true
      autoincrement: false
    user_date_added:
      type: timestamp(25)
      fixed: false
      unsigned: false
      primary: false
      notnull: true
      autoincrement: false
UsersCredentials:
  connection: doctrine
  tableName: users_credentials
  columns:
    user_credential_id:
      type: integer(4)
      fixed: false
      unsigned: false
      primary: true
      autoincrement: true
    user_id:
      type: integer(4)
      fixed: false
      unsigned: false
      primary: false
      notnull: true
      autoincrement: false
    credential_id:
      type: integer(4)
      fixed: false
      unsigned: false
      primary: false
      notnull: true
      autoincrement: false
    user_credential_date_added:
      type: timestamp(25)
      fixed: false
      unsigned: false
      primary: false
      default: '0000-00-00 00:00:00'
      notnull: true
      autoincrement: false

At the moment, if I do the following, it just generates the schema.yml:

./symfony doctrine:build-schema

But that doesn't generate the relationships.

Do I have to manually add those into the schema.yml or is there a way to generate them? And if I have to manually enter it in, won't they be over-written next time I do a doctrine:build-schema (to refresh the schema with new tables, etc)?

Here is the schema.yml:

Companies:
  connection: doctrine
  tableName: companies
  columns:
    company_id:
      type: integer(4)
      fixed: false
      unsigned: false
      primary: true
      autoincrement: true
    company_name:
      type: string(100)
      fixed: false
          unsigned: false
      primary: false
      notnull: true
      autoincrement: false
    company_logo:
      type: string(100)
      fixed: false
      unsigned: false
      primary: false
      notnull: true
      autoincrement: false
    company_date_added:
      type: timestamp(25)
      fixed: false
      unsigned: false
      primary: false
      notnull: true
      autoincrement: false
Credentials:
  connection: doctrine
  tableName: credentials
  columns:
    credential_id:
      type: integer(4)
      fixed: false
      unsigned: false
      primary: true
      autoincrement: true
    credential_name:
      type: string(100)
      fixed: false
      unsigned: false
      primary: false
      notnull: true
      autoincrement: false
    company_id:
      type: integer(4)
      fixed: false
      unsigned: false
      primary: false
      notnull: true
      autoincrement: false
    credential_date_added:
      type: timestamp(25)
      fixed: false
      unsigned: false
      primary: false
      default: '0000-00-00 00:00:00'
      notnull: true
      autoincrement: false
Groups:
  connection: doctrine
  tableName: groups
  columns:
    group_id:
      type: integer(4)
      fixed: false
      unsigned: false
      primary: true
      autoincrement: true
    group_name:
      type: string(100)
      fixed: false
      unsigned: false
      primary: false
      notnull: true
      autoincrement: false
    company_id:
      type: integer(4)
      fixed: false
      unsigned: false
      primary: false
      notnull: true
      autoincrement: false
    group_date_added:
      type: timestamp(25)
      fixed: false
      unsigned: false
      primary: false
      default: '0000-00-00 00:00:00'
      notnull: true
      autoincrement: false
GroupsCredentials:
  connection: doctrine
  tableName: groups_credentials
  columns:
    group_credential_id:
      type: integer(4)
      fixed: false
      unsigned: false
      primary: true
      autoincrement: true
    group_id:
      type: integer(4)
      fixed: false
      unsigned: false
      primary: false
      notnull: true
      autoincrement: false
    credential_id:
      type: integer(4)
      fixed: false
      unsigned: false
      primary: false
      notnull: true
      autoincrement: false
    group_credential_date_added:
      type: integer(4)
      fixed: false
      unsigned: false
      primary: false
      notnull: true
      autoincrement: false
Users:
  connection: doctrine
  tableName: users
  columns:
    user_id:
      type: integer(4)
      fixed: false
      unsigned: false
      primary: true
      autoincrement: true
    user_username:
      type: string(100)
      fixed: false
      unsigned: false
      primary: false
      notnull: true
      autoincrement: false
    user_password:
      type: string(100)
      fixed: false
      unsigned: false
      primary: false
      notnull: true
      autoincrement: false
    user_email:
      type: string(100)
      fixed: false
      unsigned: false
      primary: false
      notnull: true
      autoincrement: false
    company_id:
      type: integer(4)
      fixed: false
      unsigned: false
      primary: false
      notnull: true
      autoincrement: false
    user_date_added:
      type: timestamp(25)
      fixed: false
      unsigned: false
      primary: false
      notnull: true
      autoincrement: false
UsersCredentials:
  connection: doctrine
  tableName: users_credentials
  columns:
    user_credential_id:
      type: integer(4)
      fixed: false
      unsigned: false
      primary: true
      autoincrement: true
    user_id:
      type: integer(4)
      fixed: false
      unsigned: false
      primary: false
      notnull: true
      autoincrement: false
    credential_id:
      type: integer(4)
      fixed: false
      unsigned: false
      primary: false
      notnull: true
      autoincrement: false
    user_credential_date_added:
      type: timestamp(25)
      fixed: false
      unsigned: false
      primary: false
      default: '0000-00-00 00:00:00'
      notnull: true
      autoincrement: false

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

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

发布评论

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

评论(1

反差帅 2024-10-26 17:08:08

我最终解决了这个问题。

MySQL 数据库中的关系没有正确设置 - 我犯了一个愚蠢的错误。

I ended up fixing the issue.

The relationships weren't setup properly in the MySQL DB - stupid mistake on my part.

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