Skip to content

Commit fed7170

Browse files
author
Becky McInerney
committed
jdbc lab:
*added config files *updated dependencies *Changed TimeEntryRepository to an interface *Added jdbc connection and updated application bean to return JdbcTimeEntryRepository
1 parent b95b6c2 commit fed7170

22 files changed

Lines changed: 159 additions & 27 deletions

build.gradle

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
1+
import org.flywaydb.gradle.task.FlywayMigrateTask
2+
13
plugins {
24
id "java"
35
id "org.springframework.boot" version "1.5.4.RELEASE"
6+
id "org.flywaydb.flyway" version "4.2.0"
47
}
58

69
repositories {
@@ -10,13 +13,32 @@ repositories {
1013
dependencies {
1114
compile("org.springframework.boot:spring-boot-starter-web")
1215
compile("com.fasterxml.jackson.datatype:jackson-datatype-jsr310:2.9.1")
16+
compile("org.springframework.boot:spring-boot-starter-jdbc")
17+
18+
compile("mysql:mysql-connector-java:6.0.6")
19+
1320
testCompile("org.springframework.boot:spring-boot-starter-test")
1421
}
1522

23+
def developmentDbUrl = "jdbc:mysql://localhost:3306/tracker_dev?user=tracker&useSSL=false&useTimezone=true&serverTimezone=UTC&useLegacyDatetimeCode=false"
1624
bootRun.environment([
1725
"WELCOME_MESSAGE": "hello",
26+
"SPRING_DATASOURCE_URL": developmentDbUrl,
1827
])
1928

29+
def testDbUrl = "jdbc:mysql://localhost:3306/tracker_test?user=tracker&useSSL=false&useTimezone=true&serverTimezone=UTC&useLegacyDatetimeCode=false"
2030
test.environment([
2131
"WELCOME_MESSAGE": "Hello from test",
32+
"SPRING_DATASOURCE_URL": testDbUrl,
2233
])
34+
35+
flyway {
36+
url = developmentDbUrl
37+
user = "tracker"
38+
password = ""
39+
locations = ["filesystem:databases/tracker/migrations"]
40+
}
41+
42+
task testMigrate(type: FlywayMigrateTask) {
43+
url = testDbUrl
44+
}

ci/build.yml

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,18 @@ run:
1818
args:
1919
- -exc
2020
- |
21-
export TERM=${TERM:-dumb}
21+
22+
export DEBIAN_FRONTEND="noninteractive"
23+
24+
apt-get update
25+
26+
apt-get -y install mysql-server
27+
service mysql start
28+
2229
cd pal-tracker
30+
mysql -uroot < databases/tracker/create_databases.sql
2331
chmod +x gradlew
24-
./gradlew -P version=$(cat ../version/number) build
25-
cp build/libs/pal-tracker-*.jar ../build-output
32+
./gradlew -P version=$(cat ../version/number) testMigrate clean build || (service mysql stop && exit 1)
33+
service mysql stop
34+
35+
cp build/libs/pal-tracker-*.jar ../build-output

manifest-production.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,5 @@ applications:
33
- name: pal-tracker
44
path: build/libs/pal-tracker.jar
55
host: ps-pal-tracker-becky-allen
6+
services:
7+
- tracker-database

manifest-review.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,6 @@
22
applications:
33
- name: pal-tracker
44
path: build/libs/pal-tracker.jar
5-
host: ps-pal-tracker-review-becky-allen
5+
host: ps-pal-tracker-review
6+
services:
7+
- tracker-database
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
2.88 KB
Binary file not shown.
Binary file not shown.

0 commit comments

Comments
 (0)