VeldoraDocs

5. Database, Schema & Migrations

Veldora supports SQLite, MySQL, and PostgreSQL with a unified Schema Blueprint.

Creating a Migration

Terminal • bash
php veldora make:migration create_posts_table

database/migrations/create_posts_table.php
PHP
use Veldora\Framework\Database\Schema\Blueprint;
use Veldora\Framework\Database\Schema\Migration;
use Veldora\Framework\Database\Schema\Schema;

class CreatePostsTable extends Migration
{
    public function up(): void
    {
        Schema::create('posts', function (Blueprint $table) {
            $table->id();
            $table->integer('user_id');
            $table->string('title');
            $table->string('slug')->unique();
            $table->text('body');
            $table->boolean('is_published')->default(0);
            $table->timestamp('published_at')->nullable();
            $table->timestamps();
        });
    }

    public function down(): void
    {
        Schema::dropIfExists('posts');
    }
}

Migration Commands

Terminal • bash
# Run pending migrations
php veldora migrate

# Check migration status
php veldora migrate:status

# Rollback last migration batch
php veldora migrate:rollback

# Reset database & re-run all migrations
php veldora migrate:fresh

Available Blueprint Column Types

MethodSQL TypeDescription
$table->id()AUTO_INCREMENT PKPrimary key ID
$table->string('name', 255)VARCHAR(255)String column
$table->text('content')TEXTLarge text block
$table->integer('count')INTInteger
$table->boolean('active')TINYINT(1) / INTEGERBoolean true/false
$table->timestamp('created_at')TIMESTAMPDate & time
$table->timestamps()created_at + updated_atAuto timestamp pair
$table->softDeletes()deleted_atSoft deletion column
$table->rememberToken()remember_tokenAuth remember token

Building with AI Assistants?
Copy the Veldora AI Developer Prompt to teach ChatGPT, Claude, Cursor, or Gemini all framework APIs for error-free coding.