public override void Configure(Container container) { _logger.Debug("Configuring"); container.Adapter = _autofacIocAdapter; AppSettings = container.Resolve <IAppSettings>(); JsConfig.EmitCamelCaseNames = true; GlobalHtmlErrorHttpHandler = new RazorHandler("/oops"); Configuration = container.Resolve <IEkklesiaConfiguration>(); SetConfig(new HostConfig { DebugMode = _hostingEnvironment.IsDevelopment() || Configuration.DebugMode, WebHostUrl = _configuration["SiteUrl"] }); Plugins.Add(new RazorFormat()); Plugins.Add(new ValidationFeature()); Plugins.Add(new RequestLogsFeature()); IDbMigrator migrator = container.Resolve <IDbMigrator>(); migrator.Migrate(); }
private static void ApplyMigration(IDbMigrator migrator, IDbConnection connection) { var result = migrator.Migrate(connection); if (result.MigrationWasApplied) { connection.Execute( @"INSERT INTO PocketMigrator.AppliedMigrations (MigrationScope, MigrationVersion, Log, AppliedDate) VALUES (@migrationScope, @migrationVersion, @log, GetDate())", parameters: new Dictionary <string, object> { { "@migrationScope", migrator.MigrationScope }, { "@migrationVersion", migrator.MigrationVersion.ToString() }, { "@log", $"{migrator.GetType().AssemblyQualifiedName}\n\n{result.Log}".Trim() } }); } }
public override void Configure(Container container) { _logger.Debug("Configuring"); container.Adapter = _autofacIocAdapter; AppSettings = container.Resolve <IAppSettings>(); //Set JSON web services to return idiomatic JSON camelCase properties JsConfig.EmitCamelCaseNames = true; GlobalHtmlErrorHttpHandler = new RazorHandler("/oops"); Configuration = container.Resolve <ISoundWordsConfiguration>(); SetConfig(new HostConfig { DebugMode = _hostingEnvironment.IsDevelopment() || Configuration.DebugMode, WebHostUrl = _configuration["SITE_URL"] }); ConfigureAuth(container); MimeTypes.ExtensionMimeTypes["manifest"] = "text/cache-manifest"; MimeTypes.ExtensionMimeTypes["appcache"] = "text/cache-manifest"; MimeTypes.ExtensionMimeTypes["ico"] = "image/x-icon"; Config.AllowFileExtensions.Add("manifest"); Config.AllowFileExtensions.Add("appcache"); Plugins.Add(new RazorFormat()); Plugins.Add(new ValidationFeature()); Plugins.Add(_serverEventsFeature); IDbMigrator migrator = container.Resolve <IDbMigrator>(); migrator.Migrate(); OrmLiteConfig.InsertFilter += (command, o) => { DbEntity entity = o as DbEntity; if (entity == null) { return; } entity.CreatedOn = DateTime.UtcNow; entity.ModifiedOn = DateTime.UtcNow; }; OrmLiteConfig.UpdateFilter += (command, o) => { DbEntity entity = o as DbEntity; if (entity == null) { return; } entity.ModifiedOn = DateTime.UtcNow; }; }
private void Run(IDbMigrator migration) { using (var db = Configuration.Current.CommandSchedulerDbContext()) { var results = migration.Migrate(db); Console.WriteLine(results.ToLogString()); } }
public SqliteRepository(IDbConnection conn, IDbMigrator migrator) { _connection = conn as SQLiteConnection; if (_connection == null) { Throw.InvalidOperation("Connection provided to SqliteRepository must be of type SQLiteConnection"); } migrator.Migrate(); }
private async Task InitializeDatabase() { Task task = new Task(() => { dbMigrator.Migrate(); }); task.Start(); await task; }
public void Configure(IApplicationBuilder app, IWebHostEnvironment env, IDbMigrator migrations) { if (env.IsDevelopment()) { app.UseDeveloperExceptionPage(); } app .UseStaticFiles() .UseRouting() .UseIdentityServer() .UseAuthorization() .UseDefaultEndpoints(); migrations.Migrate(); }
private static MigrationResult ApplyMigration(IDbMigrator migrator, DbContext connection) { var result = migrator.Migrate(connection); if (result.MigrationWasApplied) { connection.Database.ExecuteSqlCommand( @"INSERT INTO PocketMigrator.AppliedMigrations (MigrationScope, MigrationVersion, Log, AppliedDate) VALUES (@migrationScope, @migrationVersion, @log, GetDate())", new SqlParameter("@migrationScope", migrator.MigrationScope), new SqlParameter("@migrationVersion", migrator.MigrationVersion.ToString()), new SqlParameter("@log", $"{migrator.GetType().AssemblyQualifiedName}\n\n{result.Log}".Trim())); } return(result); }
private void Run(IDbMigrator migration) { using (var db = Configuration.Current.CommandSchedulerDbContext()) { var results = migration.Migrate(db); Console.WriteLine(results.ToLogString()); } }