fix(previews): keep production values for previews from before the upgrade

Public pull request previews no longer get production values, and no
preview falls back to production variables. Existing previews were
deployed with these values; for example, their databases were
initialized with the production password, so they broke on redeploy.

Previews that exist at the upgrade get keeps_production_values and
keep the earlier behavior. Previews created later do not. Server
transfer moves the flag.
This commit is contained in:
Andras Bacsai
2026-10-28 12:10:27 +01:00
parent 5dacaed9f2
commit 2dcf8eeca3
10 changed files with 98 additions and 4 deletions
@@ -0,0 +1,30 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Until v4.5.1, previews used production values: the production variables that had no preview copy,
* and on public pull requests also the preview copies with the production value. Existing previews
* keep them, so their databases and services keep working. Previews created later do not get them.
*/
public function up(): void
{
Schema::table('application_previews', function (Blueprint $table) {
$table->boolean('keeps_production_values')->default(false);
});
DB::table('application_previews')->update(['keeps_production_values' => true]);
}
public function down(): void
{
Schema::table('application_previews', function (Blueprint $table) {
$table->dropColumn('keeps_production_values');
});
}
};