create-backon 0.11.0 → 0.13.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/README.md CHANGED
@@ -237,7 +237,54 @@ commands rather than one combined dashboard — "show me what's here" and
237
237
  can also accidentally edit something isn't actually a safe overview.
238
238
  `add-route`/`add-method`/`remove-route`/`list-routes`/`doctor` all keep
239
239
  working exactly as documented above; `server-config` is a wrapper around
240
- the same underlying logic, not a replacement for them.
240
+ the same underlying logic, not a replacement for them. On a `neon`/`postgres`
241
+ project, the same menu also has "Add a database table"/"Remove a database
242
+ table" — see the next section.
243
+
244
+ ## Managing the database schema
245
+
246
+ Only for the `neon`/`postgres` db choices — both speak the same Postgres
247
+ schema dialect (`drizzle-orm/pg-core`), which is what makes one implementation
248
+ cover both. SQLite uses different column builders entirely and isn't
249
+ supported here yet; `add-table`/`remove-table` refuse with a clear message
250
+ on a `sqlite`/`none` project rather than doing something wrong silently.
251
+
252
+ ```
253
+ bun run add-table
254
+ ```
255
+
256
+ or `bunx create-backon add-table` (`table` also works, and a name can be
257
+ passed as an argument: `add-table users`). Walks through a table name, an
258
+ "add an auto-increment id primary key column?" question, and then columns
259
+ one at a time — name, type (`text`/`integer`/`boolean`/`timestamp`/`uuid`),
260
+ required/unique, and a type-appropriate default (`.defaultNow()` for
261
+ timestamps, `.defaultRandom()` for uuid, a literal for text/integer/boolean).
262
+ A column can also reference another table's `id` instead of picking a type —
263
+ rendered as the idiomatic `integer(...).references(() => otherTable.id)`
264
+ pattern. Loops to "add another table?" until told to stop.
265
+
266
+ Every call only edits `src/config/schema.<ext>` — appending a real
267
+ `pgTable(...)` export and merging into the shared `drizzle-orm/pg-core`
268
+ import rather than duplicating it. **Nothing here ever touches the actual
269
+ database** — `bun run db:generate`/`db:migrate`/`db:push` (from
270
+ drizzle-kit, wired into every `neon`/`postgres` project's `package.json`)
271
+ are separate, explicit commands you run yourself when ready. See the
272
+ generated README's "Table schema" section for the `generate`+`migrate` vs.
273
+ `push` tradeoff.
274
+
275
+ `bun run remove-table` (`rm-table` also works) is the undo: picks a table,
276
+ confirms, removes its `pgTable(...)` export, and prunes any `pg-core`
277
+ builder nothing else in the file still uses. Refuses to remove a table
278
+ another table's column still references — leaving that in place would
279
+ compile fine but throw a real `ReferenceError` the moment drizzle-kit or
280
+ `db.query` tried to resolve it, so this is caught here instead. Removing
281
+ the last table resets `schema.<ext>` to its blank, freshly-scaffolded
282
+ stub, matching how `remove-method` resets a route's files when its last
283
+ method goes.
284
+
285
+ Both are also in `server-config`'s menu (see above), single-shot rather
286
+ than their own standalone "add another?" loop — `server-config`'s own
287
+ loop already re-shows state and re-prompts after every action.
241
288
 
242
289
  ## Generating API docs
243
290