fix(sqlserver): Query to ensure DB Version (#601)

pull/637/head
Roberto García 2023-11-03 20:33:47 -06:00 committed by GitHub
parent 6d0de39c50
commit 8503d4e20b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 1 additions and 13 deletions

View File

@ -27,19 +27,7 @@ func (s *Sqlserver) DeleteVersion(tableName string) string {
}
func (s *Sqlserver) GetMigrationByVersion(tableName string) string {
q := `
WITH Migrations AS
(
SELECT tstamp, is_applied,
ROW_NUMBER() OVER (ORDER BY tstamp) AS 'RowNumber'
FROM %s
WHERE version_id=@p1
)
SELECT tstamp, is_applied
FROM Migrations
WHERE RowNumber BETWEEN 1 AND 2
ORDER BY tstamp DESC
`
q := `SELECT TOP 1 tstamp, is_applied FROM %s WHERE version_id=@p1 ORDER BY tstamp DESC`
return fmt.Sprintf(q, tableName)
}