SQL Review API

EndpointPOST /v1/sql/check
Servicehttps://api.bytebase.com/#bytebase.v1.SQLService
Requesthttps://api.bytebase.com/#bytebase.v1.CheckRequest
Responsehttps://api.bytebase.com/#bytebase.v1.CheckResponse

The SQL Review API provides SQL checks based on your schema review policy.

Before you start, you should configure the SQL Review Policy.

curl -X POST http://bytebase.example.com/v1/sql/check \
     -H 'Authorization: Bearer '${bytebase_token} \
     -d '{
           "statement": "ALTER TABLE \"user\" ADD \"address\" integer; ALTER TABLE \"user\" DROP COLUMN \"age\";",
           "database": "instances/prod-instance/databases/example"
         }'
{
  "advices": [
    {
      "status": "ERROR",
      "code": 105,
      "title": "schema.backward-compatibility",
      "content": "\"ALTER TABLE \"user\" DROP COLUMN \"age\";\" may cause incompatibility with the existing data and code",
      "line": 1,
      "column": 0,
      "detail": ""
    },
    {
      "status": "WARNING",
      "code": 402,
      "title": "column.no-null",
      "content": "Column \"address\" in \"public\".\"user\" cannot have NULL value",
      "line": 1,
      "column": 0,
      "detail": ""
    }
  ]
}
Edit this page on GitHub

Subscribe to Newsletter

By subscribing, you agree with Bytebase's Terms of Service and Privacy Policy.