Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/nercury/nupgrade
NUpgrade - Lightweight database migration helper for C#
https://github.com/nercury/nupgrade
Last synced: about 2 months ago
JSON representation
NUpgrade - Lightweight database migration helper for C#
- Host: GitHub
- URL: https://github.com/nercury/nupgrade
- Owner: Nercury
- License: other
- Created: 2009-07-18T01:40:57.000Z (over 15 years ago)
- Default Branch: master
- Last Pushed: 2012-06-26T19:20:51.000Z (over 12 years ago)
- Last Synced: 2023-04-10T01:59:33.019Z (almost 2 years ago)
- Language: C#
- Homepage:
- Size: 1.52 MB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE.txt
Awesome Lists containing this project
README
NUpgrade
========NUpgrade is a database upgrade helper. At the core is Migration class, which
is used to initialize upgrade driver (so far only SQLite), check if database needs to be upgraded,
registering multiple upgrade paths, and executing actual upgrade.Example usage:
// create a new connection for local database, connection string should probably be stored elsewhere
var connection = new SQLiteConnection("Data Source=local.db;Version=3;New=True;Compress=True;");
// will migrate to this version
var requiredDbVersion = 1;// initialize new migration manager
var migration = new Migration(new NUpgradeSqliteDriver(connection), requiredDbVersion);
// check if we need to migrate
if (!migration.IsUpToDate)
{
// add all possible migration stepsmigration.Add(0, 1, schema => // to migrate from version 0 to 1, execute this
{
schema.RunSql("SOME SQL TO MODIFY DB (in driver dialect)");
});migration.Add(1, 2, schema => // to migrate from version 1 to 2
{
//...
});// find steps to execute to correctly migrate db
var migrationSteps = migration.FindUpgradeSteps();
if (migrationSteps == null)
throw new MigrationException("No migration path found.");migration.Execute(migrationSteps);
}NUpgrade.Sqlite
===============NUpgrade can be extended with additional drivers. So far only Sqlite is implemented.
Internally, SQLite driver creates a "version" table and stores version number in it. It is done behind the scenes, so no
special changes to database are required.