Skip to content

Migration support using tools like sqlx migate or flyway #3448

Description

@0xfourzerofour

Proposal:

I want to be able to manage a manticore db schema using migration files so that I have a repeatable flow for different environment.

e.g a migrations directory with the SQL code to create / update tables like migrations/1_init_tables.sql, migrations/2_update_table.sql.

I use the rust sqlx library usually and flyway for some java repos but when I try to do a migration I will get the following error

sqlx migrate run --source src/indexer/migrations --database-url mysql://localhost:9306 --dry-run
error: error returned from database: 1064 (42000): P01: syntax error, unexpected '(' near '(SELECT CONCAT(@@sql_mode, ',PIPES_AS_CONCAT,NO_ENGINE_SUBSTITUTION')),time_zone='+00:00',NAMES utf8mb4 COLLATE utf8mb4_unicode_ci;'

Checklist:

To be completed by the assignee. Check off tasks that have been completed or are not applicable.

Details
  • Implementation completed
  • Tests developed
  • Documentation updated
  • Documentation reviewed
  • OpenAPI YAML updated and issue created to rebuild clients

Activity

  1. sanikolaev commented on Jun 11, 2025

    @sanikolaev
    Collaborator

    I did some research, and instead of making Manticore work with sqlx/flyway as if it were MySQL, it might make more sense to write a driver for something like https://github.com/amacneil/dbmate (or any other tool that makes it easy to add a new driver).

    We can help if someone is willing to do it.

  2. added
    waitingWaiting for the original poster (in most cases) or something else
    on Jun 11, 2025
  3. 0xfourzerofour commented on Jun 11, 2025

    @0xfourzerofour
    Author

    @sanikolaev Yeh I can have a look at implementing that, the logic for the driver seems pretty chill. However ideally we wait for the prepare statement feature so that we can use a statement to set the migration versions instead of statically implementing it using a string formater with manticore

    https://github.com/amacneil/dbmate/blob/main/pkg/driver/mysql/mysql.go#L287

  4. sanikolaev commented on Jun 12, 2025

    @sanikolaev
    Collaborator

    ideally we wait for the prepare statement feature so that we can use a statement to set the migration versions instead of statically implementing it using a string formater with manticore

    That's right. I'll just put the link to your related PR here #3431

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    waitingWaiting for the original poster (in most cases) or something else

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions