> For the complete documentation index, see [llms.txt](https://developer.harness.io/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://developer.harness.io/api-reference/software-delivery-agent-apis/database-devops/migration-state.md).

# Migration State

This contains APIs for getting Migration State of Database Schema Entity

## Fetch SQL changesets of a instance

> Fetch SQL changesets

```json
{"openapi":"3.0.0","info":{"title":"Harness NextGen Software Delivery Platform API Reference","version":"1.0"},"tags":[{"description":"This contains APIs for getting Migration State of Database Schema Entity","name":"Migration State"}],"paths":{"/v1/orgs/{org}/projects/{project}/dbschema/{dbschema}/dbinstance/{dbinstance}/changeset/sql":{"post":{"description":"Fetch SQL changesets","operationId":"V1FetchDeployedChangesetSql","parameters":[{"$ref":"#/components/parameters/PageIndex"},{"$ref":"#/components/parameters/Limit"}],"requestBody":{"$ref":"#/components/requestBodies/FetchSQLStatementRequest"},"responses":{"200":{"$ref":"#/components/responses/FetchSQLStatementResponse"},"400":{"$ref":"#/components/responses/ErrorResponse"},"403":{"$ref":"#/components/responses/ErrorResponse"},"500":{"$ref":"#/components/responses/ErrorResponse"}},"summary":"Fetch SQL changesets of a instance","tags":["Migration State"]}}},"components":{"parameters":{"PageIndex":{"description":"Pagination page number strategy: Specify the page number within the paginated collection related to the number of items on each page.","in":"query","name":"page","schema":{"default":0,"format":"int64","type":"integer"}},"Limit":{"description":"Pagination: Number of items to return.","in":"query","name":"limit","schema":{"default":10,"maximum":100,"type":"integer"}}},"requestBodies":{"FetchSQLStatementRequest":{"content":{"application/json":{"schema":{"properties":{"changesetFQN":{"minLength":1,"type":"string"}},"required":["changesetFQN"],"type":"object"}}},"description":"Request Body for Fetching SQL statements"}},"responses":{"FetchSQLStatementResponse":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/DeployedChangesetSqlOutput"}}},"description":"Response Body for Fetching SQL statements","headers":{"X-Page-Number":{"description":"Page number in Paginated response.","schema":{"type":"integer"}},"X-Page-Size":{"description":"Maximum page size in Paginated response.","schema":{"type":"integer"}},"X-Total-Elements":{"description":"Total number of elements returned in Paginated response.","schema":{"type":"integer"}}}},"ErrorResponse":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}},"description":"Error Response body"}},"schemas":{"DeployedChangesetSqlOutput":{"description":"Response Body for Fetching SQL statements","properties":{"sql":{"items":{"type":"string"},"type":"array"}},"title":"DeployedChangesetSqlOutput","type":"object"},"Error":{"description":"Error Response","properties":{"message":{"description":"error message detail","type":"string"}},"required":["message"],"title":"Error Response","type":"object"}}}}
```

## GET /v1/orgs/{org}/projects/{project}/dbschema/{dbschema}/dbinstance/{dbinstance}/changeset/yaml

> ChangeSet deployment yaml for an instance

```json
{"openapi":"3.0.0","info":{"title":"Harness NextGen Software Delivery Platform API Reference","version":"1.0"},"tags":[{"description":"This contains APIs for getting Migration State of Database Schema Entity","name":"Migration State"}],"paths":{"/v1/orgs/{org}/projects/{project}/dbschema/{dbschema}/dbinstance/{dbinstance}/changeset/yaml":{"get":{"operationId":"V1ChangesetYamlProjDbInstance","parameters":[{"$ref":"#/components/parameters/ChangeSetParam"}],"responses":{"200":{"$ref":"#/components/responses/ChangeSetDeploymentYamlResponse"},"400":{"$ref":"#/components/responses/ErrorResponse"},"403":{"$ref":"#/components/responses/ErrorResponse"},"404":{"$ref":"#/components/responses/ErrorResponse"},"500":{"$ref":"#/components/responses/ErrorResponse"}},"summary":"ChangeSet deployment yaml for an instance","tags":["Migration State"]}}},"components":{"parameters":{"ChangeSetParam":{"description":"FQN of the changeSet deployed. It is the combination of fileName, changeSetId and author separated by ::","in":"query","name":"changeSet","required":true,"schema":{"type":"string"}}},"responses":{"ChangeSetDeploymentYamlResponse":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/ChangeSetDeploymentYamlOutput"}}},"description":"Response body for changeSet deployment yaml for an instance"},"ErrorResponse":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}},"description":"Error Response body"}},"schemas":{"ChangeSetDeploymentYamlOutput":{"description":"ChangeSet deployment yaml info for an instance","properties":{"yaml":{"type":"string"}},"required":["yaml"],"title":"ChangeSetDeploymentYamlOutput","type":"object"},"Error":{"description":"Error Response","properties":{"message":{"description":"error message detail","type":"string"}},"required":["message"],"title":"Error Response","type":"object"}}}}
```

## Flyway Migration state of an instance

> Flyway Migration state of an instance

```json
{"openapi":"3.0.0","info":{"title":"Harness NextGen Software Delivery Platform API Reference","version":"1.0"},"tags":[{"description":"This contains APIs for getting Migration State of Database Schema Entity","name":"Migration State"}],"paths":{"/v1/orgs/{org}/projects/{project}/dbschema/{dbschema}/dbinstance/{dbinstance}/flyway/migrationstate":{"get":{"description":"Flyway Migration state of an instance","operationId":"V1MigrationStateFlywayInstance","parameters":[{"$ref":"#/components/parameters/PageIndex"},{"$ref":"#/components/parameters/Limit"},{"$ref":"#/components/parameters/SearchTerm"}],"responses":{"200":{"$ref":"#/components/responses/FlywayInstanceMigrationStateResponse"},"400":{"$ref":"#/components/responses/ErrorResponse"},"403":{"$ref":"#/components/responses/ErrorResponse"},"500":{"$ref":"#/components/responses/ErrorResponse"}},"summary":"Flyway Migration state of an instance","tags":["Migration State"]}}},"components":{"parameters":{"PageIndex":{"description":"Pagination page number strategy: Specify the page number within the paginated collection related to the number of items on each page.","in":"query","name":"page","schema":{"default":0,"format":"int64","type":"integer"}},"Limit":{"description":"Pagination: Number of items to return.","in":"query","name":"limit","schema":{"default":10,"maximum":100,"type":"integer"}},"SearchTerm":{"allowEmptyValue":true,"description":"This would be used to filter resources having attributes matching the search term.","in":"query","name":"search_term","schema":{"type":"string"}}},"responses":{"FlywayInstanceMigrationStateResponse":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/FlywayInstanceMigrationStateOutput"}}},"description":"Response body for flyway migration state of an instance","headers":{"X-Page-Number":{"description":"Page number in Paginated response.","schema":{"type":"integer"}},"X-Page-Size":{"description":"Maximum page size in Paginated response.","schema":{"type":"integer"}},"X-Total-Elements":{"description":"Total number of elements returned in Paginated response.","schema":{"type":"integer"}}}},"ErrorResponse":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}},"description":"Error Response body"}},"schemas":{"FlywayInstanceMigrationStateOutput":{"description":"Flyway Migration info across schema and instance","properties":{"instanceName":{"description":"Name of the Instance","type":"string"},"migrations":{"items":{"$ref":"#/components/schemas/FlywayInstanceMigrationState"},"type":"array"},"schemaName":{"description":"Name of the Schema","type":"string"}},"required":["schemaName","instanceName"],"title":"FlywayInstanceMigrationStateOutput","type":"object"},"FlywayInstanceMigrationState":{"description":"Flyway Migration info across instances","properties":{"deployedAt":{"description":"epoch seconds when the migration was applied","format":"int64","type":"integer"},"description":{"description":"description from the migration script","type":"string"},"pipelineExecutionId":{"description":"pipeline execution Id of the pipeline execution","type":"string"},"pipelineIdentifier":{"description":"Pipeline Identifier of the pipeline","type":"string"},"stageExecutionId":{"description":"stage execution id of the pipeline execution","type":"string"},"status":{"$ref":"#/components/schemas/ChangeSetDeploymentStatus"},"type":{"description":"type of migration, whether baseline or actual script migration","type":"string"},"version":{"description":"version of flyway migration script","type":"string"}},"required":["version","type","status","deployedAt","pipelineIdentifier","pipelineExecutionId","stageExecutionId"],"title":"FlywayInstanceMigrationState","type":"object"},"ChangeSetDeploymentStatus":{"description":"Status of change set deployment","enum":["Rolled_Back","Successfully_Deployed","Not_Deployed","Deployment_Failed"],"title":"ChangeSetDeploymentStatus","type":"string"},"Error":{"description":"Error Response","properties":{"message":{"description":"error message detail","type":"string"}},"required":["message"],"title":"Error Response","type":"object"}}}}
```

## Migration state of a instance

> Migration state of a instance

```json
{"openapi":"3.0.0","info":{"title":"Harness NextGen Software Delivery Platform API Reference","version":"1.0"},"tags":[{"description":"This contains APIs for getting Migration State of Database Schema Entity","name":"Migration State"}],"paths":{"/v1/orgs/{org}/projects/{project}/dbschema/{dbschema}/dbinstance/{dbinstance}/migrationstate":{"get":{"description":"Migration state of a instance","operationId":"V1MigrationStateProjDbInstance","parameters":[{"$ref":"#/components/parameters/PageIndex"},{"$ref":"#/components/parameters/Limit"},{"$ref":"#/components/parameters/SearchTerm"}],"responses":{"200":{"$ref":"#/components/responses/InstanceMigrationStateResponse"},"400":{"$ref":"#/components/responses/ErrorResponse"},"403":{"$ref":"#/components/responses/ErrorResponse"},"500":{"$ref":"#/components/responses/ErrorResponse"}},"summary":"Migration state of a instance","tags":["Migration State"]}}},"components":{"parameters":{"PageIndex":{"description":"Pagination page number strategy: Specify the page number within the paginated collection related to the number of items on each page.","in":"query","name":"page","schema":{"default":0,"format":"int64","type":"integer"}},"Limit":{"description":"Pagination: Number of items to return.","in":"query","name":"limit","schema":{"default":10,"maximum":100,"type":"integer"}},"SearchTerm":{"allowEmptyValue":true,"description":"This would be used to filter resources having attributes matching the search term.","in":"query","name":"search_term","schema":{"type":"string"}}},"responses":{"InstanceMigrationStateResponse":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/InstanceMigrationStateOut"}}},"description":"Response body for migration state of a instance","headers":{"X-Page-Number":{"description":"Page number in Paginated response.","schema":{"type":"integer"}},"X-Page-Size":{"description":"Maximum page size in Paginated response.","schema":{"type":"integer"}},"X-Total-Elements":{"description":"Total number of elements returned in Paginated response.","schema":{"type":"integer"}}}},"ErrorResponse":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}},"description":"Error Response body"}},"schemas":{"InstanceMigrationStateOut":{"description":"Change Set deployment info for a instance","properties":{"changeSets":{"items":{"$ref":"#/components/schemas/InstanceMigrationStateChangeSet"},"type":"array"},"instanceName":{"description":"Name of the Instance","type":"string"},"schemaName":{"description":"Name of the Schema","type":"string"}},"required":["schemaName","instanceName"],"title":"InstanceMigrationStateOut","type":"object"},"InstanceMigrationStateChangeSet":{"description":"Deployment info of Change Sets across instances","properties":{"author":{"type":"string"},"changeSet":{"description":"Identifier of the Change Set","type":"string"},"changeSetFQN":{"type":"string"},"comment":{"description":"comment defined in changeSet","type":"string"},"deployedAt":{"format":"int64","type":"integer"},"fileName":{"type":"string"},"label":{"description":"label defined in changeSet","type":"string"},"pipeline":{"type":"string"},"planExecutionId":{"type":"string"},"stageExecutionId":{"type":"string"},"status":{"$ref":"#/components/schemas/ChangeSetDeploymentStatus"},"tag":{"type":"string"}},"required":["changeSet","deployedAt","author","fileName","status","pipeline","planExecutionId","stageExecutionId","changeSetFQN"],"title":"InstanceMigrationStateChangeSet","type":"object"},"ChangeSetDeploymentStatus":{"description":"Status of change set deployment","enum":["Rolled_Back","Successfully_Deployed","Not_Deployed","Deployment_Failed"],"title":"ChangeSetDeploymentStatus","type":"string"},"Error":{"description":"Error Response","properties":{"message":{"description":"error message detail","type":"string"}},"required":["message"],"title":"Error Response","type":"object"}}}}
```

## Migration state of a flyway schema

> Migration state of a flyway schema

```json
{"openapi":"3.0.0","info":{"title":"Harness NextGen Software Delivery Platform API Reference","version":"1.0"},"tags":[{"description":"This contains APIs for getting Migration State of Database Schema Entity","name":"Migration State"}],"paths":{"/v1/orgs/{org}/projects/{project}/dbschema/{dbschema}/flyway/migrationstate":{"post":{"description":"Migration state of a flyway schema","operationId":"V1MigrationStateFlywaySchema","parameters":[{"$ref":"#/components/parameters/PageIndex"},{"$ref":"#/components/parameters/Limit"},{"$ref":"#/components/parameters/SearchTerm"}],"requestBody":{"$ref":"#/components/requestBodies/MigrationStateGetRequest"},"responses":{"200":{"$ref":"#/components/responses/FlywayMigrationStateResponse"},"400":{"$ref":"#/components/responses/ErrorResponse"},"403":{"$ref":"#/components/responses/ErrorResponse"},"500":{"$ref":"#/components/responses/ErrorResponse"}},"summary":"Migration state of a flyway schema","tags":["Migration State"]}}},"components":{"parameters":{"PageIndex":{"description":"Pagination page number strategy: Specify the page number within the paginated collection related to the number of items on each page.","in":"query","name":"page","schema":{"default":0,"format":"int64","type":"integer"}},"Limit":{"description":"Pagination: Number of items to return.","in":"query","name":"limit","schema":{"default":10,"maximum":100,"type":"integer"}},"SearchTerm":{"allowEmptyValue":true,"description":"This would be used to filter resources having attributes matching the search term.","in":"query","name":"search_term","schema":{"type":"string"}}},"requestBodies":{"MigrationStateGetRequest":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/MigrationStateIn"}}},"description":"Inputs to get migration state of schema"}},"schemas":{"MigrationStateIn":{"description":"Get migration state request input","properties":{"instanceFilter":{"$ref":"#/components/schemas/MigrationStateInstanceIn"}},"title":"MigrationStateIn","type":"object"},"MigrationStateInstanceIn":{"description":"Get migration state request instance input","properties":{"instances":{"items":{"type":"string"},"type":"array"},"order":{"$ref":"#/components/schemas/OrderInstance"},"sort":{"$ref":"#/components/schemas/SortInstance"}},"title":"MigrationStateInstanceIn","type":"object"},"OrderInstance":{"default":"ASC","description":"order of instance entity","enum":["DESC","ASC"],"title":"OrderInstance","type":"string"},"SortInstance":{"default":"identifier","description":"sort for instance entity","enum":["name","updated","created","identifier"],"title":"SortInstance","type":"string"},"FlywayMigrationStateOutput":{"description":"Flyway Migration Applied for a schema information","properties":{"instances":{"items":{"$ref":"#/components/schemas/InstanceDetail"},"type":"array"},"migrations":{"items":{"$ref":"#/components/schemas/FlywayAppliedMigration"},"type":"array"},"schema":{"description":"Identifier of the Schema","type":"string"}},"required":["schema"],"title":"FlywayMigrationStateOutput","type":"object"},"InstanceDetail":{"description":"Name and identifier of instance","properties":{"identifier":{"type":"string"},"name":{"type":"string"}},"required":["identifier","name"],"title":"InstanceDetail","type":"object"},"FlywayAppliedMigration":{"description":"Flyway Migration Applied across instances","properties":{"deployedAt":{"description":"epoch seconds when the migration was applied","format":"int64","type":"integer"},"description":{"description":"Description from the migration script","type":"string"},"instances":{"items":{"$ref":"#/components/schemas/MigrationStateInstance"},"type":"array"},"type":{"description":"type of migration, whether baseline or actual script migration","type":"string"},"version":{"description":"version of flyway migration script","type":"string"}},"required":["version","type","instances","deployedAt"],"title":"FlywayAppliedMigration","type":"object"},"MigrationStateInstance":{"description":"Change Set Deployment info of instance","properties":{"error":{"type":"string"},"instance":{"description":"Identfier of the instance","type":"string"},"pipeline":{"type":"string"},"planExecutionId":{"type":"string"},"stageExecutionId":{"type":"string"},"status":{"$ref":"#/components/schemas/ChangeSetDeploymentStatus"},"tag":{"type":"string"},"updated":{"description":"Time of last Change Set Deployment/Rollback attempt ","format":"int64","type":"integer"}},"required":["instance","status","pipeline","planExecutionId","stageExecutionId"],"title":"MigrationStateInstance","type":"object"},"ChangeSetDeploymentStatus":{"description":"Status of change set deployment","enum":["Rolled_Back","Successfully_Deployed","Not_Deployed","Deployment_Failed"],"title":"ChangeSetDeploymentStatus","type":"string"},"Error":{"description":"Error Response","properties":{"message":{"description":"error message detail","type":"string"}},"required":["message"],"title":"Error Response","type":"object"}},"responses":{"FlywayMigrationStateResponse":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/FlywayMigrationStateOutput"}}},"description":"Response body for flyway migration state of a schema","headers":{"X-Page-Number":{"description":"Page number in Paginated response.","schema":{"type":"integer"}},"X-Page-Size":{"description":"Maximum page size in Paginated response.","schema":{"type":"integer"}},"X-Total-Elements":{"description":"Total number of elements returned in Paginated response.","schema":{"type":"integer"}}}},"ErrorResponse":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}},"description":"Error Response body"}}}}
```

## Migration state of a schema

> Migration state of a schema

```json
{"openapi":"3.0.0","info":{"title":"Harness NextGen Software Delivery Platform API Reference","version":"1.0"},"tags":[{"description":"This contains APIs for getting Migration State of Database Schema Entity","name":"Migration State"}],"paths":{"/v1/orgs/{org}/projects/{project}/dbschema/{dbschema}/migrationstate":{"post":{"description":"Migration state of a schema","operationId":"V1MigrationStateProjDbSchema","parameters":[{"$ref":"#/components/parameters/PageIndex"},{"$ref":"#/components/parameters/Limit"},{"$ref":"#/components/parameters/SearchTerm"}],"requestBody":{"$ref":"#/components/requestBodies/MigrationStateGetRequest"},"responses":{"200":{"$ref":"#/components/responses/MigrationStateResponse"},"400":{"$ref":"#/components/responses/ErrorResponse"},"403":{"$ref":"#/components/responses/ErrorResponse"},"500":{"$ref":"#/components/responses/ErrorResponse"}},"summary":"Migration state of a schema","tags":["Migration State"]}}},"components":{"parameters":{"PageIndex":{"description":"Pagination page number strategy: Specify the page number within the paginated collection related to the number of items on each page.","in":"query","name":"page","schema":{"default":0,"format":"int64","type":"integer"}},"Limit":{"description":"Pagination: Number of items to return.","in":"query","name":"limit","schema":{"default":10,"maximum":100,"type":"integer"}},"SearchTerm":{"allowEmptyValue":true,"description":"This would be used to filter resources having attributes matching the search term.","in":"query","name":"search_term","schema":{"type":"string"}}},"requestBodies":{"MigrationStateGetRequest":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/MigrationStateIn"}}},"description":"Inputs to get migration state of schema"}},"schemas":{"MigrationStateIn":{"description":"Get migration state request input","properties":{"instanceFilter":{"$ref":"#/components/schemas/MigrationStateInstanceIn"}},"title":"MigrationStateIn","type":"object"},"MigrationStateInstanceIn":{"description":"Get migration state request instance input","properties":{"instances":{"items":{"type":"string"},"type":"array"},"order":{"$ref":"#/components/schemas/OrderInstance"},"sort":{"$ref":"#/components/schemas/SortInstance"}},"title":"MigrationStateInstanceIn","type":"object"},"OrderInstance":{"default":"ASC","description":"order of instance entity","enum":["DESC","ASC"],"title":"OrderInstance","type":"string"},"SortInstance":{"default":"identifier","description":"sort for instance entity","enum":["name","updated","created","identifier"],"title":"SortInstance","type":"string"},"MigrationStateOut":{"description":"Change Set deployment info for a schema","properties":{"changeSets":{"items":{"$ref":"#/components/schemas/MigrationStateChangeSet"},"type":"array"},"instances":{"items":{"$ref":"#/components/schemas/InstanceDetail"},"type":"array"},"schema":{"description":"Identifier of the Schema","type":"string"}},"required":["schema"],"title":"MigrationStateOut","type":"object"},"MigrationStateChangeSet":{"description":"Deployment info of Change Sets across instances","properties":{"author":{"type":"string"},"changeSet":{"description":"Identifier of the Change Set","type":"string"},"changeSetFQN":{"description":"changesetFQN is a unique identifier for database changesets in the format filename::changesetId::author","type":"string"},"fileName":{"type":"string"},"instances":{"items":{"$ref":"#/components/schemas/MigrationStateInstance"},"type":"array"},"synced":{"default":false,"description":"If Change Set is successfully deployed to all instances","type":"boolean"},"updated":{"format":"int64","type":"integer"}},"required":["changeSet","synced","instances","updated","author","fileName","changeSetFQN"],"title":"MigrationStateChangeSet","type":"object"},"MigrationStateInstance":{"description":"Change Set Deployment info of instance","properties":{"error":{"type":"string"},"instance":{"description":"Identfier of the instance","type":"string"},"pipeline":{"type":"string"},"planExecutionId":{"type":"string"},"stageExecutionId":{"type":"string"},"status":{"$ref":"#/components/schemas/ChangeSetDeploymentStatus"},"tag":{"type":"string"},"updated":{"description":"Time of last Change Set Deployment/Rollback attempt ","format":"int64","type":"integer"}},"required":["instance","status","pipeline","planExecutionId","stageExecutionId"],"title":"MigrationStateInstance","type":"object"},"ChangeSetDeploymentStatus":{"description":"Status of change set deployment","enum":["Rolled_Back","Successfully_Deployed","Not_Deployed","Deployment_Failed"],"title":"ChangeSetDeploymentStatus","type":"string"},"InstanceDetail":{"description":"Name and identifier of instance","properties":{"identifier":{"type":"string"},"name":{"type":"string"}},"required":["identifier","name"],"title":"InstanceDetail","type":"object"},"Error":{"description":"Error Response","properties":{"message":{"description":"error message detail","type":"string"}},"required":["message"],"title":"Error Response","type":"object"}},"responses":{"MigrationStateResponse":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/MigrationStateOut"}}},"description":"Response body for migration state of a schema","headers":{"X-Page-Number":{"description":"Page number in Paginated response.","schema":{"type":"integer"}},"X-Page-Size":{"description":"Maximum page size in Paginated response.","schema":{"type":"integer"}},"X-Total-Elements":{"description":"Total number of elements returned in Paginated response.","schema":{"type":"integer"}}}},"ErrorResponse":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}},"description":"Error Response body"}}}}
```
