Skip to main content

MigrationsCommand

Enum MigrationsCommand 

Source
pub enum MigrationsCommand {
    Compose {
        name: String,
        allow_destructive: bool,
        force_overwrite: bool,
        workspace: Option<PathBuf>,
    },
    Status {
        workspace: Option<PathBuf>,
    },
    Verify {
        workspace: Option<PathBuf>,
        strict: bool,
    },
    Attune {
        target: Option<String>,
        apply: bool,
        record: bool,
        record_ledger: bool,
        record_reason: String,
        squash: bool,
        from: Option<String>,
        publish: bool,
        app: Option<String>,
        workspace: Option<PathBuf>,
    },
    Apply {
        workspace: Option<PathBuf>,
        fake: bool,
        reason: Option<String>,
    },
    Repair {
        command: RepairSubcommand,
    },
    Baseline {
        version: String,
        description: String,
        reason: String,
        app: Option<String>,
        database: Option<String>,
        workspace: Option<PathBuf>,
    },
}

Variants§

§

Compose

Compose a new migration from descriptor inventory + last snapshot.

Fields

§name: String

Operator-facing migration name. Sanitised down to a strict identifier; defaults to migration when empty.

§allow_destructive: bool

Allow destructive (drop) operations or tombstoned-app migrations. Without this flag the compose path refuses destructive deltas with a structural error.

§force_overwrite: bool

Discard hand-edits to existing migration files. Without this flag compose refuses to overwrite any up or down migration file whose current bytes do NOT match what the deterministic emitter would freshly produce — the byte-equality check stands in for a checksum compare because the emitter is deterministic (same inputs always produce the same bytes). The check is purely byte-level; it does not read the pending JSON’s checksum_up field.

§workspace: Option<PathBuf>

Workspace root override. Defaults to the current working directory.

§

Status

Print the current state of the migration ledger, grouped by app. Read-only — does not acquire the workspace lock.

Requires PostgreSQL 18 or later.

Fields

§workspace: Option<PathBuf>

Workspace root override (only used when reading Djogi.toml).

§

Verify

Compare live database catalog against the schema snapshot. Read-only — does not acquire the workspace lock or execute DDL.

Exits 0 if no error-level diagnostics are found. Exits 1 on runtime errors (config / pool / SQL). Exits 2 if the Postgres server is below version 18.

Use --strict to upgrade out-of-order migration warnings (D622) to errors, causing verify to exit non-zero when the ledger contains out-of-order applied rows.

Fields

§workspace: Option<PathBuf>

Workspace root override (only used when reading Djogi.toml).

§strict: bool

Upgrade D622 out-of-order diagnostics from Warning to Error.

§

Attune

Reconcile local migration history with the ledger. Default mode is a read-only diff between the on-disk SQL files and the ledger. Attune is read-only by default — pass --apply to commit ledger inserts / squash / parent-pointer writes. --record updates the parent repo’s recorded submodule pointer to the resolved Git target after successful attunement. --squash --from <ver> collapses local history into a single migration (localhost + dev_mode + dev profile + DJOGI_ENV gates).

Requires PostgreSQL 18 or later — exits with code 2 if the server is below the minimum.

Exit codes: 0 on success, 1 on runtime error (config / network / SQL / git), 2 on refusal (gate failure, arg validation, below PG 18).

Fields

§target: Option<String>

Optional Git target to attune the local migration history to — a local or remote commit / tag / branch. When omitted, attune reconciles against the current on-disk state. Resolution: tries local first, then git fetch --all + retries on failure.

§apply: bool

Mutate the database / parent index. Without --apply, attune is a dry-run — it scans, prints the diff, and exits without inserting / deleting ledger rows or updating the parent submodule pointer (per docs/spec/configuration.md §14: “does not mutate the database unless --apply is explicitly passed”).

§record: bool

In Record mode (--record-ledger), insert ledger rows for SQL files present on disk but absent from the ledger. With a resolved <target> argument AND --apply, also update the parent repo’s recorded submodule pointer to the target SHA.

§record_ledger: bool

Activate Record mode — insert ledger rows for SQL files present on disk but absent from the ledger. Distinct from --record (which controls the parent submodule pointer). Records the operator-supplied reason in partial_apply_note. Does NOT execute SQL.

§record_reason: String

