Skip to content

Conversation

@anihamde
Copy link
Contributor

@anihamde anihamde commented Jul 30, 2025

This PR removes the concurrently from the migration query to add an index on creation_time to the postgres auction table. This is so that the migrations in _sqlx_migrations can remain consistent between local and the prod db.

On local, we run this migration via the normal path since we aren't worried about downtime. However, on the prod db we had to run the migration manually in psql due to the risk of significant downtime from running this query (moreover, sqlx doesn't easily support running queries concurrently).

In the prod version, we manually appended an entry to the _sqlx_migrations table with the checksum corresponding to the query file to indicate that the migration has taken place.

This PR also adds an index on the auction_id in the bid table; without this, the deletes cannot happen quickly due to the ON DELETE RESTRICT clause. Similar to above, the index was created concurrently, but the migration file shows a blocking index creation.

@vercel
Copy link

vercel bot commented Jul 30, 2025

The latest updates on your projects. Learn more about Vercel for Git ↗︎

1 Skipped Deployment
Name Status Preview Comments Updated (UTC)
swap-staging ⬜️ Ignored (Inspect) Jul 31, 2025 3:55pm

@anihamde anihamde changed the title fix: get rid of Concurrently in auction creation time idx migration fix: add non-concurrent index creation migrations Jul 30, 2025
@anihamde
Copy link
Contributor Author

After merging, we should run the following two queries to add the migrations to the _sqlx_migrations table on prod:

INSERT INTO _sqlx_migrations (version, description, installed_on, success, checksum, execution_time)
VALUES (
20250726182247,
'auction creation time idx',
now(),
true,
decode('8154d649fa1c0575d15ebb7f0ac8364c356c4c2d69c4d1e02b938a7864602b89945758bd1181abdbf2fee23839c44710', 'hex'),
0
);
INSERT INTO _sqlx_migrations (version, description, installed_on, success, checksum, execution_time)
VALUES (
20250730221458,
'idx bid auction id',
now(),
true,
decode('08387a1694fb805c9dc88b5dcb1db287bad31e7ea4036dc5a043c8900581ba8a0be27297ba32fd09cd922164aeb0e99d', 'hex'),
0
);

The checksums are matched against the result of running these migrations locally.

Copy link
Contributor

@danimhr danimhr left a comment

Choose a reason for hiding this comment

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

Do we need to update the migrate down file as well?

@anihamde anihamde merged commit 5b5e1b6 into main Jul 31, 2025
1 check passed
@anihamde anihamde deleted the fix/concurrent-migration-query branch July 31, 2025 15:55
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.

3 participants