arkency / find-open-source-mentor

A platform to connect junior developers with open source projects
35 stars 11 forks source link

WIP: nested fields of repositories inside project #27

Closed oxanayoxana closed 5 years ago

oxanayoxana commented 5 years ago

I think that is wrong that we have repository_id field in projects table and also project_id in repository table. maybe it is good to make some joined table for these two like ProjectsRepository and have it this way: ProjectRepository belongs_to :project belongs_to :repository

Repository has many :project_repositories belongs_to :project, through: :project_repositories

Projects has many :project_repositories has many :repositories, through: :project_repositories

table for ProjectRepositories: t.index ["project_id"], name: "index_project_repositories_on_project_id" t.index ["repository_id"], name: "index_project_repositories_on_repository_id"

table Repositories: t.index ["project_id"], name: "index_repositories_on_project_id"

table Projects: do not add foreign keys for Repository nor for ProjectRepositories

I haven't tried that yet, maybe there's a solution without join table or I understand join table wrongly

Thanks for help!

andrzejkrzywda commented 5 years ago

I'm wondering if we need repositories as part of our data model.

What if instead we only have projects and a repository_url field?

andrzejkrzywda commented 5 years ago

@oxanayoxana The more I think about it, the more I feel that we don't need a separate concept of Repository (separate from Project). For now, I think, it's safe to assume that 1 project is 1 repo and that the Project has a name, has a github/gitlab repo url and maybe some description field.

oxanayoxana commented 5 years ago

I’ll try to do that like you suggest. (I hope tomorrow)