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

Moved indexedAt time to record instead of ipld-block #501

Merged
merged 3 commits into from
Jan 31, 2023

Conversation

dholms
Copy link
Collaborator

@dholms dholms commented Jan 27, 2023

This migration moves the indexedAt time on ipld_block to the relevant record

This makes the migration in #500 much simpler (no need to track indexedAt time) & is also fixes a leaky abstraction - ipld_block is a repo storage concept & record is an indexing layer concept.

@dholms dholms mentioned this pull request Jan 27, 2023
Comment on lines 15 to 18
indexedAt: db
.selectFrom('ipld_block')
.whereRef('ipld_block.cid', '=', ref('record.cid'))
.select('indexedAt'),
Copy link
Collaborator

Choose a reason for hiding this comment

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

If there's a missing block for a record, I think this could fail when trying to set indexedAt to null. It shouldn't really happen, but there's nothing at the db level preventing it either. Not sure if it's really necessary, but I think the fix would be to do something like this:

  const indexedAtForRecordQb = db
    .selectFrom('ipld_block')
    .whereRef('ipld_block.cid', '=', ref('record.cid'))
    .select('indexedAt')
  await db
    .updateTable('record')
    .set({ indexedAt: indexedAtForRecordQb })
    .whereExists(indexedAtForRecordQb)
    .execute()

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

ah nice. great point 👌

Copy link
Collaborator

@devinivy devinivy left a comment

Choose a reason for hiding this comment

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

Lookin good!

@devinivy devinivy merged commit b455b91 into main Jan 31, 2023
@devinivy devinivy deleted the indexed-time-on-record branch January 31, 2023 23:23
mloar pushed a commit to mloar/atproto that referenced this pull request Nov 15, 2023
)

* moved indexedAt time to record instead of ipld-block

* use underlying kysely obj in tests

* pr feedback
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.

2 participants