Added some indexes

This commit is contained in:
kay.one 2011-06-23 19:04:07 -07:00
parent bc0b1e8ae4
commit 3e61afab03
2 changed files with 26 additions and 0 deletions

View File

@ -43,6 +43,18 @@ namespace NzbDrone.Core.Datastore.Migrations
new Column("GrabDate", DbType.DateTime, ColumnProperty.Null)
});
var indexName = MigrationsHelper.GetIndexName("Episodes", "SeriesId");
Database.AddIndex(indexName, "Episodes", "SeriesId");
indexName = MigrationsHelper.GetIndexName("Episodes", "EpisodeFileId");
Database.AddIndex(indexName, "Episodes", "EpisodeFileId");
indexName = MigrationsHelper.GetIndexName("Episodes", "AirDate");
Database.AddIndex(indexName, "Episodes", "AirDate");
indexName = MigrationsHelper.GetIndexName("Episodes", "TvDbEpisodeId");
Database.AddIndex(indexName, "Episodes", "TvDbEpisodeId");
Database.AddTable("EpisodeFiles", new[]
{
@ -57,6 +69,9 @@ namespace NzbDrone.Core.Datastore.Migrations
new Column("SeasonNumber", DbType.Int32, ColumnProperty.NotNull)
});
indexName = MigrationsHelper.GetIndexName("EpisodeFiles", "SeriesId");
Database.AddIndex(indexName, "Episodes", "SeriesId");
Database.AddTable("Config", new[]
{
@ -83,6 +98,12 @@ namespace NzbDrone.Core.Datastore.Migrations
new Column("Indexer", DbType.String, ColumnProperty.NotNull)
});
indexName = MigrationsHelper.GetIndexName("History", "EpisodeId");
Database.AddIndex(indexName, "History", "EpisodeId");
indexName = MigrationsHelper.GetIndexName("History", "SeriesId");
Database.AddIndex(indexName, "History", "SeriesId");
Database.AddTable("RootDirs", new[]
{
new Column("Id", DbType.Int32, ColumnProperty.PrimaryKeyWithIdentity),

View File

@ -59,6 +59,11 @@ namespace NzbDrone.Core.Datastore
engine.CreateDatabase();
}
}
public static string GetIndexName(string tableName, params string[] columns)
{
return String.Format("IX_{0}_{1}", tableName, String.Join("_", columns));
}
}