-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Create flyway migration and database details (#57)
* Added postgres, flyway, and testcontainers for testing environment * Ditched spring data jpa, now using only jdbc * Add TODOs for production database
- Loading branch information
1 parent
3d6f836
commit 83f9136
Showing
7 changed files
with
125 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
25 changes: 25 additions & 0 deletions
25
src/main/java/com/danielvm/destiny2bot/config/FlywayConfiguration.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
package com.danielvm.destiny2bot.config; | ||
|
||
import org.flywaydb.core.Flyway; | ||
import org.springframework.boot.autoconfigure.flyway.FlywayProperties; | ||
import org.springframework.boot.autoconfigure.r2dbc.R2dbcProperties; | ||
import org.springframework.boot.context.properties.EnableConfigurationProperties; | ||
import org.springframework.context.annotation.Bean; | ||
import org.springframework.context.annotation.Configuration; | ||
|
||
@Configuration | ||
@EnableConfigurationProperties({R2dbcProperties.class, FlywayProperties.class}) | ||
public class FlywayConfiguration { | ||
|
||
@Bean(initMethod = "migrate") | ||
public Flyway flyway(FlywayProperties flywayProperties, R2dbcProperties r2dbcProperties) { | ||
return Flyway.configure() | ||
.dataSource( | ||
flywayProperties.getUrl(), | ||
r2dbcProperties.getUsername(), | ||
r2dbcProperties.getPassword()) | ||
.locations(flywayProperties.getLocations().get(0)) | ||
.baselineOnMigrate(true) | ||
.load(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
44 changes: 44 additions & 0 deletions
44
src/main/resources/db/migration/V1__Create_initial_tables.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
CREATE TABLE IF NOT EXISTS bungie_user | ||
( | ||
discord_id BIGINT PRIMARY KEY, | ||
discord_username VARCHAR(50) NOT NULL, | ||
bungie_membership_id BIGINT UNIQUE NOT NULL, | ||
bungie_access_token VARCHAR(250) UNIQUE NOT NULL, | ||
bungie_refresh_token VARCHAR(250) UNIQUE NOT NULL, | ||
bungie_token_expiration BIGINT NOT NULL | ||
); | ||
|
||
CREATE TABLE IF NOT EXISTS bungie_user_character | ||
( | ||
character_id BIGINT PRIMARY KEY, | ||
light_level INTEGER NOT NULL, | ||
destiny_class VARCHAR(10) NOT NULL, | ||
bungie_user_id BIGINT, | ||
FOREIGN KEY (bungie_user_id) REFERENCES bungie_user (bungie_membership_id) | ||
); | ||
|
||
CREATE TABLE IF NOT EXISTS character_raid | ||
( | ||
instance_id BIGINT PRIMARY KEY, | ||
raid_start_timestamp TIMESTAMP NOT NULL, | ||
is_from_beginning BOOLEAN NOT NULL, | ||
completed BOOLEAN NOT NULL, | ||
raid_name VARCHAR(100) NOT NULL, | ||
number_of_deaths INTEGER NOT NULL, | ||
oponents_defeated INTEGER NOT NULL, | ||
kill_death_assists DECIMAL NOT NULL, | ||
raid_duration INTEGER NOT NULL, | ||
user_character_id BIGINT, | ||
FOREIGN KEY (user_character_id) REFERENCES bungie_user_character (character_id) | ||
); | ||
|
||
CREATE TABLE IF NOT EXISTS raid_participant | ||
( | ||
membership_id BIGINT PRIMARY KEY, | ||
username VARCHAR(100) NOT NULL, | ||
character_class VARCHAR(10) NOT NULL, | ||
icon_path VARCHAR(100) NOT NULL, | ||
completed BOOLEAN NOT NULL, | ||
raid_instance BIGINT, | ||
FOREIGN KEY (raid_instance) REFERENCES character_raid (instance_id) | ||
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters