Repository navigation
fix: prevent loop auto-migrate with bool default false - #1672
Conversation
WalkthroughRemoved GORM default:false tags from two boolean fields in model/twofa.go: TwoFA.IsEnabled and TwoFABackupCode.IsUsed. JSON tags remain unchanged; no logic or method updates. Changes
Estimated code review effort🎯 1 (Trivial) | ⏱️ ~2 minutes Possibly related PRs
Poem
Tip 🔌 Remote MCP (Model Context Protocol) integration is now available!Pro plan users can now connect to remote MCP servers from the Integrations page. Connect with popular remote MCPs such as Notion and Linear to add more context to your reviews and chats. ✨ Finishing Touches
🧪 Generate unit tests
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. CodeRabbit Commands (Invoked using PR/Issue comments)Type Other keywords and placeholders
CodeRabbit Configuration File (
|
There was a problem hiding this comment.
Actionable comments posted: 0
🧹 Nitpick comments (1)
model/twofa.go (1)
19-19: Optional: if you still want a DB-level default without churn, prefer default:0MySQL treats boolean as TINYINT; using default:0 avoids text boolean diffs while preserving a DB default.
- IsEnabled bool `json:"is_enabled"` + IsEnabled bool `json:"is_enabled" gorm:"default:0"` ... - IsUsed bool `json:"is_used"` + IsUsed bool `json:"is_used" gorm:"default:0"`Also applies to: 33-33
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
💡 Knowledge Base configuration:
- MCP integration is disabled by default for public repositories
- Jira integration is disabled by default for public repositories
- Linear integration is disabled by default for public repositories
You can enable these sources in your CodeRabbit configuration.
📒 Files selected for processing (1)
model/twofa.go(2 hunks)
🔇 Additional comments (3)
model/twofa.go (3)
19-19: LGTM — removing gorm default:false stops MySQL AutoMigrate churnZero-value false will still be written on inserts; behavior remains unchanged while preventing the ALTER TABLE loop.
33-33: LGTM — same fix for TwoFABackupCode.IsUsed; safe with current create pathCreateBackupCodes explicitly sets IsUsed=false; queries remain unaffected.
19-19: No remaininggorm:"default:false"boolean tags found
Ran the suggested ripgrep search across the repository and it returned no matches, confirming there are no other boolean fields withgorm:"default:false".
…ault-false fix: prevent loop auto-migrate with bool default false
…ault-false fix: prevent loop auto-migrate with bool default false
…ault-false fix: prevent loop auto-migrate with bool default false
mysql bool类型实际为tinyint
默认值设置为false不会成功
会导致每次重启autoMigrate重复执行
ALTER TABLEtwo_fa_backup_codesMODIFY COLUMNis_usedboolean DEFAULT falseSummary by CodeRabbit