Skip to main content

Laravel

Migrations

Proxying

To run your migrations through the proxy copy your .env file to .env.proxy and edit the database settings:

DB_CONNECTION=pgsql

# Database name is ignored.
DB_DATABASE=postgres

# User is normally `postgres`.
DB_USERNAME=postgres
# Password is the password you configure using `PG_PROXY_PASSWORD`
# when running the Electric sync service.
DB_PASSWORD=postgres

# Host is the hostname where you're running Electric.
DB_HOST=localhost
# Port is the `PG_PROXY_PORT` you set when running Electric,
# which defaults to 65432.
DB_PORT=65432

Then set the APP_ENV to proxy when running migrations, e.g.:

APP_ENV=proxy php artisan migrate

Applying DDLX statements

Use the statement method on the DB facade.

First, create a migration:

php artisan make:migration electrify_items

Then use DB::statement in the up function:

<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Support\Facades\DB;

return new class extends Migration {
public function up(): void {
DB::statement("ALTER TABLE items ENABLE ELECTRIC");
}
};