Microservice referring to the Video Catalog Administration backend
Using Clean Architecture, DDD, TDD and the best practices
- JDK 17
- Docker
- Clone the repository:
git clone https://github.com/LeonardoBatistaCarias/codeflix-admin-catalog-java.git
- Up MySQL Database with Docker:
docker-compose up -d
- Run MySQL Migrations with Flyway:
./gradlew flywayMigrate
- Run the application as SpringBoot app:
./gradlew bootRun
O banco de dados principal é um MySQL e para subir localmente vamos utilizar o Docker. Execute o comando a seguir para subir o MySQL:
The main database is a MySQL and to up it locally we will use the Docker. Run the following command to up MySQL:
docker-compose up -d
If this is the first time you are up the database, it is necessary
to perform SQL migrations with the flyway
tool.
Run the following command to run the migrations:
./gradlew flywayMigrate
It's possible to clean (delete all tables) your database, just run the following command:
./gradlew flywayClean
There are two ways to generate an inconsistency in Flyway by leaving it in the repair state:
- Some error migration SQL file;
- Some migration file already applied has been changed (by modifying the
checksum
).
When this happens the flyway will be in a repair state.
with a record in the flyway_schema_history
table with error (success = 0
).
To run the repair, fix the files and run:
./gradlew flywayRepair
With the above command Flyway will clear the records with error from the flyway_schema_history
table,
then run the FlywayMigrate command to try to migrate them again.
In addition to the commands already shown, we have some very useful ones like info and validate:
./gradlew flywayInfo
./gradlew flywayValidate
To know all available commands: Flyway Gradle Plugin
In build.gradle
, Flyway is configured to first read the variables from
FLYWAY_DB
, FLYWAY_USER
and FLYWAY_PASS
environment and then use a default value
if you can't find them. With that, to point to another environment just overwrite
these variables when executing the commands, for example:
FLYWAY_DB=jdbc:mysql://prod:3306/adm_videos FLYWAY_USER=root FLYWAY_PASS=123h1hu ./gradlew flywayValidate