Apply SQL skills to real DevOps operations in PostgreSQL: write database migrations, monitor health, analyze query performance, back up and restore databases, and build operational dashboards. These are the queries you'll run at 3 AM during incidents.
Database migrations are versioned, repeatable changes to your database schema. They let teams evolve the database safely, just like Git lets teams evolve code.
docker exec -it pg-sql-course psql -U postgres -d devops_sql-- Create a migrations tracking table:
CREATE TABLE schema_migrations (
version VARCHAR(14) PRIMARY KEY,
name VARCHAR(255) NOT NULL,
applied_at TIMESTAMP WITH TIME ZONE DEFAULT NOW()
);-- This table tracks which migrations have been applied.
-- Migration tools (Flyway, Alembic, Prisma) create a similar table automatically.
SELECT * FROM schema_migrations;Without migrations, database changes are manual, error-prone, and impossible to reproduce. Migrations solve this by recording every schema change as a versioned script. Each migration has an 'up' (apply) and 'down' (rollback) direction. The schema_migrations table tracks which versions have been applied, preventing double-application. Every serious project uses migrations — they're as essential as version control.
schema_migrations table created and empty — no migrations applied yet.