Some additional lints for Schemacrawler
The main purpose of this lint library is to enhance native schemacrawler lints with some more hardcore constraints and some specific postgres types. That's why a postgreSQL database instance is required to test.
This project has been created to be used at our former office Mairie de la Ville de Nouméa to test our database schema quality in a more easy way and make it possible for our partners to apply our database quality policy the easy way.
Notice that this version is designed to run on schemacrawler 14.x.x
...
and hence is requiring JDK-1.8 to be built and run.
For now the jar is not available on maven central repo, so you'll have to build it yourself :
git clone https://github.com/mbarre/schemacrawler-additional-lints.git schemacrawler-additional-lints
cd schemacrawler-additional-lints
export LINT_VERSION=1.02.02
Build without testing as a local postgres install is required to test.
mvn install -Dmaven.test.skip=true
cp target/schemacrawler-additional-lints-${LINT_VERSION}.jar $SCHEMACRAWLER_HOME/lib
... and you're done, you just have to pass your normal schemacrawler lint command and enjoy.
To be able to test locally, assuming you have a locally postgreSQL instance
up and running with the proper superuser
account, then run the following
commands
dropdb --if-exists sc_lint_test
createdb sc_lint_test
mvn install
cp target/schemacrawler-additional-lints-${LINT_VERSION}.jar $SCHEMACRAWLER_HOME/lib
Or, install Docker Compose to deploy PostgreSQL and the database
docker-compose -f docker/postgresql.yml up
mvn install
cp target/schemacrawler-additional-lints-${LINT_VERSION}.jar $SCHEMACRAWLER_HOME/lib
Schemacrawler Additional Lints is now released with an image on Docker Hub. This is an extension of the SchemaCrawler Docker Image.
You can run docker container like this :
docker run --name schemacrawler-additional-lints --rm -i -t --entrypoint=/bin/bash --net=host mbarre/schemacrawler-additional-lints
--net=host option will allow you to work on database deployed on your host.
Use the Schemacrawler Interactive Shell
schemacrawler --shell
Use the following script from within the shell to launch the lints analysis :
connect --server=your_db_server --database=your_db --user=your_user
load --info-level=minimum
execute --command lint
Or, simplier...
schemacrawler --server=your_db_server --database=your_db --user=your_user --info-level=minimum --command lint
The docker image also includes the command which export lints in csv files, for more information see adriens/schemacrawler-additional-command-lints-as-csv
You can try it this way :
schemacrawler --server=your_db_server --database=your_db --user=your_user --info-level=minimum --command csv
A default linter config file is available in the schemacrawler container home directory : schemacrawler-linter-config.xml. You can use it to include or exclude tables, change the lints severity, by adding --linter-configs=schemacrawler-linter-config.xml to lint and csv commands.
Check that dependencies are up-to-date :
mvn versions:display-dependency-updates
Check that plugins are up-to-date :
mvn versions:display-plugin-updates
schemacrawler -server=postgresql -host=localhost -port=5432 -database=pdc -user=pdc_adm -password=pdc_adm -infolevel=maximum -schemas=pdc_adm -loglevel=INFO -c=lint --outputfile=lint_pdc.html -outputformat=html
If you like this lint library, you can donate :
- Stars on github
- Ideas for new lints
- Code for new lints
- Code to increase code coverage
- Create issue
- A nice logo
- Feebdack on this library
- Anything you think that could make us happy to go on developing this library, including just some kind words on our gitter
To Jetbrains for offering an IntelliJ IDEA Free Open Source License to this project contributors.