diff --git a/backend/sportsmatch/.gitignore b/backend/sportsmatch/.gitignore index c2065bc2..dbdc3dc9 100644 --- a/backend/sportsmatch/.gitignore +++ b/backend/sportsmatch/.gitignore @@ -35,3 +35,7 @@ out/ ### VS Code ### .vscode/ + +### h2 database ### +./sportsmatch +*.db \ No newline at end of file diff --git a/backend/sportsmatch/src/main/java/com/sportsmatch/SportsmatchApplication.java b/backend/sportsmatch/src/main/java/com/sportsmatch/SportsmatchApplication.java index 826ce3cf..26f19ee5 100644 --- a/backend/sportsmatch/src/main/java/com/sportsmatch/SportsmatchApplication.java +++ b/backend/sportsmatch/src/main/java/com/sportsmatch/SportsmatchApplication.java @@ -32,7 +32,14 @@ public static void main(String[] args) { @Override public void run(String... args) throws Exception { - addData(); + checkRecords(); + } + + private void checkRecords() { + List users = userRepository.findAll(); + if (users.isEmpty()) { + addData(); + } } public void addData() { diff --git a/backend/sportsmatch/src/main/resources/application.properties b/backend/sportsmatch/src/main/resources/application.properties index b1569583..f8872f49 100644 --- a/backend/sportsmatch/src/main/resources/application.properties +++ b/backend/sportsmatch/src/main/resources/application.properties @@ -1,11 +1,11 @@ -spring.datasource.url=jdbc:h2:mem:testdb +spring.datasource.url=jdbc:h2:file:./sportsmatch +spring.jpa.hibernate.ddl-auto=update spring.datasource.driver-class-name=org.h2.Driver spring.datasource.username=sa spring.datasource.password=password spring.jpa.database-platform=org.hibernate.dialect.H2Dialect spring.jpa.show-sql=true spring.h2.console.enabled=true - spring.mvc.hiddenmethod.filter.enabled=true jwt.secret=56e1a2c8b7a56f5c480cf0045186dbc514d9172e4fbbc81dd82f541384274c3c \ No newline at end of file