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

Add event logging to DB? #48

Open
ochompsky opened this issue Aug 25, 2024 · 2 comments
Open

Add event logging to DB? #48

ochompsky opened this issue Aug 25, 2024 · 2 comments

Comments

@ochompsky
Copy link

ochompsky commented Aug 25, 2024

It looks like it logs to a local h2 db, which is not ideal for docker containers without persistant storage. I wonder the feasibility of logging to an actual db server?

I'm going to play around with SnapAdminAutoConfiguration as that seems to be the place to do these changes.

Are you able to provide the DDL for internal table structures?

@ochompsky
Copy link
Author

ochompsky commented Aug 31, 2024

i've forked a version of this here https://github.com/ochompsky/snap-admin/tree/main

in that version, it will allow for a remotely specified db connection. in your properties you will need something like:

internal:
  datasource:
    driver-class-name: "org.postgresql.Driver"
    url: "jdbc:postgresql://server:5432/postgres"
    username: "user"
    password: "pass"
    hibernate-dialect: "org.hibernate.dialect.PostgreSQLDialect"
    hbm2ddl-auto: update

note that i've only tested it with postgres. i know for a fact it will not work with mysql because the column sql needs to be renamed. EDIT: i've also renamed it so now it should work with all common databases, but haven't tried h2 yet.

im not submitting a PR because it's a breaking change and really this needs to be changed to work with all common remote db's

EDIT2: @aileftech - do you want me to submit a PR? i've tested this change with the default H2, Postgres as well as MYSQL and it appears to work. the only downside is that will require a user to specify which one to use out of the box, i haven't implemented any default. but there's no reason they can't add the below properties along with other snapadmin ones:

internal:
  datasource:
    driver-class-name: "org.h2.Driver"
    url: "jdbc:h2:file:./snapadmin_internal"
    username: "sa"
    password: "password"
    hibernate-dialect: "org.hibernate.dialect.H2Dialect"
    hbm2ddl-auto: update

@BlackHornet
Copy link

I would suggest to just create that PR :) this is really a nice addition

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

No branches or pull requests

2 participants