Esempio n. 1
0
        protected void seedSchemas(ITenant tenant)
        {
            if (Options.AutoCreateSchemaObjects == AutoCreate.None)
            {
                return;
            }

            var allSchemaNames = Options.Storage.AllSchemaNames();
            var generator      = new DatabaseSchemaGenerator(tenant);

            generator.Generate(Options, allSchemaNames);
        }
Esempio n. 2
0
        private void CreateDatabaseObjects()
        {
            if (_options.AutoCreateSchemaObjects == AutoCreate.None)
            {
                return;
            }

            var allSchemaNames = Schema.AllSchemaNames();
            var generator      = new DatabaseSchemaGenerator(Advanced);

            generator.Generate(_options, allSchemaNames);
        }
Esempio n. 3
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. 4
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. 5
0
        private void CreateDatabaseObjects()
        {
            if (_options.AutoCreateSchemaObjects == AutoCreate.None)
            {
                return;
            }

            var allSchemaNames = Schema.AllSchemaNames();
            var generator      = new DatabaseSchemaGenerator(Advanced);

            generator.Generate(allSchemaNames);

            if (Schema.Events.IsActive)
            {
                EventStore.InitializeEventStoreInDatabase();
            }
        }
Esempio n. 6
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);
        }
Esempio n. 7
0
        private void writeDatabaseSchemaGenerationScript(string directory, FileSystem system, IFeatureSchema[] schemaObjects)
        {
            var allSchemaNames = StoreOptions.Storage.AllSchemaNames();
            var script         = DatabaseSchemaGenerator.GenerateScript(StoreOptions, allSchemaNames);

            var writer = new StringWriter();

            if (script.IsNotEmpty())
            {
                writer.WriteLine(script);

                writer.WriteLine();
            }

            foreach (var feature in schemaObjects)
            {
                writer.WriteLine($"\\i {feature.Identifier}.sql");
            }

            var filename = directory.AppendPath("all.sql");

            system.WriteStringToFile(filename, writer.ToString());
        }