从更新的夹具文件加载数据而不擦除现有数据

时间:2012-06-07 16:51:35

标签: symfony1 doctrine symfony-1.4 sfguard

我安装了sfGuard插件,其中设置了三个用户组和权限。这是在最初安装插件时完成的,并且数据库中没有大量数据。我想添加一个具有新权限的新用户组。

我已经在fixtures目录中编辑了sfGuard.yml文件。如何在不擦除当前数据的情况下将新的yml数据上载到SQL数据库?

这是sfGuard.yml片段:

sfGuardGroup:
  Group_univ_admin:
    name:           univ_admins
    description:    Universal Administrators
    Permissions:    [Permission_admin, Permission_universal]
  Group_univ_editor:
    name:           univ_editors
    description:    Universal Editors
    Permissions:    [Permission_editor, Permission_universal]
  Group_dept_admin:
    name:           dept_admins
    description:    Department Administrators
    Permissions:    [Permission_admin, Permission_department]
  Group_dept_editor:
    name:           dept_editors
    description:    Department Editors
    Permissions:    [Permission_editor, Permission_department]
  Group_dept_faculty:
    name:           dept_faculties
    description:    Department Faculties
    Permissions:    [Permission_faculty, Permission_department]

sfGuardPermission:
  Permission_admin:
    name:           administrator
    description:    Administrator permission
  Permission_editor:
    name:           editor
    description:    Editor permission
  Permission_universal:
    name:           universal
    description:    Universal permission
  Permission_department:
    name:           department
    description:    Department permission
  Permission_faculty:
    name:           faculty
    description:    Faculty permission

任何方向都会很棒!

1 个答案:

答案 0 :(得分:3)

我相信加载数据的标准灯具任务不会覆盖任何现有数据,只要您不重新构建数据库和模型:

php symfony doctrine:data-load data/fixtures/some_specific_file.yml

我建议明确调用fixtures文件名(如上所述),以避免意外地在项目结构的其他地方包含fixtures文件。有几个地方可以包含它们,例如sfDoctrineGuardPlugin。当然,在生产之前也要在开发/本地数据库上运行它以避免搞砸。