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

Add central entities table with properties #4123

Merged
merged 3 commits into from
Aug 14, 2024
Merged

Add central entities table with properties #4123

merged 3 commits into from
Aug 14, 2024

Conversation

JAORMX
Copy link
Contributor

@JAORMX JAORMX commented Aug 12, 2024

Summary

Provide a brief overview of the changes and the issue being addressed.
Explain the rationale and any background necessary for understanding the changes.
List dependencies required by this change, if any.

Fixes #(related issue)

Change Type

Mark the type of change your PR introduces:

  • Bug fix (resolves an issue without affecting existing features)
  • Feature (adds new functionality without breaking changes)
  • Breaking change (may impact existing functionalities or require documentation updates)
  • Documentation (updates or additions to documentation)
  • Refactoring or test improvements (no bug fixes or new functionality)

Testing

Outline how the changes were tested, including steps to reproduce and any relevant configurations.
Attach screenshots if helpful.

Review Checklist:

  • Reviewed my own code for quality and clarity.
  • Added comments to complex or tricky code sections.
  • Updated any affected documentation.
  • Included tests that validate the fix or feature.
  • Checked that related changes are merged.

@JAORMX JAORMX requested a review from a team as a code owner August 12, 2024 15:17
@JAORMX JAORMX marked this pull request as draft August 12, 2024 15:17
@jhrozek
Copy link
Contributor

jhrozek commented Aug 12, 2024

One sqlc-generated file was forgotten, so I force-pushed to your branch to see if CI would be greener.

SELECT id, 'artifact', name, project_id, provider_id, created_at FROM artifacts;

INSERT INTO entities (id, entity_type, name, project_id, provider_id, created_at)
SELECT id, 'pull_request', name, project_id, provider_id, created_at FROM pull_requests;
Copy link
Contributor

Choose a reason for hiding this comment

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

I'm not sure this is enough. Our infra first migrates the DB while the old code is running and then upgrades the minder code, which creates a race where an entry might be added to the old tables but never to the new ones.

What if we create a SQL trigger that starts writing to the new table on create and update instead, commit that first so that the existing code writes to the new tables and then copy the existing data? (I also wonder about the size of the data and if we'd create a huge transaction, but that's a matter of checking our SaaS data size)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think we should just choose a migration on the golang migration wrapper.

Copy link
Member

Choose a reason for hiding this comment

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

+1 to doing the migration in the golang wrapper in a later PR after the tables are created and we start writing to them from the application code (but before we assume they are there on the read side).

I worry about doing SQL bulk inserts / updates leading to database locks, though I acknowledge that we haven't had those problems yet.

@JAORMX JAORMX force-pushed the entities-properties branch 6 times, most recently from 1f44ea9 to 1325b09 Compare August 13, 2024 10:30
@JAORMX JAORMX closed this Aug 13, 2024
@JAORMX JAORMX reopened this Aug 13, 2024
@JAORMX JAORMX closed this Aug 13, 2024
@JAORMX JAORMX reopened this Aug 13, 2024
@JAORMX JAORMX marked this pull request as ready for review August 13, 2024 11:25
@JAORMX JAORMX marked this pull request as draft August 13, 2024 12:21
This way it runs every time minder updates

Signed-off-by: Juan Antonio Osorio <[email protected]>
@coveralls
Copy link

coveralls commented Aug 13, 2024

Coverage Status

coverage: 53.924% (+0.03%) from 53.899%
when pulling 34a6d85 on entities-properties
into d4d29c2 on main.

@JAORMX JAORMX marked this pull request as ready for review August 13, 2024 12:37
@JAORMX JAORMX merged commit 44f715a into main Aug 14, 2024
21 of 22 checks passed
@JAORMX JAORMX deleted the entities-properties branch August 14, 2024 05:24
dmjb pushed a commit that referenced this pull request Aug 14, 2024
* Add central entities table with properties

Signed-off-by: Juan Antonio Osorio <[email protected]>

* Add entity population to migration command

This way it runs every time minder updates

Signed-off-by: Juan Antonio Osorio <[email protected]>

* Create repositories on entities table as well

Signed-off-by: Juan Antonio Osorio <[email protected]>

---------

Signed-off-by: Juan Antonio Osorio <[email protected]>
psekar pushed a commit to tinytrail/minder that referenced this pull request Aug 15, 2024
* Add central entities table with properties

Signed-off-by: Juan Antonio Osorio <[email protected]>

* Add entity population to migration command

This way it runs every time minder updates

Signed-off-by: Juan Antonio Osorio <[email protected]>

* Create repositories on entities table as well

Signed-off-by: Juan Antonio Osorio <[email protected]>

---------

Signed-off-by: Juan Antonio Osorio <[email protected]>
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.

4 participants