{"title":"Amber V2 Can Remember Things Now","summary":"Amber 2.0.0-beta.3 and Amber CLI 2.0.4 make Grant, Micrate migrations, and SQLite part of the tested default web application.","date":"2026-08-11","category":"Release","author":"Seth Tucker","url":"https://amberframework.org/blog/2026/08/11/amber-v2-persistence-by-default","markdown_url":"https://amberframework.org/blog/2026/08/11/amber-v2-persistence-by-default.md","json_url":"https://amberframework.org/blog/2026/08/11/amber-v2-persistence-by-default.json","image_url":"https://amberframework.org/assets/characters/grant-records-warehouse-higgsfield-15eba71da83e0ab79e600def5476faf2.webp","content_markdown":"# Amber V2 can remember things now\n\nWe found a funny gap in Amber V2's supposedly complete first application: the\nweb template had routes, controllers, ECR, typed configuration, CSS, and\nJavaScript—but no database. The Pet Tracker tutorial had to keep its animals in\nan in-memory array because the default application could not persist them.\n\nAmber `2.0.0-beta.3` and Amber CLI `2.0.4` close that gap. A new web application\nnow includes Grant ORM, Micrate-powered database commands, and SQLite by\ndefault. The supported tutorial creates a real Pet, stores it, edits it, and\nreads the updated record back.\n\n## Build the database-backed Pet Tracker\n\n```bash\nbrew install amberframework/amber_cli/amber_cli\namber new pet_tracker\ncd pet_tracker\namber generate scaffold Pet name:string:required species:string:required adopted:bool\namber database migrate\namber watch\n```\n\nOpen <http://127.0.0.1:3000/pets/new>. No database server is required: SQLite\nstores the development database under `db/`. Pass `-d pg` or `-d mysql` to\n`amber new` when the application should use a server database instead.\n\n## What the scaffold actually creates\n\nThe scaffold is a complete application boundary, not a pile of disconnected\nsnippets:\n\n- `src/models/pet.cr` contains the Grant model;\n- `src/schemas/pet_schema.cr` validates create and update input;\n- `src/controllers/pet_controller.cr` owns HTML CRUD actions;\n- `src/views/pet/` contains index, show, new, edit, and shared form ECR;\n- `db/migrations/` contains reversible Micrate SQL;\n- `spec/models/` and `spec/controllers/` contain the generated checks;\n- `config/routes.cr` receives the Pet resource routes.\n\nThe generated form includes CSRF protection, chooses create or edit from the\nmodel's persisted state, and uses `_method=PATCH` for updates. Required model\nfields also expose nil-safe form readers so a brand-new record can render\nbefore it has received input.\n\n## The database command is part of the CLI\n\nMicrate is compiled into the standalone `amber` executable. Applications do\nnot need a second migration command or another moving dependency.\n\n```bash\namber database migrate\namber database status\namber database rollback\namber database redo\namber database seed\n```\n\nDevelopment and test use separate URLs. Run\n`AMBER_ENV=test amber database migrate` before tests that need the schema, and\nset `DATABASE_URL` in production rather than committing credentials.\n\n## This is now a release test\n\nThe release gate no longer stops after a homepage compiles. It generates the\nPet scaffold, migrates development and test, runs the generated specs, builds\nand boots the application, submits the create form, reads the stored Pet,\nsubmits the edit form, and verifies the updated value.\n\nThat full journey runs on Apple Silicon macOS, x86-64 Linux, and ARM64 Linux.\nWindows x86-64 generates, migrates, tests, compiles, boots, and exercises the\nsame database-backed web app in CI. Windows remains outside the beta release\ngate because CLI 2.0.5 does not publish a standalone Windows archive; the\ndocumented source build is the current installation path.\n\nStart with [Build a Pet Tracker](/docs/v2/guides/pet-tracker/), inspect the\n[web-template contract](/docs/v2/guides/web-template/), and use the\n[migration guide](/docs/v2/guides/models/grant/migrations/) when the schema\nneeds to change.\n"}