PHP code example of californiamountainsnake / laravel-migrations

1. Go to this page and download the library: Download californiamountainsnake/laravel-migrations library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

californiamountainsnake / laravel-migrations example snippets



use CaliforniaMountainSnake\LaravelMigrations\BaseMigration;
use Illuminate\Database\Schema\Builder;
use Illuminate\Support\Facades\Schema;

class DatabaseOneMigration extends BaseMigration {
    /**
     * @return Builder
     */
    public function getDatabaseConnection() : Builder {
         return Schema::connection('your_db_connection_name');
    }
}


use Illuminate\Database\Schema\Blueprint;

class CreateUsersTable extends DatabaseOneMigration  {
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up(): void
    {
        $this->getDatabaseConnection()->create('users', static function (Blueprint $table) {
            $table->bigIncrements('id')->unsigned();
            $table->string('email', 256)->unique();
            $table->string('name', 256);
            
            $table->engine    = 'InnoDB';
            $table->charset   = 'utf8mb4';
            $table->collation = 'utf8mb4_unicode_520_ci';
        });
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down(): void
    {
        $this->getDatabaseConnection()->dropIfExists('users');
    }
}