diff --git a/azure-pipelines.yml b/azure-pipelines.yml index 5ec74b379..ab5f0bd3f 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -576,6 +576,7 @@ stages: -e POSTGRES_PASSWORD=radarr \ -e POSTGRES_USER=radarr \ -p 5432:5432/tcp \ + -v /usr/share/zoneinfo/America/Chicago:/etc/localtime:ro \ postgres:14 displayName: Start postgres - bash: | @@ -721,6 +722,7 @@ stages: -e POSTGRES_PASSWORD=radarr \ -e POSTGRES_USER=radarr \ -p 5432:5432/tcp \ + -v /usr/share/zoneinfo/America/Chicago:/etc/localtime:ro \ postgres:14 displayName: Start postgres - bash: | diff --git a/src/NuGet.config b/src/NuGet.config index 2e32ec8bf..491960136 100644 --- a/src/NuGet.config +++ b/src/NuGet.config @@ -8,5 +8,6 @@ + diff --git a/src/NzbDrone.Core.Test/Datastore/DatabaseFixture.cs b/src/NzbDrone.Core.Test/Datastore/DatabaseFixture.cs index 2769e8e7b..428cb8ede 100644 --- a/src/NzbDrone.Core.Test/Datastore/DatabaseFixture.cs +++ b/src/NzbDrone.Core.Test/Datastore/DatabaseFixture.cs @@ -27,6 +27,20 @@ public void vacuum() Mocker.Resolve().Vacuum(); } + [Test] + public void postgres_should_not_contain_timestamp_without_timezone_columns() + { + if (Db.DatabaseType != DatabaseType.PostgreSQL) + { + return; + } + + Mocker.Resolve() + .OpenConnection().Query("SELECT table_name, column_name, data_type FROM INFORMATION_SCHEMA.COLUMNS WHERE table_schema = 'public' AND data_type = 'timestamp without time zone'") + .Should() + .BeNullOrEmpty(); + } + [Test] public void get_version() { diff --git a/src/NzbDrone.Core/Datastore/Migration/212_postgres_update_timestamp_columns_to_with_timezone.cs b/src/NzbDrone.Core/Datastore/Migration/212_postgres_update_timestamp_columns_to_with_timezone.cs new file mode 100644 index 000000000..eadebdbf9 --- /dev/null +++ b/src/NzbDrone.Core/Datastore/Migration/212_postgres_update_timestamp_columns_to_with_timezone.cs @@ -0,0 +1,57 @@ +using System; +using System.Collections.Generic; +using FluentMigrator; +using NzbDrone.Core.Datastore.Migration.Framework; + +namespace NzbDrone.Core.Datastore.Migration +{ + [Migration(212)] + public class postgres_update_timestamp_columns_to_with_timezone : NzbDroneMigrationBase + { + protected override void MainDbUpgrade() + { + Alter.Table("Blocklist").AlterColumn("Date").AsDateTimeOffset().NotNullable(); + Alter.Table("Blocklist").AlterColumn("PublishedDate").AsDateTimeOffset().Nullable(); + Alter.Table("Collections").AlterColumn("Added").AsDateTimeOffset().Nullable(); + Alter.Table("Collections").AlterColumn("LastInfoSync").AsDateTimeOffset().Nullable(); + Alter.Table("Commands").AlterColumn("QueuedAt").AsDateTimeOffset().NotNullable(); + Alter.Table("Commands").AlterColumn("StartedAt").AsDateTimeOffset().Nullable(); + Alter.Table("Commands").AlterColumn("EndedAt").AsDateTimeOffset().Nullable(); + Alter.Table("DownloadClientStatus").AlterColumn("InitialFailure").AsDateTimeOffset().Nullable(); + Alter.Table("DownloadClientStatus").AlterColumn("MostRecentFailure").AsDateTimeOffset().Nullable(); + Alter.Table("DownloadClientStatus").AlterColumn("DisabledTill").AsDateTimeOffset().Nullable(); + Alter.Table("DownloadHistory").AlterColumn("Date").AsDateTimeOffset().NotNullable(); + Alter.Table("ExtraFiles").AlterColumn("Added").AsDateTimeOffset().NotNullable(); + Alter.Table("ExtraFiles").AlterColumn("LastUpdated").AsDateTimeOffset().NotNullable(); + Alter.Table("History").AlterColumn("Date").AsDateTimeOffset().NotNullable(); + Alter.Table("ImportListStatus").AlterColumn("InitialFailure").AsDateTimeOffset().Nullable(); + Alter.Table("ImportListStatus").AlterColumn("MostRecentFailure").AsDateTimeOffset().Nullable(); + Alter.Table("ImportListStatus").AlterColumn("DisabledTill").AsDateTimeOffset().Nullable(); + Alter.Table("IndexerStatus").AlterColumn("InitialFailure").AsDateTimeOffset().Nullable(); + Alter.Table("IndexerStatus").AlterColumn("MostRecentFailure").AsDateTimeOffset().Nullable(); + Alter.Table("IndexerStatus").AlterColumn("DisabledTill").AsDateTimeOffset().Nullable(); + Alter.Table("IndexerStatus").AlterColumn("CookiesExpirationDate").AsDateTimeOffset().Nullable(); + Alter.Table("MetadataFiles").AlterColumn("LastUpdated").AsDateTimeOffset().NotNullable(); + Alter.Table("MetadataFiles").AlterColumn("Added").AsDateTimeOffset().Nullable(); + Alter.Table("MovieFiles").AlterColumn("DateAdded").AsDateTimeOffset().NotNullable(); + Alter.Table("MovieMetadata").AlterColumn("DigitalRelease").AsDateTimeOffset().Nullable(); + Alter.Table("MovieMetadata").AlterColumn("InCinemas").AsDateTimeOffset().Nullable(); + Alter.Table("MovieMetadata").AlterColumn("LastInfoSync").AsDateTimeOffset().Nullable(); + Alter.Table("MovieMetadata").AlterColumn("PhysicalRelease").AsDateTimeOffset().Nullable(); + Alter.Table("Movies").AlterColumn("Added").AsDateTimeOffset().Nullable(); + Alter.Table("PendingReleases").AlterColumn("Added").AsDateTimeOffset().NotNullable(); + Alter.Table("ScheduledTasks").AlterColumn("LastExecution").AsDateTimeOffset().NotNullable(); + Alter.Table("ScheduledTasks").AlterColumn("LastStartTime").AsDateTimeOffset().Nullable(); + Alter.Table("SubtitleFiles").AlterColumn("Added").AsDateTimeOffset().NotNullable(); + Alter.Table("SubtitleFiles").AlterColumn("LastUpdated").AsDateTimeOffset().NotNullable(); + Alter.Table("VersionInfo").AlterColumn("AppliedOn").AsDateTimeOffset().Nullable(); + } + + protected override void LogDbUpgrade() + { + Alter.Table("Logs").AlterColumn("Time").AsDateTimeOffset().NotNullable(); + Alter.Table("UpdateHistory").AlterColumn("Date").AsDateTimeOffset().NotNullable(); + Alter.Table("VersionInfo").AlterColumn("AppliedOn").AsDateTimeOffset().Nullable(); + } + } +} diff --git a/src/NzbDrone.Core/Radarr.Core.csproj b/src/NzbDrone.Core/Radarr.Core.csproj index 830aac966..8dc0d13c5 100644 --- a/src/NzbDrone.Core/Radarr.Core.csproj +++ b/src/NzbDrone.Core/Radarr.Core.csproj @@ -5,7 +5,6 @@ - @@ -14,8 +13,9 @@ - - + + +