-
Notifications
You must be signed in to change notification settings - Fork 308
switch to {participant,team}_id in payment_instructions #4046
Conversation
Ready for review @rohitpaulk @aandis. |
@kaguillera and I used #3893 as a pattern here. |
But we ended up doing it all in one PR instead of three. Ready for review @rohitpaulk @aandis! :-) |
FROM payment_instructions | ||
ORDER BY participant_id, team_id, mtime DESC; | ||
|
||
END; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is going to require some downtime on prod so that while this migration runs, no one creates a new payment_instruction
or runs into error while creating them. I am not sure how big our prod payment_instructions
table is, which would decide how long this migration takes. Is that an acceptable downtime @whit537 ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
#3864 (comment) for reference
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we club the two UPDATE
s into a single UPDATE
statement so that this takes lesser time?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is going to require some downtime on prod so that while this migration runs, no one creates a new
payment_instruction
or runs into error while creating them.
I suppose that's a reason to split this across multiple PRs.
I am not sure how big our prod
payment_instructions
table is, which would decide how long this migration takes.
It's small:
gratipay::MAROON=> select count(*) from payment_instructions;
┌───────┐
│ count │
├───────┤
│ 3796 │
└───────┘
(1 row)
(The old tips
table from Gittipay 1.0 has 82,911 records, but we're not dealing with that here.)
Testing on a local backup, I'm seeing < 2 seconds to apply branch.sql
:
[gratipay] $ time psql gratipay-bak < sql/branch.sql
Null display is "¤".
Line style is unicode.
Border style is 2.
BEGIN
ALTER TABLE
ALTER TABLE
DROP VIEW
UPDATE 3787
UPDATE 3787
ALTER TABLE
ALTER TABLE
ALTER TABLE
ALTER TABLE
CREATE VIEW
CREATE TRIGGER
COMMIT
real 0m1.695s
user 0m0.005s
sys 0m0.006s
[gratipay] $
Is that an acceptable downtime @whit537 ?
I could go either way. Based on the above test, it looks like the downtime is going to be very brief, but I could also see aiming for zero downtime in the interest of professional pride. :-)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we club the two
UPDATE
s into a singleUPDATE
statement so that this takes lesser time?
Done in 7a0c2d9, and it looks like indeed it's twice as fast (even though, for simplicity, it uses a subselect instead of a FROM
):
[gratipay] $ time psql gratipay-bak < sql/branch.sql
Null display is "¤".
Line style is unicode.
Border style is 2.
BEGIN
ALTER TABLE
ALTER TABLE
DROP VIEW
UPDATE 3787
ALTER TABLE
ALTER TABLE
ALTER TABLE
ALTER TABLE
CREATE VIEW
CREATE TRIGGER
COMMIT
real 0m0.827s
user 0m0.005s
sys 0m0.005s
[gratipay] $
Removed usage from some more places. Not sure if we still use some of those. |
@aandis Cool. Looks like we need some better test coverage tho. ;-) |
... because the way @kaguillera and I approached this was to make the schema change, and then fix whatever the test suite surfaced. The fact that the tests didn't surface the cases you found indicates that we have an opportunity to improve our test coverage here. |
A lack of test coverage of the bin/migrate-tips.py script surfaced during a refactor (#4046). Therefore, we: - Move heavy lifting from the bin/migrate-tips.py executable into a migrate_all_tips function in the gratipay library for easier testing - Split out tip migration tests into their own test script - Add a few tests for migrate_all_tips
|
5badb96
to
88525b1
Compare
88525b1
to
38b59f1
Compare
0953c0d
to
318a9cb
Compare
Hack close to try restarting the build. Can't see how to do it in the Travis UI. 😕 |
Okay! @kaguillera and I added some tests in #4049 and 355b271 to cover the additional fixes (now) in 62f6f9d. Ready for re-review here, @aandis @rohitpaulk! 😤 |
62f6f9d
to
f00ddfe
Compare
Rebased on master. Previous head was 62f6f9d. |
f00ddfe
to
e6776c9
Compare
Rebased on master. Previous head was f00ddfe |
Looks good to me. |
I'll leave it to @whit537 or @rohitpaulk to merge, deploy and test this on prod in one go. Let's make sure deployment is done right. Run the migration first and then push application changes. |
We should also turn maintenance mode on when doing this. (Our @whit537 - Can you have a look at |
Right. Soooooooo ... we don't have Piwik on right now either (gratipay/inside.gratipay.com#437). 😁 |
I changed get_payment_instruction to not accept a slug.
Rebased on master. Previous head was 4f303d4. |
e6776c9
to
ff40d99
Compare
Alright, @kaguillera and I have digested and taken on board the desired approach of zero-downtime migrations at #3864 (comment) (and the links following). We're now planning to split this into a multi-step migration as recommended there and as implemented in #3893. |
Part of #835.