Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
56 changes: 31 additions & 25 deletions apps/cli/src/legacy/commands/db/reset/SIDE_EFFECTS.md

Large diffs are not rendered by default.

336 changes: 331 additions & 5 deletions apps/cli/src/legacy/commands/db/reset/reset.integration.test.ts

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion apps/cli/src/legacy/commands/db/reset/reset.layers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ import { legacyTelemetryStateLayer } from "../../../telemetry/legacy-telemetry-s
* command, so `LegacyGoProxy` is not composed here.
*
* `legacyDockerRunLayer` backs the native local recreate's PG15+ one-shot migrate
* jobs (`legacyStartSetupLocalDatabase`, reused via `legacyRecreateLocalDatabase`)
* jobs (`legacyRunFreshDbSetup`, reused via `legacyRecreateLocalDatabase`)
* — same reasoning as `db start`'s own `start.layers.ts`.
* `legacyEdgeRuntimeScriptLayer`/`legacyPgDeltaSslProbeLayer` back that same shared
* setup pipeline's best-effort pg-delta migrations-catalog warmup (`db-setup.ts`'s
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ import {
mockLegacyPlatformApiService,
mockLegacyTelemetryStateTracked,
useLegacyTempWorkdir,
useLegacyShadowCacheDisabled,
legacySequentialExecBatch,
} from "../../../../../../../tests/helpers/legacy-mocks.ts";
import { CliArgs } from "../../../../../../shared/cli/cli-args.service.ts";
Expand Down Expand Up @@ -317,6 +318,11 @@ const flags = (
const failError = (exit: Exit.Exit<unknown, unknown>) =>
Exit.isFailure(exit) ? exit.cause.reasons.find(Cause.isFailReason)?.error : undefined;

// The baseline PGDATA cache is ON by default and roots its tar directory at the ambient
// `SUPABASE_HOME` — which this suite does not pin — so a cold provision here would read from, and
// publish into, the developer's real `~/.supabase`. This suite's subject is not the cache.
useLegacyShadowCacheDisabled();

describe("legacy db schema declarative generate integration", () => {
const tmp = useLegacyTempWorkdir();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import { LegacyPgDeltaEngine } from "./legacy-pgdelta-engine.service.ts";
import { LegacyPgDeltaNextAdapter } from "./legacy-pgdelta-next-adapter.service.ts";
import { LegacyPgDeltaNextShadow } from "./legacy-pgdelta-next-shadow.service.ts";
import type { LegacyDbTomlValues } from "../../../shared/legacy-db-config.toml-read.ts";
import { useLegacyShadowCacheDisabled } from "../../../../../tests/helpers/legacy-mocks.ts";

const common = {
context: {
Expand Down Expand Up @@ -104,6 +105,11 @@ function setup() {
};
}

// The baseline PGDATA cache is ON by default and roots its tar directory at the ambient
// `SUPABASE_HOME` — which this suite does not pin — so a cold provision here would read from, and
// publish into, the developer's real `~/.supabase`. This suite's subject is not the cache.
useLegacyShadowCacheDisabled();

describe("pg-delta next shadow selection", () => {
it.effect("does not provision a second shadow for prepared database diffs", () => {
const { state, layer } = setup();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,6 @@ interface NativeShadowBase {
interface ProvisionedDeclarativeShadow {
readonly declarativeUrl: string;
readonly restoredFromPgDataSnapshot: boolean;
readonly snapshotKey: string | undefined;
}

/**
Expand Down Expand Up @@ -282,14 +281,14 @@ export const legacyPgDeltaNextShadowLayer = Layer.effect(
// reaches that seam when its export publishes the tar; any other handle (warm because
// another process published between peek and acquire, or uncached) never runs a
// snapshot, so signal immediately — the waiter then just re-peeks current disk state.
const seamWillRun = handle.snapshotRequired && !handle.baselinePresent;
const seamHandle: LegacyShadowAcquiredHandle = seamWillRun
? {
...handle,
snapshotBaseline: handle.snapshotBaseline.pipe(Effect.ensuring(onBaselineSeam)),
}
: handle;
if (!seamWillRun) yield* onBaselineSeam;
const seamHandle: LegacyShadowAcquiredHandle =
handle._tag === "cold"
? {
...handle,
snapshotBaseline: handle.snapshotBaseline.pipe(Effect.ensuring(onBaselineSeam)),
}
: handle;
if (handle._tag !== "cold") yield* onBaselineSeam;
yield* awaitShadowReady(input, seamHandle);
const setup = setupRunInput(input, seamHandle);
yield* legacyMigrateNextShadowDatabase(input.spawner, setup, seamHandle);
Expand Down Expand Up @@ -319,8 +318,7 @@ export const legacyPgDeltaNextShadowLayer = Layer.effect(
);
return {
declarativeUrl: legacyToPostgresURL(setup.connConfig),
restoredFromPgDataSnapshot: handle.baselinePresent,
snapshotKey: handle.snapshotKey,
restoredFromPgDataSnapshot: handle._tag === "warm",
} satisfies ProvisionedDeclarativeShadow;
}).pipe(Effect.provide(runtimeWith(outputService)), Effect.mapError(nextShadowError));

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
*
* - `parallel` — both snapshots are published: both provisions warm-restore concurrently. A warm
* provision skips the platform baseline entirely (`legacySetupShadowDatabase`'s
* `baselinePresent` branch), so the declarative fiber prints nothing and the migrations fiber's
* `warm` branch), so the declarative fiber prints nothing and the migrations fiber's
* `Applying migration ...` lines stream live and in order.
* - `baseline-handoff` — both are cold with the SAME cache key (webhooks agree): the baseline is
* paid exactly once. The migrations shadow cold-provisions; its snapshot export runs at the
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import {
import { LegacyEdgeRuntimeScriptError } from "../../../shared/legacy-edge-runtime-script.errors.ts";
import { legacyApplyDeclarativePgDelta } from "./legacy-pgdelta.apply.ts";
import type { LegacyPgDeltaContext } from "../../../shared/legacy-pgdelta.ts";
import { useLegacyShadowCacheDisabled } from "../../../../../tests/helpers/legacy-mocks.ts";

const CTX: LegacyPgDeltaContext = {
projectId: "ref",
Expand Down Expand Up @@ -52,6 +53,11 @@ function makeDeclarativeDir(): string {
const failError = (exit: Exit.Exit<unknown, unknown>) =>
Exit.isFailure(exit) ? exit.cause.reasons.find(Cause.isFailReason)?.error : undefined;

// The baseline PGDATA cache is ON by default and roots its tar directory at the ambient
// `SUPABASE_HOME` — which this suite does not pin — so a cold provision here would read from, and
// publish into, the developer's real `~/.supabase`. This suite's subject is not the cache.
useLegacyShadowCacheDisabled();

describe("legacyApplyDeclarativePgDelta", () => {
it.effect(
"fails with LegacyPgDeltaDeclarativeApplyError interpolating the RELATIVE dir, not the absolute one, when the declarative dir doesn't exist",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import * as HttpClientResponse from "effect/unstable/http/HttpClientResponse";
import {
mockLegacyCliConfig,
mockLegacyShadowContainerCliSpawner,
useLegacyShadowCacheDisabled,
} from "../../../../../tests/helpers/legacy-mocks.ts";
import { mockOutput, mockRuntimeInfo } from "../../../../../tests/helpers/mocks.ts";
import { CliArgs } from "../../../../shared/cli/cli-args.service.ts";
Expand Down Expand Up @@ -178,6 +179,11 @@ function setup(
const failError = (exit: Exit.Exit<unknown, unknown>) =>
Exit.isFailure(exit) ? exit.cause.reasons.find(Cause.isFailReason)?.error : undefined;

// The baseline PGDATA cache is ON by default and roots its tar directory at the ambient
// `SUPABASE_HOME` — which this suite does not pin — so a cold provision here would read from, and
// publish into, the developer's real `~/.supabase`. This suite's subject is not the cache.
useLegacyShadowCacheDisabled();

describe("legacyDeclarativeSeamLayer.exportCatalog", () => {
it.effect(
"provisions a shadow on a baseline cache miss, then reuses the cached catalog with no further container work",
Expand Down
Loading