Skip to content
This repository was archived by the owner on Mar 8, 2025. It is now read-only.
This repository was archived by the owner on Mar 8, 2025. It is now read-only.

sql to determine version number is not deterministic #12

Description

@robacarp

My experience with postgres shows that a SELECT statement cannot be trusted to order the data in a consistent way, especially with older tables. While porting some unrelated migration history over to migrate.cr, I found that I needed to change the current_version sql slightly:

    def current_version
-      query = "SELECT %{column} FROM %{table}" % {
+      query = "SELECT %{column} FROM %{table} ORDER BY %{column} DESC" % {
        column: @column,
        table:  @table,
      }

      @db.scalar(query).as(Int32 | Int64)
    end

It's possible I'm misunderstanding the point of what that method does, but this tweak got it working for me.

Activity

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

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions