All Projects → halvardssm → Deno Nessie

halvardssm / Deno Nessie

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

Programming Languages

typescript
32286 projects

Projects that are alternatives of or similar to Deno Nessie

Sqlboiler
Generate a Go ORM tailored to your database schema.
Stars: ✭ 4,497 (+1080.31%)
Mutual labels:  mysql, postgresql, postgres, sqlite3
Lucid
AdonisJS official SQL ORM. Supports PostgreSQL, MySQL, MSSQL, Redshift, SQLite and many more
Stars: ✭ 613 (+60.89%)
Mutual labels:  hacktoberfest, mysql, postgresql, sqlite3
Vscode Sqltools
Database management for VSCode
Stars: ✭ 741 (+94.49%)
Mutual labels:  mysql, postgresql, postgres, sqlite3
Electrocrud
Database CRUD Application Built on Electron | MySQL, Postgres, SQLite
Stars: ✭ 1,267 (+232.55%)
Mutual labels:  mysql, postgresql, postgres, sqlite3
Dbbench
🏋️ dbbench is a simple database benchmarking tool which supports several databases and own scripts
Stars: ✭ 52 (-86.35%)
Mutual labels:  hacktoberfest, mysql, postgresql
Redash
Make Your Company Data Driven. Connect to any data source, easily visualize, dashboard and share your data.
Stars: ✭ 20,147 (+5187.93%)
Mutual labels:  hacktoberfest, mysql, postgresql
Jet
Type safe SQL builder with code generation and automatic query result data mapping
Stars: ✭ 373 (-2.1%)
Mutual labels:  mysql, postgresql, postgres
Chartbrew
Open-source web platform for creating charts out of different data sources (databases and APIs) 📈📊
Stars: ✭ 199 (-47.77%)
Mutual labels:  hacktoberfest, mysql, postgresql
Sqlcell
SQLCell is a magic function for the Jupyter Notebook that executes raw, parallel, parameterized SQL queries with the ability to accept Python values as parameters and assign output data to Python variables while concurrently running Python code. And *much* more.
Stars: ✭ 145 (-61.94%)
Mutual labels:  hacktoberfest, postgresql, postgres
Prest
PostgreSQL ➕ REST, low-code, simplify and accelerate development, ⚡ instant, realtime, high-performance on any Postgres application, existing or new
Stars: ✭ 3,023 (+693.44%)
Mutual labels:  hacktoberfest, postgresql, postgres
Sqlx
🧰 The Rust SQL Toolkit. An async, pure Rust SQL crate featuring compile-time checked queries without a DSL. Supports PostgreSQL, MySQL, SQLite, and MSSQL.
Stars: ✭ 5,039 (+1222.57%)
Mutual labels:  mysql, postgresql, postgres
Dbdpg
Perl Postgres driver DBD::Pg aka dbdpg
Stars: ✭ 38 (-90.03%)
Mutual labels:  hacktoberfest, postgresql, postgres
Migrate
Database migrations. CLI and Golang library.
Stars: ✭ 7,712 (+1924.15%)
Mutual labels:  hacktoberfest, mysql, postgres
Grafana
The open and composable observability and data visualization platform. Visualize metrics, logs, and traces from multiple sources like Prometheus, Loki, Elasticsearch, InfluxDB, Postgres and many more.
Stars: ✭ 45,930 (+11955.12%)
Mutual labels:  hacktoberfest, mysql, postgres
Mybb
MyBB is a free and open source forum software.
Stars: ✭ 750 (+96.85%)
Mutual labels:  hacktoberfest, mysql, postgresql
Dolibarr
Dolibarr ERP CRM is a modern software package to manage your company or foundation's activity (contacts, suppliers, invoices, orders, stocks, agenda, accounting, ...). It is open source software (written in PHP) and designed for small and medium businesses, foundations and freelancers. You can freely install, use and distribute it as a standalon…
Stars: ✭ 2,877 (+655.12%)
Mutual labels:  hacktoberfest, mysql, postgresql
Entityframework.exceptions
Handle database errors easily when working with Entity Framework Core. Supports SQLServer, PostgreSQL, SQLite, Oracle and MySql
Stars: ✭ 266 (-30.18%)
Mutual labels:  mysql, postgresql, sqlite3
Pg chameleon
MySQL to PostgreSQL replica system
Stars: ✭ 274 (-28.08%)
Mutual labels:  mysql, postgresql, postgres
Yiigo
🔥 Go 轻量级开发通用库 🚀🚀🚀
Stars: ✭ 304 (-20.21%)
Mutual labels:  mysql, postgresql, postgres
Check postgres
Nagios check_postgres plugin for checking status of PostgreSQL databases
Stars: ✭ 438 (+14.96%)
Mutual labels:  hacktoberfest, postgresql, postgres

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

