Skip to content

ritasker/dotnet-db-migrate

Repository files navigation

Pier 8 DB Tools

Build Status NuGet

A CLI that adds and migrates database migrations for MS SQL and PostgreSQL.

Quick Start

Installation

dotnet tool install -g dotnet-db-migrate

Example Usage

dotnet db add-migration "AddContactsTable"

Added migration script ./20200520180400_AddContactsTable.sql

You would then add the SQL for the migration.

eg, for PostgreSQL.

CREATE EXTENSION pgcrypto;
CREATE TABLE contacts(
  id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
  name TEXT,
  email TEXT
);

Then you can execute the migration using the following command,

dotnet db migrate "Server=localhost;Port=5432;Database=db-migrate;User Id=postgres;Password=password;" -p psql

Master ConnectionString => Host=localhost;Port=5432;Database=db-migrate;Username=postgres;Password=********
Created database db-migrate
Beginning database upgrade
Checking whether journal table exists..
Journal table does not exist
Executing Database Server script '20200520180400_AddContactsTable.sql'
Checking whether journal table exists..
Creating the "schemaversions" table
The "schemaversions" table has been created
Upgrade successful

Contributing

This is an open-source project. I request your participation through issues and pull requests!

License

dotnet-db-migrate is licensed under MIT. Refer to LICENSE for more information.

About

A .NET Core Global Tool to deploy changes to SQL databases using DbUp.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages