Script to initially populate policy_acknowledgments table assuming that all current users have already accepted the given policy.
IGNORE clause is for situations when the script will be executed twice to don't change history.
Differential D5309
[keyserver] add script to populate `policy_acknowledgments` table kamil on Oct 6 2022, 4:10 AM. Authored by Tags None Referenced Files
Details Script to initially populate policy_acknowledgments table assuming that all current users have already accepted the given policy. IGNORE clause is for situations when the script will be executed twice to don't change history.
Diff Detail
Event Timeline
Comment Actions
It is not clear for me why do we assume that all users accepted policy when it is inserted into table for the first time but since you wrote it in the diff summary then I assume it is explicitly required in corresponding Linear issue so I am not going to dig into that. Separately I am of an opinion that it is better to implement this function in a way that it iterates over all policy types to execute appropriate SQL query. Comment Actions
To create an account, you have to accept the policies... so everybody with an account has already accepted them. The goal of the Linear task is to support changing the policies and then requiring everybody to re-accept the new policies.
Wouldn't hurt, but keep in mind that this is a simple one-time script, so code quality / thoroughness is not so important here.
Comment Actions Running this script manually seems like an unnecessary task - we can use our migrations to do it for us. So I would propose the following ordering of operations:
This approach feels safer because:
The 2nd point is important, because when we run this script manually, we need to chose when to run it. If we do that before inserting into / updating the policy table after logout is in place, we could have users that accepted the terms but weren't marked as so (it isn't a huge issue but it's better to avoid it - they would need to accept again when we start requiring it). If we do it after we start marking terms as accepted after login from the login screen, we could have another issue: what if, before we run this script, a registered user decided to not login due to the terms? The user would get marked as accepted, when we run this script, because the account was created. So depending on how important the issues sound to us, we can decide to use more complicated approach with migration, or keep the manual one. So it's probably up to @ashoat. (we can also decide to release the logic and the migration at once, which will be the simplest approach). Comment Actions
The second thing which in my opinion makes IGNORE is a case where those changes will be deployed and between deployment and running a script will be a time gap, and if new user will sign in within this gap there will be an entry in table and script will fail. I know it's not so possible with the current amount of users but why not make it easier for someone responsible for running it. This sounds reasonable to me. |