# Database migrations

**Target length:** 11 minutes  
**Kernel on camera:** 2.74.26  
**Audience:** Someone who needs to move rows onto testdb and has been told the GUI contains a migrate button.

Say the shape of the job before any command. The live store is testdb keys. A migration you can finish on camera is: decide a key, decide a value with no spaces if you use `MINSERT`, write the lines, `GET` them back, `COUNT` them. For a CSV or JSONL file, `veloce mount` imports into testdb (`nativeBinary=false`) — that is import-on-attach, not a native mount. The Control Center command `SHOW MIGRATE` is a catalog of file-family analogs. Its own message says analog, not engine 3. Packs that teach `SHOW GATEWAY` and the later workbench overlays are not this host kernel. Label them analog on screen. File attach details are training `07-attach.md`.

Do not point an application `DATABASE_URL` at port 15432 or 2143 as a cutover. The sidecar notes say to leave a CRM URL on the database that already serves that app until the app’s real queries succeed on a clone, and until the disk can hold the data. This video uses a handful of rows.

## On-screen beats

1. Whiteboard: source rows → testdb key → value. Three example rows.
2. Terminal: `MINSERT` those rows, `MGET`, `COUNT`.
3. Control Center SQL box: button `SHOW MIGRATE`. Read the message “analog ≠ native” and “not engine 3”.
4. Optional: sidecar `CREATE TABLE` plus `INSERT` of the same three rows, then `SELECT`.
5. Say what you will not run: a hex dump of a customer file, a production connection string, a “native cutover” tool.

## GUI vs CLI

| Show in the GUI | Show in the terminal |
| --- | --- |
| SQL console, the `SHOW MIGRATE` button. It POSTs to `/api/v1/pack16` | `MINSERT` / `MGET` / `COUNT` on port 2143 |
| If the JSON includes `certifiedClaim`, it is false | Sidecar `psql` only if you already started `pgwire-sidecar.mjs` in the create-database video |

`SHOW MIGRATE` is also a line the workgroup server routes into the pack-16 handler. Prefer the button so the audience sees the catalog columns: ID, FAMILY, ARRIVES, ANALOG, LEFTOVER.

## Spoken script

“Migration here means rows landing in testdb. I am not going to open a customer backup on this machine. I have three rows on a card.”

Read the card.

```text
sku apple   name Ada    qty 2
sku pear    name Grace  qty 5
sku plum    name Linus  qty 1
```

“The key is the sku. The value is the rest, and because I want one `MINSERT`, I will keep each value as a single token. I am using a pipe inside the token so the line still splits on spaces.”

```text
MINSERT TESTDB sku-apple Ada|2 sku-pear Grace|5 sku-plum Linus|1
```

“Reply: `OK 3`.”

```text
MGET TESTDB sku-apple sku-pear sku-plum
GET TESTDB sku-apple
COUNT TESTDB
```

“I can see Ada, Grace, and Linus. Count includes whatever was already in this data directory, so I say the delta: three new keys, and I read them back by key. That is the migration check. A key you cannot `GET` did not land.”

“If a value needs spaces, use one `INSERT` per row. `INSERT` takes the remainder of the line as the value.”

```text
INSERT TESTDB sku-apple Ada Lovelace|qty=2
```

“Same key replaces the previous value. Reply `OK 1`. `GET TESTDB sku-apple` shows the new text.”

Open Control Center, SQL console. Click `SHOW MIGRATE`. Do not edit the box into a file path.

“This button asks the pack for a catalog. The columns are family, what arrives, what the analog does, and what is leftover. The message on that result says sixteen families, analog sniff and teach, not engine 3, analog is not native. Read leftover cells if they are on screen. They are the honesty. A family name in that grid is a teaching row. It is not a loader I just ran against your files, and it is not a product we are replacing by name.”

