Migrations
Apply a migration
Section titled “Apply a migration”curl -X POST https://postdb.dev/api/migrations \ -H "Authorization: Bearer YOUR_API_KEY" \ -H "Content-Type: application/json" \ -d '{ "name": "add_users_table", "sql": "CREATE TABLE users (id UUID PRIMARY KEY DEFAULT gen_random_uuid(), email TEXT UNIQUE NOT NULL, created_at TIMESTAMPTZ DEFAULT NOW())" }'List applied migrations
Section titled “List applied migrations”curl https://postdb.dev/api/migrations \ -H "Authorization: Bearer YOUR_API_KEY"Returns all migrations with name, applied timestamp, and status.
Best practices
Section titled “Best practices”- Name migrations with a timestamp prefix:
20240115_add_users_table - Keep migrations additive where possible — avoid destructive
DROPstatements - Test rollback SQL before applying in production