Changing Laravel auth table name and column names
Stefan Bogdanescu
Founder & Senior Architect · 2026-06-29
Title: Effortlessly Customize Your Laravel Auth Table Names and Columns Without Breaking Anything
As a developer working with Laravel's auth system, you may encounter situations where you want to change the table name or column names of your auth tables. This blog post aims to guide you through this process efficiently, ensuring that your customizations will work seamlessly without breaking anything.
Changing the Table Name
If you want to rename the 'users' table to 'accounts', follow these steps: 1. Create a new migration file for the change: `php artisan make:migration rename_auth_table_to_accounts` 2. Open the newly created migration and add the following code: ```php public function up() { Schema::rename('users', 'accounts'); }/**
- Reverse the migrations.
*/
public function down() {
Schema::rename('accounts', 'users');
}
php
3. Run the migration to apply the change:
`php artisan migrate --path=./database/migrations/2021_01_01_your_migration_name_here.php`
<h3>Changing Column Names</h3>
If you want to rename 'name' column to 'username', follow these steps:
1. Create a new migration file for the change:
`php artisan make:migration change_username_column_in_accounts_table`
2. Open the newly created migration and add the following code:
```php
public function up() {
Schema::table('accounts', function (Blueprint $table) {
$table->string('username')->after('name');
$table->dropColumn('name');
});
}
/**
* Reverse the migrations.
*/
public function down() {
Schema::table('accounts', function (Blueprint $table) {
$table->dropColumn('username');
$table->string('name')->after('email_addr');
});
}- Run the migration to apply the change:
php artisan migrate --path=./database/migrations/2021_01_01_your_migration_name_here.php
Changing 'email' Column Name
If you want to rename the 'email' column to 'email_addr', follow these steps: 1. Create a new migration file for the change: `php artisan make:migration change_email_column_to_email_addr_in_accounts_table` 2. Open the newly created migration and add the following code: ```php public function up() { Schema::table('accounts', function (Blueprint $table) { $table->string('email_addr')->change(); }); }/**
- Reverse the migrations.
*/
public function down() {
Schema::table('accounts', function (Blueprint $table) {
$table->dropColumn('email_addr');
$table->string('email')->after('last_updated_at');
});
}
php
3. Run the migration to apply the change:
`php artisan migrate --path=./database/migrations/2021_01_01_your_migration_name_here.php`
<h3>Changing 'updated_at' Column Name</h3>
If you want to rename the 'updated_at' column to 'last_updated_at', follow these steps:
1. Create a new migration file for the change:
`php artisan make:migration change_updated_at_column_to_last_updated_at_in_accounts_table`
2. Open the newly created migration and add the following code:
```php
public function up() {
Schema::table('accounts', function (Blueprint $table) {
$table->string('last_updated_at')->change();
});
}
/**
* Reverse the migrations.
*/
public function down() {
Schema::table('accounts', function (Blueprint $table) {
$table->dropColumn('last_updated_at');
$table->string('updated_at')->after('email_addr');
});
}- Run the migration to apply the change:
php artisan migrate --path=./database/migrations/2021_01_01_your_migration_name_here.php