Going further

Import from a CI/CD pipeline

The same job as the scheduled import, triggered after a migration deploys instead of on a timer — so the documentation updates when the schema does, and drift is caught at deploy.

  1. Wrap the extractor as a stored procedure in your database (once). The demo workspace documents this flow — load the demo and open the ZestreaDB extraction flow to see what it looks like.

  2. Store the Automation Key as a pipeline secret and expose it to the step as ZESTREA_KEY.

  3. Grant the service account GRANT VIEW DEFINITION and GRANT SELECT ON sys.sql_expression_dependencies.

  4. Add this as the post-deploy step — pick your authentication and copy the whole command:

    SQL login

    SERVER=your-server.example.com,1433
    DATABASE=YourDatabase
    SQLUSER=your-user
    SQLPASS=your-password
    ZESTREA_KEY=your-api-key
    sqlcmd -S "$SERVER" -U "$SQLUSER" -P "$SQLPASS" -C -d "$DATABASE" \
      -Q "EXEC dbo.ZestreaDB_ExtractSchema" \
      -h -1 -W -y 0 -o /tmp/schema.json \
    && curl -X POST https://zestreadb.com/api/v1/ingest/schema \
      -H "Authorization: Bearer $ZESTREA_KEY" \
      -H "Content-Type: application/json" \
      --data-binary @/tmp/schema.json

    Windows auth

    SERVER=your-server.example.com,1433
    DATABASE=YourDatabase
    ZESTREA_KEY=your-api-key
    sqlcmd -S "$SERVER" -E -C -d "$DATABASE" \
      -Q "EXEC dbo.ZestreaDB_ExtractSchema" \
      -h -1 -W -y 0 -o /tmp/schema.json \
    && curl -X POST https://zestreadb.com/api/v1/ingest/schema \
      -H "Authorization: Bearer $ZESTREA_KEY" \
      -H "Content-Type: application/json" \
      --data-binary @/tmp/schema.json

    Entra ID

    SERVER=your-server.example.com,1433
    DATABASE=YourDatabase
    ZESTREA_KEY=your-api-key
    sqlcmd -S "$SERVER" -G -C -d "$DATABASE" \
      -Q "EXEC dbo.ZestreaDB_ExtractSchema" \
      -h -1 -W -y 0 -o /tmp/schema.json \
    && curl -X POST https://zestreadb.com/api/v1/ingest/schema \
      -H "Authorization: Bearer $ZESTREA_KEY" \
      -H "Content-Type: application/json" \
      --data-binary @/tmp/schema.json

    The -h -1 -W -y 0 flags stop sqlcmd formatting the output for a terminal.

Running on every deploy is cheap: the extractor’s content hash means a deploy that did not change the schema does nothing.