Skip to content

Populate the forge_instance table at startup - #575

Open
MoralCode wants to merge 9 commits into
mainfrom
feat/populate_forge_instance_startup
Open

MoralCode wants to merge 9 commits into
mainfrom
feat/populate_forge_instance_startup

Conversation

@MoralCode

Copy link
Copy Markdown
Contributor

Description
This PR populates the initial contents of the forge_instances table with the two built-in default instances: github.com and gitlab.com.

It does this via two mechanisms:

  1. A database migration, to cover existing instances.
  2. An addition to the startup script to populate this data if the forge instances table is completely empty at startup (such as might be the case for a fresh instance after we move away from migration based data initialization).

This has to be done with a migration because I anticipate future migrations will update database structure/constraints to "creatively reinterpret" existing forge type fields as instances (they conveniently share the same number space for now). As a result, we need to basically guarantee these records exist in every existing instance so that future db migrations dont fail.

This is another step towards resolving #293
this PR also unblocks work to migrate collection tasks, such as pull request collection, to utilize instance IDs as part of their unique identity

Notes for Reviewers

Signed commits

  • Yes, I signed my commits.

Generative AI disclosure

Please select one option:

  • This contribution was NOT assisted or created by Generative AI tools.
  • This contribution was assisted or created by Generative AI tools.

If AI tools were used, please provide details below:
- What tools were used? Possibly code autocomplete in cursor. but this code was mostly written a long time ago so im inclined to trust my lack of AI disclosures as a sign there wasnt much AI use
- How were these tools used? maybe coding?
- Did you review these outputs before submitting this PR? yes, extensively code reviewed etc

…e table

Signed-off-by: Adrian Edwards <adredwar@redhat.com>
Signed-off-by: Adrian Edwards <adredwar@redhat.com>
Signed-off-by: Adrian Edwards <adredwar@redhat.com>
Signed-off-by: Adrian Edwards <adredwar@redhat.com>
Intelligently detecting it based on key presence at first startup is just too niche a condition/too rare and will make user support more painful.

Instead the "whether we queue these tasks" logic should rely on both "is the instance enabled" AND "do we have keys" separately

Signed-off-by: Adrian Edwards <adredwar@redhat.com>
…SS instances

Signed-off-by: Adrian Edwards <adredwar@redhat.com>
…table

This covers existing instances.

Signed-off-by: Adrian Edwards <adredwar@redhat.com>
Signed-off-by: Adrian Edwards <adredwar@redhat.com>

from collectoss.application.db.models.operations import ForgeInstance
from collectoss.util.enums import ForgePlatformType
from sqlalchemy.orm.attributes import get_history

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

[pylint] reported by reviewdog 🐶
W0611: Unused get_history imported from sqlalchemy.orm.attributes (unused-import)

Signed-off-by: Adrian Edwards <adredwar@redhat.com>
@codecov

codecov Bot commented Nov 16, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 0% with 15 lines in your changes missing coverage. Please review.
✅ Project coverage is 16.84%. Comparing base (0bb5f6b) to head (e5dfd6e).

Files with missing lines Patch % Lines
collectoss/util/startup.py 0.00% 15 Missing ⚠️
Additional details and impacted files
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@MoralCode MoralCode changed the title Populate the force_instance table at startup Populate the forge_instance table at startup Nov 17, 2026
@MoralCode

Copy link
Copy Markdown
Contributor Author

I need to add automated tests for this....

@MoralCode

Copy link
Copy Markdown
Contributor Author

i have run the migrations for this on my local instance and confirmed they work. just waiting to set up testing for the above (to ensure first instance startup/init behavior is okay (for when we eventually rely on that)

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

Labels

None yet

Projects

Development

Successfully merging this pull request may close these issues.

1 participant