Chad 2010-06-08
There's a sfGuardUser in the sfDoctrineGuardPlugin, which is using the `sf_guard_user` table. After installation of the plugin, by default that table only contains the least columns for security purpose, not even there's a column to store an email address.
To extend it, I think there are at least two ways:
1. ovrride the `sf_guard_user` table schema;
2. add a new table to store more custom user information.
Both of the solutions are very useful. For example, we can do the following configuration:
- // config/doctrine/schema.yml
- #...
- sfGuardUser:
- columns:
- user_type: { type: integer(1) }
- #...
With this, we will have an additional `user_type` column added into the `sf_guard_user` table.
We can also add a completely new table and add a foreign key constraint to the extended custom table:
- // config/doctrine/schema.yml
- #...
- CustomUser:
- columns:
- guard_user_id: { type: integer(4), notnull: true }
- email: { type: string(45), notnull: true }
- relations:
- GuardUser:
- class: sfGuardUser
- local: guard_user_id
- foreign: id
- foreignAlias: CustomUser
- foreignKeyName: fk_custom_user_sf_guard_user
- foreignType: one
- onDelete: CASCADE
- #...
It's important to know that we should use "integer(4)" for that `guard_user_id` column. Because it's a foreign key, it should match the data type of the `id` column in `sf_guard_user` table, which is also "integer(4)". Otherwise SQL error (errno: 150) would occur when running the generated SQL script.