Skip to content

perdolle/maks_database_migration_tool

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 

Repository files navigation

Database Migration Tool

A simple JavaScript package for managing database migrations in Node.js applications.

Installation

You can install the Database Migration Tool via npm:

npm install database-migration-tool

Usage

const MigrationTool = require('database-migration-tool');

// Create an instance of MigrationTool with database connection options
const migrationTool = new MigrationTool({
  db: /* Your database connection */,
  migrationsDir: './migrations' // Optional: specify the directory containing migration files
});

// Migrate the database
migrationTool.migrate()
  .then(() => console.log('Database migration completed successfully'))
  .catch(error => console.error('Error migrating database:', error));

Migration Files

Migration files are JavaScript files that export objects with up and optionally down methods, responsible for applying and reverting the migration, respectively. Place your migration files in a directory (default: ./migrations).

Example migration file (./migrations/migration_1.js):

module.exports = {
  async up(db) {
    // Database-specific code to apply the migration
  },
  
  async down(db) {
    // Database-specific code to revert the migration
  }
};

License

This package is licensed under the MIT License. See the LICENSE file for details.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published