forked from supabase/cli
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrepair.command.ts
More file actions
67 lines (64 loc) · 2.47 KB
/
Copy pathrepair.command.ts
File metadata and controls
67 lines (64 loc) · 2.47 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
import { Argument, Command, Flag } from "effect/unstable/cli";
import { withJsonErrorHandling } from "../../../../shared/output/json-error-handling.ts";
import { withLegacyCommandInstrumentation } from "../../../telemetry/legacy-command-instrumentation.ts";
import { legacyMigrationDbRuntimeLayer } from "../migration.layers.ts";
import { legacyMigrationRepair } from "./repair.handler.ts";
const config = {
versions: Argument.string("version").pipe(
Argument.withDescription("Migration version(s) to repair."),
Argument.variadic(),
),
status: Flag.choice("status", ["applied", "reverted"] as const).pipe(
Flag.withDescription("Version status to update."),
),
dbUrl: Flag.string("db-url").pipe(
Flag.withDescription(
"Repairs migrations of the database specified by the connection string (must be percent-encoded).",
),
Flag.optional,
),
linked: Flag.boolean("linked").pipe(
Flag.withDescription("Repairs the migration history of the linked project."),
// Go: `repairFlags.Bool("linked", true, …)`.
Flag.withDefault(true),
),
local: Flag.boolean("local").pipe(
Flag.withDescription("Repairs the migration history of the local database."),
),
password: Flag.string("password").pipe(
Flag.withAlias("p"),
Flag.withDescription("Password to your remote Postgres database."),
Flag.optional,
),
} as const;
export const legacyMigrationRepairCommand = Command.make("repair", config).pipe(
Command.withDescription("Repair the migration history table."),
Command.withShortDescription("Repair the migration history table"),
Command.withHandler((flags) =>
legacyMigrationRepair({
versions: flags.versions.map(String),
status: flags.status,
dbUrl: flags.dbUrl,
linked: flags.linked,
local: flags.local,
password: flags.password,
}).pipe(
withLegacyCommandInstrumentation({
flags: {
status: flags.status,
"db-url": flags.dbUrl,
linked: flags.linked,
local: flags.local,
// `password` is a credential — always reaches telemetry as `<redacted>`.
password: flags.password,
},
// --status is Flag.choice and is auto-detected as safe via `config`
// below (Go's isEnumFlag, cmd/root_analytics.go:110-116); password stays redacted.
config,
aliases: { p: "password" },
}),
withJsonErrorHandling,
),
),
Command.provide(legacyMigrationDbRuntimeLayer(["migration", "repair"])),
);