A database schema defines the structure of application data. Treating schema changes as versioned migrations lets developers evolve tables without breaking existing production deployments. section 2.3.2 section 2.4.2
Use a migration-centered workflow when changing an application’s data model:
- Name: write an ordered SQL migration, such as adding a nullable category column to the appointments table. section 2.3.2
- What: let Goose or Flyway apply pending migrations at application startup and skip migrations already applied. section 2.3.2 section 2.4.2
- Why: coordinate the schema with application records, INSERT statements, SELECT statements, and deployment compatibility. section 2.3.2 section 2.4.2
- Defer mandatory constraints when existing rows cannot satisfy them; backfill values through a data migration before enforcing the constraint later. section 2.3.2
Adding appointment categories
Create a migration that adds a nullable category column, update the Appointment record, include category in INSERT and SELECT operations, then start the application so Goose applies the change. A request can create an appointment with category "cardiology". 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 up/down SQL migration for adding or removing the appointments category column. section 2.3.2





















































