Categories: Laravel
Tags:

When you set up a Laravel project and run migrations, it may automatically create several tables in your database. These tables are foundational for Laravel’s built-in features such as authentication, sessions, and password resets. Here’s what each of the common tables means:

Common Tables Created by Laravel Migrations

  1. migrations
    • Purpose: Keeps track of which database migrations have been run.
    • Columns:
      • id: Unique ID for the migration entry.
      • migration: The name of the migration file.
      • batch: The batch number allows Laravel to know which migrations were run together.
    • Meaning: This table helps Laravel ensure that your database schema stays in sync with your migrations. When you run php artisan migrate, Laravel checks this table to determine which migrations have already been executed.
  2. users
    • Purpose: Stores user information for authentication.
    • Columns:
      • id: Unique identifier for the user.
      • name: User’s full name.
      • email: User’s email address, used for logging in.
      • email_verified_at: Timestamp for when the user’s email was verified.
      • password: Hashed password for the user.
      • remember_token: Token used for “Remember Me” functionality.
      • created_at & updated_at: Timestamps for when the user was created and last updated.
    • Meaning: This table is used by Laravel’s built-in authentication system to manage users.
  3. password_resets
    • Purpose: Stores tokens for resetting user passwords.
    • Columns:
      • email: The email address of the user requesting a password reset.
      • token: A token that is emailed to the user and used to verify the reset request.
      • created_at: Timestamp of when the reset request was created.
    • Meaning: This table is used when users request to reset their password. Laravel generates a token and stores it in this table, allowing users to reset their passwords securely.
  4. failed_jobs
    • Purpose: Stores jobs that failed during execution.
    • Columns:
      • id: Unique ID for the failed job.
      • connection: The connection the job was using (e.g., database, Redis).
      • queue: The name of the queue.
      • payload: The job’s data.
      • exception: Details about the exception that caused the job to fail.
      • failed_at: Timestamp of when the job failed.
    • Meaning: This table helps you track any queued jobs that have failed and allows you to debug or retry them.
  5. personal_access_tokens (for Laravel Sanctum)
    • Purpose: Stores API tokens for user authentication via Laravel Sanctum.
    • Columns:
      • id: Unique identifier for the token.
      • tokenable_type: The model type (e.g., App\Models\User).
      • tokenable_id: The corresponding model ID (e.g., user ID).
      • name: The name of the token.
      • token: The hashed token value.
      • abilities: The abilities (permissions) the token has.
      • last_used_at: Timestamp of the token’s last usage.
    • Meaning: This table is used for API authentication with Laravel Sanctum, allowing users or systems to authenticate via tokens.

Custom Tables for the School ERP

As you build your School ERP, you’ll need to create custom tables for managing school data. Some common tables you might consider creating:

  1. students: Stores student details.
  2. teachers: Stores teacher details.
  3. classes: Manages class information.
  4. subjects: Stores details about subjects.
  5. attendance: Tracks student attendance.
  6. grades: Manages students’ grades or marks.

Each table will have its own set of fields depending on the information you need to manage, and you’ll define these using Laravel migrations.