PHP code example of mitsuki / mitsuki-db-migrations

1. Go to this page and download the library: Download mitsuki/mitsuki-db-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/ */

    

mitsuki / mitsuki-db-migrations example snippets


use Mitsuki\Database\Schema\Schema;
use Mitsuki\Database\Table;
use Mitsuki\Database\Migrations\Migration;

class CreateUsersTable extends Migration
{
    public function up(): void
    {
        Schema::create('users', function (Table $table) {
            $table->string('username', 100);
            $table->string('email')->nullable();
            $table->timestamps(); // Adds 'created_at' and 'updated_at'
        }, $this);
    }

    public function down(): void
    {
        $this->table('users')->drop()->save();
    }
}


$table->foreignIdFor(\App\Models\User::class)
      ->constrained()
      ->onDelete('cascade');