Skip to main content
Troubleshoot State-Based Workflow (SDL) specific validation errors.
SDL is currently supported for PostgreSQL and MySQL. Validation rules enforce strict conventions to ensure maintainable schema definitions. The rules differ per engine - see PostgreSQL validation errors and MySQL validation errors.

PostgreSQL Validation Errors

Missing Schema Qualification

Error:
Cause: SDL requires all objects to have schema prefix. Solution:
Apply to all objects:
  • Tables: CREATE TABLE public.users
  • Indexes: CREATE INDEX idx_name ON public.users(name)
  • Views: CREATE VIEW public.active_users AS ...
  • Functions: CREATE FUNCTION public.get_user() ...

Column-Level Constraint

Error:
Cause: SDL requires constraints at table level (except NOT NULL, DEFAULT, GENERATED). Solution:
Allowed at column level:

Unnamed Constraint

Error:
Solution:
Naming conventions:
  • Primary keys: {table}_pkey
  • Unique constraints: {table}_{column}_key
  • Foreign keys: fk_{table}_{referenced_table}
  • Check constraints: check_{description}

Foreign Key Type Mismatch

Error:
Cause: Column types don’t match between foreign key and referenced column. Solution:

Foreign Key Missing Schema

Error:
Solution:

CHECK Constraint References Other Table

Error:
Cause: CHECK constraints can only reference columns in the same table. Solution:

Migration Generation Fails

Error:
Causes:
  1. Duplicate constraint names across tables
  2. Duplicate index names
  3. Conflicting object names
Solution: Ensure all object names are unique:

MySQL Validation Errors

Unsupported Statement

Error:
Cause: SDL files declare the desired end state; imperative statements (ALTER, DROP, RENAME, TRUNCATE, DML) are rejected because Bytebase generates the migration DDL itself. Solution:

CREATE TABLE … AS SELECT

Error:
Cause: CREATE TABLE ... AS SELECT is imperative - its resulting schema depends on the query, so it cannot be represented as a schema snapshot. Solution: Write the table’s full column definitions explicitly. To backfill data, use the migration-based workflow.

Dependency Cycle

Error:
Cause: Objects in the SDL files reference each other in a cycle (for example, two views selecting from each other), so no valid creation order exists. Solution: Break the cycle by removing or restructuring one of the circular references.

Next Steps

SDL Develop Guide

Learn SDL syntax requirements

SDL Limitations

Understand SDL constraints

CI/CD Issues

Troubleshoot CI/CD problems