larvitdbmigration is a Node.js utility designed for managing database schema and data evolution through a versioned script approach. It supports both traditional relational databases like MariaDB (and MySQL) and NoSQL solutions such as Elasticsearch. Currently stable at version 7.0.188, the package appears to have an active release cadence, frequently publishing patches and minor features as indicated by the high patch number within the 7.x series. A key differentiator is its ability to handle migrations across diverse database types within a single framework. It utilizes simple JavaScript or SQL files for migration scripts, providing flexibility for complex logic or straightforward DDL statements. The tool automatically creates and updates a `db_version` table or index to track the current database state, ensuring migrations are applied only once and in the correct order.
npm install larvitdbmigrationVerified import paths — ran on the pinned version, not inferred.
Demonstrates how to initialize and run database migrations for MariaDB using environment variables for sensitive credentials, including a basic logger and an example migration script.
Review Elasticsearch configurations. If a custom HTTP client was provided, replace `got` with `axios`. Ensure any migration scripts using `got` are updated to `axios`.
Update imports to TypeScript syntax (`import { ... } from 'pkg'`). Review Elasticsearch migration scripts to ensure they only rely on `url` and `log` from the options object. Remove any code relying on Elasticsearch locking.Ensure only one migration file type (.js or .sql) exists per version. Use `.js` files for complex logic and `.sql` for simple DDL statements only when no `.js` file is present for that version.
Check for name conflicts with `db_version`. If a conflict exists or a different name is preferred, set the `tableName` or `indexName` option in the `DbMigration` constructor to a unique name.