-
Notifications
You must be signed in to change notification settings - Fork 1
Usage
Mike Schenk edited this page May 6, 2017
·
5 revisions
The Migrator object needs three things:
-
A deployment journal
This object keeps track of the migrations that have been deployed to the target data store
-
A migrations provider
This object provides the lists of migrations and stored code definitions that are included in the current version of the system being deployed
-
A progress reporter
This object accepts progress messages and start/end block calls and formats and provides them to the user via some user interface. ConsoleProgressReporter and TeamCityProgressReporter are avaialble in the base package.
The Migrator object is used to
EnsureJournal
EnsureBaseline
-
Plan
a deployment DeployOffline
DeployOnline
Create an executable or include code such as the following in some part of your application that can run during installation or deployment:
// create an appropriate progressReporter
var progressReporter = new ConsoleProgressReporter();
// create SQL connection info
var connectionInfo = new ConnectionProperties(DatabaseServer, DatabaseName, useWindowsIntegratedSecurity: true);
// create our deployment journal and have it open its connection
journal = new SingleTableJournal(connectionInfo, progressReporter);
journal.Open();
// create our script runner and have it open its connection
runner = new ScriptRunner(connectionInfo);
runner.Open();
var scriptMigrationsProvider = new FileSystemScriptsMigrationProvider(
Path.Combine(SqlScriptsPath, "scripts"), "*.sql",
Path.Combine(SqlScriptsPath, "objects"), "*.sql",
runner
);
migrator = new Migrator(journal, scriptMigrationsProvider, progressReporter, includeOnlineMigrationsDuringOffline: true);
migrator.DeployOffline();