public UpgradeEngine GetMigrationUpdateEngine()
        {
            UpgradeEngineBuilder builder;

            switch (_databaseType)
            {
            case DatabaseType.Sqlite:
                builder = DeployChanges.To.SQLiteDatabase(_connectionString);
                break;

            case DatabaseType.Oracle:
                throw new NotImplementedException("Oracle Implementation does not yet exist");

            case DatabaseType.MariaDb:
                throw new NotImplementedException("MariaDb Implementation does not yet exist");

            case DatabaseType.Postgresql:
                throw new NotImplementedException("Postgresql Implementation does not yet exist");

            default:
                throw new ArgumentOutOfRangeException();
            }

            return(builder
                   .WithScripts(MigrationLocator.GetSchemaMigrations())
                   .Build());
        }
 public MigrationRunner(string mongoServerLocation, string databaseName)
 {
     _MongoServerLocation = mongoServerLocation;
     Database = MongoServer.Create(mongoServerLocation).GetDatabase(databaseName);
     DatabaseStatus = new DatabaseMigrationStatus(this);
     MigrationLocator = new MigrationLocator();
 }
Esempio n. 3
0
 public MigrationRunner(string connectionString, string databaseName, string collectionName = DEFAULT_COLLECTION_NAME)
 {
     var client = new MongoClient(connectionString);
     Database = client.GetServer().GetDatabase(databaseName);
     DatabaseStatus = new DatabaseMigrationStatus(this);
     MigrationLocator = new MigrationLocator();
 }
        public void GetLatestVersionNoMigrations()
        {
            var locator = new MigrationLocator();

            locator.LatestVersion().Should().BeEquivalentTo(
                MigrationVersion.Default);
        }
        public void GetLatestVersionWithMigrations()
        {
            var locator = new MigrationLocator();

            locator.LookForMigrationsInAssembly(Assembly.GetExecutingAssembly());
            locator.LatestVersion().Should().BeEquivalentTo(
                new MigrationVersion(new DateTime(2019, 7, 18, 16, 38, 00), "TestMigration"));
        }
        public void HandlesMigrationFilterException()
        {
            var locator = new MigrationLocator();
            var badAsm  = Substitute.For <Assembly>();

            badAsm.GetTypes().Returns(x => throw new Exception("baadf00d"));
            locator.LookForMigrationsInAssembly(badAsm);
            locator.Invoking(l => l.GetAllMigrations().ToArray()).Should()
            .Throw <MigrationException>()
            .WithMessage("Cannot load migrations from assembly*");
        }
        public void GetMigrationsAfterVersion()
        {
            var locator = new MigrationLocator();

            locator.LookForMigrationsInAssembly(Assembly.GetExecutingAssembly());
            var migrations = locator.GetMigrationsAfter(
                new AppliedMigration(new M20190718162300_TestCollectionMigration()));

            // check migrations are ordered
            migrations.Select(x => x.Version).Should().BeEquivalentTo(new[]
            {
                new MigrationVersion("M20190718163800_TestMigration")
            });
        }
        public void GetMigrationsAfterNull()
        {
            var locator = new MigrationLocator();

            locator.LookForMigrationsInAssembly(Assembly.GetExecutingAssembly());
            var migrations = locator.GetMigrationsAfter(null);

            // check migrations are ordered
            migrations.Select(x => x.Version).Should().BeEquivalentTo(new[]
            {
                new MigrationVersion("M20190718160124_WithoutAttributeMigration"),
                new MigrationVersion("M20190718162300_TestCollectionMigration"),
                new MigrationVersion("M20190718163800_TestMigration")
            }, opts => opts.WithStrictOrdering());
        }
 public MigrationManager(Database database, MigrationLocator migrationLocator) {
     _database = database;
     _migrations = migrationLocator();
 }
 public MigrationRunner(MongoDatabase database)
 {
     Database = database;
     DatabaseStatus = new DatabaseMigrationStatus(this);
     MigrationLocator = new MigrationLocator();
 }
Esempio n. 11
0
 public MigrationLocatorTest()
 {
     locator = new MigrationLocator(typeof(MigrationLocatorTest).Assembly);
 }
 public void TestMigrationLocatorFindsMigrations()
 {
     MigrationLocator.GetSchemaMigrations().ShouldNotBeEmpty();
 }