When --record-ledger is set, the rationale recorded on every inserted ledger row’s partial_apply_note.

§squash: bool

Coalesce every committed migration from --from to HEAD into a single squashed migration. HISTORY REWRITE — gated on localhost + dev profile + dev_mode + DJOGI_ENV.

§from: Option<String>

Inclusive starting version for --squash (e.g. V20260101000000__init).

§publish: bool

After a successful squash, push the rewritten migrations/ submodule to its remote. Without this flag the rewrite stays local. Squash NEVER auto-publishes.

§app: Option<String>

Optional explicit app label to scope --squash to a single bucket. Required when --from matches a version in multiple buckets; auto-detected when the version is unique to one bucket.

§workspace: Option<PathBuf>

Workspace root override.

§

Apply

Apply all pending migrations in ledger order. This is the canonical spelling; djogi migrate apply is a compatibility alias.

Transaction semantics are per-segment: transactional segments roll back on error; non-transactional segments autocommit and may leave partial progress.

On crash or unexpected termination, re-run djogi migrations apply. For partial non-transactional progress, use djogi migrations repair resume-partial.

Existing-database adoption: use --fake to mark pending migrations as applied without executing their SQL. This is for databases whose schema already exists (from a prior tool, manual DDL, or restored backup). Use djogi migrations verify or manual inspection to confirm the schema matches the target state before faking. The --fake flag respects the same out-of-order policy as real apply; if CI/prod policy is Reject, fake-apply on an out-of-order version is also rejected.

For previewing pending work without executing it, use djogi migrations status.

If the command is interrupted after recording a ledger row with a terminal status (applied, faked, baseline), re-running reports VersionAlreadyApplied (exit 2). For non-terminal statuses (failed, rolled_back), the stale row is removed and re-apply proceeds automatically. If the snapshot is missing or stale, reconcile it with djogi migrations attune or repair snapshot-rebuild.

Fields

§workspace: Option<PathBuf>

Workspace root override. Defaults to the current working directory.

§fake: bool

Record pending migrations as applied without executing their SQL. For existing-database adoption only. Requires --reason. Subject to the same out-of-order policy as real apply; if CI/prod policy is Reject, fake-apply on an out-of-order version is also rejected.

§reason: Option<String>

Reason for faking these migrations. Required when --fake is set. Persisted to the ledger’s audit trail so future inspections can understand why this version was recorded without SQL execution. Has no effect on normal (non-fake) apply.

§

Repair

Operator-confirmed repair flows for ledger drift, partial applies, and missing snapshots. Every subcommand requires explicit confirmation — invoking the CLI subcommand IS the operator acknowledgment.

Fields

§command: RepairSubcommand

The specific repair operation to perform.

§

Baseline

Project the live database schema into a baseline ledger row and snapshot. Use for existing databases being adopted under Djogi’s migration ledger, where the schema already exists and compose + apply cannot run on a populated database without a starting point.

Projects the live catalog into a single baseline ledger row (no SQL runs against user tables) and writes the projected snapshot so future migrations diff against the real DB state. Invoking the subcommand IS the operator acknowledgment.

Requires PostgreSQL 18 or later — exits with code 2 if the server is below the minimum.

Exit codes: 0 on success, 1 on runtime error (config / network / SQL / projection failure), 2 on refusal (empty --reason, duplicate version, unresolvable database URL, snapshot-persist failure after ledger insert, session-pinning correctness failure, or below PG 18).

Fields

§version: String

Version label for the baseline ledger row (e.g. V00000000000000__baseline). Must be unique in the ledger.

§description: String

One-line description stored in the ledger row.

§reason: String

Required non-empty reason recorded in the baseline note (audit trail entry).

§app: Option<String>

App label for the migration bucket. Defaults to the global bucket (empty string) when not specified.

§database: Option<String>

Database name. Defaults to main if not specified.

§workspace: Option<PathBuf>

Workspace root override.

Trait Implementations§

Source§

impl FromArgMatches for MigrationsCommand

Source§

fn from_arg_matches(__clap_arg_matches: &ArgMatches) -> Result<Self, Error>

Instantiate Self from ArgMatches, parsing the arguments as needed. Read more
Source§

fn from_arg_matches_mut( __clap_arg_matches: &mut ArgMatches, ) -> Result<Self, Error>