Nessie

Nessie logo

A modular database migration tool for Deno inspired by Laravel and Phinx. 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.

The query builder is no longer maintained. If you need the code, it has been moved to its own repo. It can also be found in Nessie version 1.1.3 or older.

See documentation for the clients.

Nessie is available through:

Usage

  • init: Generates a nessie.config.ts file

    deno run --allow-net --allow-read --allow-write https://deno.land/x/nessie/cli.ts init

  • make [name]: Create migration

    deno run --allow-net --allow-read --allow-write https://deno.land/x/nessie/cli.ts make create_users

  • make:seed [name]: Create seed

    deno run --allow-net --allow-read --allow-write https://deno.land/x/nessie/cli.ts 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 https://deno.land/x/nessie/cli.ts migrate

    deno run --allow-net --allow-read https://deno.land/x/nessie/cli.ts migrate 1

    deno run --allow-net --allow-read https://deno.land/x/nessie/cli.ts 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 https://deno.land/x/nessie/cli.ts rollback

    deno run --allow-net --allow-read https://deno.land/x/nessie/cli.ts rollback 2

    deno run --allow-net --allow-read https://deno.land/x/nessie/cli.ts 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 https://deno.land/x/nessie/cli.ts seed

    deno run --allow-net --allow-read https://deno.land/x/nessie/cli.ts seed seed_file.js

    deno run --allow-net --allow-read https://deno.land/x/nessie/cli.ts seed ".+.ts"

Flags

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

Contributing

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

Uses

Examples

See example repo for a REST API which uses Oak and Nessie.

Previously Nessie required the functions to return a string (or array of strings), but this will be changed in the next major release. There now exists an abstract migration class which you can extend to access the client and its properties. This enables better flexibility in migrations and allows a more complex workflow. To check this feature out and to help discover bugs, you can already take this new syntax for a test by checking out the example folder, or the examples below with the experimental tag.

nessie.config.ts with all default values

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

const nessieOptions = {
  migrationFolder: "./db/migrations",
  seedFolder: "./db/seeds",
  experimental: true,
};

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

export default {
  client: new ClientPostgreSQL(nessieOptions, connectionOptions),
};

We are moving towards class based migration files, so please consider taking a look at the new syntax. If you are seeking the legacy methods, please look in the example folder or further down on this page.

Minimal example of a migration file (experimental)

import { AbstractMigration, Info } from "https://deno.land/x/nessie/mod.ts";
import type { Client } from "https://deno.land/x/[email protected]/mod.ts";

export default class ExperimentalMigration extends AbstractMigration<Client> {
  async up({ dialect }: Info): Promise<void> {
    this.client.query("CREATE TABLE table1 (id int)");
  }

  async down({ dialect }: Info): Promise<void> {
    this.client.query("DROP TABLE table1");
  }
}

Seed file (experimental)

import { AbstractSeed, Info } from "https://deno.land/x/nessie/mod.ts";
import type { Client } from "https://deno.land/x/[email protected]/mod.ts";

export default class ExperimentalSeed extends AbstractSeed<Client> {
  async run({ dialect }: Info): Promise<void> {
    this.client.query("INSERT INTO table1 VALUES (1234)");
  }
}

Minimal example of a migration file (legacy)

import { Migration } from "https://deno.land/x/nessie/mod.ts";

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

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

Seed file (legacy)

import { Seed } from "https://deno.land/x/nessie/mod.ts";

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.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].