Skip to content

Commit

Permalink
fix: using quotes instead of renaming the 'rows' keyword
Browse files Browse the repository at this point in the history
  • Loading branch information
Christian Michallek committed Jun 18, 2024
1 parent 81dcffe commit a7d9f11
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions database/seed.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,21 +23,21 @@ func MustApplyDatabaseSeed(file string, db *gorm.DB, excludedTables ...[]string)

applySeedCheckSQL := `
SELECT
SUM(TABLE_ROWS) AS rows2
SUM(TABLE_ROWS) AS 'rows'
FROM
information_schema.TABLES
WHERE
TABLE_SCHEMA = ? AND TABLE_NAME NOT IN ?
`
result := struct {
Rows2 uint64
Rows uint64
}{}
statement := db.Raw(applySeedCheckSQL, db.Migrator().CurrentDatabase(), excludedTablesInSQL)
if err := statement.Scan(&result).Error; err != nil {
panic(fmt.Errorf("failed to check whether seed should be applied: %w", err))
}

if result.Rows2 > 0 {
if result.Rows > 0 {
return
}

Expand Down

0 comments on commit a7d9f11

Please sign in to comment.