Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file added asset/sql_flyway.webp
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
19 changes: 19 additions & 0 deletions core/db_in_docker/Readme.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# Database in docker

What I would like to achieve here it to have a database in Docker,
also with a supported data migration tool.

After some research, I choose PostgresSQL as databse and Flyway as data migration tool to achieve this functionality.

![big](/asset/sql_flyway.webp)



### reference:
[https://www.sqltutorial.org/sql-list-all-tables/](https://www.sqltutorial.org/sql-list-all-tables/)

[https://blog.devgenius.io/tips-and-tricks-to-using-postgresql-docker-image-80047673c9a5](https://blog.devgenius.io/tips-and-tricks-to-using-postgresql-docker-image-80047673c9a5)


TODO:
How to mirgate a csv file into DB?
20 changes: 20 additions & 0 deletions core/db_in_docker/docker-compose.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
services:

postgres:
restart: always
image: postgres:12.14
environment:
- POSTGRES_PASSWORD=pwd
ports:
- "0.0.0.0:5432:5432"
command: ["-c", "fsync=false"]

flyway:
image: boxfuse/flyway:5.2.4
environment:
- FLYWAY_CONNECT_RETRIES=60
volumes:
- ./src/db_migration:/flyway/sql/
depends_on:
- postgres
command: migrate -url=jdbc:postgresql://postgres:5432/postgres -user=postgres -password=pwd -connectRetries=60
5 changes: 5 additions & 0 deletions core/db_in_docker/src/db_migration/V1__create_table.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
CREATE TABLE person (
id serial PRIMARY KEY,
first_name varchar(50),
last_name varchar(50)
);