@netlify/agent-runner-cli 1.105.0-netlifydb.0 → 1.106.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/bin-local.js +44 -44
- package/dist/bin.js +48 -48
- package/dist/index.js +40 -40
- package/dist/skills/netlify-database@netlifydb/SKILL.md +45 -2
- package/package.json +1 -1
|
@@ -113,12 +113,49 @@ export default defineConfig({
|
|
|
113
113
|
|
|
114
114
|
### Step 5: Generate migrations
|
|
115
115
|
|
|
116
|
-
|
|
116
|
+
Every time you change the schema, you MUST generate a new migration with a descriptive name.
|
|
117
|
+
|
|
118
|
+
**Step 5a — Derive a descriptive slug from the schema changes.**
|
|
119
|
+
|
|
120
|
+
The slug should summarise what the migration does, using lowercase `snake_case`, a leading imperative verb, and at most
|
|
121
|
+
50 characters. It must match the regex `^[a-z0-9_]{1,50}$` — only lowercase letters, digits, and underscores.
|
|
122
|
+
|
|
123
|
+
Good examples:
|
|
124
|
+
- `add_users_bio` — added a `bio` column to the `users` table
|
|
125
|
+
- `create_comments_table` — added a new `comments` table
|
|
126
|
+
- `index_posts_author_id` — added an index on `posts.author_id`
|
|
127
|
+
- `drop_legacy_sessions` — removed an obsolete table
|
|
128
|
+
|
|
129
|
+
Bad examples (do NOT use):
|
|
130
|
+
- `update` (not descriptive)
|
|
131
|
+
- `AddUsersBio` (wrong case)
|
|
132
|
+
- `add-users-bio` (hyphens are not allowed)
|
|
133
|
+
- `misc changes` (spaces are not allowed; also not descriptive)
|
|
134
|
+
|
|
135
|
+
**Step 5b — Write the slug to the file referenced by the `NETLIFY_DB_MIGRATION_NAME_FILE` environment variable.**
|
|
136
|
+
|
|
137
|
+
The agent runner provides a file path in the `NETLIFY_DB_MIGRATION_NAME_FILE` environment variable. You MUST read this
|
|
138
|
+
environment variable to find the path on disk, then write the slug to that file. The file lives outside the project
|
|
139
|
+
directory and is managed by the agent runner — do NOT try to read, write, or reason about any file inside the project
|
|
140
|
+
itself for this purpose.
|
|
141
|
+
|
|
142
|
+
Use `>` (overwrite), not `>>` (append), so the latest slug is the only one recorded:
|
|
117
143
|
|
|
118
144
|
```bash
|
|
119
|
-
|
|
145
|
+
MIGRATION_NAME="add_users_bio"
|
|
146
|
+
echo "$MIGRATION_NAME" > "$NETLIFY_DB_MIGRATION_NAME_FILE"
|
|
120
147
|
```
|
|
121
148
|
|
|
149
|
+
**Step 5c — Run `drizzle-kit generate` with the same slug passed to `--name`.**
|
|
150
|
+
|
|
151
|
+
```bash
|
|
152
|
+
npx drizzle-kit generate --name "$MIGRATION_NAME"
|
|
153
|
+
```
|
|
154
|
+
|
|
155
|
+
Both the file write and the `--name` flag are required: the file write lets the agent runner reuse your slug if it
|
|
156
|
+
has to re-run `drizzle-kit generate` as a safety net, and the `--name` flag ensures the migration file is named
|
|
157
|
+
correctly on this run. If you skip the file write, the agent runner may regenerate the migration with a random name.
|
|
158
|
+
|
|
122
159
|
This creates SQL migration files in `netlify/database/migrations/`.
|
|
123
160
|
|
|
124
161
|
### Step 6: Use the database in functions
|
|
@@ -420,3 +457,9 @@ leading to unpredictable and broken behavior.
|
|
|
420
457
|
5. **Misunderstanding `netlify db migrations reset`**: This command only deletes migration files that have
|
|
421
458
|
**not yet been applied** to your preview branch. It cannot undo an already-applied migration — to change
|
|
422
459
|
something that's already applied, you must roll forward with a new migration.
|
|
460
|
+
|
|
461
|
+
6. **Skipping the migration name slug**: When using Drizzle ORM, always derive a descriptive `snake_case` slug, write
|
|
462
|
+
it to the file referenced by `NETLIFY_DB_MIGRATION_NAME_FILE`, and pass it to `drizzle-kit generate --name
|
|
463
|
+
"$MIGRATION_NAME"`. Running `drizzle-kit generate` with no `--name` produces an auto-generated random name that
|
|
464
|
+
doesn't describe the change. The file write is important even if you also pass `--name`: the agent runner re-runs
|
|
465
|
+
`drizzle-kit generate` as a safety net and needs the slug from the file so the migration name stays consistent.
|
package/package.json
CHANGED