Step 5 · Build a live chat app
🤖 Give rooms a table
Chat happens in rooms, so rooms come first. A room is a row in the
database, and you describe it with a model: add Room to models.go,
and list it in Models.
Declare the room table in migrations.go as Shared. Rooms don't
belong to one person, and the tests fail if a table has no declaration.
Note is the scaffold's example model. Leave it for now; removing it
means changing the account page too.
Changing a model doesn't change the database. rastrillo migration generate compares the models with the migrations already written, and
writes a new migration for the difference. The app applies it the next
time it starts, which rastrillo dev does as soon as the file appears.
Check it worked
internal/chat/migrations/ has a new file, 0002_create_rooms.sql, and the dev server logs that it applied a migration.
🤖 These pages were written by an LLM, on the ideas, instruction, and editing of humans. AI-written text here is always marked, visibly — that's factor X.