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

[db] Implement new Team and Project entities #4368

Merged
merged 2 commits into from
Jun 4, 2021
Merged

Conversation

jankeromnes
Copy link
Contributor

@jankeromnes jankeromnes commented Jun 1, 2021

How to test

mysql> insert into d_b_team (id, name, creationDate) values (UUID(), 'YOUR TEAM', '2021-06-03T10:00:00.000Z');

mysql> select * from d_b_team;

mysql> select id, name from d_b_user;

mysql> insert into d_b_team_membership (id, teamId, userId) values (UUID(), 'YOUR-TEAM-ID', 'YOUR-USER-ID');
  • Refresh the dashboard -- the console should now log Teams: [{ ... }] (i.e. your team)

@jankeromnes
Copy link
Contributor Author

jankeromnes commented Jun 1, 2021

Migration seems to work as expected:

(view MySQL tables)
mysql> describe d_b_project;
+-------------------+--------------+------+-----+----------------------+--------------------------------+
| Field             | Type         | Null | Key | Default              | Extra                          |
+-------------------+--------------+------+-----+----------------------+--------------------------------+
| id                | char(36)     | NO   | PRI | NULL                 |                                |
| cloneURL          | varchar(255) | NO   |     | NULL                 |                                |
| teamId            | char(36)     | NO   | MUL | NULL                 |                                |
| appInstallationId | varchar(255) | NO   |     | NULL                 |                                |
| connectedSince    | varchar(255) | NO   |     | NULL                 |                                |
| deleted           | tinyint(4)   | NO   |     | 0                    |                                |
| _lastModified     | timestamp(6) | NO   | MUL | CURRENT_TIMESTAMP(6) | on update CURRENT_TIMESTAMP(6) |
+-------------------+--------------+------+-----+----------------------+--------------------------------+
7 rows in set (0.00 sec)

mysql> describe d_b_team;
+---------------+--------------+------+-----+----------------------+--------------------------------+
| Field         | Type         | Null | Key | Default              | Extra                          |
+---------------+--------------+------+-----+----------------------+--------------------------------+
| id            | char(36)     | NO   | PRI | NULL                 |                                |
| name          | varchar(255) | NO   |     | NULL                 |                                |
| creationDate  | varchar(255) | NO   |     | NULL                 |                                |
| deleted       | tinyint(4)   | NO   |     | 0                    |                                |
| _lastModified | timestamp(6) | NO   | MUL | CURRENT_TIMESTAMP(6) | on update CURRENT_TIMESTAMP(6) |
+---------------+--------------+------+-----+----------------------+--------------------------------+
5 rows in set (0.01 sec)

mysql> describe d_b_team_member;
+---------------+--------------+------+-----+----------------------+--------------------------------+
| Field         | Type         | Null | Key | Default              | Extra                          |
+---------------+--------------+------+-----+----------------------+--------------------------------+
| id            | char(36)     | NO   | PRI | NULL                 |                                |
| teamId        | char(36)     | NO   | MUL | NULL                 |                                |
| userId        | char(36)     | NO   | MUL | NULL                 |                                |
| deleted       | tinyint(4)   | NO   |     | 0                    |                                |
| _lastModified | timestamp(6) | NO   | MUL | CURRENT_TIMESTAMP(6) | on update CURRENT_TIMESTAMP(6) |
+---------------+--------------+------+-----+----------------------+--------------------------------+

Now I should probably add a few useful methods to the interfaces and verify they work.

@jankeromnes jankeromnes force-pushed the jx/teams-and-projects branch 2 times, most recently from c18f55e to c9f4aba Compare June 3, 2021 14:39
@jankeromnes jankeromnes marked this pull request as ready for review June 3, 2021 14:58

export const TeamDB = Symbol('TeamDB');
export interface TeamDB {
findTeamsByUser(userId: string): Promise<Team[]>;
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Potential improvements / follow-ups:

  • create a new team
  • delete a team
  • add user to team
  • remove user from team

components/gitpod-db/src/typeorm/entity/db-project.ts Outdated Show resolved Hide resolved
@Index("ind_userId")
userId: string;

// This column triggers the db-sync deletion mechanism. It's not intended for public consumption.
Copy link
Member

Choose a reason for hiding this comment

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

lets add creationTimeas well

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Why add a creationTime to a team membership? (Note: There is already the _lastModified field, and I don't expect that we'll modify memberships -- just add or delete.)

Copy link
Member

Choose a reason for hiding this comment

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

I cannot access _lastmodified can I? In the member list I'd like to see joined 2 months ago or so.

components/gitpod-db/src/typeorm/entity/db-team.ts Outdated Show resolved Hide resolved
components/dashboard/src/App.tsx Outdated Show resolved Hide resolved
Also:
- set up EditorConfig to trim trailing whitespaces
- install Docker VS Code extension by default
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.

2 participants