Free and open source · Apache 2.0 →

Your entities change.
Migrax writes the migration.

Database migrations generated from your JPA entities: plain SQL with a rollback script, linted for locking and data loss, and verified against your own Hibernate, EclipseLink or OpenJPA mapping before it reaches production.

Java 17+ · Spring Boot · Quarkus · Micronaut · Helidon · Jakarta EE

Not on Java? Migrax applies your hand-written SQL migrations too, for Python, Node.js, Go, .NET, PHP or Ruby: any language.

28versions of Hibernate, EclipseLink and OpenJPA supported
12databases, from SQLite to Oracle
5frameworks, plus Maven and Gradle plugins
0configuration files to write
1

Change an entity

Add a field, rename a column, create a table. Write Java as usual.

2

Run migrax generate

Get readable SQL and a rollback script, checked for risky statements.

3

Run migrax migrate

Apply it from the command line, in CI, or when the application starts.

See it in 30 seconds

Change an entity, and Migrax writes the SQL and the script that undoes it.

Customer.java
   @Column(nullable = false, length = 100)
   String name;
+
+  @Column(length = 30)
+  String phone;
 }
0002_add_customers_phone.sql
ALTER TABLE customers ADD COLUMN phone varchar(30);
rollback/0002_add_customers_phone.sql
-- Note: deletes data written to customers.phone since the migration ran.
ALTER TABLE customers DROP COLUMN phone;

The new column, and a rollback script that says which data undoing it would delete.

Customer.java
-  @Column(nullable = false, length = 100)
-  String name;
+  @Column(name = "full_name", nullable = false, length = 100)
+  String fullName;
0003_rename_customers_name.sql
ALTER TABLE customers RENAME COLUMN name TO full_name;
rollback/0003_rename_customers_name.sql
ALTER TABLE customers RENAME COLUMN full_name TO name;

A dropped column next to a new one looks like a rename. Migrax asks, and renames it so the data stays; in CI it stops and tells you to pass --rename.

PurchaseOrder.java
@Entity
@Table(name = "orders")
public class PurchaseOrder {
  @Id
  @GeneratedValue(strategy = GenerationType.IDENTITY)
  Long id;

  @ManyToOne(optional = false)
  Customer customer;

  @Column(nullable = false, precision = 12, scale = 2)
  BigDecimal total;
}
0004_create_orders.sql
CREATE TABLE orders (customer_id bigint NOT NULL, id bigint GENERATED BY DEFAULT AS IDENTITY NOT NULL, total numeric(12,2) NOT NULL, CONSTRAINT orders_pkey PRIMARY KEY (id));
ALTER TABLE orders ADD CONSTRAINT fk_orders_customer_id_54d4cc52 FOREIGN KEY (customer_id) REFERENCES customers (id);
rollback/0004_create_orders.sql
-- Note: deletes data written to orders since the migration ran.
ALTER TABLE orders DROP CONSTRAINT fk_orders_customer_id_54d4cc52;
DROP TABLE orders;

Types and keys come from Hibernate's own mapping, so they match what Hibernate expects; unnamed constraints get readable names.

Customer.java
   @Column(name = "full_name", nullable = false, length = 100)
   String fullName;
-
-  @Column(length = 30)
-  String phone;
 }
$ migrax generate
1 change(s) for postgresql:
  1. drop column customers.phone  [DESTRUCTIVE]
     ALTER TABLE customers DROP COLUMN phone;
error[MXE108]: 1 destructive change(s) detected (marked [DESTRUCTIVE] above).
rollback/0005_remove_customers_phone.sql
-- WARNING: restores the structure of customers.phone but not its data.
ALTER TABLE customers ADD COLUMN phone varchar(30);

Nothing is dropped until you say --allow-destructive, and the rollback script warns that it can't bring the data back.

Why teams use Migrax

Everything a migration needs, checked before it reaches production.

  • Migrations written for you


    Change an entity, run migrax generate. Tables, columns, keys, indexes, join tables, element collections, sequences and inheritance come out exactly as your Hibernate, EclipseLink or OpenJPA maps them.

  • Checked before production


    Every migration is linted for statements that lock big tables, fail on existing rows or break running instances. migrax verify checks the result against your mapping, and Hibernate validates it itself.

  • Rollback included


    Each generated migration comes with a rollback script, and verify tests every one of them: roll back, apply again, same schema.

  • Asks before it loses data


    A dropped column that looks renamed? Migrax asks, and renames it so the data stays. Drops only happen when you say --allow-destructive.

  • Catches manual changes


    migrax drift compares the live database with what your migrations produce and lists every difference, including columns someone made narrower.

  • Zero setup


    Run it in your service folder. It compiles the project, finds the dependencies and reads the database settings from your application configuration.

Works with your stack

Detected automatically. No plugin configuration needed to get started.

FrameworksSpring BootQuarkusMicronaut 4 and 5Helidon 4Jakarta EEPlain Hibernate
Any languagePythonNode.jsGo.NETPHPRubyhand-written SQL migrations, how
JPA providersHibernate 4.0 to 7.4EclipseLink 2.7 to 4.0OpenJPA 3.2 and 4.1Spring Data JPA and Micronaut Data JPA, through Hibernateeach read through its own mapping
No JPASpring Data JDBC 3.0 to 4.1Micronaut Data JDBC and R2DBC 4 and 5entities without JPA or Hibernate
DatabasesPostgreSQLCockroachDBYugabyteDBMySQL 8MariaDBTiDBSQL ServerOracle 12c+H2HSQLDBDerbySQLite
Run it fromCommand lineMaven pluginGradle pluginApplication startupContainer image

From the blog

How-tos and the thinking behind Migrax. All articles

Spring Boot: migrations at startup, health checks and metrics

Apply database migrations when a Spring Boot application starts, before JPA, and see them in Actuator: a health check, Prometheus metrics, several instances starting together, and what changes when a pipeline runs the migrations instead.

Generate and apply database migrations without leaving IntelliJ IDEA

Rename a JPA field and let the Migrax plugin for IntelliJ IDEA write the migration, ask whether it was a rename, and apply it, with screenshots from a real run.

Generated SQL migrations for Python, TypeScript and Go projects

Your ORM already knows the schema. Export it as SQL, and Migrax writes versioned migrations with rollback scripts for SQLAlchemy, Drizzle and GORM projects, then checks them in CI.

Ready when your next entity changes

Install the command line tool in a minute, then run it in any service folder.

Install Migrax Read how it works