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); }
private void CreateDatabaseObjects() { if (_options.AutoCreateSchemaObjects == AutoCreate.None) { return; } var allSchemaNames = Schema.AllSchemaNames(); var generator = new DatabaseSchemaGenerator(Advanced); generator.Generate(_options, allSchemaNames); }
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()); }
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()); }
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(); } }
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); }
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()); }