Instantiate Self from ArgMatches, parsing the arguments as needed. Read more
Source§

fn update_from_arg_matches( &mut self, __clap_arg_matches: &ArgMatches, ) -> Result<(), Error>

Assign values from ArgMatches to self.
Source§

fn update_from_arg_matches_mut<'b>( &mut self, __clap_arg_matches: &mut ArgMatches, ) -> Result<(), Error>

Assign values from ArgMatches to self.
Source§

impl Subcommand for MigrationsCommand

Source§

fn augment_subcommands<'b>(__clap_app: Command) -> Command

Append to Command so it can instantiate Self via FromArgMatches::from_arg_matches_mut Read more
Source§

fn augment_subcommands_for_update<'b>(__clap_app: Command) -> Command

Append to Command so it can instantiate self via FromArgMatches::update_from_arg_matches_mut Read more
Source§

fn has_subcommand(__clap_name: &str) -> bool

Test whether Self can parse a specific subcommand

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<V> IntoPortableFieldValue<Option<V>> for V

Source§

fn into_portable_field_value(self) -> Option<V>

Convert self into the field’s declared portable value type. Read more
Source§

impl<V> IntoPortableFieldValue<Tracked<V>> for V

Source§

fn into_portable_field_value(self) -> Tracked<V>

Convert self into the field’s declared portable value type. Read more
Source§

impl<V> IntoPortableFieldValue<V> for V

Source§

fn into_portable_field_value(self) -> V

Convert self into the field’s declared portable value type. Read more
Source§

impl<T> Paint for T
where T: ?Sized,

Source§

fn fg(&self, value: Color) -> Painted<&T>

Returns a styled value derived from self with the foreground set to value.

This method should be used rarely. Instead, prefer to use color-specific builder methods like red() and green(), which have the same functionality but are pithier.

§Example

Set foreground color to white using fg():

use yansi::{Paint, Color};

painted.fg(Color::White);

Set foreground color to white using white().

use yansi::Paint;

painted.white();
Source§

fn primary(&self) -> Painted<&T>

Returns self with the fg() set to [Color :: Primary].

§Example
println!("{}", value.primary());
Source§

fn fixed(&self, color: u8) -> Painted<&T>

Returns self with the fg() set to [Color :: Fixed].

§Example
println!("{}", value.fixed(color));
Source§

fn rgb(&self, r: u8, g: u8, b: u8) -> Painted<&T>

Returns self with the fg() set to [Color :: Rgb].

§Example
println!("{}", value.rgb(r, g, b));
Source§

fn black(&self) -> Painted<&T>

Returns self with the fg() set to [Color :: Black].

§Example
println!("{}", value.black());
Source§

fn red(&self) -> Painted<&T>

Returns self with the fg() set to [Color :: Red].

§Example
println!("{}", value.red());
Source§

fn green(&self) -> Painted<&T>

Returns self with the fg() set to [Color :: Green].

§Example
println!("{}", value.green());
Source§

fn yellow(&self) -> Painted<&T>

Returns self with the fg() set to [Color :: Yellow].

§Example
println!("{}", value.yellow());
Source§

fn blue(&self) -> Painted<&T>

Returns self with the fg() set to [Color :: Blue].

§Example
println!("{}", value.blue());
Source§

fn magenta(&self) -> Painted<&T>

Returns self with the fg() set to [Color :: Magenta].

§Example
println!("{}", value.magenta());
Source§

fn cyan(&self) -> Painted<&T>

Returns self with the fg() set to [Color :: Cyan].

§Example
println!("{}", value.cyan());
Source§

fn white(&self) -> Painted<&T>

Returns self with the fg() set to [Color :: White].

§Example
println!("{}", value.white());
Source§

fn bright_black(&self) -> Painted<&T>

Returns self with the fg() set to [Color :: BrightBlack].

§Example
println!("{}", value.bright_black());
Source§

fn bright_red(&self) -> Painted<&T>

Returns self with the fg() set to [Color :: BrightRed].

§Example
println!("{}", value.bright_red());
Source§

fn bright_green(&self) -> Painted<&T>

Returns self with the fg() set to [Color :: BrightGreen].

§Example
println!("{}", value.bright_green());
Source§

fn bright_yellow(&self) -> Painted<&T>

