Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

sql to determine version number is not deterministic #12

Closed
robacarp opened this issue Jun 22, 2018 · 2 comments
Closed

sql to determine version number is not deterministic #12

robacarp opened this issue Jun 22, 2018 · 2 comments

Comments

@robacarp
Copy link
Contributor

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.

@vladfaust
Copy link
Owner

@robacarp there is a single version value in migrate.cr's table, no need for ordering then. You may be confused with micrate's tons of rows 😊

@robacarp
Copy link
Contributor Author

Great context, thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants