Skip to content

Commit

Permalink
SMA-27: Made H2 Data Persistent (#24)
Browse files Browse the repository at this point in the history
  • Loading branch information
markpernia authored Feb 6, 2024
1 parent da8bd6f commit 022c2c9
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 3 deletions.
4 changes: 4 additions & 0 deletions backend/sportsmatch/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -35,3 +35,7 @@ out/

### VS Code ###
.vscode/

### h2 database ###
./sportsmatch
*.db
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,14 @@ public static void main(String[] args) {

@Override
public void run(String... args) throws Exception {
addData();
checkRecords();
}

private void checkRecords() {
List<User> users = userRepository.findAll();
if (users.isEmpty()) {
addData();
}
}

public void addData() {
Expand Down
4 changes: 2 additions & 2 deletions backend/sportsmatch/src/main/resources/application.properties
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit 022c2c9

Please sign in to comment.