Esempio n. 1
0
        public string ToDDL()
        {
            var writer = new StringWriter();

            new SchemaPatch(StoreOptions.DdlRules).WriteTransactionalScript(writer, w =>
            {
                var allSchemaNames = StoreOptions.Storage.AllSchemaNames();
                DatabaseSchemaGenerator.WriteSql(StoreOptions, allSchemaNames, w);

                foreach (var feature in _features.AllActiveFeatures(_tenant))
                {
                    feature.Write(StoreOptions.DdlRules, writer);
                }
            });

            return(writer.ToString());
        }
Esempio n. 2
0
        public string ToDatabaseScript()
        {
            var writer = new StringWriter();

            StoreOptions.Advanced.DdlRules.WriteScript(writer, (r, w) =>
            {
                var allSchemaNames = StoreOptions.Storage.AllSchemaNames();
                DatabaseSchemaGenerator.WriteSql(StoreOptions, allSchemaNames, w);

                foreach (var feature in _features.AllActiveFeatures(_tenant))
                {
                    feature.Write(r, w);
                }
            });

            return(writer.ToString());
        }
Esempio n. 3
0
        public SchemaPatch ToPatch(bool withSchemas = true)
        {
            var patch = new SchemaPatch(StoreOptions.DdlRules);

            if (withSchemas)
            {
                var allSchemaNames = StoreOptions.Storage.AllSchemaNames();
                DatabaseSchemaGenerator.WriteSql(StoreOptions, allSchemaNames, patch.UpWriter);
            }

            var @objects = _features.AllActiveFeatures(_tenant).SelectMany(x => x.Objects).ToArray();

            using (var conn = _tenant.CreateConnection())
            {
                conn.Open();

                patch.Apply(conn, StoreOptions.AutoCreateSchemaObjects, @objects);
            }

            return(patch);
        }