# How to handle database migrations with Liquibase on Ktor

DevFeed: [How to handle database migrations with Liquibase on Ktor](<https://devfeed.tech/articles/how-to-handle-database-migrations-with-liquibase-on-ktor-25568.md>)

Original publisher: [Read original article](<https://www.marcogomiero.com/posts/2022/ktor-migration-liquibase/>)

Author: Marco Gomiero

Published: 2022-01-24T00:00:00Z

Content type: tutorial

Language: en

Sources: [Posts on Marco Gomiero](<https://devfeed.tech/sources/posts-on-marco-gomiero.md>)

Topics: [Ktor](<https://devfeed.tech/topics/ktor.md>), [migration](<https://devfeed.tech/topics/migration.md>), [backend-development](<https://devfeed.tech/topics/backend-development.md>), [Gradle](<https://devfeed.tech/topics/gradle.md>), [MySQL](<https://devfeed.tech/topics/mysql.md>), [XML](<https://devfeed.tech/topics/xml.md>)

Tags: [backend](<https://devfeed.tech/tags/backend.md>), [backend-development](<https://devfeed.tech/tags/backend-development.md>), [gradle](<https://devfeed.tech/tags/gradle.md>), [ktor](<https://devfeed.tech/tags/ktor.md>), [migration](<https://devfeed.tech/tags/migration.md>), [migrations](<https://devfeed.tech/tags/migrations.md>), [mysql](<https://devfeed.tech/tags/mysql.md>), [xml](<https://devfeed.tech/tags/xml.md>)

## AI overview

This tutorial explains how to set up Liquibase in a Ktor project and create Gradle tasks for migrating test and production MySQL databases. It covers database schema evolution, data migration, rollback, dependencies, XML changelog data, and configuration through environment variables.

## Source excerpt

SERIES: Building a backend with Ktor Part 1: Structuring a Ktor project Part 2: How to persist Ktor logs Part 3: How to use an in-memory database for testing on Ktor Part 4: How to handle database migrations with Liquibase on Ktor Part 5 Generate API documentation from Swagger on Ktor Part 6: How to schedule jobs with Quartz on Ktor Part 7: Moving from mobile to backend development with Ktor Databases are an important and critical part of backend infrastructures. They are the place where all the information is stored and that data cannot be compromised or lost. That's why it is important to have proper management of the evolution of the database: it is necessary to be able to modify the schema, migrate the data, or roll back to a previous schema version if something unexpected happened.