A database migration is a versioned, repeatable change to a database schema or data state. It supports evolutionary changes without breaking existing deployments: add new fields as optional, preserve existing reads and updates, and make them mandatory only after existing records are handled. section 2.3.2 section 2.4.2
A migration workflow typically follows these steps:
- Write a numbered SQL migration that changes the schema. section 2.3.2
- Configure a migration tool to discover and apply scripts in order at application startup. section 2.3.2 section 2.4.2
- Update application records, queries, inserts, and reads to use the new field. section 2.3.2
- Plan follow-up migrations for defaults or data conversion before enforcing new constraints. section 2.3.2
Adding an appointment category
Add migration 002_Appointment_add_category.sql with an up operation that adds a nullable category column and a down operation that removes it. Update the Appointment record and SQL statements so new appointments accept and return category values. Goose skips the migration when it has already been applied. section 2.3.2
Listing 2.4 Schema migration to add a new column to Appointments.
-- +goose Up ALTER TABLE appointments ADD COLUMN category VARCHAR(255); -- +goose Down ALTER TABLE appointments DROP COLUMN category;
Inspect the reversible SQL migration that adds and removes the appointments category column. section 2.3.2






















