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
Displayis the rendered line. - Hint
Args --hints/--hints-file, shared bygenerateandpush.- Resolution
- Result of
resolve_renames. - Terminal
Prompt - The terminal prompt: drizzle-kit’s
ResolveSelect, drawn withinquire::Select.
Enums§
Traits§
- Rename
Prompt - Asks one rename-or-create question.
Functions§
- entity_
id - drizzle-kit’s identifier tuple for
nameinquestion’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 schemapublic, 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
prevandcurrentfromhints, then frommode, the way drizzle-kit’s resolver does.