Problem: If you are using the Rights module for role-based access control (RBAC) in a Yii application, your application may work correctly on a local Windows development environment but fail after deployment to a Linux-based server.
One common error looks like this:
Table 'DATABASE_NAME.AuthAssignment' doesn't exist
This error can be confusing because the authassignment table may already exist in your database. The problem is often not that the table is missing, but that the application is requesting the table using different capitalization.
What Does the AuthAssignment Error Mean?
The AuthAssignment table is used by the Yii Rights module to store role and permission assignments. When Yii tries to query this table, the database server must find a table with the exact name it expects.
For example, your database may contain:
authassignment
while the Yii configuration or Rights module may be requesting:
AuthAssignment
On environments where table-name case differences are tolerated, the application may appear to work normally. After moving the application to Linux, however, the same configuration can result in a database error.
Why Does This Happen After Moving Yii to Linux?
The most common reason is case sensitivity in the database table name.
During development, you may have created your Rights tables using lowercase names such as:
authassignmentauthitemauthitemchildrights
However, the Yii Rights configuration may reference them using names such as:
AuthAssignmentAuthItemAuthItemChildRights
These names are not necessarily treated as identical on a Linux/MySQL production server.
This is why an application can work on a local development machine and then produce a table doesn't exist error after deployment.
How to Check the Actual Table Names
Before changing your Yii configuration, check the names of the tables that actually exist in your production database.
You can use the following MySQL command:
SHOW TABLES;
Look for the tables created by the Rights module. Depending on your installation, you may see names similar to:
authassignmentauthitemauthitemchildrights
Pay attention to capitalization. If the database contains authassignment, do not assume that AuthAssignment will always refer to the same table on Linux.
Solution: Match Yii Table Names With Your Database
The simplest solution is to configure the Yii Rights module with the exact table names used by your database.
Open:
protected/config/main.php
Then locate your authManager configuration.
For example:
'components'=>array(
'authManager'=>array(
'defaultRoles'=>array('guest'),
'class'=>'RDbAuthManager',
'assignmentTable'=>'authassignment',
'itemTable'=>'authitem',
'rightsTable'=>'rights',
'itemChildTable'=>'authitemchild',
),
),
The important part is that each configured table name matches the corresponding database table name.
| Rights Configuration | Example Database Table |
|---|---|
assignmentTable | authassignment |
itemTable | authitem |
itemChildTable | authitemchild |
rightsTable | rights |
Why the assignmentTable Setting Matters
The assignmentTable property tells RDbAuthManager which database table contains role assignments.
If your database contains:
authassignment
your configuration should use:
'assignmentTable'=>'authassignment'
rather than:
'assignmentTable'=>'AuthAssignment'
The same principle applies to the other Rights tables. If their actual names are lowercase, configure them using the lowercase names.
Check All Rights Tables, Not Just AuthAssignment
Fixing AuthAssignment may only resolve the first error. The Rights module can use multiple database tables, so inconsistent capitalization in another table can cause a similar error later.
Check all relevant configuration values:
'class'=>'RDbAuthManager',
'assignmentTable'=>'authassignment',
'itemTable'=>'authitem',
'rightsTable'=>'rights',
'itemChildTable'=>'authitemchild',
Compare every value against the actual table names in your production database.
Step-by-Step Troubleshooting Checklist
If you continue to receive the error after updating main.php, work through the following checks.
1. Confirm That the Table Exists
Run:
SHOW TABLES;
Confirm that the Rights tables are present in the database you are currently using.
2. Confirm the Selected Database
Make sure your Yii application is connecting to the intended production database.
A configuration problem can make an existing table appear to be missing when the application is actually connected to a different database.
3. Check the Exact Table Name
Compare the name returned by the database with the name configured in main.php.
For example:
Database:authassignmentYii configuration:AuthAssignment
These should be made consistent.
4. Check the Other Rights Tables
Do not check only authassignment. Verify authitem, authitemchild, and rights as well if they are part of your Rights configuration.
5. Check the Production Environment
If the application worked locally but fails on the server, compare the development and production environments. Differences in operating system, database configuration, table naming, or deployment processes can expose case-related problems.
6. Check the Database User Permissions
If the table exists and the name matches but Yii still cannot access it, verify that the database user configured in Yii has permission to read the relevant tables.
7. Check Your Yii Database Connection
Review the database connection configuration in:
protected/config/main.php
Verify the database host, database name, username, and other connection settings used by the production application.
Common Mistake: Assuming “Table Doesn't Exist” Means the Table Is Missing
A database error saying that a table does not exist does not always mean that the table was never created.
In a Yii Rights deployment, you should also investigate:
- Table-name capitalization
- Database selection
- Production database configuration
- Rights module configuration
- Database permissions
- Differences between development and production environments
This approach can prevent unnecessary database changes or reinstalling the Rights module when the actual problem is simply a naming mismatch.
Should You Rename the Database Tables?
Renaming the tables is not always necessary. If the existing database tables contain production data, changing table names without understanding the application's configuration and dependencies can introduce additional problems.
A safer first step is usually to make the Yii Rights configuration match the existing database schema.
If you decide to rename tables as part of a controlled migration, make sure that all application configuration, queries, migrations, and module dependencies using those table names are updated consistently.
Yii Rights RBAC and Database Table Naming
The Rights module provides role-based access control functionality for Yii applications. Because RBAC data is stored in database tables, the application and database schema must agree on the table names.
This becomes particularly important when deploying older Yii applications from one operating system or hosting environment to another.
A consistent database naming convention can make deployments easier to maintain and reduce environment-specific errors.
How to Prevent This Error in Future Deployments
To reduce the chance of encountering the AuthAssignment error again, consider the following practices:
- Use consistent table naming conventions.
- Document the Rights module database schema.
- Keep development and production database structures synchronized.
- Check table names after importing a database.
- Review Yii configuration files during deployment.
- Test database-dependent modules in an environment similar to production.
- Avoid changing table capitalization without checking application dependencies.
Quick Fix Summary
If your Yii application shows:
Table 'DATABASE_NAME.AuthAssignment' doesn't exist
and your database contains:
authassignment
check the Rights configuration and make the table names match exactly:
'components'=>array(
'authManager'=>array(
'defaultRoles'=>array('guest'),
'class'=>'RDbAuthManager',
'assignmentTable'=>'authassignment',
'itemTable'=>'authitem',
'rightsTable'=>'rights',
'itemChildTable'=>'authitemchild',
),
),
Then verify the remaining Rights tables, database connection, and permissions if the error persists.
Frequently Asked Questions
Why does Yii say AuthAssignment doesn't exist when the table exists?
The table may exist under a different capitalization, such as authassignment. Depending on the operating system and database configuration, table-name case differences can cause Yii to receive a “table doesn't exist” error.
Why does the Yii Rights module work on Windows but fail on Linux?
One possible reason is a difference in how the development and production database environments handle table-name capitalization. A configuration that appears to work locally can therefore fail when deployed to Linux.
What is the AuthAssignment table used for in Yii Rights?
The authassignment table stores assignments between users and authorization items such as roles. It is one of the database tables used by the Rights RBAC implementation.
How can I check whether authassignment exists in MySQL?
You can list the tables in the selected database with:
SHOW TABLES;
Then check whether the Rights table exists and whether its capitalization matches your Yii configuration.
Where should I configure the Rights database table names in Yii?
For a typical Yii 1 application using the Rights module, the configuration is commonly placed in protected/config/main.php under the authManager component.
Do I need to reinstall the Yii Rights module?
Not necessarily. If the required tables already exist, first check the table names, database connection, Rights configuration, and database permissions before reinstalling or recreating the database tables.
What if changing the table names does not fix the error?
Check that Yii is connected to the correct database, confirm the database user has the required permissions, verify all Rights table names, and review the production database configuration. If necessary, inspect the SQL query generated by the application to identify which table name Yii is requesting.
Can inconsistent table naming cause other Yii database errors?
Yes. If application code expects one table name while the database contains another, similar “table doesn't exist” errors can occur elsewhere in the application. Consistent naming between the application and database schema helps avoid these deployment issues.
Last updated: