Skip to content

Conversation

@Kiyazz
Copy link
Contributor

@Kiyazz Kiyazz commented Jan 3, 2026

Pull Request Checklist

Issue

https://otwarchive.atlassian.net/browse/AO3-7249

Purpose

This PR adds new tables for storing old usernames and emails to prevent needing to query the audits table, which can be large for old accounts and doesn't easily support an index. This allows cleaning up the audits table and increasing performance of querying old credentials

References

AO3-7216 is supposed to be reverted as part of this PR

Credit

kiyazz (he/him)

…ons, and add rows on changes to columns of users table
@github-actions github-actions bot added Has Migrations Contains migrations and therefore needs special attention when deploying Awaiting Review labels Jan 3, 2026
@Kiyazz Kiyazz changed the title AO3-7249 Add new tables for past usernames and emails, define migrati… AO3-7249 Track past emails and usernames via a separate table Jan 4, 2026
@Kiyazz Kiyazz marked this pull request as ready for review January 5, 2026 10:01
@Kiyazz
Copy link
Contributor Author

Kiyazz commented Jan 5, 2026

Right now the PR has 2 parts of 3 from what's required. The last part asks for reverting a previous PR which i'm unsure if I should do inside a commit here

Copy link
Member

@brianjaustin brianjaustin left a comment

Choose a reason for hiding this comment

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

We usually don't mind reverting a previous PR as part of a newer, larger one. However, we did end up splitting that part out into a separate ticket (https://otwarchive.atlassian.net/browse/AO3-7251) for safety (writing and reading in the same PR is a recipe for a messy deploy), so good instinct there 😅

Some comments for you when you have time

@Kiyazz
Copy link
Contributor Author

Kiyazz commented Jan 7, 2026

Right now I use the old name + timestamp to uniquely identify a change. This works in testing but isn't guaranteed to work in production because audit and table entry timestamps don't have to match. Actual unique identifying would take an extra database table

@brianjaustin
Copy link
Member

audit and table entry timestamps don't have to match

This might require ruby instead of SQL (which means a small possibility of race conditions, which is fine), but what about checking old value + timestamp within a resolution of 60 seconds? That way, we can account for a delay between the change and callback execution in the vast majority of cases

@Kiyazz
Copy link
Contributor Author

Kiyazz commented Jan 8, 2026

That's easily possible to do in SQL. Since it's batching by user, no race conditions are possible either.

Copy link
Member

@brianjaustin brianjaustin left a comment

Choose a reason for hiding this comment

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

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Has Migrations Contains migrations and therefore needs special attention when deploying Priority: High Reviewed: Ready to Merge

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants