private MigrationHistory LoadMigrationHistory() { var ids = ExecuteSqlQuery($"SELECT database_id FROM master.sys.databases WHERE name = '{_databaseName}'", row => (int)row["database_id"]); if (ids.Any()) { var rows = ExecuteSqlQuery($@"SELECT h.[Type], h.[HashCode], h.[Attributes], j.[Role], p.[HashCode] AS [PrerequisiteHashCode] FROM [{_databaseName}].[dbo].[__MergableMigrationHistory] h LEFT JOIN [{_databaseName}].[dbo].[__MergableMigrationHistoryPrerequisite] j ON h.MigrationId = j.MigrationId LEFT JOIN [{_databaseName}].[dbo].[__MergableMigrationHistory] p ON j.PrerequisiteMigrationId = p.MigrationId ORDER BY h.MigrationId, j.Role, p.MigrationId", row => new MigrationHistoryRow { Type = LoadString(row["Type"]), HashCode = LoadBigInteger(row["HashCode"]), Attributes = LoadString(row["Attributes"]), Role = LoadString(row["Role"]), PrerequisiteHashCode = LoadBigInteger(row["PrerequisiteHashCode"]) }); return(MigrationHistory.LoadMementos(LoadMementos(rows))); } else { return(new MigrationHistory()); } }
private MigrationHistory WhenLoadMigrationHistory(MigrationMemento[] mementos) { return(MigrationHistory.LoadMementos(mementos)); }