mirror of
https://github.com/Sonarr/Sonarr
synced 2026-04-30 00:51:41 +02:00
New: Bump minimum Postgres version to 15 for FluentMigrator
This commit is contained in:
parent
bef2986357
commit
5f846ab51e
13 changed files with 23 additions and 40 deletions
|
|
@ -18,7 +18,6 @@ public void should_add_unknown_to_old_profile()
|
|||
{
|
||||
c.Insert.IntoTable("Profiles").Row(new
|
||||
{
|
||||
Id = 0,
|
||||
Name = "SDTV",
|
||||
Cutoff = 1,
|
||||
Items = new List<object>
|
||||
|
|
|
|||
|
|
@ -16,7 +16,6 @@ public void should_add_ultrahd_to_old_profile()
|
|||
{
|
||||
c.Insert.IntoTable("Profiles").Row(new
|
||||
{
|
||||
Id = 0,
|
||||
Name = "SDTV",
|
||||
Cutoff = 1,
|
||||
Items = "[ { \"quality\": 1, \"allowed\": true } ]",
|
||||
|
|
|
|||
|
|
@ -22,7 +22,6 @@ public void should_add_webrip_qualities_and_group_with_webdl()
|
|||
{
|
||||
c.Insert.IntoTable("Profiles").Row(new
|
||||
{
|
||||
Id = 0,
|
||||
Name = "SDTV",
|
||||
Cutoff = 1,
|
||||
Items = $"[{GenerateQualityJson(1, true)}, {GenerateQualityJson((int)Quality.WEBRip480p, false)}, {GenerateQualityJson((int)Quality.WEBRip720p, false)}, {GenerateQualityJson((int)Quality.WEBRip1080p, false)}, {GenerateQualityJson((int)Quality.WEBRip2160p, false)}]"
|
||||
|
|
@ -45,7 +44,6 @@ public void should_add_bluray480p_quality_and_group_with_dvd()
|
|||
{
|
||||
c.Insert.IntoTable("Profiles").Row(new
|
||||
{
|
||||
Id = 0,
|
||||
Name = "SDTV",
|
||||
Cutoff = 1,
|
||||
Items = $"[{GenerateQualityJson(1, true)}, {GenerateQualityJson((int)Quality.DVD, false)}, {GenerateQualityJson((int)Quality.Bluray480p, false)}]"
|
||||
|
|
@ -68,7 +66,6 @@ public void should_add_webrip_and_webdl_if_webdl_is_missing()
|
|||
{
|
||||
c.Insert.IntoTable("Profiles").Row(new
|
||||
{
|
||||
Id = 0,
|
||||
Name = "SDTV",
|
||||
Cutoff = 1,
|
||||
Items = $"[{GenerateQualityJson(1, true)}, {GenerateQualityJson((int)Quality.WEBRip480p, false)}, {GenerateQualityJson((int)Quality.WEBRip720p, false)}, {GenerateQualityJson((int)Quality.WEBRip1080p, false)}]"
|
||||
|
|
@ -91,7 +88,6 @@ public void should_group_webrip_and_webdl_with_the_same_resolution()
|
|||
{
|
||||
c.Insert.IntoTable("Profiles").Row(new
|
||||
{
|
||||
Id = 0,
|
||||
Name = "SDTV",
|
||||
Cutoff = 1,
|
||||
Items = $"[{GenerateQualityJson(1, true)}, {GenerateQualityJson((int)Quality.WEBRip480p, false)}, {GenerateQualityJson((int)Quality.WEBRip720p, false)}, {GenerateQualityJson((int)Quality.WEBRip1080p, false)}, {GenerateQualityJson((int)Quality.WEBRip2160p, false)}]"
|
||||
|
|
|
|||
|
|
@ -16,7 +16,6 @@ public void should_add_remux_to_old_profile()
|
|||
{
|
||||
c.Insert.IntoTable("Profiles").Row(new
|
||||
{
|
||||
Id = 0,
|
||||
Name = "Bluray",
|
||||
Cutoff = 7,
|
||||
Items = "[ { \"quality\": 7, \"allowed\": true }, { \"quality\": 19, \"allowed\": true } ]"
|
||||
|
|
@ -38,12 +37,11 @@ public void should_add_remux_to_old_profile_with_groups()
|
|||
var db = WithMigrationTestDb(c =>
|
||||
{
|
||||
c.Insert.IntoTable("Profiles").Row(new
|
||||
{
|
||||
Id = 0,
|
||||
Name = "Bluray",
|
||||
Cutoff = 7,
|
||||
Items = "[ { \"id\": 1001, \"name\": \"Why?!\", \"allowed\": true, \"items\": [{ \"quality\": 8, \"allowed\": true }, { \"quality\": 7, \"allowed\": true }] }, { \"quality\": 19, \"allowed\": true } ]"
|
||||
});
|
||||
{
|
||||
Name = "Bluray",
|
||||
Cutoff = 7,
|
||||
Items = "[ { \"id\": 1001, \"name\": \"Why?!\", \"allowed\": true, \"items\": [{ \"quality\": 8, \"allowed\": true }, { \"quality\": 7, \"allowed\": true }] }, { \"quality\": 19, \"allowed\": true } ]"
|
||||
});
|
||||
});
|
||||
|
||||
var profiles = db.Query<Profile122>("SELECT \"Items\" FROM \"Profiles\" LIMIT 1");
|
||||
|
|
|
|||
|
|
@ -11,12 +11,11 @@ namespace NzbDrone.Core.Test.Datastore.Migration
|
|||
[TestFixture]
|
||||
public class mediainfo_channel_propertiesFixture : MigrationTest<mediainfo_channels>
|
||||
{
|
||||
private void AddEpisodeFile(mediainfo_channels m, int id)
|
||||
private void AddEpisodeFile(mediainfo_channels m, int seriesId)
|
||||
{
|
||||
var episode = new
|
||||
{
|
||||
Id = id,
|
||||
SeriesId = id,
|
||||
SeriesId = seriesId,
|
||||
Quality = new { }.ToJson(),
|
||||
Size = 0,
|
||||
DateAdded = DateTime.UtcNow,
|
||||
|
|
|
|||
|
|
@ -60,7 +60,6 @@ public void should_process_file_with_missing_title(string subtitlePath, string e
|
|||
|
||||
c.Insert.IntoTable("EpisodeFiles").Row(new
|
||||
{
|
||||
Id = 1,
|
||||
SeriesId = 1,
|
||||
RelativePath = episodePath,
|
||||
Quality = new { }.ToJson(),
|
||||
|
|
|
|||
|
|
@ -30,7 +30,6 @@ public void equal_both_becomes_equal_every_option()
|
|||
{
|
||||
c.Insert.IntoTable("CustomFilters").Row(new
|
||||
{
|
||||
Id = 1,
|
||||
Type = "series",
|
||||
Label = "Is Both",
|
||||
Filters = filtersString
|
||||
|
|
@ -67,7 +66,6 @@ public void notEqual_both_becomes_notEqual_every_option()
|
|||
{
|
||||
c.Insert.IntoTable("CustomFilters").Row(new
|
||||
{
|
||||
Id = 1,
|
||||
Type = "series",
|
||||
Label = "Is Both",
|
||||
Filters = filtersString
|
||||
|
|
@ -104,7 +102,6 @@ public void equal_true_becomes_notEqual_all()
|
|||
{
|
||||
c.Insert.IntoTable("CustomFilters").Row(new
|
||||
{
|
||||
Id = 1,
|
||||
Type = "series",
|
||||
Label = "Is Both",
|
||||
Filters = filtersString
|
||||
|
|
@ -141,7 +138,6 @@ public void notEqual_true_becomes_equal_all()
|
|||
{
|
||||
c.Insert.IntoTable("CustomFilters").Row(new
|
||||
{
|
||||
Id = 1,
|
||||
Type = "series",
|
||||
Label = "Is Both",
|
||||
Filters = filtersString
|
||||
|
|
@ -178,7 +174,6 @@ public void equal_false_becomes_equal_all()
|
|||
{
|
||||
c.Insert.IntoTable("CustomFilters").Row(new
|
||||
{
|
||||
Id = 1,
|
||||
Type = "series",
|
||||
Label = "Is Both",
|
||||
Filters = filtersString
|
||||
|
|
@ -215,7 +210,6 @@ public void notEqual_false_becomes_notEqual_all()
|
|||
{
|
||||
c.Insert.IntoTable("CustomFilters").Row(new
|
||||
{
|
||||
Id = 1,
|
||||
Type = "series",
|
||||
Label = "Is Both",
|
||||
Filters = filtersString
|
||||
|
|
@ -252,7 +246,6 @@ public void missing_hasUnmonitored_unchanged()
|
|||
{
|
||||
c.Insert.IntoTable("CustomFilters").Row(new
|
||||
{
|
||||
Id = 1,
|
||||
Type = "series",
|
||||
Label = "Is Both",
|
||||
Filters = filtersString
|
||||
|
|
@ -295,7 +288,6 @@ public void has_hasUnmonitored_not_in_first_entry()
|
|||
{
|
||||
c.Insert.IntoTable("CustomFilters").Row(new
|
||||
{
|
||||
Id = 1,
|
||||
Type = "series",
|
||||
Label = "Is Both",
|
||||
Filters = filtersString
|
||||
|
|
@ -335,7 +327,6 @@ public void has_umonitored_is_empty()
|
|||
{
|
||||
c.Insert.IntoTable("CustomFilters").Row(new
|
||||
{
|
||||
Id = 1,
|
||||
Type = "series",
|
||||
Label = "Is Both",
|
||||
Filters = filtersString
|
||||
|
|
|
|||
|
|
@ -27,7 +27,6 @@ public void should_add_bluray576p_to_old_profile()
|
|||
{
|
||||
c.Insert.IntoTable("QualityProfiles").Row(new
|
||||
{
|
||||
Id = 0,
|
||||
Name = "Bluray",
|
||||
Cutoff = 7,
|
||||
Items = $"[{GenerateQualityJson((int)Quality.DVD, true)}, {GenerateQualityJson((int)Quality.Bluray480p, true)}, {GenerateQualityJson((int)Quality.Bluray720p, false)}]"
|
||||
|
|
@ -50,7 +49,6 @@ public void should_not_allow_bluray576p_if_blurary480p_not_allowed()
|
|||
{
|
||||
c.Insert.IntoTable("QualityProfiles").Row(new
|
||||
{
|
||||
Id = 0,
|
||||
Name = "Bluray",
|
||||
Cutoff = 7,
|
||||
Items = $"[{GenerateQualityJson((int)Quality.DVD, true)}, {GenerateQualityJson((int)Quality.Bluray480p, false)}, {GenerateQualityJson((int)Quality.Bluray720p, false)}]"
|
||||
|
|
@ -73,7 +71,6 @@ public void should_add_bluray576p_to_old_profile_with_grouped_bluray_480p()
|
|||
{
|
||||
c.Insert.IntoTable("QualityProfiles").Row(new
|
||||
{
|
||||
Id = 0,
|
||||
Name = "Bluray",
|
||||
Cutoff = 7,
|
||||
Items = $"[{GenerateQualityGroupJson(1000, "DVD", new[] { (int)Quality.DVD, (int)Quality.Bluray480p }, true)}, {GenerateQualityJson((int)Quality.Bluray720p, false)}]"
|
||||
|
|
@ -97,7 +94,6 @@ public void should_not_add_bluray576p_to_profile_with_bluray_576p()
|
|||
{
|
||||
c.Insert.IntoTable("QualityProfiles").Row(new
|
||||
{
|
||||
Id = 0,
|
||||
Name = "Bluray",
|
||||
Cutoff = 7,
|
||||
Items = $"[{GenerateQualityJson((int)Quality.DVD, true)}, {GenerateQualityJson((int)Quality.Bluray480p, false)}, {GenerateQualityJson((int)Quality.Bluray576p, false)}, {GenerateQualityJson((int)Quality.Bluray720p, false)}]"
|
||||
|
|
@ -120,7 +116,6 @@ public void should_not_add_bluray576p_to_profile_with_grouped_bluray_576p()
|
|||
{
|
||||
c.Insert.IntoTable("QualityProfiles").Row(new
|
||||
{
|
||||
Id = 0,
|
||||
Name = "Bluray",
|
||||
Cutoff = 7,
|
||||
Items = $"[{GenerateQualityGroupJson(1000, "DVD", new[] { (int)Quality.DVD, (int)Quality.Bluray480p, (int)Quality.Bluray576p }, true)}, {GenerateQualityJson((int)Quality.Bluray720p, false)}]"
|
||||
|
|
|
|||
|
|
@ -18,8 +18,8 @@ public DatabaseEngineVersionCheck()
|
|||
|
||||
public override void Up()
|
||||
{
|
||||
IfDatabase("sqlite").Execute.WithConnection(LogSqliteVersion);
|
||||
IfDatabase("postgresql").Execute.WithConnection(LogPostgresVersion);
|
||||
IfDatabase(ProcessorId.SQLite).Execute.WithConnection(LogSqliteVersion);
|
||||
IfDatabase(ProcessorId.PostgreSQL).Execute.WithConnection(LogPostgresVersion);
|
||||
}
|
||||
|
||||
private void LogSqliteVersion(IDbConnection conn, IDbTransaction tran)
|
||||
|
|
|
|||
|
|
@ -8,8 +8,8 @@ public class remove_invalid_roksbox_metadata_images : NzbDroneMigrationBase
|
|||
{
|
||||
protected override void MainDbUpgrade()
|
||||
{
|
||||
IfDatabase("sqlite").Execute.Sql("DELETE FROM \"MetadataFiles\" WHERE \"Consumer\" = 'RoksboxMetadata' AND \"Type\" = 5 AND (\"RelativePath\" LIKE '%/metadata/%' OR \"RelativePath\" LIKE '%\\metadata\\%')");
|
||||
IfDatabase("postgresql").Execute.Sql("DELETE FROM \"MetadataFiles\" WHERE \"Consumer\" = 'RoksboxMetadata' AND \"Type\" = 5 AND (\"RelativePath\" LIKE '%/metadata/%' OR \"RelativePath\" LIKE '%\\\\metadata\\\\%')");
|
||||
IfDatabase(ProcessorId.SQLite).Execute.Sql("DELETE FROM \"MetadataFiles\" WHERE \"Consumer\" = 'RoksboxMetadata' AND \"Type\" = 5 AND (\"RelativePath\" LIKE '%/metadata/%' OR \"RelativePath\" LIKE '%\\metadata\\%')");
|
||||
IfDatabase(ProcessorId.PostgreSQL).Execute.Sql("DELETE FROM \"MetadataFiles\" WHERE \"Consumer\" = 'RoksboxMetadata' AND \"Type\" = 5 AND (\"RelativePath\" LIKE '%/metadata/%' OR \"RelativePath\" LIKE '%\\\\metadata\\\\%')");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -8,10 +8,10 @@ public class import_exclusion_type : NzbDroneMigrationBase
|
|||
{
|
||||
protected override void MainDbUpgrade()
|
||||
{
|
||||
IfDatabase("sqlite").Alter.Table("ImportListExclusions").AlterColumn("TvdbId").AsInt32();
|
||||
IfDatabase(ProcessorId.SQLite).Alter.Table("ImportListExclusions").AlterColumn("TvdbId").AsInt32();
|
||||
|
||||
// PG cannot autocast varchar to integer
|
||||
IfDatabase("postgresql").Execute.Sql("ALTER TABLE \"ImportListExclusions\" ALTER COLUMN \"TvdbId\" TYPE INTEGER USING \"TvdbId\"::integer");
|
||||
IfDatabase(ProcessorId.PostgreSQL).Execute.Sql("ALTER TABLE \"ImportListExclusions\" ALTER COLUMN \"TvdbId\" TYPE INTEGER USING \"TvdbId\"::integer");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
using System;
|
||||
using System.Diagnostics;
|
||||
using System.Reflection;
|
||||
using FluentMigrator;
|
||||
using FluentMigrator.Runner;
|
||||
using FluentMigrator.Runner.Generators;
|
||||
using FluentMigrator.Runner.Initialization;
|
||||
|
|
@ -31,14 +32,19 @@ public void Migrate(string connectionString, MigrationContext migrationContext,
|
|||
|
||||
_logger.Info("*** Migrating {0} ***", connectionString);
|
||||
|
||||
var db = databaseType == DatabaseType.SQLite ? "sqlite" : "postgresql";
|
||||
var db = databaseType switch
|
||||
{
|
||||
DatabaseType.SQLite => ProcessorId.SQLite,
|
||||
DatabaseType.PostgreSQL => ProcessorId.PostgreSQL,
|
||||
_ => throw new NotImplementedException($"Unknown database type: {databaseType}")
|
||||
};
|
||||
|
||||
var serviceProvider = new ServiceCollection()
|
||||
.AddLogging(b => b.AddNLog())
|
||||
.AddFluentMigratorCore()
|
||||
.Configure<RunnerOptions>(cfg => cfg.IncludeUntaggedMaintenances = true)
|
||||
.ConfigureRunner(builder => builder
|
||||
.AddPostgres()
|
||||
.AddPostgres15_0()
|
||||
.AddNzbDroneSQLite()
|
||||
.WithGlobalConnectionString(connectionString)
|
||||
.ScanIn(Assembly.GetExecutingAssembly()).For.All())
|
||||
|
|
|
|||
|
|
@ -50,7 +50,8 @@ private static string GetConnectionString(PostgresOptions options)
|
|||
Port = options.Port,
|
||||
Username = options.User,
|
||||
Password = options.Password,
|
||||
Enlist = false
|
||||
Enlist = false,
|
||||
IncludeErrorDetail = true,
|
||||
};
|
||||
|
||||
return builder.ConnectionString;
|
||||
|
|
|
|||
Loading…
Reference in a new issue