Cleanup and fixes: godoc comments, removed dead code, fixed renumber FK constraint bug
- Added comprehensive godoc comments for auto-flush functions (bd-4) - Removed unused issueMap in scoreCollisions (bd-6) - Fixed renumber command FK constraint failure (bd-143) - Changed UpdateIssueID to use explicit connection with FK disabled - Resolves 'constraint failed: FOREIGN KEY constraint failed' error - Deleted 22 test/placeholder issues - Renumbered issues from bd-1 to bd-143 (eliminated gaps) Amp-Thread-ID: https://ampcode.com/threads/T-65f78f08-4856-4af0-9d6c-af33e88b5f63 Co-authored-by: Amp <amp@ampcode.com>
This commit is contained in:
@@ -1149,18 +1149,25 @@ func (s *SQLiteStorage) UpdateIssue(ctx context.Context, id string, updates map[
|
||||
|
||||
// UpdateIssueID updates an issue ID and all its text fields in a single transaction
|
||||
func (s *SQLiteStorage) UpdateIssueID(ctx context.Context, oldID, newID string, issue *types.Issue, actor string) error {
|
||||
tx, err := s.db.BeginTx(ctx, nil)
|
||||
// Get exclusive connection to ensure PRAGMA applies
|
||||
conn, err := s.db.Conn(ctx)
|
||||
if err != nil {
|
||||
return fmt.Errorf("failed to get connection: %w", err)
|
||||
}
|
||||
defer conn.Close()
|
||||
|
||||
// Disable foreign keys on this specific connection
|
||||
_, err = conn.ExecContext(ctx, `PRAGMA foreign_keys = OFF`)
|
||||
if err != nil {
|
||||
return fmt.Errorf("failed to disable foreign keys: %w", err)
|
||||
}
|
||||
|
||||
tx, err := conn.BeginTx(ctx, nil)
|
||||
if err != nil {
|
||||
return fmt.Errorf("failed to begin transaction: %w", err)
|
||||
}
|
||||
defer tx.Rollback()
|
||||
|
||||
// Defer foreign key checks until end of transaction
|
||||
_, err = tx.ExecContext(ctx, `PRAGMA defer_foreign_keys = ON`)
|
||||
if err != nil {
|
||||
return fmt.Errorf("failed to defer foreign keys: %w", err)
|
||||
}
|
||||
|
||||
_, err = tx.ExecContext(ctx, `
|
||||
UPDATE issues
|
||||
SET id = ?, title = ?, description = ?, design = ?, acceptance_criteria = ?, notes = ?, updated_at = ?
|
||||
|
||||
Reference in New Issue
Block a user