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); } }
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()); }
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); } }
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); } }
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); }
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()); }
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()); }
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()); }
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()); }