twenty/packages/twenty-server
Charles Bochet e976a1bdfc
Uniformize datasources (#5196)
## Context

We recently enabled the option to bypass SSL certificate authority
validation when establishing a connection to PostgreSQL. Previously, if
this validation failed, the server would revert to unencrypted traffic.
Now, it maintains encryption even if the SSL certificate check fails. In
the process, we overlooked a few DataSource setups, prompting a review
of DataSource creation within our code.

## Current State

Our DataSource initialization is distributed as follows:
- **Database folder**: Contains 'core', 'metadata', and 'raw'
DataSources. The 'core' and 'metadata' DataSources manage migrations and
static resolver calls to the database. The 'raw' DataSource is utilized
in scripts and commands that require handling both aspects.
- **typeorm.service.ts script**: These DataSources facilitate
multi-schema connections.

## Vision for Discussion
- **SystemSchema (formerly core) DataSource**: Manages system schema
migrations and system resolvers/repos. The 'core' schema will be renamed
to 'system' as the Core API will include parts of the system and
workspace schemas.
- **MetadataSchema DataSource**: Handles metadata schema migrations and
metadata API resolvers/repos.
- **(Dynamic) WorkspaceSchema DataSource**: Will be used in the Twenty
ORM to access a specific workspace schema.

We currently do not support cross-schema joins, so maintaining these
DataSources separately should be feasible. Core API resolvers will
select the appropriate DataSource based on the field context.
- **To be discussed**: The potential need for an AdminDataSource (akin
to 'Raw'), which would be used in commands, setup scripts, and the admin
panel to connect to any database schema without loading any model. This
DataSource should be reserved for cases where utilizing metadata,
system, or workspace entities is impractical.

## In This PR
- Ensuring all existing DataSources are compliant with the SSL update.
- Introducing RawDataSource to eliminate the need for declaring new
DataSource() instances in commands.
2024-04-27 11:43:44 +02:00
..
@types Compile with swc on twenty-server (#4863) 2024-04-14 09:09:51 +02:00
patches Fix workspace schema caching when user is not logged in (#5173) 2024-04-25 14:45:14 +02:00
scripts Uniformize datasources (#5196) 2024-04-27 11:43:44 +02:00
src Uniformize datasources (#5196) 2024-04-27 11:43:44 +02:00
test feat: refactor folder structure (#4498) 2024-03-15 14:40:58 +01:00
.env.example GH-3546 Recaptcha on login form (#4626) 2024-04-25 23:52:28 +02:00
.env.test File token chores (#4664) 2024-03-26 13:42:09 +01:00
.eslintrc.cjs chore: extend root eslint config in twenty-server (#5101) 2024-04-22 17:34:24 +02:00
.gitignore feat: workspace:health nullable fix (#3882) 2024-02-08 18:22:29 +01:00
.prettierignore Migrate to a monorepo structure (#2909) 2023-12-10 18:10:54 +01:00
.prettierrc Migrate to a monorepo structure (#2909) 2023-12-10 18:10:54 +01:00
.swcrc Compile with swc on twenty-server (#4863) 2024-04-14 09:09:51 +02:00
jest.config.ts Refactor backend folder structure (#4505) 2024-03-15 18:37:09 +01:00
nest-cli.json Compile with swc on twenty-server (#4863) 2024-04-14 09:09:51 +02:00
package.json Bump version to 0.10.3 2024-04-26 17:52:13 +02:00
project.json chore: extend root eslint config in twenty-server (#5101) 2024-04-22 17:34:24 +02:00
tsconfig.build.json chore: set up twenty-emails config so build isn't needed in development (#3619) 2024-01-29 06:17:12 -03:00
tsconfig.json 4586 fix workspace member feature (#4680) 2024-03-28 17:59:48 +01:00