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

Poll migration is not idempotent #7964

Merged
merged 1 commit into from Aug 8, 2019
Merged
Changes from all commits
Commits
File filter...
Filter file types
Jump to…
Jump to file or symbol
Failed to load files and symbols.

Always

Just for now

Poll migration is not idempotent

The migration script is not idempotent due to database constrains on the
poll related objects, namely:

polls: index_polls_on_post_id_and_name (post_id,name) UNIQUE
poll_options: index_poll_options_on_poll_id_and_digest  (poll_id,digest) UNIQUE
poll_votes:  index_poll_votes_on_poll_id_and_poll_option_id_and_user_id  (poll_id,poll_option_id,user_id) UNIQUE

This change skips a particular poll migration if it's already found on
the db.
  • Loading branch information...
Eduardo Poleo
Eduardo Poleo committed Aug 2, 2019
commit fd5b269f6a864c473e2d68472a8209ca82f76cc1
@@ -95,6 +95,8 @@ def up
step = poll["step"].to_i.clamp(0, max)
anonymous_voters = poll["anonymous_voters"].to_i.clamp(0, PG_INTEGER_MAX)

next if Poll.exists?(post_id: r.post_id, name: escape(name))

poll_id = execute(<<~SQL
INSERT INTO polls (
post_id,
ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.