Skip to content

Commit

Permalink
oppdatert flyway config
Browse files Browse the repository at this point in the history
  • Loading branch information
tofiksa committed Jul 25, 2024
1 parent 47f0b4a commit 9389061
Show file tree
Hide file tree
Showing 14 changed files with 66 additions and 34 deletions.
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@
<dependency>
<groupId>org.flywaydb</groupId>
<artifactId>flyway-core</artifactId>
<version>9.16.0</version>
<version>9.20.0</version>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
Expand Down
3 changes: 2 additions & 1 deletion src/main/java/no/josefushighscore/JosefusHighscore.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,9 @@

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.autoconfigure.flyway.FlywayAutoConfiguration;

@SpringBootApplication
@SpringBootApplication(exclude = {FlywayAutoConfiguration.class})
public class JosefusHighscore {

public static void main(String[] args) {
Expand Down
10 changes: 8 additions & 2 deletions src/main/java/no/josefushighscore/dto/UserDto.java
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,14 @@ public UserDto() {

}

public static User builder() {
return new User();
public static UserDto fromUser(User user) {
UserDto dto = new UserDto();
dto.setUsername(user.getUsername());
dto.setFirstname(user.getFirstname());
dto.setLastname(user.getLastname());
dto.setEmail(user.getEmail());

return dto;
}

public String getFullname() {
Expand Down
10 changes: 10 additions & 0 deletions src/main/java/no/josefushighscore/model/User.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import no.josefushighscore.dto.UserDto;
import org.springframework.security.core.GrantedAuthority;
import org.springframework.security.core.authority.SimpleGrantedAuthority;
import org.springframework.security.core.userdetails.UserDetails;
Expand Down Expand Up @@ -98,6 +99,15 @@ public Collection<? extends GrantedAuthority> getAuthorities() {
return this.roles.stream().map(SimpleGrantedAuthority::new).collect(toList());
}

public UserDto toDto() {
return new UserDto(
this.getUsername(),
this.getFirstname(),
this.getLastname(),
this.getEmail()
);
}

@Override
public String getPassword() {
return this.password;
Expand Down
3 changes: 1 addition & 2 deletions src/main/java/no/josefushighscore/service/UserService.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ public UserService(UserRegister userRepository) {
}

public Optional<User> getUserDetails(String username) {

return this.userRepository.getUserDetails(username);
return userRepository.getUserDetails(username);
}
}
49 changes: 29 additions & 20 deletions src/main/resources/application.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,17 +18,6 @@ spring:
FAIL_ON_UNKNOWN_PROPERTIES: false
ACCEPT_SINGLE_VALUE_AS_ARRAY: true
default-property-inclusion: non_empty
flyway:
url: ${spring.datasource.url}
schemas: josefushighscore
enabled: true
locations: classpath:/db/migration
user: ${SUPABASE_JOSEFUS_DB_USER}
password: ${SUPABASE_JOSEFUS_DB_PWD}
jwt:
secret: ${JOSEFUS_JWT_SECRET}
expiration-time: 3600000

datasource:
url: ${SUPABASE_JOSEFUS_DB_URL}
username: ${SUPABASE_JOSEFUS_DB_USER}
Expand All @@ -37,7 +26,20 @@ spring:
prepStmtCacheSize: 250
prepStmtCacheSqlLimit: 2048
useServerPrepStmts: true

flyway:
url: ${spring.datasource.url}
default-schema: josefushighscore
schemas:
- josefushighscore
enabled: true
locations: classpath:db/migration
user: ${SUPABASE_JOSEFUS_DB_USER}
password: ${SUPABASE_JOSEFUS_DB_PWD}
baselineOnMigrate: true
check-location: true
jwt:
secret: ${JOSEFUS_JWT_SECRET}
expiration-time: 3600000
jpa:
openInView: false
show_sql: false
Expand All @@ -46,16 +48,23 @@ spring:
ddl-auto: update
properties:
# fixes Caused by: java.sql.SQLFeatureNotSupportedException: Method org.postgresql.jdbc.PgConnection.createClob() is not yet implemented.
hibernate.jdbc.lob.non_contextual_creation: true
hibernate.default_schema: josefushighscore

hibernate:
jdbc:
lob:
non_contextual_creation: true
default_schema: josefushighscore
data:
jpa:
repositories.enabled: true

logging:
level:
org.springframework.web: INFO
org.springframework.security: Debug
org.hibernate.SQL: debug
org.hibernate.type.descriptor.sql: trace
org:
springframework:
web: INFO
security: INFO
hibernate:
SQL: debug
type:
descriptor:
sql: trace
flywaydb: INFO

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
CREATE TABLE IF NOT EXISTS USER (
CREATE TABLE IF NOT EXISTS josefushighscore."user" (
user_id bigint NOT NULL,
email varchar(255),
firstname varchar(255),
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
CREATE TABLE IF NOT EXISTS josefushighscore.user_roles (
user_id bigint NOT NULL,
roles varchar(255)
);
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
CREATE TABLE IF NOT EXISTS SCORE (
CREATE TABLE IF NOT EXISTS josefushighscore.score (
score_id bigint NOT NULL,
score bigint NOT NULL,
created_at timestamp without time zone NOT NULL,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
CREATE TABLE IF NOT EXISTS GAME (
CREATE TABLE IF NOT EXISTS josefushighscore.game (
game_id bigint NOT NULL,
created_at timestamp without time zone NOT NULL,
updated_at timestamp without time zone NOT NULL,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
ALTER TABLE josefushighscore.user_roles ADD COLUMN role_id bigint;
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
-- Add supabase_id column to User table in josefushighscore schema
ALTER TABLE josefushighscore."user" ADD COLUMN supabase_id UUID;

-- Add foreign key constraint
ALTER TABLE josefushighscore."user" ADD CONSTRAINT fk_user_supabase_id
FOREIGN KEY (supabase_id)
REFERENCES auth.users(id);

0 comments on commit 9389061

Please sign in to comment.