private void generateOrUpdateFeature(Type featureType, IFeatureSchema feature) { lock (_updateLock) { using (var conn = _factory.Create()) { conn.Open(); var patch = new SchemaPatch(_options.DdlRules); patch.Apply(conn, _options.AutoCreateSchemaObjects, feature.Objects); patch.AssertPatchingIsValid(_options.AutoCreateSchemaObjects); var ddl = patch.UpdateDDL; if (patch.Difference != SchemaPatchDifference.None && ddl.IsNotEmpty()) { var cmd = conn.CreateCommand(ddl); try { cmd.ExecuteNonQuery(); _options.Logger().SchemaChange(ddl); RegisterCheck(featureType, feature); } catch (Exception e) { throw new MartenCommandException(cmd, e); } } else if (patch.Difference == SchemaPatchDifference.None) { RegisterCheck(featureType, feature); } } } }
public void should_not_throw_exception_on_assertion(SchemaPatchDifference difference, AutoCreate autoCreate) { var patch = new SchemaPatch(new DdlRules()); var table1 = new Table(new DbObjectName("public", "sometable1")); patch.Log(table1, difference); patch.AssertPatchingIsValid(autoCreate); }
public void should_throw_exception_on_assertion(SchemaPatchDifference difference, AutoCreate autoCreate) { var patch = new SchemaPatch(new DdlRules()); var table1 = new Table(new DbObjectName("public", "sometable1")); patch.Log(table1, difference); Exception <InvalidOperationException> .ShouldBeThrownBy(() => { patch.AssertPatchingIsValid(autoCreate); }); }