parse

Reads a version out of text, or refuses.

Parts are separated by . or by _, the two being interchangeable: a file can be called V2.1__x.sql or V2_1__x.sql, and a class has no choice, . not being legal in an identifier. Every part has to be digits and nothing else - no sign, no letters, no spaces - which is what keeps 1.x.2 from quietly becoming 1.2.

Throws

INVALID_MIGRATION where text is empty, holds a part that is not a number, or holds one too large for a Long.


internal fun parse(text: String, origin: String): MigrationVersion