Skip to content

Commit 0af0682

Browse files
committed
initial commit
0 parents  commit 0af0682

34 files changed

+2208
-0
lines changed

README.md

+42
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
# java-cli-maven-mysql-liquibase-com-tbl-exp
2+
3+
## Description
4+
Creates a small database table
5+
called `dog`. This table, `dog`, has been normalized to 3NF.
6+
Two new tables have been added, `breedLookup` and `colorLookup`.
7+
Creates a new table `dog_expanded` that joins
8+
`dog`, `breedLookup` and `colorLookup`. Added clustered indexes on
9+
`dog`.breedId and `dog`.colorId and a non-clustered index for
10+
`dog_expanded`.id. Turned `dog_expanded` into a view with an
11+
implicit index on `dog_expanded`.id. Using a common table expression with the aggregate
12+
COUNT, create a new view `breed_count`. All output normally
13+
seen in a terminal will be in `java-srv/log` which will dump to the screen. The project may seem to hang but the logs from the container must be written to the project this can take up to 3 min.
14+
15+
Uses liquibase migration tool to augment
16+
the schema.
17+
18+
## Tech stack
19+
- java
20+
- liquibase
21+
- maven
22+
- log4j
23+
- mysql driver
24+
25+
## Docker stack
26+
- maven:3-openjdk-17
27+
- mariadb:latest
28+
- webdevops/liquibase:mysql
29+
30+
## To run
31+
`sudo ./install.sh -u`
32+
Creates java-srv/log
33+
34+
## To stop
35+
`sudo ./install.sh -d`
36+
Removes java-srv/log
37+
38+
## For help
39+
`sudo ./install.sh -h`
40+
41+
## Credit
42+
- [Java code based on](https://github.com/htorun/dbtableprinter)

db/sql/00-create-database.sql

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
CREATE DATABASE `animal`;

db/sql/01-grant-user.sql

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
GRANT ALL PRIVILEGES ON `animal`.* TO 'maria'@'%';
2+
FLUSH PRIVILEGES;

docker-compose.yml

+45
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
version: '3'
2+
services:
3+
java-srv:
4+
build: java-srv
5+
volumes:
6+
- ./java-srv/log:/root/log
7+
depends_on:
8+
- liquibase-srv
9+
links:
10+
- "db:db"
11+
12+
liquibase-srv:
13+
image: webdevops/liquibase:mysql
14+
command: update
15+
volumes:
16+
- ./liquibase-srv:/liquibase
17+
environment:
18+
- LIQUIBASE_URL=jdbc:mysql://db:3306/animal
19+
- LIQUIBASE_CHANGELOG=master.xml
20+
- LIQUIBASE_USERNAME=maria
21+
- LIQUIBASE_PASSWORD=pass
22+
depends_on:
23+
- db
24+
links:
25+
- db
26+
27+
db:
28+
image: mariadb:latest
29+
volumes:
30+
# - ./db/data_dump:/var/lib/mysqll
31+
- ./db/sql:/docker-entrypoint-initdb.d
32+
environment:
33+
- MYSQL_ALLOW_EMPTY_PASSWORD=true
34+
- MYSQL_USER=maria
35+
- MYSQL_PASSWORD=pass
36+
37+
# adminer:
38+
# image: adminer
39+
# restart: always
40+
# ports:
41+
# - 80:8080
42+
# depends_on:
43+
# - liquibase-srv
44+
# links:
45+
# - "db:db"

0 commit comments

Comments
 (0)