“There is a seed statement the pack accepts: `MIGRATE DAT ANALOG SEED TABLE` plus a table token. It plants an in-memory analog seed. I am not running it in this take. If you show it in a follow-up, keep the words analog seed on the lower third, and show that the reply is marked analog, `certifiedClaim` false, `nativeBinary` false. It does not open a customer file from disk. A native cutover orchestrator is leftover and external. `SHOW MIGRATE CDC` is a different line. It returns the migrate plane’s snapshot and a leftover that names native code as external. It does not start change-data-capture to another vendor.”

“Workbench on the website, slash workbench and slash tools slash isam-index, is the free browser desk for keyed-file teaching. It is online only. It is not this Windows service, and it is not a zip you install beside Workgroup.”

Optional sidecar, if it is still running from the previous video.

```sql
CREATE TABLE sku_move (
  sku VARCHAR(32) PRIMARY KEY,
  name VARCHAR(64),
  qty INTEGER
);
INSERT INTO sku_move (sku, name, qty) VALUES
  ('apple', 'Ada', 2),
  ('pear', 'Grace', 5),
  ('plum', 'Linus', 1);
SELECT sku, name, qty FROM sku_move WHERE sku = 'pear';
```

“Those statements are the sidecar profile on port fifteen four thirty-two: create table, multi-row insert, equality select. The rows are stored through testdb. `ALTER TABLE … ADD COLUMN IF NOT EXISTS` is in the tested list if you need to show a widen. Recursive CTE, full outer join, union, and `CREATE INDEX CONCURRENTLY` as a concurrent build are outside that promise — concurrent is accepted as an ordinary index. I am not demonstrating the ones that throw. If `psql` prints an error, that is the sidecar refusing, and the client should get the error rather than hang.”

“What I want you to remember when you leave: load keys, read keys, count. Use the migrate screen to see the analog catalog and its leftovers. Keep production connection strings where the application already works. Disk and the real queries decide any later move, not this demo.”

## Exact commands

Kernel lines:

```text
MINSERT TESTDB sku-apple Ada|2 sku-pear Grace|5 sku-plum Linus|1
MGET TESTDB sku-apple sku-pear sku-plum
GET TESTDB sku-apple
INSERT TESTDB sku-apple Ada Lovelace|qty=2
COUNT TESTDB
SHOW MIGRATE
SHOW MIGRATE CDC
```

`SHOW MIGRATE` returns a catalog whose message includes “not engine 3” and “analog ≠ native”.  
`SHOW MIGRATE CDC` returns JSON for the migrate plane, `certifiedClaim` false, with a native-code leftover.

Pack seed, optional, in-process analog, not a customer file:

```text
MIGRATE DAT ANALOG SEED TABLE DEMO
```

Sidecar SQL on 127.0.0.1:15432 only, profile `pgwire-testdb-v2`:

```sql
CREATE TABLE sku_move (
  sku VARCHAR(32) PRIMARY KEY,
  name VARCHAR(64),
  qty INTEGER
);
INSERT INTO sku_move (sku, name, qty) VALUES
  ('apple', 'Ada', 2),
  ('pear', 'Grace', 5),
  ('plum', 'Linus', 1);
SELECT sku, name, qty FROM sku_move WHERE sku = 'pear';
```

The sidecar self-test also accepts `ALTER TABLE … ADD COLUMN IF NOT EXISTS` on a table it created. Use that only if you are widening `sku_move` in the sidecar, not on port 2143.

## Do not say

- Actian Zen, Pervasive, or Btrieve. If a catalog cell contains one of those words, do not read the brand. Say “keyed-file analog” and point at `/tools/isam-index`.
- That `SHOW MIGRATE` imported a database, or that pack 12 through 17 is the host kernel. Host kernel is 2.74.3. `SHOW GATEWAY` and the workbench overlays are analog.
- A Community SKU, a headless migration edition, or a native cutover service.
- “Point the CRM at 15432.” The sidecar document says the opposite until the app’s queries and the disk say otherwise.
- `MIGRATE DAT FROM HEX` with a real customer file on camera. That statement exists for a hex payload. This video does not use it.
- Always On, Kubernetes, EKS, RDS, DPDK, XDP, SPIRE, or GenRM as part of the migration.
- A duration or a rows-per-second figure.