Returns self with the fg() set to [Color :: BrightYellow].

§Example
println!("{}", value.bright_yellow());
Source§

fn bright_blue(&self) -> Painted<&T>

Returns self with the fg() set to [Color :: BrightBlue].

§Example
println!("{}", value.bright_blue());
Source§

fn bright_magenta(&self) -> Painted<&T>

Returns self with the fg() set to [Color :: BrightMagenta].

§Example
println!("{}", value.bright_magenta());
Source§

fn bright_cyan(&self) -> Painted<&T>

Returns self with the fg() set to [Color :: BrightCyan].

§Example
println!("{}", value.bright_cyan());
Source§

fn bright_white(&self) -> Painted<&T>

Returns self with the fg() set to [Color :: BrightWhite].

§Example
println!("{}", value.bright_white());
Source§

fn bg(&self, value: Color) -> Painted<&T>

Returns a styled value derived from self with the background set to value.

This method should be used rarely. Instead, prefer to use color-specific builder methods like on_red() and on_green(), which have the same functionality but are pithier.

§Example

Set background color to red using fg():

use yansi::{Paint, Color};

painted.bg(Color::Red);

Set background color to red using on_red().

use yansi::Paint;

painted.on_red();
Source§

fn on_primary(&self) -> Painted<&T>

Returns self with the bg() set to [Color :: Primary].

§Example
println!("{}", value.on_primary());
Source§

fn on_fixed(&self, color: u8) -> Painted<&T>

Returns self with the bg() set to [Color :: Fixed].

§Example
println!("{}", value.on_fixed(color));
Source§

fn on_rgb(&self, r: u8, g: u8, b: u8) -> Painted<&T>

Returns self with the bg() set to [Color :: Rgb].

§Example
println!("{}", value.on_rgb(r, g, b));
Source§

fn on_black(&self) -> Painted<&T>

Returns self with the bg() set to [Color :: Black].

§Example
println!("{}", value.on_black());
Source§

fn on_red(&self) -> Painted<&T>

Returns self with the bg() set to [Color :: Red].

§Example
println!("{}", value.on_red());
Source§

fn on_green(&self) -> Painted<&T>

Returns self with the bg() set to [Color :: Green].

§Example
println!("{}", value.on_green());
Source§

fn on_yellow(&self) -> Painted<&T>

Returns self with the bg() set to [Color :: Yellow].

§Example
println!("{}", value.on_yellow());
Source§

fn on_blue(&self) -> Painted<&T>

Returns self with the bg() set to [Color :: Blue].

§Example
println!("{}", value.on_blue());
Source§

fn on_magenta(&self) -> Painted<&T>

Returns self with the bg() set to [Color :: Magenta].

§Example
println!("{}", value.on_magenta());
Source§

fn on_cyan(&self) -> Painted<&T>

Returns self with the bg() set to [Color :: Cyan].

§Example
println!("{}", value.on_cyan());
Source§

fn on_white(&self) -> Painted<&T>

Returns self with the bg() set to [Color :: White].

§Example
println!("{}", value.on_white());
Source§

fn on_bright_black(&self) -> Painted<&T>

Returns self with the bg() set to [Color :: BrightBlack].

§Example
println!("{}", value.on_bright_black());
Source§

fn on_bright_red(&self) -> Painted<&T>

Returns self with the bg() set to [Color :: BrightRed].

§Example
println!("{}", value.on_bright_red());
Source§

fn on_bright_green(&self) -> Painted<&T>

Returns self with the bg() set to [Color :: BrightGreen].

§Example
println!("{}", value.on_bright_green());
Source§

fn on_bright_yellow(&self) -> Painted<&T>

Returns self with the bg() set to [Color :: BrightYellow].

§Example
println!("{}", value.on_bright_yellow());
Source§

fn on_bright_blue(&self) -> Painted<&T>

Returns self with the bg() set to [Color :: BrightBlue].

§Example
println!("{}", value.on_bright_blue());
Source§

fn on_bright_magenta(&self) -> Painted<&T>

Returns self with the bg() set to [Color :: BrightMagenta].

§Example
println!("{}", value.on_bright_magenta());
Source§

fn on_bright_cyan(&self) -> Painted<&T>

Returns self with the bg() set to [Color :: BrightCyan].

§Example
println!("{}", value.on_bright_cyan());
Source§

