Nanomigrator
NanoMigrator is a C# tool to apply migrations to database. MySQL, MS SQL Server, MongoDB and Oracle are supported.
Install / Use
/learn @yar3333/NanomigratorREADME
NanoMigrator
NanoMigrator is a C# tool to apply migrations (up and down) to database. MySQL, MS SQL Server, MongoDB and Oracle are supported.
Features:
- simple: just a SQL/JSON/CMD/BAT/EXE files in specific folder;
- support several environments (custom connection groups, such as
developmentandproduction); - support several databases per environment.
Also, you can use GUI version of NanoMigrator.
Installation
First, install NuGet. Then, install NanoMigrator from the package manager console:
PM> Install-Package NanoMigrator
Using
First, create config file databases.nmjson like next:
{
"migrationsDirectory": "migrations",
"migrationsTable": "migrations",
"connectionGroups": {
"development": {
"TestSqlServerLocalDatabase": {
"driver": "SqlServer",
"connectionString": "Data Source=(localdb)\\MSSQLLocalDB;AttachDbFilename=c:\\mydir\\my_database_file.mdf;User ID=MY_LOGIN;Password=MY_PASSWORD;Initial Catalog=MY_DATABASE"
},
"TestSqlServerFromAppConfig": {
"driver": "SqlServer",
"appConfigFile":"mydir\\app.config",
"connectionName":"MainConnection"
},
"TestMySqlDatabase": {
"driver": "MySql",
"connectionString": "server=localhost;user id=root;password=123456;database=MY_DATABASE;persistsecurityinfo=True;charset=utf8"
},
"TestMongoDatabase": {
"driver": "MongoDB",
"connectionString": "mongodb://localhost/MY_DATABASE"
}
}
}
}
Create test migration UP file migrations\0001_TestSqlServerLocalDatabase_My_first_migration.sql (change TestSqlServerLocalDatabase to your connection name):
SELECT 1;
Create test migration DOWN file migrations\0001_TestSqlServerLocalDatabase_My_first_migration_DOWN.sql (change TestSqlServerLocalDatabase to your connection name):
SELECT 2;
Next, test connections:
PM> NanoMigrator status
To simulate migration, run:
PM> NanoMigrator simulate
To migrate to the last version, run:
PM> NanoMigrator migrate
To revert all migrations, run:
PM> NanoMigrator migrate 0
Run NanoMigrator without arguments to get more help.
Migration files
Migration files are *.sql/*.json/*.cmd/*.bat/*.exe files in folder, specified in migrationsDirectory parameter of config file (subfolders are also scanned).
Each file name must be in the next format:
index_name_description_postfix.ext
Where:
indexis a positive integer number (leading zeroes are possible);nameis connection name (TestSqlServerLocalDatabase,TestSqlServerFromAppConfigorTestMySqlDatabasefor config file listed above);descriptionis a transaction description text;postfixis a optional part (may be:UP/FORfor forward migration file orDOWN/REVfor revert migration file); when ommited then forward migration file is assumed.
SQL/JSON files applyable for:
*.sql- SQL connections (file content is a SQL text; several statements is supported - use ";" as delimiter);*.json- MongoDB connections (file content is a text for MongoDB'srunCommand).
NanoMigrator run *.cmd/*.bat/.exe migrations in the next maner:
- argument %1 - active connection string in
driver:connectionStringformat (for example:MySql:server=localhost;user id=root;password=123456;database=MY_DATABASE;persistsecurityinfo=True;charset=utf8); - environment variables
MIGRATION_DB_<CONNECTION_NAME>- connection strings to all known databases indriver:connectionStringformat.
Related Skills
feishu-drive
349.2k|
things-mac
349.2kManage Things 3 via the `things` CLI on macOS (add/update projects+todos via URL scheme; read/search/list from the local Things database)
clawhub
349.2kUse the ClawHub CLI to search, install, update, and publish agent skills from clawhub.com
codebase-memory-mcp
1.2kHigh-performance code intelligence MCP server. Indexes codebases into a persistent knowledge graph — average repo in milliseconds. 66 languages, sub-ms queries, 99% fewer tokens. Single static binary, zero dependencies.
