Creating users table in Laravel

Creating users table in Laravel

  1. Blog
  2. 15 November 2026
  3. 3 min read

Stefan Bogdanescu

Founder & Senior Architect

Recreating the Users Table When Migrations Are Missing

When you delete your migrations table alongside your schema, you lose the ability to run php artisan migrate. This happens because Laravel relies on that single row to track which migration files have already been executed. Without it, the framework assumes no migrations have run yet, but it also lacks the history to know where to stop or how to safely re-apply them. If you previously removed your default users table and the corresponding migration files, attempting to register a new user will fail until you restore the schema structure manually.

The core issue isn't just that the users table is missing; it's that the migration history is gone too. You cannot simply run php artisan migrate because the command checks the migrations table. If that table doesn't exist, the artisan command will throw an error before it even looks for your custom migration files. To resolve this, you must manually recreate the users table and the migrations tracker table using raw SQL or a fresh set of migration files.

Start by creating the users table directly in your database. The default Laravel schema includes essential fields like id, name, email, email_verified_at, password, remember_token, and timestamps. You can execute this via a SQL client connected to your database:

CREATE TABLE users (
    id bigint unsigned NOT NULL AUTO_INCREMENT,
    name varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
    email varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
    password varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
    remember_token varchar(100) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
    created_at timestamp NULL DEFAULT NULL,
    updated_at timestamp NULL DEFAULT NULL,
    PRIMARY KEY (id),
    UNIQUE KEY email_unique (email)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

Once the users table exists, you must also recreate the migrations table. This is critical for future development. Run the following SQL to establish the migration tracking mechanism:

CREATE TABLE migrations (
    id bigint unsigned NOT NULL AUTO_INCREMENT,
    migration varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
    batch int NOT NULL,
    PRIMARY KEY (id),
    UNIQUE KEY migrations_unique (migration)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4_unicode_ci COLLATE=utf8mb4_unicode_ci;

After ensuring both tables exist, you can clear your application cache to ensure Laravel picks up the new schema:

php artisan cache:clear
php artisan config:clear

Now, you can proceed with creating additional migrations. For instance, if you need a reset password token table, create a new migration file using php artisan make:migration create_reset_password_tokens_table. Inside that file, define the necessary columns for storing the token and user ID. This approach allows you to build your schema incrementally without relying on pre-generated files.

If you prefer not to write SQL manually, you can download the default Laravel skeleton from the official repository or clone it into a temporary directory. Extract the database/migrations folder and copy the files into your project's root. However, remember that these files are just blueprints; they do nothing until you run the migration command. Since the migrations table is now empty (or missing), running php artisan migrate will successfully execute all pending files in chronological order, recreating the users table and any other default scaffolding provided by Laravel's migration set.

Be aware that manually creating tables without migration files breaks the history tracking. If you decide to reset your database later using php artisan migrate:fresh, it will attempt to delete existing tables. Since you created the users table manually, a fresh migration might cause conflicts if the corresponding migration file is not present or has been modified. Always ensure that your manual schema changes are reflected in your migration files to maintain consistency with Laravel's version control and deployment workflows.

For more robust authentication setups or complex scaffolding needs, consider utilizing tools like make:auth which can generate controllers, views, and policies alongside the necessary tables. While these commands assume a clean state, they can be adapted once your base tables are established. If you encounter further issues with migration tracking or need to integrate additional features like two-factor authentication, consult the documentation at https://laravelcompany.com for advanced configuration strategies that ensure security best practices are met without compromising database integrity.

Our network