#1041·pgroll

Unexpected migration schema numbering

Author: orpheusxCreated Jun 17, 2026Updated Jun 18, 2026
Labelsbug

I've been using pgroll for the last few months with great success. Today, however, I got some odd behavior.

My migration files are named using the convention NNNN_myschema_mytablename_operation.yaml where the leading NNNN is an incrementing number expressed in a fixed length string. Within the file I assign the version_schema property to match the numeric prefix. So, for example, if the version_schema was "0003" the file would be named something like 0003_myschema_mytablename_operation.yaml.

The most recent version schema in my database is myschema_9 according to the response from pgroll latest schema --schema myschema . Pgroll created it for the file I named 0009_myschema_mytablename_operation_blah.yaml.

Here's where it got strange. When I ran pgroll start for my next migration, 0010_myschema_mytablename_add_column_foo.yaml, it calculated that the next schema should be myschema_8 instead of myschema_10.

Apart from the schema name numbering, the migration worked as expected and since I had another migration to run I thought I would continue and see where pgroll went from there. The next migration file was named 0011_myschema_mytablename_drop_column_baz.yaml but I mistakenly set the version_schema to "0010" (the same as the previous migration.) When I ran this file the output included the following:

2026-06-17 15:43:33 INFO  created versioned schema for migration                                                                                                
                      ├ migration: 8
                      └ schema_name: myschema_8

When I completed the second migration, the myschema_8 schema disappeared altogether. The original schema, with all the changes correctly applied, is all that remained.

It seems like pgroll is working correctly but the naming behavior is a problem when my hand coded schema management tool goes to update my database client's jdbcUrl.