public static int Main(string[] args) { if (args.Length < 3) { Console.WriteLine("Usage: RunMongoMigrations server[:port] databaseName migrationAssembly"); return(1); } var server = args[0]; var database = args[1]; var migrationsAssembly = args[2]; var runner = new MigrationRunner(("mongodb://" + server), database); runner.MigrationLocator.LookForMigrationsInAssembly(Assembly.LoadFrom(migrationsAssembly)); try { runner.UpdateToLatest(); return(0); } catch (MigrationException e) { Console.WriteLine("Migrations Failed: " + e); Console.WriteLine(args[0], args[1], args[2]); return(1); } }
public static void EnsureLatest(string connectionString, string databaseName) { var runner = new MigrationRunner(connectionString, databaseName); runner.MigrationLocator.LookForMigrationsInAssemblyOfType <ErrorRepository>(); runner.UpdateToLatest(); }
public static void RunMigrations() { var runner = new MigrationRunner(Configuration.Connection, Configuration.DbName); runner.MigrationLocator.LookForMigrationsInAssemblyOfType <MigrationInitial>(); runner.UpdateToLatest(); }
public void TestMigration() { var runner = new MigrationRunner("mongodb://*****:*****@clickmongoqa.cloudapp.net:13878/clickberry"); // migrations are ordered by version runner.MigrationLocator.LookForMigrationsInAssemblyOfType <IPortalMigration>(); // updating database runner.UpdateToLatest(); runner.DatabaseStatus.ThrowIfNotLatestVersion(); }
public void Initialize() { var runner = new MigrationRunner(_url); // migrations are ordered by version runner.MigrationLocator.LookForMigrationsInAssemblyOfType <IPortalMigration>(); if (_automigration) { // updating database runner.UpdateToLatest(); } runner.DatabaseStatus.ThrowIfNotLatestVersion(); }
private static bool InitializeMigration(IMongoDatabase db) { if (null != db) { var runner = new MigrationRunner(db); runner.MigrationLocator.LookForMigrationsInAssembly(Assembly.GetExecutingAssembly()); // runner.MigrationLocator.LookForMigrationsInAssemblyOfType<Migration1>(); runner.DatabaseStatus.ValidateMigrationsVersions(); runner.UpdateToLatest(); return(true); } return(false); }
private static void Run(Options options) { var runner = new MigrationRunner($"mongodb://{options.Host}:{options.Port}", options.Database); runner.MigrationLocator.LookForMigrationsInAssembly(Assembly.LoadFrom(options.Migrations)); try { runner.UpdateToLatest(); Environment.Exit(0); } catch (MigrationException e) { Console.WriteLine("Migrations Failed: " + e); ////Console.WriteLine(server, database, migrationsAssembly); Environment.Exit(1); } }
public static void EnsureLatest(string connectionString, string databaseName) { if (_isUpdating) { return; } _isUpdating = true; try { var runner = new MigrationRunner(connectionString, databaseName); runner.MigrationLocator.LookForMigrationsInAssemblyOfType <EventRepository>(); runner.UpdateToLatest(); } catch (Exception ex) { Log.Error().Exception(ex).Message("Error ensuring latest db version: {0}", ex.Message).Report().Write(); } finally { _isUpdating = false; } }