npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

liquibase-linter

v0.1.1

Published

A liquibase linter in JS

Downloads

265

Readme

Liquibase linter

This linter is meant to check if your liquibase migrations follow some best practices.

⚠️ Only works for json and yaml formatted liquibase migrations

Available rules

Do not use breaking changes

This rule is meant to not introduce breaking changes carelessly. Following changes are checked, as they introduce a breaking change in your database schema:

  • dropColumn
  • dropTable
  • renameColumn
  • renameTable

Sometimes, you will want to use one of these type of change. If you are sure that it is safe (no consumer is needing a column, for instance), you can still use it by adding the changelog in a .liquibase-linter-ignore.yaml file

How to use the linter ?

For now, the linter is only available in a JavaScript script. You need to:

  1. Install the dependency (npm install liquibase-linter --save-dev or yarn add --dev liquibase-linter)
  2. Create a JavaScript file where you import the dependency
  3. Specify the path name of the file you want to check
import { lint } from "liquibase-linter";

lint("my/file/path.yaml");

Example in combination with danger.js

import { fail, warn, danger } from "danger";
import { lint } from "liquibase-linter";

const updatedFiles = [...danger.git.created_files, ...danger.git.modified_files];

const liquibaseConfig = {
  failOnErrors: false,
  liquibaseLinterIgnorePath: ".liquibase-linter-ignore.yaml",
};

const loggerByLevel = {
  WARNING: warn,
  ERROR: fail,
};

const liquibaseLinterViolations = updatedFiles
  .filter(fileName => fileName.includes("src/main/resources/db/changelog"))
  .flatMap(fileName => lint(fileName, liquibaseIgnoreConfig));

liquibaseLinterViolations.forEach(violation =>
  loggerByLevel[violation.level](
    `Changeset ${violation.changeSetId} from ${violation.fileName} fails with message: \n    ${violation.message}`
  )
);

Liquibase Linter Ignore

You can create a liquibase linter ignore file to ignore some of the violations reported by the linter if you know the changes provided are safe.

For instance, if you add this file, the violations related to the changeSet 1623249542074-24 in your db/changes/20210609163846-failing-changeset.yaml migration file will be ignored.

.liquibase-linter-ignore.yaml

ignores:
  - fileName: db/changes/20210609163846-failing-changeset.yaml
    changeSet: 1623249542074-24