Question

I need to change the name of the user table in an existing CI application which uses ion auth.

In the ion_auth.php file it has these configs:

    | -------------------------------------------------------------------------
    | Tables.
    | -------------------------------------------------------------------------
    | Database table names.
    */
    $config['tables']['users']           = 'users';
    $config['tables']['groups']          = 'groups';
    $config['tables']['users_groups']    = 'users_groups';
    $config['tables']['login_attempts']  = 'login_attempts';

    /*
    | Users table column and Group table column you want to join WITH.
    |
    | Joins from users.id
    | Joins from groups.id
    */
    $config['join']['users']  = 'user_id';
    $config['join']['groups'] = 'group_id';

The new table name needs to be "customer" the PK will be "customer_id" not just "id"

Which of these ['users'] = 'users'; is the actual table name?

In order to join the new customer_id to the existing users_groups table what do I need to do?

Do I have to edit ion_auth_model.php in anyway to achieve what I need to achieve?

Or is what I am trying to do way more complex than I think it is?

Thanks

@kevindeleon. Thanks for response.

When I make that change I get 5 errors, all a variation of this,

    A PHP Error was encountered

    Severity: Notice

    Message: Undefined index: customer

    Filename: models/ion_auth_model.php

    Line Number: 1362

Do I simply change those items to "customer" is there any reason for not doing that?

Thanks

Was it helpful?

Solution

If you are only concerned with changing the 'users' table name:

$config['tables']['users']  = 'customers';

And then just change the table name in your DB.

There is no configuration option to change the column name from 'id' to something else that I know of.

All of the Ion Auth methods are still going to use the "user" terminology though...as in delete_user, remember_user etc.

I personally would just leave it all as is unless there is some business need to change it to 'customers,' or if you already have a table called 'users' or something. The reason I say this is that having different table names and column names from Ion Auth just ends up in confusion when discussing with other developers or when reading back-and-forth in the model/config when working...but that is just my experience with it. It is open source after-all and the code is out there...you can change the whole thing if you like! :D

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top