Beispiel #1
0
        private void WriteDatabaseSchemaGenerationScript(string directory, FileSystem system)
        {
            var allSchemaNames = AllSchemaNames();
            var script         = DatabaseSchemaGenerator.GenerateScript(allSchemaNames);

            if (script.IsNotEmpty())
            {
                var filename = directory.AppendPath("database_schemas.sql");
                system.WriteStringToFile(filename, script);
            }
        }
Beispiel #2
0
        public string ToDDL()
        {
            var writer = new StringWriter();

            var allSchemaNames = AllSchemaNames();

            DatabaseSchemaGenerator.WriteSql(StoreOptions, allSchemaNames, writer);

            foreach (var schemaObject in AllSchemaObjects())
            {
                schemaObject.WriteSchemaObjects(this, writer);
            }

            return(writer.ToString());
        }
Beispiel #3
0
        public void ApplyAllConfiguredChangesToDatabase()
        {
            var patch = new SchemaPatch(this);

            var allSchemaNames = AllSchemaNames();

            DatabaseSchemaGenerator.WriteSql(StoreOptions, allSchemaNames, patch.UpWriter);

            patch.Updates.Apply(this, patch.UpdateDDL);

            foreach (var schemaObject in AllSchemaObjects())
            {
                schemaObject.GenerateSchemaObjectsIfNecessary(StoreOptions.AutoCreateSchemaObjects, this, patch);
            }
        }
Beispiel #4
0
        public void ApplyAllConfiguredChangesToDatabase()
        {
            var patch = new SchemaPatch(this);

            var allSchemaNames = AllSchemaNames();

            DatabaseSchemaGenerator.WriteSql(StoreOptions, allSchemaNames, patch.UpWriter);

            patch.Updates.Apply(this, patch.UpdateDDL);

            foreach (var schemaObject in AllSchemaObjects())
            {
                // Need to override the AutoCreate value here so stuff can actually work
                schemaObject.GenerateSchemaObjectsIfNecessary(AutoCreate.CreateOrUpdate, this, patch);
            }
        }
Beispiel #5
0
        public SchemaPatch ToPatch(bool withSchemas = true)
        {
            var patch = new SchemaPatch();

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

            foreach (var schemaObject in AllSchemaObjects())
            {
                schemaObject.WritePatch(this, patch);
            }

            return(patch);
        }
Beispiel #6
0
        public string ToPatch()
        {
            var writer = new StringWriter();

            var allSchemaNames = AllSchemaNames();

            DatabaseSchemaGenerator.WriteSql(allSchemaNames, writer);

            var recorder = new DDLRecorder(writer);

            foreach (var schemaObject in AllSchemaObjects())
            {
                schemaObject.WritePatch(this, recorder);
            }

            return(writer.ToString());
        }
Beispiel #7
0
        public string ToDDL()
        {
            var writer = new StringWriter();

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

                foreach (var schemaObject in AllSchemaObjects())
                {
                    schemaObject.WriteSchemaObjects(this, writer);
                }
            });



            return(writer.ToString());
        }
Beispiel #8
0
        public string ToDDL()
        {
            var writer = new StringWriter();

            var allSchemaNames = AllSchemaNames();

            DatabaseSchemaGenerator.WriteSql(allSchemaNames, writer);

            StoreOptions.AllDocumentMappings.Each(x => x.SchemaObjects.WriteSchemaObjects(this, writer));

            if (Events.IsActive && !StoreOptions.AllDocumentMappings.Contains(Events.As <IDocumentMapping>()))
            {
                Events.As <IDocumentMapping>().SchemaObjects.WriteSchemaObjects(this, writer);
            }

            writer.WriteLine(SchemaBuilder.GetSqlScript(StoreOptions.DatabaseSchemaName, "mt_hilo"));

            return(writer.ToString());
        }
Beispiel #9
0
        private void writeDatabaseSchemaGenerationScript(string directory, FileSystem system, ISchemaObjects[] schemaObjects)
        {
            var allSchemaNames = AllSchemaNames();
            var script         = DatabaseSchemaGenerator.GenerateScript(StoreOptions, allSchemaNames);

            var writer = new StringWriter();

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

                writer.WriteLine();
            }

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

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

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