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

Remove unecessary dialect config #953

Merged
merged 1 commit into from
Mar 20, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
69 changes: 38 additions & 31 deletions README.md
Original file line number Diff line number Diff line change
@@ -28,9 +28,9 @@ Suricate uses WebSockets to control and update dashboards on external displays.
* [Download](#download)
* [Install](#install)
* [Configuration](#configuration)
* [Default Configuration](#default-configuration)
* [Database](#database)
* [H2 vs PostgreSQL](#h2-vs-postgresql)
* [H2](#h2)
* [PostgreSQL](#postgresql)
* [Initialization with Flyway](#initialization-with-flyway)
* [Authentication](#authentication)
* [Database](#database-1)
@@ -78,64 +78,66 @@ After running the command, the application will be accessible on http://localhos

## Configuration

### Default Configuration
### Database

By default, Suricate:
Suricate supports multiple database management systems:

- runs on a H2 file database
- provides a sign-in/sign-up authentication mode based on the database
- H2 (default)
- PostgreSQL

### Database
#### H2

#### H2 vs PostgreSQL
By default, Suricate runs on an H2 file database, activated through the `h2` profile in `application.yml`:

Suricate supports running on different database management systems (DBMS):
```yaml
spring:
profiles:
active: 'h2'
```

- H2
- PostgreSQL
This activates the `application-h2.yml` file, which contains the necessary H2 configuration.

#### PostgreSQL

You can define the DBMS you want to use in the `application.yml` file with the `spring.profiles.active`
parameter:
To switch to PostgreSQL, activate the `postgresql` profile:

```yaml
spring:
profiles:
active: ## Provider should be 'h2' or 'postgresql'
active: 'postgresql'
```

It will activate the default `application-DBMS.yml` configuration file with the required properties for the chosen DBMS.
This enables the `application-postgresql.yml` file, which contains the PostgreSQL-specific configuration.

You will still need to define your database connection properties in the `application.yml` file:
Additionally, you need to provide your database connection details in an external configuration file:

```yaml
spring:
datasource:
password: ''
url: ''
username: ''
url: '<your-database-url>'
username: '<your-username>'
password: '<your-password>'
```

Please note that the `application-DBMS.yml` files activate Flyway to automatically set up the database
structure (tables, constraints, etc.) and the minimum required functional data.

#### Initialization with Flyway

Suricate uses [Flyway](https://docs.spring.io/spring-boot/docs/2.0.0.M5/reference/html/howto-database-initialization.html) to manage the database initialization.
It is enabled by default to automatically set up the database structure (tables, constraints, etc.) and the minimum
required functional data at the first start of the application.
Suricate uses [Flyway](https://docs.spring.io/spring-boot/docs/2.0.0.M5/reference/html/howto-database-initialization.html) for database initialization.

Depending on the database management system you use, Flyway will use the appropriate scripts located in the
`src/main/resources/flyway` folder.
By default, Flyway:
- Automatically sets up the database structure (tables, constraints, etc.).
- Populates the database with the minimum required functional data on the first startup.

Flyway stores the current version of the database in a table named `schema_version` defined by the following property:
It applies the appropriate scripts based on your database management system. These scripts are located in `src/main/resources/flyway`.

Flyway maintains the database version in a table named `schema_version`, configured as:

```yml
spring:
flyway:
table: 'schema_version'
```

Flyway can be deactivated by setting the following property to `false`:
If needed, it can be disabled by setting:

```yml
spring:
@@ -145,9 +147,14 @@ spring:

### Authentication

Suricate provides multiple types of authentication that can be activated or deactivated based on your requirements.
Suricate supports multiple authentication methods:

- Database Authentication
- LDAP Authentication
- Social Login (OIDC - OpenID Connect)

Regardless of the method used, Suricate issues a JWT token to authenticate users on the backend.

All the authentication modes deliver a JWT token that is used to authenticate the user on the Back-End.
You can configure the JWT token using the following properties:

```yml
6 changes: 3 additions & 3 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -9,7 +9,7 @@ services:
volumes:
- postgres:/data/postgres
ports:
- '5432:5432'
- "5432:5432"
networks:
- suricate
restart: unless-stopped
@@ -18,13 +18,13 @@ services:
image: michelin/suricate
environment:
SPRING_PROFILES_ACTIVE: postgresql
SPRING_DATASOURCE_URL: 'jdbc:postgresql://postgres:5432/postgres?currentSchema=suricate'
SPRING_DATASOURCE_URL: "jdbc:postgresql://postgres:5432/postgres?currentSchema=suricate"
SPRING_DATASOURCE_USERNAME: ${POSTGRES_USER:-postgres}
SPRING_DATASOURCE_PASSWORD: ${POSTGRES_PASSWORD:-changeme}
networks:
- suricate
ports:
- 8080:8080
- "8080:8080"
depends_on:
- postgres
restart: unless-stopped
8 changes: 1 addition & 7 deletions src/main/resources/application-postgresql.yml
Original file line number Diff line number Diff line change
@@ -5,10 +5,4 @@ spring:
url: 'jdbc:postgresql://localhost:5432/postgres?currentSchema=suricate'
username: 'postgres'
flyway:
locations: 'classpath:flyway/postgresql'
jpa:
properties:
hibernate:
dialect: 'org.hibernate.dialect.PostgreSQLDialect'
temp:
use_jdbc_metadata_defaults: false
locations: 'classpath:flyway/postgresql'
3 changes: 0 additions & 3 deletions src/test/resources/application-configuration-test.yml
Original file line number Diff line number Diff line change
@@ -36,8 +36,5 @@ spring:
locations: 'classpath:flyway/postgresql,classpath:flyway/h2'
jpa:
open-in-view: false
properties:
hibernate:
dialect: 'org.hibernate.dialect.H2Dialect'
main:
banner-mode: 'off'
Original file line number Diff line number Diff line change
@@ -18,10 +18,5 @@ spring:
locations: 'classpath:flyway/postgresql'
jpa:
open-in-view: false
properties:
hibernate:
dialect: 'org.hibernate.dialect.PostgreSQLDialect'
temp:
use_jdbc_metadata_defaults: false
main:
banner-mode: 'off'
3 changes: 0 additions & 3 deletions src/test/resources/application-integration-test.yml
Original file line number Diff line number Diff line change
@@ -24,8 +24,5 @@ spring:
enabled: true
jpa:
open-in-view: false
properties:
hibernate:
dialect: 'org.hibernate.dialect.H2Dialect'
main:
banner-mode: 'off'