PHP Classes

File: database/migrations/01_create_table_users.php

Recommend this page to a friend!
  Packages of Amirreza Ebrahimi   URL Shortener Application   database/migrations/01_create_table_users.php   Download  
File: database/migrations/01_create_table_users.php
Role: Class source
Content type: text/plain
Description: Class source
Class: URL Shortener Application
Application to create and redirect short URLs
Author: By
Last change:
Date: 7 months ago
Size: 1,080 bytes
 

Contents

Class file image Download
<?php

use Illuminate\Database\Capsule\Manager as DataBase;

class
CreateTableUsers
{
   
/**
     * Run the migrations to create the 'users' table.
     *
     * @return void
     */
   
public function up(): void
   
{
       
DataBase::schema()->create('users', function ($table) {
           
# Define columns for the 'users' table
           
$table->id()->autoIncrement(); # Primary key with auto-increment
           
$table->string('name'); # User's name
           
$table->string('email')->unique(); # User's email (must be unique)
           
$table->string('otpCode'); # OTP code for user authentication
           
$table->string('otpExpired'); # OTP expiration time
           
$table->timestamp('created_at')->useCurrent(); # Timestamp for record creation
       
});
    }

   
/**
     * Reverse the migrations by dropping the 'users' table.
     *
     * @return void
     */
   
public function down(): void
   
{
       
# Drop the 'users' table if it exists
       
DataBase::schema()->dropIfExists('users');
    }
}