This repository has been archived by the owner on Nov 9, 2017. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 10
General Usage Guide
jpoehls edited this page Aug 23, 2010
·
2 revisions
DotNetMigrations is a command line utility for tracking and migrating database versions. In order to use it’s compiled binaries, please follow the the steps below:
- Download the binaries from the Downloads section of this project.
- Unzip the files into a directory.
- Update the db.exe.config file
- Update the appSettings – migrateFolder value if you wish for migration scripts to be saved in a different location.
- Update the appSettings – PlugInDirectory value if you wish to store custom plug-ins that extend DotNetMigrations in a different location.
- Update the connectionString section with the migration name you wish to use as the key.
- Update the dnm.logs section if you are using additional log classes than the default.
- Open a command window and navigate to the directory that contains db.exe.
- Generate a new Migration Script (see examples below)
- Open the created file and write the setup and teardown sql scripts that’ll be used when the database migrates to the version.
- Migrate the database.
db.exe “[connection string]”
- In the above statement…
- … represents the name of the command you wish to run.
- … represents the name of the migration – should be the same name as your connection string key in the configuration file.
- … represents any additional arguments required by the command (i.e. a specific version number to migrate to).
- …[connection string] represents an optional argument where you can directly enter the connection string instead of referring to the one found in the configuration file.
In the below examples, we’ll assume we have named our migrations as TestDb.
db.exe generate TestDb
db.exe migrate TestDb
db.exe migrate TestDb 0
db.exe migrate TestDb 201001291432
db.exe version TestDb
db.exe rollback TestDb