Skip to content

Commit

Permalink
Add MySQL prisma schema and doc update
Browse files Browse the repository at this point in the history
  • Loading branch information
anthonyolazabal committed Oct 26, 2023
1 parent be94fcd commit dadf71d
Show file tree
Hide file tree
Showing 12 changed files with 986 additions and 92 deletions.
3 changes: 2 additions & 1 deletion .dockerignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,5 @@ deployments
postman
.DS_Store
.env
.git
.git
notes.txt
2 changes: 1 addition & 1 deletion .env
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
DATABASE_URL="postgresql://hivemq:hivemq@192.168.69.230:5432/hivemq?schema=public"
DATABASE_URL="mysql://hivemq:hivemq@127.0.0.1:3306/hivemq"
TOKEN_KEY="@lsirfgjoirnkk!!"
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -396,3 +396,5 @@ FodyWeavers.xsd

# JetBrains Rider
*.sln.iml

notes.txt
19 changes: 15 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -78,21 +78,27 @@ Sync dev to DB (need to have a valid connection string in the DATABASE_URL envir
```
npx prisma migrate dev
```

Based on the database needed, the good prisma schema as to be used (renamed):
- schema.prisma.mysql
- schema.prisma.postgres

## Database compatibility
Thanks to Prisma, we can connect to several types of database engine with the same code. Here is the status of tests and validations carried out on the various engines compatible with the security extension.
[Full list of supported version](https://docs.hivemq.com/ese/4.20/enterprise-security-extension/ese#sql-db-versions)

| DB | Tested | Validated | Connection string format |
|---------------|:------:|:---------:|:--------------------------------------------------------------------------------------------------------------------:|
| PostgreSQL | YES | YES | postgresql://username:password@server:port/database_name?schema=public |
| MariaDB | NO | NO | mysql://USER:PASSWORD@HOST:PORT/DATABASE |
| MySQL | NO | NO | mysql://USER:PASSWORD@HOST:PORT/DATABASE |
| MariaDB | YES | YES | mysql://USER:PASSWORD@HOST:PORT/DATABASE |
| MySQL | YES | YES | mysql://USER:PASSWORD@HOST:PORT/DATABASE |
| SQL Server | NO | NO | sqlserver://HOST:PORT;database=DATABASE;user=USER;password=PASSWORD;encrypt=true |
| Azure SQL | NO | NO | sqlserver://HOST:PORT;database=DATABASE;user=USER;password=PASSWORD;encrypt=true |
| Amazon Aurora | NO | NO | mysql://USER:PASSWORD@HOST:PORT/DATABASE |

[More details on configuring Prisma connection string](https://www.prisma.io/docs/concepts/database-connectors)


## Database preparation
The schema of the Enterprise Security Extension remain untouched. The authentication on the API and the UI is done with the accounts that are in the resp_api_users table.
To be able to access the user needs to have the eseapi_admin role assigned which has himself the eseapiadmin permission.
Expand Down Expand Up @@ -134,13 +140,18 @@ where rest_api_users.username = 'eseapiadmin'

## Build Docker Image
```
docker build -t ese-companion --platform linux/amd64 .
docker build -t ese-companion-dbflavor --platform linux/amd64 .
```
(Platform is specified when other CPU than AMD64 are used like ARM)

## Run Docker image

At the moment two DB flavors are available (later on SQL Server is in the roadmap) :
- [PostgreSQL version](https://hub.docker.com/repository/docker/anthonyolazabal/ese-companion-postgresql/general)
- [MySQL version](https://hub.docker.com/repository/docker/anthonyolazabal/ese-companion-mysql/general)

```
docker run --env=TOKEN_KEY=@JwTT0k3nK3y!!!@JwTT0k3nK3y!!! --env=DATABASE_URL=postgresql://hivemq:[email protected]:5432/hivemq-ese-dev?schema=public -p 3301:3001 -d ese-companion:latest
docker run --env=TOKEN_KEY=@JwTT0k3nK3y!!!@JwTT0k3nK3y!!! --env=DATABASE_URL=postgresql://hivemq:[email protected]:5432/hivemq-ese-dev?schema=public -p 3301:3001 -d ese-companion-dbflavor:latest
```

Two important environment variables are needed :
Expand Down
6 changes: 3 additions & 3 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "ESE_Editor",
"name": "ESE_Companion",
"version": "1.0.0",
"description": "ESE Api and UI for HiveMQ ESE Database",
"description": "ESE Api and UI for HiveMQ Enterprise Security extension database",
"main": "index.js",
"scripts": {
"build-app": "npm run build-client && npm install && npm start",
Expand Down Expand Up @@ -29,4 +29,4 @@
"devDependencies": {
"nodemon": "^2.0.22"
}
}
}
Loading

0 comments on commit dadf71d

Please sign in to comment.