Mads Hartmann b43fbfa22f
Add tests for findAllWorkspaceAndInstances (#4120)
* Add test for findAllWorkspaceAndInstances

The test is currently failing with a missing database error. I think
this is a problem with the test database setup rather than the specific
test

* Resolve failing test

Turns out that TypeORM column names are case sensitive when used for
ordering. The error message is terrible

    Cannot read property 'databaseName' of undefined

In this case we used contextUrl and it should have been contextURL.

While column names in mysql are case insensitive I also fixed one other
occurrence of contextUrl even though it is not necessary; but using the
column names makes it easier to find when searching for references etc.

* Add a launch configuration for db-test

* Add more assertions to the test
2021-05-28 13:58:32 +02:00
..
2020-08-25 09:25:15 +00:00
2020-08-25 09:25:15 +00:00

Gitpod-db

Contains all the database related functionality, implemented using typeorm.

Adding a new table

  1. Create a migration - use the baseline as an exemplar
  2. Create a new entity that implements the requisite interface or extend an existing entity as required - see db-user.ts
  3. If it is a new table, create the matching injectable ORM implementation and interface (if required) - see user-db-impl.ts and user-db.ts. Otherwise extend the existing interface and implementation as required.
  4. Add the injectable implementation to the DB container module, binding the interface and implementation as appropriate, otherwise it will not be instantiated correctly e.g.
    bind(TypeORMUserDBImpl).toSelf().inSingletonScope();
    bind(UserDB).toService(TypeORMUserDBImpl);
  1. Add the new ORM as an injected component where required e.g. in user-controller.ts
    @inject(UserDB) protected readonly userDb: UserDB;