コード例 #1
0
ファイル: Tenant.cs プロジェクト: vgrokk/marten
        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);
                    }
                }
            }
        }
コード例 #2
0
        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);
        }
コード例 #3
0
        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);
            });
        }