Sign in or sign up before continuing. Don't have an account yet? Register now to get started.
BE: Add new workspace ports table
<!--IssueSummary start-->
<details>
<summary>
Everyone can contribute. [Help move this issue forward](https://handbook.gitlab.com/handbook/marketing/developer-relations/contributor-success/community-contributors-workflows/#contributor-links) while earning points, leveling up and collecting rewards.
</summary>
- [Work on this issue](https://contributors.gitlab.com/manage-issue?action=work&projectId=278964&issueIid=509815)
- [Close this issue](https://contributors.gitlab.com/manage-issue?action=close&projectId=278964&issueIid=509815)
</details>
<!--IssueSummary end-->
MR: Pending
<!--
The first line of this issue description must be one of the following:
1. `MR: Pending`
2. `MR: <MR link with trailing +>`,
3. If there are multiple MRs:
```
MRs:
- <MR 1 link with trailing +>`
- <MR 2 link with trailing +>`
- ...
```
4. `MR: No MR`
...and the first description line of the MR should be `Issue: <Issue link with trailing +>`
For more context, see:
https://about.gitlab.com/handbook/engineering/development/dev/create/ide/index.html#relationship-of-issues-to-mrs
-->
<!--
The following sections should be filled out as part of the refinement process before the issue is prioritized.
For more context, see:
https://about.gitlab.com/handbook/engineering/development/dev/create/ide/#2-pre-iteration-planning-meeting
-->
## Description
We want to introduce a new database table workspace_ports that will save data about ports that have been opened/closed by a user from within the workspace. We will use this data to determine which ports need to be exposed in k8s through a service by the gitlab-agent.
## Acceptance Criteria
- [ ] Migration to add new workspace_ports table
- [ ] Ask DB experts for viability of this data [migration](https://gitlab.com/gitlab-org/gitlab/-/merge_requests/174932/diffs?commit_id=4931fa7efc724de1c95423b2280fff8cf4d46fec). See the conversation [here](https://gitlab.com/gitlab-org/gitlab/-/issues/509828#note_2273035665) for more context.
- [ ] Add ports for existing workspaces in the workspace_ports table (Migration/Add during reconcile) based on feedback.
- [ ] Add new `WorkspacePort` model to the remote development module
- [ ] Associations for `workspace` and `user` added
- [ ] Add validation to test presence of all non nullable fields
- [ ] Entry in db/docs created for the new workspace_ports table
- [ ] Spec factory added for workspace_ports
- [ ] Add model specs
## Technical Requirement
- Fields for `workspace_ports` table:
* workspace_id (int, fk, indexed)
* port_number (int, not null)
* port_type (smallint, not null, [0: 'default', 1: 'user_defined'])
<!-- Replace with other type, e.g. bug or maintenance, if appropriate -->
<!-- Replace with other subtype if appropriate -->
<!-- By default, all issues start in the unprioritized status. See https://handbook.gitlab.com/handbook/engineering/development/dev/create/remote-development/#-planning-process -->
<!-- For simplicity and to avoid triage bot warnings about missing workflow labels, we will default to issues starting at the refinement phase -->
issue