Skip to content

Commit bcacca8

Browse files
authored
docs: show sqb rename and sqb mv on the homepage, README and preview card (#958)
* docs: make the hero-shop example build repeatedly daily_revenue was an incremental model with no inputs, so its second build failed. It now reads a small payments seed with paid_at as its cursor input. * docs: show sqb rename and sqb mv on the homepage, README and preview card The hero, step 03, step 07 and the README now use sqb mv and sqb rename, with the old-name compatibility view in the plan output. The rename GIF is re-recorded with sqb mv and the link preview card shows sqb rename.
1 parent c372fd3 commit bcacca8

12 files changed

Lines changed: 143 additions & 22 deletions

File tree

‎.github/demos/rename.gif‎

87.7 KB
Loading

‎README.md‎

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,11 @@ Python data pipelines, and it keeps its state in append-only tables in your own
1919
external state database, no manifest files and no paid tier.
2020

2121
<p align="center">
22-
<img src="https://raw.githubusercontent.com/chio-labs/sqlbuild/main/.github/demos/rename.gif" alt="Moving and renaming an incremental model: sqb plan migrates the existing table instead of rebuilding it" width="100%">
22+
<img src="https://raw.githubusercontent.com/chio-labs/sqlbuild/main/.github/demos/rename.gif" alt="Moving and renaming an incremental model with sqb mv: sqb plan migrates the existing table instead of rebuilding it" width="100%">
2323
</p>
2424

25-
Move an incremental model to a new folder and name, and `sqb plan` migrates its table instead of
26-
rebuilding it.
25+
Move an incremental model to a new folder and name with `sqb mv`, and `sqb plan` migrates its table
26+
instead of rebuilding it.
2727

2828
## Quick start
2929

@@ -62,9 +62,11 @@ The playground runs on local DuckDB, with no warehouse credentials.
6262

6363
### Change it without rebuilding everything
6464

65-
- **Renames keep their history.** Rename or move an incremental or snapshot model and SQLBuild
65+
- **Renames keep their history.** [`sqb rename` and `sqb mv`](https://sqlbuild.com/docs/cli/rename/)
66+
update every reference, and the next build
6667
[migrates](https://sqlbuild.com/docs/concepts/models/migrations/) the existing table instead of
67-
rebuilding it.
68+
rebuilding it. The old name keeps working through a compatibility view.
69+
`sqb rename column:<model>.<column>` renames an incremental model's column in place.
6870
- **Replay on change.** When a model's SQL changes, choose how far back to reprocess, from only the
6971
new data to the last 14 days to a full rebuild, with
7072
[`replay_on_change`](https://sqlbuild.com/docs/concepts/incremental/#replay-on-change).

‎website/examples/README.md‎

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,20 @@ rm models/weekly_revenue.sql
4242
sqb janitor
4343
```
4444

45+
## Step 07: rename
46+
47+
`waffle-shop` shows the state after the rename. Give the model its old name, build it, then rename
48+
it back:
49+
50+
```bash
51+
cd waffle-shop
52+
mv models/marts/daily_order_rollup.sql models/marts/daily_activity_rollup.sql
53+
sed -i 's/daily_order_rollup/daily_activity_rollup/g' models/marts/hourly_activity_with_daily_context.sql
54+
sqb build
55+
sqb rename model:daily_activity_rollup daily_order_rollup
56+
sqb plan
57+
```
58+
4559
## Hero: move and rename
4660

4761
`hero-shop` shows the state after the move. The model started as `models/marts/revenue.sql`:
@@ -51,6 +65,9 @@ cd hero-shop
5165
mkdir -p models/marts
5266
mv models/finance/daily_revenue.sql models/marts/revenue.sql
5367
sqb build
54-
mv models/marts/revenue.sql models/finance/daily_revenue.sql
68+
sqb mv model:revenue models/finance/daily_revenue.sql
5569
sqb plan
5670
```
71+
72+
`sqb rename` and `sqb mv` add `migrate_from` to the model header; the example projects leave it out,
73+
so they can be set up again.

‎website/examples/hero-shop/models/finance/daily_revenue.sql‎

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,14 @@ MODEL (
55
cursor revenue_date,
66
cursor_type timestamp,
77
cursor_grain day,
8+
cursor_inputs (
9+
payments paid_at,
10+
),
811
);
912

10-
SELECT CAST('2026-04-01' AS DATE) AS revenue_date, 2850 AS total_revenue_cents
13+
SELECT
14+
CAST(paid_at AS DATE) AS revenue_date,
15+
SUM(amount_cents) AS total_revenue_cents
16+
FROM __seed("payments")
17+
GROUP BY
18+
CAST(paid_at AS DATE)
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
payment_id,paid_at,amount_cents
2+
1,2026-04-01 09:12:00,1250
3+
2,2026-04-01 13:40:00,1600
4+
3,2026-04-02 10:05:00,900
5+
4,2026-04-02 18:22:00,2100
6+
5,2026-04-03 11:47:00,1450
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
seeds:
2+
- name: payments
3+
description: Successful payments.
4+
columns:
5+
- name: payment_id
6+
type: INTEGER
7+
- name: paid_at
8+
type: TIMESTAMP
9+
- name: amount_cents
10+
type: INTEGER
119 KB
Loading

‎website/public/index.html‎

Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
<meta property="og:image" content="https://sqlbuild.com/assets/og-sqlbuild.png" />
1919
<meta property="og:image:width" content="1200" />
2020
<meta property="og:image:height" content="630" />
21-
<meta property="og:image:alt" content="SQLBuild: the refactorable warehouse. A model file is moved and renamed." />
21+
<meta property="og:image:alt" content="SQLBuild: the refactorable warehouse. sqb rename renames a model, and sqb plan migrates its table from prod.revenue to prod.daily_revenue. History kept. Nothing rebuilt." />
2222
<meta name="twitter:card" content="summary_large_image" />
2323
<meta name="twitter:image" content="https://sqlbuild.com/assets/og-sqlbuild.png" />
2424
<link rel="icon" type="image/png" href="assets/icon.png" />
@@ -76,13 +76,13 @@ <h1>The refactorable warehouse</h1>
7676
<div
7777
class="terminal hero-visual"
7878
role="img"
79-
aria-label="A model file is moved and renamed, and sqb plan shows a migration of the existing table instead of a rebuild."
80-
><span class="hv-stack"><span class="hv-a"><span class="tree"><span class="dim">models</span>
79+
aria-label="sqb mv moves and renames a model file, and sqb plan shows a migration of the existing table instead of a rebuild, with a view keeping the old name working."
80+
><span class="hv-l hv-l0"><span class="cmd">sqb mv model:revenue<span class="hv-break"> </span>models/finance/daily_revenue.sql</span></span><span class="hv-stack"><span class="hv-a"><span class="tree"><span class="dim">models</span>
8181
<span class="dim">└──</span> marts
8282
<span class="dim">└──</span> revenue.sql</span></span><span class="hv-b"><span class="tree"><span class="dim">models</span>
8383
<span class="dim">└──</span> finance
8484
<span class="dim">└──</span> <span class="info">daily_revenue.sql</span></span></span></span>
85-
<span class="hv-l hv-l1"><span class="cmd">sqb plan</span></span><span class="hv-l hv-l2"><span class="strong">Migrations</span> <span class="dim">(1)</span></span><span class="hv-l hv-l3"><span class="tree"><span class="dim">└──</span></span> daily_revenue <span class="info strong">migrate</span><span class="hv-wide"> <span class="dim">prod.revenue -&gt;</span> prod.daily_revenue</span></span><span class="hv-l hv-l4"><span class="tree"> <span class="dim">├──</span></span> <span class="dim">compatibility</span> <span class="ok">compatible</span></span><span class="hv-l hv-l5"><span class="tree"> <span class="dim">├──</span></span> <span class="dim">transfer</span> physical copy<span class="hv-wide">, promote by staged rename</span></span><span class="hv-l hv-l6"><span class="tree"> <span class="dim">└──</span></span> <span class="dim">discovery</span> automatic</span></div>
85+
<span class="hv-l hv-l1"><span class="cmd">sqb plan</span></span><span class="hv-l hv-l2"><span class="strong">Migrations</span> <span class="dim">(1)</span></span><span class="hv-l hv-l3"><span class="tree"><span class="dim">└──</span></span> daily_revenue <span class="info strong">migrate</span><span class="hv-wide"> <span class="dim">prod.revenue -&gt;</span> prod.daily_revenue</span></span><span class="hv-l hv-l4"><span class="tree"> <span class="dim">├──</span></span> <span class="dim">compatibility</span> <span class="ok">compatible</span></span><span class="hv-l hv-l5"><span class="tree"> <span class="dim">├──</span></span> <span class="dim">transfer</span> physical copy<span class="hv-wide">, promote by staged rename</span></span><span class="hv-l hv-l6"><span class="tree"> <span class="dim">└──</span></span> <span class="dim">old name</span> prod.revenue</span><span class="hv-l hv-l7"><span class="tree"> <span class="dim">├──</span></span> <span class="dim">view</span> until 2026-11-05</span><span class="hv-l hv-l8"><span class="tree"> <span class="dim">└──</span></span> <span class="dim">old table</span> archived</span></div>
8686
</div>
8787

8888
<section>
@@ -190,7 +190,7 @@ <h3>Turn review comments into compile errors</h3>
190190
<h3>Reorganise without breaking anything</h3>
191191
<p>
192192

193-
Declarations live next to the models that use them, and the compiler enforces who can see them. <code>sqb scope</code> shows what a move would break.
193+
Declarations live next to the models that use them, and the compiler enforces who can see them. <code>sqb scope</code> shows what a move would break, and <code>sqb mv</code> moves the model's private macros, enums and constants with it.
194194
</p>
195195
</div>
196196
<pre class="terminal"><span class="tree">models/marts/
@@ -322,15 +322,24 @@ <h3>See what the tests missed</h3>
322322
<h3>Rename models without rebuilding history</h3>
323323
<p>
324324

325-
A renamed incremental model keeps its table instead of starting again. If the logic changed too, declare <code>migrate_from</code>.
325+
<code>sqb rename</code> and <code>sqb mv</code> update every reference and keep the existing table, so an incremental model doesn't start again. The old name keeps working as a view. Renamed columns keep their history too.
326326
</p>
327327
</div>
328-
<pre class="terminal"><span class="cmd">sqb plan</span>
328+
<pre class="terminal"><span class="cmd">sqb rename model:daily_activity_rollup daily_order_rollup</span>
329+
<span class="info strong">Rename model daily_activity_rollup -&gt; daily_order_rollup</span>
330+
<span class="dim">├──</span> models/marts/daily_order_rollup.sql<span class="dim"> (moved from models/marts/daily_activity_rollup.sql)</span>
331+
<span class="dim">└──</span> models/marts/hourly_activity_with_daily_context.sql
332+
<span class="dim"> └──</span> 36:19 reference __ref(&quot;daily_activity_rollup&quot;) -&gt; __ref(&quot;daily_order_rollup&quot;)
333+
<span class="ok strong">Compiled: ok, 2 files changed</span>
334+
335+
<span class="cmd">sqb plan</span>
329336
<span class="strong">Migrations</span> <span class="dim">(1)</span>
330337
<span class="dim">└──</span> daily_order_rollup <span class="info strong">migrate</span> <span class="dim">dev.daily_activity_rollup -&gt;</span> dev.daily_order_rollup
331338
<span class="dim">├── compatibility</span> <span class="ok">compatible</span>
332339
<span class="dim">├── transfer</span> physical copy, promote by staged rename
333-
<span class="dim">└── discovery</span> automatic</pre>
340+
<span class="dim">└── old name</span> dev.daily_activity_rollup
341+
<span class="dim">├── view</span> until 2026-11-05
342+
<span class="dim">└── old table</span> archived</pre>
334343
</div>
335344
<div class="step">
336345
<div class="step-text">

‎website/public/styles.css‎

Lines changed: 69 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -742,7 +742,7 @@ footer a {
742742
margin-top: 0;
743743
}
744744

745-
/* Hero visual: a model is moved and renamed, then sqb plan shows the migration. */
745+
/* Hero visual: sqb mv moves and renames a model, then sqb plan shows the migration. */
746746
.hero {
747747
display: grid;
748748
grid-template-columns: minmax(0, 1fr) auto;
@@ -754,7 +754,7 @@ footer a {
754754
border: 1px solid var(--panel-border);
755755
border-left: 1px solid var(--inner-line);
756756
border-radius: var(--radius);
757-
min-height: 236px;
757+
min-height: 300px;
758758
}
759759

760760
.hero-visual {
@@ -823,6 +823,27 @@ footer a {
823823
}
824824
}
825825

826+
@keyframes hv-l0 {
827+
0%,
828+
6% {
829+
opacity: 0;
830+
transform: translateY(3px);
831+
}
832+
9%,
833+
92% {
834+
opacity: 1;
835+
transform: none;
836+
}
837+
96%,
838+
100% {
839+
opacity: 0;
840+
}
841+
}
842+
843+
.hv-l0 {
844+
animation-name: hv-l0;
845+
}
846+
826847
@keyframes hv-l1 {
827848
0%,
828849
24% {
@@ -949,6 +970,48 @@ footer a {
949970
animation-name: hv-l6;
950971
}
951972

973+
@keyframes hv-l7 {
974+
0%,
975+
45% {
976+
opacity: 0;
977+
transform: translateY(3px);
978+
}
979+
48%,
980+
92% {
981+
opacity: 1;
982+
transform: none;
983+
}
984+
96%,
985+
100% {
986+
opacity: 0;
987+
}
988+
}
989+
990+
.hv-l7 {
991+
animation-name: hv-l7;
992+
}
993+
994+
@keyframes hv-l8 {
995+
0%,
996+
48% {
997+
opacity: 0;
998+
transform: translateY(3px);
999+
}
1000+
51%,
1001+
92% {
1002+
opacity: 1;
1003+
transform: none;
1004+
}
1005+
96%,
1006+
100% {
1007+
opacity: 0;
1008+
}
1009+
}
1010+
1011+
.hv-l8 {
1012+
animation-name: hv-l8;
1013+
}
1014+
9521015
@media (prefers-reduced-motion: reduce) {
9531016
.hero-visual .hv-a,
9541017
.hero-visual .hv-b,
@@ -979,4 +1042,8 @@ footer a {
9791042
.hero-visual .hv-wide {
9801043
display: none;
9811044
}
1045+
1046+
.hero-visual .hv-break::after {
1047+
content: '\\\A ';
1048+
}
9821049
}

‎website/recordings/README.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ scripts are the source; the rendered GIF, MP4 and PNG files go to `out/`, which
66

77
| Demo | Shows |
88
|------|-------|
9-
| `rename` | A model is moved and renamed, and `sqb plan` migrates the existing table. |
9+
| `rename` | `sqb mv` moves and renames a model, and `sqb plan` migrates the existing table. |
1010
| `contract` | A renamed column fails `sqb compile` against an enforced contract. |
1111
| `rules` | A custom rule and a missing test mock fail `sqb compile`. |
1212
| `scope` | `sqb scope --as-path` previews what a move would lose. |

0 commit comments

Comments
 (0)