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

Fix: Prevent duplicated column error in Event Tickets migration #7677

Merged
merged 2 commits into from
Jan 16, 2025

Conversation

pauloiankoski
Copy link
Contributor

@pauloiankoski pauloiankoski commented Jan 15, 2025

Description

When running automated tests, database tables are truncated while preserving the effects of migrations. Recently, we introduced a migration that modifies the give_event_tickets table by adding a new amount column. However, since migrations are executed repeatedly after each database refresh (before most tests run), this led to an error when attempting to add the amount column multiple times.

To address this issue, this PR replaces the existing query execution method with a conditional check using maybe_add_column. This ensures the ALTER TABLE query is only executed if the column does not already exist, preventing redundant operations and errors.

Note: since a reformat operation has been performed in the file, note that the main change is located at the line 71.

Affects

Event Tickets migrations

Testing Instructions

  1. Run unit tests then ensure no DB errors are returned.
  2. Ensure the give_event_tickets is still being modified to have the new amount column.

Pre-review Checklist

  • Acceptance criteria satisfied and marked in related issue
  • Relevant @unreleased tags included in DocBlocks
  • Includes unit tests
  • Reviewed by the designer (if follows a design)
  • Self Review of code and UX completed

@jonwaldstein jonwaldstein self-requested a review January 16, 2025 16:22
Copy link
Contributor

@jonwaldstein jonwaldstein left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

@pauloiankoski pauloiankoski merged commit 77e45e0 into develop Jan 16, 2025
20 checks passed
@pauloiankoski pauloiankoski deleted the fix/event-tickets-amount-migration branch January 16, 2025 19:15
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

Successfully merging this pull request may close these issues.

2 participants