Search code examples
symfony1doctrinesymfony-1.4sfguard

Loading data from updated fixture file without wiping out existing data


I have the sfGuard plugin installed with three user groups and permissions set. This was done when the plugin was originally installed, and there was not a lot of data in the database. I would like to add a new user group with new permissions.

I have edited the sfGuard.yml file in the fixtures directory. How do I upload the new yml data to the SQL database without wiping out my current data?

Here is the sfGuard.yml snippet:

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

Any direction would be great!


Solution

  • I believe the standard fixtures task for loading data will NOT overwrite any existing data, as long as you're not re-building the db and models:

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

    I would recommend calling the fixtures filename explicitly (as above) to avoid accidentally including a fixtures file from elsewhere in the project structure. There are several places from which they can be included, such as the sfDoctrineGuardPlugin. Do of course also run this on a dev/local database before production to avoid screw-ups.