Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/duskpoet/martlet
Migrate your database schema in a simple manner
https://github.com/duskpoet/martlet
Last synced: 9 days ago
JSON representation
Migrate your database schema in a simple manner
- Host: GitHub
- URL: https://github.com/duskpoet/martlet
- Owner: duskpoet
- License: mit
- Created: 2024-05-03T15:37:53.000Z (7 months ago)
- Default Branch: main
- Last Pushed: 2024-07-26T11:12:09.000Z (4 months ago)
- Last Synced: 2024-07-26T13:17:26.168Z (4 months ago)
- Language: JavaScript
- Homepage:
- Size: 123 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
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
```bash
npm i -g martlet
```## Usage
Put migration files in a directory named `migrations` in the root of your project. Files should have the following naming pattern:
```
_.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:**
```sql
create table users (
id serial primary key,
name text not null
);-- up/down --
drop table users;
``````bash
martlet --help
```### Commands
#### Up
```bash
martlet up --database-url postgres://user:password@localhost:5432/dbname
```#### Down
```bash
martlet down 0 --database-url postgres://user:password@localhost:5432/dbname
```## Reasoning
Node js ecosystem has many database migration tools, some are independent, some are parts of ORM libraries.
I needed a simple and minimalistic tool that can just apply migrations written as sql in `.sql` files, and have up and down migrations in a single file, to enable Copilot write down migrations for me :)