Skip to main content
POST
/
api
/
database
/
migrations
Create and Execute Database Migration
curl --request POST \
  --url https://api.example.com/api/database/migrations \
  --header 'Authorization: Bearer <token>' \
  --header 'Content-Type: application/json' \
  --data '
{
  "version": "20260416170500",
  "name": "create_posts_table",
  "sql": "CREATE TABLE posts (id UUID PRIMARY KEY DEFAULT gen_random_uuid(), title TEXT NOT NULL);"
}
'
{
  "version": "20260416170500",
  "name": "create_posts_table",
  "statements": [
    "CREATE TABLE posts (id UUID PRIMARY KEY DEFAULT gen_random_uuid(), title TEXT NOT NULL);"
  ],
  "createdAt": "2026-04-16T17:05:00.000Z",
  "message": "Migration executed successfully"
}

Authorizations

Authorization
string
header
required

Bearer authentication header of the form Bearer <token>, where <token> is your auth token.

Body

application/json
version
string
required

Migration version in YYYYMMDDHHmmss format.

Pattern: ^\d{14}$
name
string
required

Migration name

Minimum string length: 1
sql
string
required

SQL text to parse and execute immediately

Minimum string length: 1

Response

Migration executed and recorded successfully

version
string
required
Pattern: ^\d{14}$
name
string
required
statements
string[]
required
createdAt
string<date-time>
required
message
string
required