From 3e61afab03a4aa2ebdb7e0fa754cb8fad7683958 Mon Sep 17 00:00:00 2001 From: "kay.one" Date: Thu, 23 Jun 2011 19:04:07 -0700 Subject: [PATCH] Added some indexes --- .../Datastore/Migrations/Migration20110622.cs | 21 +++++++++++++++++++ NzbDrone.Core/Datastore/MigrationsHelper.cs | 5 +++++ 2 files changed, 26 insertions(+) diff --git a/NzbDrone.Core/Datastore/Migrations/Migration20110622.cs b/NzbDrone.Core/Datastore/Migrations/Migration20110622.cs index 94b9e93ff..bb509ce00 100644 --- a/NzbDrone.Core/Datastore/Migrations/Migration20110622.cs +++ b/NzbDrone.Core/Datastore/Migrations/Migration20110622.cs @@ -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), diff --git a/NzbDrone.Core/Datastore/MigrationsHelper.cs b/NzbDrone.Core/Datastore/MigrationsHelper.cs index 4ca071790..fa4e55986 100644 --- a/NzbDrone.Core/Datastore/MigrationsHelper.cs +++ b/NzbDrone.Core/Datastore/MigrationsHelper.cs @@ -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)); + } }