Welcome Guest, Not a member yet? Register   Sign In
Migrate users to shield
#1

(This post was last modified: 02-14-2024, 10:51 AM by frocco.)

Hello,

I am using migrations to insert users from another application to shield users table.
I need to preserve the previous id value and insert it as the current id.
shield will not allow me to replace the primary key id with current value.

I cannot get this to work.

Code:
$user = new User([
                "id" => $row->id, // Previous id from other database table
  ]);
$model = new UserModel;
            $model->save($user);

            $user = $model->findById($model->getInsertID());
            $user->activate();
Reply
#2

Do not use the Model. CodeIgniter Model dose not permit to change the id.

Use Query Builder.
https://codeigniter.com/user_guide/datab...ilder.html
Reply
#3

Thanks, will try it.
Reply




Theme © iAndrew 2016 - Forum software by © MyBB