docs(website): update seed (year + choice-sets) and readline keys for the merge
Seed page reflects #33/#34: year-as-int columns, built-in value sets (priority/severity/rating), advisory now status-only; output blocks re-captured and the seed cast re-recorded. Assistive-editor documents the #29 readline shortcuts (Ctrl-A/E/W/K/U, Esc) and #30 cross-mode history recall; multi-line stays the only planned item.
This commit is contained in:
@@ -71,24 +71,26 @@ get an address. Matching is case-insensitive and looks at the name's parts
|
||||
| `price`, `amount`, `cost`, `salary` | a money amount | `int`, `real`, `decimal` |
|
||||
| `age` · `quantity`, `qty`, `stock` | a plausible age / small number | `int` |
|
||||
| `date`, `dob`, `created_at`, `updated_at` | a recent (or birth-window) date | `date`, `datetime` |
|
||||
| `year`, `*_year`, `published`, `founded`, `birth_year` | a plausible year (a birth window for `birth_year`) | `int` |
|
||||
| `priority`, `severity`, `rating`, `stars` | a value from a built-in set (low/medium/high, 1–5, …) | `text`, `int` |
|
||||
| `is_active`, `has_*`, `enabled` | `true` / `false` | `bool` |
|
||||
|
||||
When a column's name **isn't** recognised, seed falls back to its **type**:
|
||||
placeholder words for `text`, a number for `int` and `real`, a recent value
|
||||
for `date`. So a column like `published` (just an `int` to the database) gets
|
||||
an arbitrary number, not a sensible year. That is exactly what the
|
||||
[`set` clause](#choosing-values-yourself) is for — pin those columns
|
||||
explicitly.
|
||||
for `date`. A column like `isbn` or `title` — text with no specific meaning
|
||||
seed can infer — gets placeholder words; pin it with the
|
||||
[`set` clause](#choosing-values-yourself) if you want something specific.
|
||||
|
||||
Two name families are handled specially:
|
||||
|
||||
- **Identifier-like names** that are *not* a foreign key or the primary key —
|
||||
`code`, `sku`, `ref`, `barcode`, a `*_id` that isn't a relationship — get
|
||||
**unique** values, so they read like real identifiers and never collide.
|
||||
- **Choice-like names** — `status`, `role`, `type`, `category`, `priority`,
|
||||
and similar — have no sensible generic value, so seed fills them with
|
||||
placeholder text and then [tells you](#columns-seed-cant-guess) to choose
|
||||
the real values yourself.
|
||||
- **Open-ended choice names** — `status`, `role`, `type`, `category`, and the
|
||||
like — have no single sensible default, so seed fills them with placeholder
|
||||
text and then [tells you](#columns-seed-cant-guess) to choose the real
|
||||
values yourself. (Common choices that *do* have a conventional set —
|
||||
`priority`, `severity`, `rating` — are filled from it, per the table above.)
|
||||
|
||||
Any column with a `unique` [constraint](/reference/constraints/) always gets
|
||||
collision-free values, whatever its name — that is a correctness guarantee,
|
||||
@@ -102,27 +104,28 @@ table, so every generated reference is valid. Seed the parent first:
|
||||
|
||||
```rdbms
|
||||
seed authors 5
|
||||
seed books 6 set published between 1950 and 2020
|
||||
seed books 6
|
||||
```
|
||||
|
||||
```
|
||||
6 row(s) seeded into books
|
||||
┌─────────┬────────────────────┬───────────┬───────────┬─────────────────────────────┐
|
||||
│ book_id │ title │ author_id │ published │ isbn │
|
||||
├─────────┼────────────────────┼───────────┼───────────┼─────────────────────────────┤
|
||||
│ 1 │ Austen Wuckert │ 4 │ 1960 │ nihil molestiae │
|
||||
│ 2 │ Dayne Cremin │ 4 │ 1978 │ repellat rerum │
|
||||
│ 3 │ Jayda Hagenes │ 1 │ 1987 │ corrupti perspiciatis earum │
|
||||
│ 4 │ Bethany VonRueden │ 5 │ 1961 │ laborum deserunt facere │
|
||||
│ 5 │ Maximillian Hammes │ 2 │ 2018 │ fuga in │
|
||||
│ 6 │ Skylar Cassin │ 2 │ 2020 │ alias qui │
|
||||
└─────────┴────────────────────┴───────────┴───────────┴─────────────────────────────┘
|
||||
┌─────────┬──────────────────┬───────────┬───────────┬─────────────────────────┐
|
||||
│ book_id │ title │ author_id │ published │ isbn │
|
||||
├─────────┼──────────────────┼───────────┼───────────┼─────────────────────────┤
|
||||
│ 1 │ Austen Wuckert │ 4 │ 1976 │ sit nihil │
|
||||
│ 2 │ Leanne Fisher │ 3 │ 1961 │ in ex │
|
||||
│ 3 │ Ludwig Bahringer │ 5 │ 1986 │ sapiente provident │
|
||||
│ 4 │ Jeff Little │ 3 │ 2021 │ fugit sint eum │
|
||||
│ 5 │ Kameron Moore │ 1 │ 1995 │ incidunt cumque quia │
|
||||
│ 6 │ Walker Hammes │ 5 │ 1997 │ enim saepe consequuntur │
|
||||
└─────────┴──────────────────┴───────────┴───────────┴─────────────────────────┘
|
||||
```
|
||||
|
||||
Every `author_id` points at a real author (1–5). Duplicates are expected and
|
||||
correct — one author has many books. (`title` and `isbn` here are placeholder
|
||||
text, since neither name maps to a real-world generator; pin them with
|
||||
[`set`](#choosing-values-yourself) if you want something specific.)
|
||||
correct — one author has many books. `published` got a plausible year on its
|
||||
own (seed recognises year-like columns); `title` and `isbn` are placeholder
|
||||
text, since neither name maps to a real-world generator — pin them with
|
||||
[`set`](#choosing-values-yourself) if you want something specific.
|
||||
|
||||
If a parent table is **empty**, seed refuses rather than inventing a reference
|
||||
that would break the relationship:
|
||||
@@ -180,10 +183,11 @@ nothing new to learn — four forms:
|
||||
| Named generator | `set contact as email` | force a specific generator |
|
||||
| Range | `set price between 10 and 100` | a value in the range (also dates) |
|
||||
|
||||
Combine them with commas:
|
||||
`status` has no built-in set — its real values are domain-specific — so it is
|
||||
the natural column to pin:
|
||||
|
||||
```rdbms
|
||||
seed tickets 6 set status in ('open', 'pending', 'closed'), priority in ('low', 'high')
|
||||
seed tickets 6 set status in ('open', 'pending', 'closed')
|
||||
```
|
||||
|
||||
```
|
||||
@@ -193,13 +197,17 @@ seed tickets 6 set status in ('open', 'pending', 'closed'), priority in ('low',
|
||||
├───────────┼──────────────────────────┼─────────┼──────────┤
|
||||
│ 7 │ atque libero │ pending │ high │
|
||||
│ 8 │ culpa maiores et │ open │ low │
|
||||
│ 9 │ natus rerum animi │ open │ high │
|
||||
│ 9 │ natus rerum animi │ open │ medium │
|
||||
│ 10 │ sapiente rem │ closed │ low │
|
||||
│ 11 │ placeat blanditiis quasi │ closed │ high │
|
||||
│ 12 │ sed exercitationem │ closed │ low │
|
||||
└───────────┴──────────────────────────┴─────────┴──────────┘
|
||||
```
|
||||
|
||||
`status` takes your values; `priority` filled itself from its built-in set
|
||||
(low/medium/high). Comma-separate several `set` clauses to pin more than one
|
||||
column at once.
|
||||
|
||||
Text values and list items are **quoted** (`'admin'`), exactly as elsewhere;
|
||||
only numbers are bare. Dates in a range are quoted too
|
||||
(`set joined between '2023-01-01' and '2024-12-31'`). A range on a number
|
||||
@@ -234,16 +242,22 @@ seed tickets.status set status in ('open', 'closed')
|
||||
|
||||
```
|
||||
12 row(s) seeded into tickets
|
||||
┌───────────┬───────────────────────────┬────────┬──────────────────────────────────┐
|
||||
│ ticket_id │ subject │ status │ priority │
|
||||
├───────────┼───────────────────────────┼────────┼──────────────────────────────────┤
|
||||
│ 1 │ ad natus │ closed │ sed iusto │
|
||||
│ 2 │ voluptas iure aut │ closed │ eveniet consequatur consequuntur │
|
||||
│ 3 │ rerum nulla reprehenderit │ closed │ est quibusdam et │
|
||||
│ 4 │ cumque autem voluptas │ open │ facere maxime │
|
||||
│ 5 │ sit harum │ open │ eveniet commodi reprehenderit │
|
||||
│ 6 │ rerum deserunt │ closed │ mollitia ut repellendus │
|
||||
└───────────┴───────────────────────────┴────────┴──────────────────────────────────┘
|
||||
┌───────────┬──────────────────────────┬────────┬──────────┐
|
||||
│ ticket_id │ subject │ status │ priority │
|
||||
├───────────┼──────────────────────────┼────────┼──────────┤
|
||||
│ 1 │ ad natus │ closed │ low │
|
||||
│ 2 │ iusto officia │ closed │ high │
|
||||
│ 3 │ possimus error │ closed │ high │
|
||||
│ 4 │ reprehenderit et earum │ open │ low │
|
||||
│ 5 │ cumque autem voluptas │ open │ low │
|
||||
│ 6 │ maxime sed sit │ closed │ medium │
|
||||
│ 7 │ atque libero │ open │ high │
|
||||
│ 8 │ culpa maiores et │ closed │ low │
|
||||
│ 9 │ natus rerum animi │ closed │ medium │
|
||||
│ 10 │ sapiente rem │ closed │ low │
|
||||
│ 11 │ placeat blanditiis quasi │ closed │ high │
|
||||
│ 12 │ sed exercitationem │ open │ low │
|
||||
└───────────┴──────────────────────────┴────────┴──────────┘
|
||||
```
|
||||
|
||||
Only `status` changed; the other columns are untouched. Column-fill **refuses**
|
||||
@@ -252,9 +266,9 @@ primary-key and autogenerated (`serial` / `shortid`) columns — you do not
|
||||
|
||||
## Columns seed can't guess
|
||||
|
||||
Choice-like columns — `status`, `role`, `type`, and the like — get placeholder
|
||||
text, because there is no sensible generic value for them. After a seed, the
|
||||
playground points this out:
|
||||
Open-ended choice columns — `status`, `role`, `type`, and the like — get
|
||||
placeholder text, because there is no single sensible value for them. After a
|
||||
seed, the playground points this out:
|
||||
|
||||
```rdbms
|
||||
seed tickets 6
|
||||
@@ -262,23 +276,25 @@ seed tickets 6
|
||||
|
||||
```
|
||||
6 row(s) seeded into tickets
|
||||
┌───────────┬───────────────────────────┬──────────────────────────────┬──────────────────────────────────┐
|
||||
│ ticket_id │ subject │ status │ priority │
|
||||
├───────────┼───────────────────────────┼──────────────────────────────┼──────────────────────────────────┤
|
||||
│ 1 │ ad natus │ temporibus eos rerum │ sed iusto │
|
||||
│ 2 │ voluptas iure aut │ repudiandae commodi possimus │ eveniet consequatur consequuntur │
|
||||
│ 3 │ rerum nulla reprehenderit │ earum culpa │ est quibusdam et │
|
||||
│ 4 │ cumque autem voluptas │ ea praesentium pariatur │ facere maxime │
|
||||
│ 5 │ sit harum │ et et laboriosam │ eveniet commodi reprehenderit │
|
||||
│ 6 │ rerum deserunt │ qui voluptate │ mollitia ut repellendus │
|
||||
└───────────┴───────────────────────────┴──────────────────────────────┴──────────────────────────────────┘
|
||||
┌───────────┬────────────────────────┬────────────────────────────────────┬──────────┐
|
||||
│ ticket_id │ subject │ status │ priority │
|
||||
├───────────┼────────────────────────┼────────────────────────────────────┼──────────┤
|
||||
│ 1 │ ad natus │ temporibus eos rerum │ low │
|
||||
│ 2 │ iusto officia │ iure aut provident │ high │
|
||||
│ 3 │ possimus error │ consequatur consequuntur molestiae │ high │
|
||||
│ 4 │ reprehenderit et earum │ recusandae est quibusdam │ low │
|
||||
│ 5 │ cumque autem voluptas │ ea praesentium pariatur │ low │
|
||||
│ 6 │ maxime sed sit │ sapiente et et │ medium │
|
||||
└───────────┴────────────────────────┴────────────────────────────────────┴──────────┘
|
||||
```
|
||||
|
||||
> `status, priority` filled with generic text — they look like fixed value
|
||||
> sets. Pin them next time with `set status in ('…', '…')`, or fix these rows
|
||||
> with `seed tickets.status set status in ('…', '…')`.
|
||||
> `status` filled with generic text — they look like fixed value sets. Pin
|
||||
> them next time with `set status in ('…', '…')`, or fix these rows with
|
||||
> `seed tickets.status set status in ('…', '…')`.
|
||||
|
||||
The two fixes it suggests are the [`set` clause](#choosing-values-yourself) on
|
||||
Here `priority` was filled from its built-in set automatically, so only
|
||||
`status` is flagged. The two fixes it suggests are the
|
||||
[`set` clause](#choosing-values-yourself) on
|
||||
the next seed, and [column-fill](#filling-one-column) to repair the rows you
|
||||
just made. If a `check` constraint restricts a column to a list of values
|
||||
(`check status in ('open', 'closed')`), seed reads that list and uses it
|
||||
|
||||
@@ -49,14 +49,24 @@ lists options and `help` lists commands.
|
||||
|
||||
Move and edit within the line with the usual keys: <kbd>←</kbd>/<kbd>→</kbd>
|
||||
by character, <kbd>Home</kbd>/<kbd>End</kbd> to the ends, and
|
||||
<kbd>Delete</kbd>/<kbd>Backspace</kbd> to remove characters. Your
|
||||
project-scoped command history is available with <kbd>↑</kbd>/<kbd>↓</kbd>.
|
||||
<kbd>Delete</kbd>/<kbd>Backspace</kbd> to remove characters. Readline-style
|
||||
shortcuts work too: <kbd>Ctrl</kbd>+<kbd>A</kbd> / <kbd>Ctrl</kbd>+<kbd>E</kbd>
|
||||
jump to the start / end of the line, <kbd>Ctrl</kbd>+<kbd>W</kbd> deletes the
|
||||
word before the cursor, <kbd>Ctrl</kbd>+<kbd>K</kbd> clears from the cursor to
|
||||
the end of the line, <kbd>Ctrl</kbd>+<kbd>U</kbd> clears from the start to the
|
||||
cursor, and <kbd>Esc</kbd> clears the whole line at once (or, right after you
|
||||
accept a completion, undoes that first).
|
||||
|
||||
Your project-scoped command history is available with <kbd>↑</kbd>/<kbd>↓</kbd>.
|
||||
If you recall an advanced-mode (SQL) command while you are in simple mode, it
|
||||
comes back with a leading `:` — the [one-line escape to advanced
|
||||
mode](/getting-started/modes/) — so it still runs exactly as you typed it.
|
||||
|
||||
A long command does not get cut off: the line scrolls sideways to keep the
|
||||
cursor in view, and on a tall terminal the input field uses two rows so you
|
||||
can see more of it at once.
|
||||
|
||||
:::note[Planned]
|
||||
Multi-line entry and extra readline-style shortcuts (Ctrl-A/E/W/K/U) are
|
||||
planned and not yet available.
|
||||
Multi-line entry — <kbd>Enter</kbd> inserting a newline, with a separate key to
|
||||
submit — is planned and not yet available.
|
||||
:::
|
||||
|
||||
Reference in New Issue
Block a user