Nessie
A database migration tool for deno inspired by Laravel. Supports PostgreSQL and MySQL, soon: SQLite. See documentation.
Supported databases
- PostgreSQL
- MySQL - Currently it works with password for 5.*, but for >=8 you have to send a blank password, see Deno MySQL for version support
- SQLite
If you have a database system you would like to see in this list, feel free to make an issue or create a pr with your implementation.
Usage
init
: Generates anessie.config.ts
filedeno run --allow-net --allow-read --allow-write https://deno.land/x/nessie/cli.ts init
make [name]
: Create migrationdeno run --allow-net --allow-read --allow-write https://deno.land/x/nessie/cli.ts make create_users
migrate
: Run migration - will migrate all migrations in your migration folder (sorted by timestamp) newer than the latest migration in your dbdeno 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 -c ./nessie.config.ts
rollback
: Rollback - will rollback the latest migrationdeno run --allow-net --allow-read https://deno.land/x/nessie/cli.ts rollback
Flags
-c, --config
: Path to config file, will default to ./nessie.config.ts-d, --debug
: Enables verbose output
Contributing
Feel free to make pr’s or create an issue!
Uses
Examples
nessie.config.ts
import { nessieConfigType } from "https://deno.land/x/nessie/mod.ts";
const config: nessieConfigType = {
migrationFolder: "./migrations",
connection: { // These are the connection option from their respective db clients, will differ
host: "localhost",
port: 5432,
user: "root",
password: "pwd",
name: "nessie",
},
dialect: "pg",
};
export default config;
Minimal example of a migration file
import { Schema } from "https://deno.land/x/nessie/mod.ts";
export const up = (schema: Schema): void => {
schema.create("users", (table) => {
table.id();
table.string("name", 100).nullable();
table.boolean("is_true").default("false");
table.custom("custom_column int default 1");
table.timestamps();
});
schema.queryString(
"INSERT INTO users VALUES (DEFAULT, 'Deno', true, 2, DEFAULT, DEFAULT);",
);
};
export const down = (schema: Schema): void => {
schema.drop("users");
};
See example folder for more