質問

if you work with an existing database, and the database contains a user table that contains all the information from our user how we can make... once i installed fosuserBundle he will create a new table fos_user..how can i merge my old data with the new data, or transfering the old data to the new data Is it possible to do reverse, engineering, if yes how ?? Thank you

役に立ちましたか?

解決

I got a similiar task to do for a couple of days, you just need to extend the FOSUserBundle User Entity with your UserEntity where you're going to add all the Columns you need that the BaseUser doesn't provide.

use FOS\UserBundle\Model\User as BaseUser;

/**
 * user
 *
 * @ORM\Table(name="user")
 * 
 */
class User extends BaseUser
{
    //Here you can extend the BaseUser provided from the FOSUserBundle
    //with the Columns you need 
}

After that you just need to write a SQL Script with migrates the Data from the one Table to the new Table

INSERT INTO fos_user(`id`, `username`, `username_canonical`, `email`, `email_canonical`, `enabled`, `password`)
SELECT      `id`, `name`, `name`, `email`, `email`, `active`, `password` 
FROM        old_user_table;

This is the script i was using to do this datamigration. Just run it in phpmyadmin.

It is not necessary to add the *_canonical fields manually AFAIK, i'm just doing it to be safe.

Hope it helped.

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top