public async Task SyncDatabaseAsync() { var repositories = GetAllRepositories(); foreach (var repository in repositories) { if (string.IsNullOrEmpty(repository.TableName) || repository.TableColumns == null || repository.TableColumns.Count <= 0) { continue; } if (!await _settingsManager.Database.IsTableExistsAsync(repository.TableName)) { await CreateTableAsync(repository.TableName, repository.TableColumns, string.Empty, false); } else { await AlterTableAsync(repository.TableName, repository.TableColumns, string.Empty); } } var config = await ConfigRepository.GetAsync(); if (config.Id == 0) { await ConfigRepository.InsertAsync(config); } await SyncContentTablesAsync(); await UpdateConfigVersionAsync(); }
private async Task UpdateConfigVersionAsync() { var configInfo = await ConfigRepository.GetAsync(); if (configInfo.Id > 0) { configInfo.DatabaseVersion = _settingsManager.Version; configInfo.UpdateDate = DateTime.UtcNow; await ConfigRepository.UpdateAsync(configInfo); } }