GitHub release (latest SemVer) (Deno) GitHub Workflow Status (branch) (query-builder) (clients) nest badge


Nessie logo

A modular database migration tool for Deno inspired by Laravel. Currently supports PostgreSQL, MySQL and SQLite.

If you would like to see your DB flavor supported, take a look at how to make a client plugin with examples in the clients folder or in the section How to make a client.

See documentation for the query builder.

See documentation for the clients.

Nessie is available through:


  • init: Generates a nessie.config.ts file

    deno run --allow-net --allow-read --allow-write init

  • make [name]: Create migration

    deno run --allow-net --allow-read --allow-write make create_users

  • make:seed [name]: Create seed

    deno run --allow-net --allow-read --allow-write make:seed create_users

  • migrate [amount?]: Run migration - will migrate your migrations in your migration folder (sorted by timestamp) newer than the latest migration in your db. Amount defines how many migrations, defaults to all available if not set.

    deno run --allow-net --allow-read migrate

    deno run --allow-net --allow-read migrate 1

    deno run --allow-net --allow-read migrate -c ./nessie.config.ts

  • rollback [amount?]: Rollback - will rollback your migrations. Amount defines how many migrations, defaults to 1 if not set.

    deno run --allow-net --allow-read rollback

    deno run --allow-net --allow-read rollback 2

    deno run --allow-net --allow-read rollback all

  • seed [matcher?]: Seed - will seed your database. Optional matcher will match all files in your seed folder by string literal or RegExp.

    deno run --allow-net --allow-read seed

    deno run --allow-net --allow-read seed seed_file.js

    deno run --allow-net --allow-read seed ".+.ts"


  • -c, --config: Path to config file, will default to ./nessie.config.ts
  • -d, --debug: Enables verbose output


All contributions are welcome, make sure to read the contribution guideline.



nessie.config.ts with all default values

import { ClientPostgreSQL } from "./clients/ClientPostgreSQL.ts";

const nessieOptions = {
  migrationFolder: "./db/migrations",
  seedFolder: "./db/seeds",

const connectionOptions = {
  database: "nessie",
  hostname: "localhost",
  port: 5432,
  user: "root",
  password: "pwd",

export default {
  client: new ClientPostgreSQL(nessieOptions, connectionOptions),
  exposeQueryBuilder: false,

Minimal example of a migration file

import { Migration } from "";

export const up: Migration = () => {
  return "CREATE TABLE table1 (id int);";

export const down: Migration = () => {
  return "DROP TABLE table1";

Using the native query builder (exposeQueryBuilder: true)

import { Migration } from "";
import { Schema } from "";

export const up: Migration<Schema> = ({ queryBuilder }) => {
  queryBuilder.create("users", (table) => {;
    table.string("name", 100).nullable();
    table.custom("custom_column int default 1");

    "INSERT INTO users VALUES (DEFAULT, 'Deno', true, 2, DEFAULT, DEFAULT);",

  return queryBuilder.query

export const down: Migration<Schema> = ({ queryBuilder }) => {
  return queryBuilder.drop("users");

Seed file

import { Seed } from "";

export const run: Seed = () => {
  return "INSERT INTO testTable VALUES (1)"

See the example folder for more

How to make a client

A client needs to extend AbstractClient and implement the ClientI interface.

query: Takes a query string or array of query strings and sends them of to the batabase for execution. Should return whatever the database responds.

prepare: Will be run when the migration or rollback commands are executed. This should create the connection, set up the nessie_migrations table and prepare the database for incoming migrations.

migrate: Takes a number as an optional input, will default to all files if not set. Will run Math.min(amount, numberOfFiles) migration files. Only handles the up method.

rollback: Takes a number as an optional input, will default to 1 if not set. Will run Math.min(amount, numberOfFiles) migration files. Only handles the down method.

seed: Takes an optional matcher as input. Matcher can be regex or string. Will seed the database. Handles the run method in seed files.

close: Will be the last method run before the program is finished. This should close the database connection.

Deno Nessie

A modular Deno library for PostgreSQL, MySQL, MariaDB and SQLite migrations

Deno Nessie Info

⭐ Stars 358
🔗 Source Code
🕒 Last Update 9 months ago
🕒 Created a year ago
🐞 Open Issues 4
➗ Star-Issue Ratio 90
😎 Author halvardssm