May 26, 2021
Tip 1 #
You have done some commits to your git repository and one of your mates that doesn’t have access to it wants to see the difference between two versions.
npm install -g diff2html-cli
Find the revision number and determine the file you want to check, then run the command:
diff2html <revision-number> path/to/file.ext
It will automatically open the browser and show the diff just like GitHub does it. Later you can save the html page and send it to your mate.
Tip 2 #
Assume that you have a dedicated repository with SQL Schema migrations for your project. In order to quickly run some test against it or use that database schema in other projects you might want to package it with Docker image and store in your registry.
I will use MySQL in this example.
Prepare your migrations in a directory in an ascendant order, like that:
/migrations 00001_init.sql 00002_create_user_table.sql 00003_drop_user_table.sql
Create Dockerfile. Pay attention that we are copying all the migration file to
During the build entrypoint script will run all the sql files against the database.
FROM mysql/mysql-server:8.0.25 ADD ./migrations/* /docker-entrypoint-initdb.d EXPOSE 3306
Build and run your container.
docker build -t <image_name> . docker run --rm -p 3306:3306 -e MYSQL_ROOT_PASSWORD=<password> -e MYSQL_DATABASE=<database_name> <image_name>
Note that you should pass
MYSQL_DATABASE variable, otherwise it will fail, because you don’t have any database.