Skip to main content

Module renames

Module renames 

Source
Expand description

Rename-or-create prompts for drizzle generate and drizzle push, ported from drizzle-kit’s resolver (cli/prompts.ts).

When the diff drops one entity and creates another of the same kind in the same scope, it cannot tell a rename from a drop plus a create. The CLI never guesses:

  • With a terminal on stdin, it asks, one question per created entity that has deleted candidates, in drizzle-kit’s order (schemas, enums, tables, columns, indexes, views). The first choice creates; each other choice renames from one candidate. A rename consumes its candidate.
  • Without one, it answers from --hints / --hints-file (drizzle-kit’s JSON hint format). An unhinted index, constraint or view is dropped and created, which loses nothing. Unhinted schemas, enums, tables and columns are listed and the command exits with code 2 without changing anything.

Hints are consulted in interactive runs too, so a hinted question is not asked. push --force only skips the data-loss confirmation, not these questions, as in drizzle-kit.

Structs§

Choice
One choice of the prompt; its Display is the rendered line.
HintArgs
--hints / --hints-file, shared by generate and push.
Resolution
Result of resolve_renames.
TerminalPrompt
The terminal prompt: drizzle-kit’s ResolveSelect, drawn with inquire::Select.

Enums§

Hint
One parsed hint (drizzle-kit’s Hint).
Mode
How unanswered questions are handled.

Traits§

RenamePrompt
Asks one rename-or-create question.

Functions§

entity_id
drizzle-kit’s identifier tuple for name in question’s scope: [name] for schemas, [schema, name] for enums, tables, and views, [schema, table, name] for columns, indexes, and constraints. SQLite and MySQL use the placeholder schema public, as drizzle-kit does.
missing_hints_report
drizzle-kit’s missing-hints report (missing-hints-report.ts), plus the deleted candidates of each question.
parse_hints
Parses a JSON hints array.
prompt_choices
The prompt’s choices, as drizzle-kit renders them: first + <name> create <kind>, then ~ <old> › <new> rename <kind> for each candidate, padded to a common width.
prompt_message
The question line: Is <key> <kind> created or renamed from another <kind>?
resolve_for_command
Resolves renames for a command: interactive when stdin is a terminal, hints mode otherwise.
resolve_renames
Decides every rename-or-create question between prev and current from hints, then from mode, the way drizzle-kit’s resolver does.