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:
@@ -82,12 +82,10 @@ export const casts = [
|
|||||||
name: 'seed',
|
name: 'seed',
|
||||||
title: 'Fill a table with realistic, ready-to-query data in one command',
|
title: 'Fill a table with realistic, ready-to-query data in one command',
|
||||||
width: 90,
|
width: 90,
|
||||||
// Two seeds: a people table (`name` → real names, `joined` → recent dates,
|
// Two seeds: a people table (`name` → real names, `joined` → recent dates)
|
||||||
// which seed nails today) and a tickets table that mixes a free-text column
|
// and a tickets table mixing a free-text column (`subject`), an
|
||||||
// (`subject`), an auto-detected `priority` (short once #34 lands — until
|
// auto-detected `priority` (a built-in low/medium/high set, #34), and a
|
||||||
// then a fresh recording fills it with placeholder text), and a `status`
|
// `status` pinned via `set status in (...)` to show the override clause.
|
||||||
// pinned via `set status in (...)` to show the override clause. Re-record
|
|
||||||
// in the final sweep once #34 is in.
|
|
||||||
height: 28,
|
height: 28,
|
||||||
typeSpeed: '45ms',
|
typeSpeed: '45ms',
|
||||||
steps: [
|
steps: [
|
||||||
|
|||||||
+559
-556
File diff suppressed because it is too large
Load Diff
@@ -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` |
|
| `price`, `amount`, `cost`, `salary` | a money amount | `int`, `real`, `decimal` |
|
||||||
| `age` · `quantity`, `qty`, `stock` | a plausible age / small number | `int` |
|
| `age` · `quantity`, `qty`, `stock` | a plausible age / small number | `int` |
|
||||||
| `date`, `dob`, `created_at`, `updated_at` | a recent (or birth-window) date | `date`, `datetime` |
|
| `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` |
|
| `is_active`, `has_*`, `enabled` | `true` / `false` | `bool` |
|
||||||
|
|
||||||
When a column's name **isn't** recognised, seed falls back to its **type**:
|
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
|
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
|
for `date`. A column like `isbn` or `title` — text with no specific meaning
|
||||||
an arbitrary number, not a sensible year. That is exactly what the
|
seed can infer — gets placeholder words; pin it with the
|
||||||
[`set` clause](#choosing-values-yourself) is for — pin those columns
|
[`set` clause](#choosing-values-yourself) if you want something specific.
|
||||||
explicitly.
|
|
||||||
|
|
||||||
Two name families are handled specially:
|
Two name families are handled specially:
|
||||||
|
|
||||||
- **Identifier-like names** that are *not* a foreign key or the primary key —
|
- **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
|
`code`, `sku`, `ref`, `barcode`, a `*_id` that isn't a relationship — get
|
||||||
**unique** values, so they read like real identifiers and never collide.
|
**unique** values, so they read like real identifiers and never collide.
|
||||||
- **Choice-like names** — `status`, `role`, `type`, `category`, `priority`,
|
- **Open-ended choice names** — `status`, `role`, `type`, `category`, and the
|
||||||
and similar — have no sensible generic value, so seed fills them with
|
like — have no single sensible default, so seed fills them with placeholder
|
||||||
placeholder text and then [tells you](#columns-seed-cant-guess) to choose
|
text and then [tells you](#columns-seed-cant-guess) to choose the real
|
||||||
the real values yourself.
|
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
|
Any column with a `unique` [constraint](/reference/constraints/) always gets
|
||||||
collision-free values, whatever its name — that is a correctness guarantee,
|
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
|
```rdbms
|
||||||
seed authors 5
|
seed authors 5
|
||||||
seed books 6 set published between 1950 and 2020
|
seed books 6
|
||||||
```
|
```
|
||||||
|
|
||||||
```
|
```
|
||||||
6 row(s) seeded into books
|
6 row(s) seeded into books
|
||||||
┌─────────┬────────────────────┬───────────┬───────────┬─────────────────────────────┐
|
┌─────────┬──────────────────┬───────────┬───────────┬─────────────────────────┐
|
||||||
│ book_id │ title │ author_id │ published │ isbn │
|
│ book_id │ title │ author_id │ published │ isbn │
|
||||||
├─────────┼────────────────────┼───────────┼───────────┼─────────────────────────────┤
|
├─────────┼──────────────────┼───────────┼───────────┼─────────────────────────┤
|
||||||
│ 1 │ Austen Wuckert │ 4 │ 1960 │ nihil molestiae │
|
│ 1 │ Austen Wuckert │ 4 │ 1976 │ sit nihil │
|
||||||
│ 2 │ Dayne Cremin │ 4 │ 1978 │ repellat rerum │
|
│ 2 │ Leanne Fisher │ 3 │ 1961 │ in ex │
|
||||||
│ 3 │ Jayda Hagenes │ 1 │ 1987 │ corrupti perspiciatis earum │
|
│ 3 │ Ludwig Bahringer │ 5 │ 1986 │ sapiente provident │
|
||||||
│ 4 │ Bethany VonRueden │ 5 │ 1961 │ laborum deserunt facere │
|
│ 4 │ Jeff Little │ 3 │ 2021 │ fugit sint eum │
|
||||||
│ 5 │ Maximillian Hammes │ 2 │ 2018 │ fuga in │
|
│ 5 │ Kameron Moore │ 1 │ 1995 │ incidunt cumque quia │
|
||||||
│ 6 │ Skylar Cassin │ 2 │ 2020 │ alias qui │
|
│ 6 │ Walker Hammes │ 5 │ 1997 │ enim saepe consequuntur │
|
||||||
└─────────┴────────────────────┴───────────┴───────────┴─────────────────────────────┘
|
└─────────┴──────────────────┴───────────┴───────────┴─────────────────────────┘
|
||||||
```
|
```
|
||||||
|
|
||||||
Every `author_id` points at a real author (1–5). Duplicates are expected and
|
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
|
correct — one author has many books. `published` got a plausible year on its
|
||||||
text, since neither name maps to a real-world generator; pin them with
|
own (seed recognises year-like columns); `title` and `isbn` are placeholder
|
||||||
[`set`](#choosing-values-yourself) if you want something specific.)
|
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
|
If a parent table is **empty**, seed refuses rather than inventing a reference
|
||||||
that would break the relationship:
|
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 |
|
| Named generator | `set contact as email` | force a specific generator |
|
||||||
| Range | `set price between 10 and 100` | a value in the range (also dates) |
|
| 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
|
```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 │
|
│ 7 │ atque libero │ pending │ high │
|
||||||
│ 8 │ culpa maiores et │ open │ low │
|
│ 8 │ culpa maiores et │ open │ low │
|
||||||
│ 9 │ natus rerum animi │ open │ high │
|
│ 9 │ natus rerum animi │ open │ medium │
|
||||||
│ 10 │ sapiente rem │ closed │ low │
|
│ 10 │ sapiente rem │ closed │ low │
|
||||||
│ 11 │ placeat blanditiis quasi │ closed │ high │
|
│ 11 │ placeat blanditiis quasi │ closed │ high │
|
||||||
│ 12 │ sed exercitationem │ closed │ low │
|
│ 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;
|
Text values and list items are **quoted** (`'admin'`), exactly as elsewhere;
|
||||||
only numbers are bare. Dates in a range are quoted too
|
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
|
(`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
|
12 row(s) seeded into tickets
|
||||||
┌───────────┬───────────────────────────┬────────┬──────────────────────────────────┐
|
┌───────────┬──────────────────────────┬────────┬──────────┐
|
||||||
│ ticket_id │ subject │ status │ priority │
|
│ ticket_id │ subject │ status │ priority │
|
||||||
├───────────┼───────────────────────────┼────────┼──────────────────────────────────┤
|
├───────────┼──────────────────────────┼────────┼──────────┤
|
||||||
│ 1 │ ad natus │ closed │ sed iusto │
|
│ 1 │ ad natus │ closed │ low │
|
||||||
│ 2 │ voluptas iure aut │ closed │ eveniet consequatur consequuntur │
|
│ 2 │ iusto officia │ closed │ high │
|
||||||
│ 3 │ rerum nulla reprehenderit │ closed │ est quibusdam et │
|
│ 3 │ possimus error │ closed │ high │
|
||||||
│ 4 │ cumque autem voluptas │ open │ facere maxime │
|
│ 4 │ reprehenderit et earum │ open │ low │
|
||||||
│ 5 │ sit harum │ open │ eveniet commodi reprehenderit │
|
│ 5 │ cumque autem voluptas │ open │ low │
|
||||||
│ 6 │ rerum deserunt │ closed │ mollitia ut repellendus │
|
│ 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**
|
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
|
## Columns seed can't guess
|
||||||
|
|
||||||
Choice-like columns — `status`, `role`, `type`, and the like — get placeholder
|
Open-ended choice columns — `status`, `role`, `type`, and the like — get
|
||||||
text, because there is no sensible generic value for them. After a seed, the
|
placeholder text, because there is no single sensible value for them. After a
|
||||||
playground points this out:
|
seed, the playground points this out:
|
||||||
|
|
||||||
```rdbms
|
```rdbms
|
||||||
seed tickets 6
|
seed tickets 6
|
||||||
@@ -262,23 +276,25 @@ seed tickets 6
|
|||||||
|
|
||||||
```
|
```
|
||||||
6 row(s) seeded into tickets
|
6 row(s) seeded into tickets
|
||||||
┌───────────┬───────────────────────────┬──────────────────────────────┬──────────────────────────────────┐
|
┌───────────┬────────────────────────┬────────────────────────────────────┬──────────┐
|
||||||
│ ticket_id │ subject │ status │ priority │
|
│ ticket_id │ subject │ status │ priority │
|
||||||
├───────────┼───────────────────────────┼──────────────────────────────┼──────────────────────────────────┤
|
├───────────┼────────────────────────┼────────────────────────────────────┼──────────┤
|
||||||
│ 1 │ ad natus │ temporibus eos rerum │ sed iusto │
|
│ 1 │ ad natus │ temporibus eos rerum │ low │
|
||||||
│ 2 │ voluptas iure aut │ repudiandae commodi possimus │ eveniet consequatur consequuntur │
|
│ 2 │ iusto officia │ iure aut provident │ high │
|
||||||
│ 3 │ rerum nulla reprehenderit │ earum culpa │ est quibusdam et │
|
│ 3 │ possimus error │ consequatur consequuntur molestiae │ high │
|
||||||
│ 4 │ cumque autem voluptas │ ea praesentium pariatur │ facere maxime │
|
│ 4 │ reprehenderit et earum │ recusandae est quibusdam │ low │
|
||||||
│ 5 │ sit harum │ et et laboriosam │ eveniet commodi reprehenderit │
|
│ 5 │ cumque autem voluptas │ ea praesentium pariatur │ low │
|
||||||
│ 6 │ rerum deserunt │ qui voluptate │ mollitia ut repellendus │
|
│ 6 │ maxime sed sit │ sapiente et et │ medium │
|
||||||
└───────────┴───────────────────────────┴──────────────────────────────┴──────────────────────────────────┘
|
└───────────┴────────────────────────┴────────────────────────────────────┴──────────┘
|
||||||
```
|
```
|
||||||
|
|
||||||
> `status, priority` filled with generic text — they look like fixed value
|
> `status` filled with generic text — they look like fixed value sets. Pin
|
||||||
> sets. Pin them next time with `set status in ('…', '…')`, or fix these rows
|
> them next time with `set status in ('…', '…')`, or fix these rows with
|
||||||
> with `seed tickets.status set status in ('…', '…')`.
|
> `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
|
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
|
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
|
(`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>
|
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
|
by character, <kbd>Home</kbd>/<kbd>End</kbd> to the ends, and
|
||||||
<kbd>Delete</kbd>/<kbd>Backspace</kbd> to remove characters. Your
|
<kbd>Delete</kbd>/<kbd>Backspace</kbd> to remove characters. Readline-style
|
||||||
project-scoped command history is available with <kbd>↑</kbd>/<kbd>↓</kbd>.
|
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
|
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
|
cursor in view, and on a tall terminal the input field uses two rows so you
|
||||||
can see more of it at once.
|
can see more of it at once.
|
||||||
|
|
||||||
:::note[Planned]
|
:::note[Planned]
|
||||||
Multi-line entry and extra readline-style shortcuts (Ctrl-A/E/W/K/U) are
|
Multi-line entry — <kbd>Enter</kbd> inserting a newline, with a separate key to
|
||||||
planned and not yet available.
|
submit — is planned and not yet available.
|
||||||
:::
|
:::
|
||||||
|
|||||||
Reference in New Issue
Block a user