fn on_bright_white(&self) -> Painted<&T>

Returns self with the bg() set to [Color :: BrightWhite].

§Example
println!("{}", value.on_bright_white());
Source§

fn attr(&self, value: Attribute) -> Painted<&T>

Enables the styling Attribute value.

This method should be used rarely. Instead, prefer to use attribute-specific builder methods like bold() and underline(), which have the same functionality but are pithier.

§Example

Make text bold using attr():

use yansi::{Paint, Attribute};

painted.attr(Attribute::Bold);

Make text bold using using bold().

use yansi::Paint;

painted.bold();
Source§

fn bold(&self) -> Painted<&T>

Returns self with the attr() set to [Attribute :: Bold].

§Example
println!("{}", value.bold());
Source§

fn dim(&self) -> Painted<&T>

Returns self with the attr() set to [Attribute :: Dim].

§Example
println!("{}", value.dim());
Source§

fn italic(&self) -> Painted<&T>

Returns self with the attr() set to [Attribute :: Italic].

§Example
println!("{}", value.italic());
Source§

fn underline(&self) -> Painted<&T>

Returns self with the attr() set to [Attribute :: Underline].

§Example
println!("{}", value.underline());

Returns self with the attr() set to [Attribute :: Blink].

§Example
println!("{}", value.blink());

Returns self with the attr() set to [Attribute :: RapidBlink].

§Example
println!("{}", value.rapid_blink());
Source§

fn invert(&self) -> Painted<&T>

Returns self with the attr() set to [Attribute :: Invert].

§Example
println!("{}", value.invert());
Source§

fn conceal(&self) -> Painted<&T>

Returns self with the attr() set to [Attribute :: Conceal].

§Example
println!("{}", value.conceal());
Source§

fn strike(&self) -> Painted<&T>

Returns self with the attr() set to [Attribute :: Strike].

§Example
println!("{}", value.strike());
Source§

fn quirk(&self, value: Quirk) -> Painted<&T>

Enables the yansi Quirk value.

This method should be used rarely. Instead, prefer to use quirk-specific builder methods like mask() and wrap(), which have the same functionality but are pithier.

§Example

Enable wrapping using .quirk():

use yansi::{Paint, Quirk};

painted.quirk(Quirk::Wrap);

Enable wrapping using wrap().

use yansi::Paint;

painted.wrap();
Source§

fn mask(&self) -> Painted<&T>

Returns self with the quirk() set to [Quirk :: Mask].

§Example
println!("{}", value.mask());
Source§

fn wrap(&self) -> Painted<&T>

Returns self with the quirk() set to [Quirk :: Wrap].

§Example
println!("{}", value.wrap());
Source§

fn linger(&self) -> Painted<&T>

Returns self with the quirk() set to [Quirk :: Linger].

§Example
println!("{}", value.linger());
Source§

fn clear(&self) -> Painted<&T>

👎Deprecated since 1.0.1:

renamed to resetting() due to conflicts with Vec::clear(). The clear() method will be removed in a future release.

Returns self with the quirk() set to [Quirk :: Clear].

§Example
println!("{}", value.clear());
Source§

fn resetting(&self) -> Painted<&T>

Returns self with the quirk() set to [Quirk :: Resetting].

§Example
println!("{}", value.resetting());
Source§

fn bright(&self) -> Painted<&T>

Returns self with the quirk() set to [Quirk :: Bright].

§Example
println!("{}", value.bright());
Source§

fn on_bright(&self) -> Painted<&T>

Returns self with the quirk() set to [Quirk :: OnBright].

§Example
println!("{}", value.on_bright());
Source§

fn whenever(&self, value: Condition) -> Painted<&T>

Conditionally enable styling based on whether the Condition value applies. Replaces any previous condition.

See the crate level docs for more details.

§Example

Enable styling painted only when both stdout and stderr are TTYs:

use yansi::{Paint, Condition};

painted.red().on_yellow().whenever(Condition::STDOUTERR_ARE_TTY);
Source§

fn new(self) -> Painted<Self>
where Self: Sized,

Create a new Painted with a default Style. Read more
Source§

fn paint<S>(&self, style: S) -> Painted<&Self>
where S: Into<Style>,

Apply a style wholesale to self. Any previous style is replaced. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more