diff --git a/asset/sql_flyway.webp b/asset/sql_flyway.webp new file mode 100644 index 0000000..dd6491a Binary files /dev/null and b/asset/sql_flyway.webp differ diff --git a/core/db_in_docker/Readme.md b/core/db_in_docker/Readme.md new file mode 100644 index 0000000..356b6c2 --- /dev/null +++ b/core/db_in_docker/Readme.md @@ -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? \ No newline at end of file diff --git a/core/db_in_docker/docker-compose.yaml b/core/db_in_docker/docker-compose.yaml new file mode 100644 index 0000000..a56bbab --- /dev/null +++ b/core/db_in_docker/docker-compose.yaml @@ -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 diff --git a/core/db_in_docker/src/db_migration/V1__create_table.sql b/core/db_in_docker/src/db_migration/V1__create_table.sql new file mode 100644 index 0000000..85243b8 --- /dev/null +++ b/core/db_in_docker/src/db_migration/V1__create_table.sql @@ -0,0 +1,5 @@ +CREATE TABLE person ( + id serial PRIMARY KEY, + first_name varchar(50), + last_name varchar(50) +);