martlet

0.0.3 • Public • Published

Migrate your database schema in a simple manner.

Martlet project provides a seamless way to manage database schema versions leveraging PostgreSQL (other databases will be added later). Through a CLI interface, users can execute up or down migrations. The software's core functionality lies in applying migrations in a transaction, handling database connections, and dynamically loading the database driver as needed.

Installation

npm i -g martlet
yarn global add martlet

Usage

Put migration files in a directory named migrations in the root of your project. Files should have the following naming pattern:

<version>_<name>.sql

Example:

001_create_table.sql
002_add_column.sql

Inside the migration file, you can write SQL statements to create or modify the database schema. The up queries should be separated from the down queries by a -- up/down -- comment.

Example:

create table users (
    id serial primary key,
    name text not null
);

-- up/down --

drop table users;
martlet --help

Commands

Up

martlet up --database-url postgres://user:password@localhost:5432/dbname

Down

martlet down 0 --database-url postgres://user:password@localhost:5432/dbname

Package Sidebar

Install

npm i martlet

Weekly Downloads

138

Version

0.0.3

License

MIT

Unpacked Size

13.1 kB

Total Files

16

Last publish

Collaborators

  • duskpoet