-
Notifications
You must be signed in to change notification settings - Fork 86
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
RFC: GithubRepo is modeled incorrectly #1083
Comments
@joshsmith I put this into the integration MVP milestone, but technically, we could "launch" without resolving this, since we'll only be dealing with one github app installation for now. However, our data is definitely modeled incorrectly here, so we should deal with it as soon as we can. |
We had a conversation about this offline where I clarified that a We can also mitigate the problem of not having access to the installation by fetching it from the API if it does not currently exist. This issue likely needs rewritten to deal with the above, but for now, it's low priority. |
@begedin would you mind clarifying the relevance of this issue for me now? I'm not sure it's relevant any longer at all, but I could be wrong. |
@joshsmith I went through the code, and near as I can tell, this is still slightly relevant, but probably as a different issue altogether. A repo is tied to a single installation either way, with the only possible case happening where an installation is removed, followed by a new one being added to the same account and the same repo. Our
Basically, there is some strangeness in the process. I would say, to make this as stable as possible we should In the case of
In the case of
Another thing we should do is handle the A potential solution would be
I'm not sure we want to do this as part of this issue, or by creating a new one, but I think at least parts of this are worth doing. |
Problem
#1080 added a unique index to the
github_repos
schema.#1081 also changes behavior when syncing github repos to match by
github_id
The model for a
GithubRepo
, however, looks like this (important bits only):The problem here is, in a real world, a github repository is not uniquely identified by an installation, but by it's
github_id
, as we are aiming to change.In our specific case, a
belongs_to :github_app_installation
simply tells us which installation provided us with the information about the repository.I guess our initial goal was to model it so each installation stores it's own copy, even though, on github, it's the same record. With the addition of other records, this no longer works optimally.
However, with the way it all works, since in our model, a repo can only belong to a single installation, we will encounter A LOT of difficulties as we start dealing with multiple installations.
Proposed general solution
GithubAppInstallationGithubRepo
,GithubInstallationRepo
?GithubAppInstallationRepo
,InstallationGithubRepo
?GithubAppInstallationRepo
sounds best to me.Specific changes needed
In
CodeCorps.GitHub.Event.Installation.Repos
:delete_repos
,:sync_repos
steps are replaced with:ensure_repos
- find or create al repositories:disassociate_repos
- deleteGithubAppInstallationRepo
records no longer in the installation:associate_repos
- createGithubAppInstallationRepo
records in the installationThe text was updated successfully, but these errors were encountered: