1
0
mirror of https://github.com/bitwarden/server.git synced 2024-11-28 13:15:12 +01:00

[SM-195] Enable legacy timestamp for migrations (#2238)

This commit is contained in:
Oscar Hinton 2022-09-08 10:36:08 +02:00 committed by GitHub
parent b612426782
commit 6a0e134129
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 54 additions and 51 deletions

View File

@ -24,6 +24,9 @@ public class DatabaseContextFactory : IDesignTimeDbContextFactory<DatabaseContex
var globalSettings = GlobalSettingsFactory.GlobalSettings; var globalSettings = GlobalSettingsFactory.GlobalSettings;
var optionsBuilder = new DbContextOptionsBuilder<DatabaseContext>(); var optionsBuilder = new DbContextOptionsBuilder<DatabaseContext>();
var connectionString = globalSettings.PostgreSql?.ConnectionString; var connectionString = globalSettings.PostgreSql?.ConnectionString;
// NpgSql 6.0 changed how timezones works. We have not yet updated our projects to support this new behavior and need to fallback to the previous behavior.
// Check https://www.npgsql.org/doc/release-notes/6.0.html#timestamp-rationalization-and-improvements for more details.
AppContext.SetSwitch("Npgsql.EnableLegacyTimestampBehavior", true);
if (string.IsNullOrWhiteSpace(connectionString)) if (string.IsNullOrWhiteSpace(connectionString))
{ {
throw new Exception("No Postgres connection string found."); throw new Exception("No Postgres connection string found.");

View File

@ -32,13 +32,13 @@ namespace Bit.PostgresMigrations.Migrations
.HasColumnType("text"); .HasColumnType("text");
b.Property<DateTime>("CreationDate") b.Property<DateTime>("CreationDate")
.HasColumnType("timestamp with time zone"); .HasColumnType("timestamp without time zone");
b.Property<string>("Data") b.Property<string>("Data")
.HasColumnType("text"); .HasColumnType("text");
b.Property<DateTime?>("DeletedDate") b.Property<DateTime?>("DeletedDate")
.HasColumnType("timestamp with time zone"); .HasColumnType("timestamp without time zone");
b.Property<string>("Favorites") b.Property<string>("Favorites")
.HasColumnType("text"); .HasColumnType("text");
@ -53,7 +53,7 @@ namespace Bit.PostgresMigrations.Migrations
.HasColumnType("smallint"); .HasColumnType("smallint");
b.Property<DateTime>("RevisionDate") b.Property<DateTime>("RevisionDate")
.HasColumnType("timestamp with time zone"); .HasColumnType("timestamp without time zone");
b.Property<byte>("Type") b.Property<byte>("Type")
.HasColumnType("smallint"); .HasColumnType("smallint");
@ -76,7 +76,7 @@ namespace Bit.PostgresMigrations.Migrations
.HasColumnType("uuid"); .HasColumnType("uuid");
b.Property<DateTime>("CreationDate") b.Property<DateTime>("CreationDate")
.HasColumnType("timestamp with time zone"); .HasColumnType("timestamp without time zone");
b.Property<string>("ExternalId") b.Property<string>("ExternalId")
.HasMaxLength(300) .HasMaxLength(300)
@ -89,7 +89,7 @@ namespace Bit.PostgresMigrations.Migrations
.HasColumnType("uuid"); .HasColumnType("uuid");
b.Property<DateTime>("RevisionDate") b.Property<DateTime>("RevisionDate")
.HasColumnType("timestamp with time zone"); .HasColumnType("timestamp without time zone");
b.HasKey("Id"); b.HasKey("Id");
@ -167,7 +167,7 @@ namespace Bit.PostgresMigrations.Migrations
.HasColumnType("uuid"); .HasColumnType("uuid");
b.Property<DateTime>("CreationDate") b.Property<DateTime>("CreationDate")
.HasColumnType("timestamp with time zone"); .HasColumnType("timestamp without time zone");
b.Property<string>("Identifier") b.Property<string>("Identifier")
.HasMaxLength(50) .HasMaxLength(50)
@ -182,7 +182,7 @@ namespace Bit.PostgresMigrations.Migrations
.HasColumnType("character varying(255)"); .HasColumnType("character varying(255)");
b.Property<DateTime>("RevisionDate") b.Property<DateTime>("RevisionDate")
.HasColumnType("timestamp with time zone"); .HasColumnType("timestamp without time zone");
b.Property<byte>("Type") b.Property<byte>("Type")
.HasColumnType("smallint"); .HasColumnType("smallint");
@ -203,7 +203,7 @@ namespace Bit.PostgresMigrations.Migrations
.HasColumnType("uuid"); .HasColumnType("uuid");
b.Property<DateTime>("CreationDate") b.Property<DateTime>("CreationDate")
.HasColumnType("timestamp with time zone"); .HasColumnType("timestamp without time zone");
b.Property<string>("Email") b.Property<string>("Email")
.HasMaxLength(256) .HasMaxLength(256)
@ -219,13 +219,13 @@ namespace Bit.PostgresMigrations.Migrations
.HasColumnType("text"); .HasColumnType("text");
b.Property<DateTime?>("LastNotificationDate") b.Property<DateTime?>("LastNotificationDate")
.HasColumnType("timestamp with time zone"); .HasColumnType("timestamp without time zone");
b.Property<DateTime?>("RecoveryInitiatedDate") b.Property<DateTime?>("RecoveryInitiatedDate")
.HasColumnType("timestamp with time zone"); .HasColumnType("timestamp without time zone");
b.Property<DateTime>("RevisionDate") b.Property<DateTime>("RevisionDate")
.HasColumnType("timestamp with time zone"); .HasColumnType("timestamp without time zone");
b.Property<byte>("Status") b.Property<byte>("Status")
.HasColumnType("smallint"); .HasColumnType("smallint");
@ -260,7 +260,7 @@ namespace Bit.PostgresMigrations.Migrations
.HasColumnType("uuid"); .HasColumnType("uuid");
b.Property<DateTime>("Date") b.Property<DateTime>("Date")
.HasColumnType("timestamp with time zone"); .HasColumnType("timestamp without time zone");
b.Property<byte?>("DeviceType") b.Property<byte?>("DeviceType")
.HasColumnType("smallint"); .HasColumnType("smallint");
@ -310,13 +310,13 @@ namespace Bit.PostgresMigrations.Migrations
.HasColumnType("uuid"); .HasColumnType("uuid");
b.Property<DateTime>("CreationDate") b.Property<DateTime>("CreationDate")
.HasColumnType("timestamp with time zone"); .HasColumnType("timestamp without time zone");
b.Property<string>("Name") b.Property<string>("Name")
.HasColumnType("text"); .HasColumnType("text");
b.Property<DateTime>("RevisionDate") b.Property<DateTime>("RevisionDate")
.HasColumnType("timestamp with time zone"); .HasColumnType("timestamp without time zone");
b.Property<Guid>("UserId") b.Property<Guid>("UserId")
.HasColumnType("uuid"); .HasColumnType("uuid");
@ -339,10 +339,10 @@ namespace Bit.PostgresMigrations.Migrations
.HasColumnType("character varying(200)"); .HasColumnType("character varying(200)");
b.Property<DateTime?>("ConsumedDate") b.Property<DateTime?>("ConsumedDate")
.HasColumnType("timestamp with time zone"); .HasColumnType("timestamp without time zone");
b.Property<DateTime>("CreationDate") b.Property<DateTime>("CreationDate")
.HasColumnType("timestamp with time zone"); .HasColumnType("timestamp without time zone");
b.Property<string>("Data") b.Property<string>("Data")
.HasColumnType("text"); .HasColumnType("text");
@ -352,7 +352,7 @@ namespace Bit.PostgresMigrations.Migrations
.HasColumnType("character varying(200)"); .HasColumnType("character varying(200)");
b.Property<DateTime?>("ExpirationDate") b.Property<DateTime?>("ExpirationDate")
.HasColumnType("timestamp with time zone"); .HasColumnType("timestamp without time zone");
b.Property<string>("SessionId") b.Property<string>("SessionId")
.HasMaxLength(100) .HasMaxLength(100)
@ -380,7 +380,7 @@ namespace Bit.PostgresMigrations.Migrations
.HasColumnType("boolean"); .HasColumnType("boolean");
b.Property<DateTime>("CreationDate") b.Property<DateTime>("CreationDate")
.HasColumnType("timestamp with time zone"); .HasColumnType("timestamp without time zone");
b.Property<string>("ExternalId") b.Property<string>("ExternalId")
.HasMaxLength(300) .HasMaxLength(300)
@ -394,7 +394,7 @@ namespace Bit.PostgresMigrations.Migrations
.HasColumnType("uuid"); .HasColumnType("uuid");
b.Property<DateTime>("RevisionDate") b.Property<DateTime>("RevisionDate")
.HasColumnType("timestamp with time zone"); .HasColumnType("timestamp without time zone");
b.HasKey("Id"); b.HasKey("Id");
@ -429,7 +429,7 @@ namespace Bit.PostgresMigrations.Migrations
.HasColumnType("uuid"); .HasColumnType("uuid");
b.Property<DateTime>("CreationDate") b.Property<DateTime>("CreationDate")
.HasColumnType("timestamp with time zone"); .HasColumnType("timestamp without time zone");
b.Property<string>("Email") b.Property<string>("Email")
.HasMaxLength(256) .HasMaxLength(256)
@ -481,13 +481,13 @@ namespace Bit.PostgresMigrations.Migrations
.HasColumnType("character varying(30)"); .HasColumnType("character varying(30)");
b.Property<DateTime>("CreationDate") b.Property<DateTime>("CreationDate")
.HasColumnType("timestamp with time zone"); .HasColumnType("timestamp without time zone");
b.Property<bool>("Enabled") b.Property<bool>("Enabled")
.HasColumnType("boolean"); .HasColumnType("boolean");
b.Property<DateTime?>("ExpirationDate") b.Property<DateTime?>("ExpirationDate")
.HasColumnType("timestamp with time zone"); .HasColumnType("timestamp without time zone");
b.Property<byte?>("Gateway") b.Property<byte?>("Gateway")
.HasColumnType("smallint"); .HasColumnType("smallint");
@ -523,7 +523,7 @@ namespace Bit.PostgresMigrations.Migrations
.HasColumnType("character varying(50)"); .HasColumnType("character varying(50)");
b.Property<DateTime?>("OwnersNotifiedOfAutoscaling") b.Property<DateTime?>("OwnersNotifiedOfAutoscaling")
.HasColumnType("timestamp with time zone"); .HasColumnType("timestamp without time zone");
b.Property<string>("Plan") b.Property<string>("Plan")
.HasMaxLength(50) .HasMaxLength(50)
@ -542,7 +542,7 @@ namespace Bit.PostgresMigrations.Migrations
.HasColumnType("text"); .HasColumnType("text");
b.Property<DateTime>("RevisionDate") b.Property<DateTime>("RevisionDate")
.HasColumnType("timestamp with time zone"); .HasColumnType("timestamp without time zone");
b.Property<int?>("Seats") b.Property<int?>("Seats")
.HasColumnType("integer"); .HasColumnType("integer");
@ -610,7 +610,7 @@ namespace Bit.PostgresMigrations.Migrations
.HasColumnType("uuid"); .HasColumnType("uuid");
b.Property<DateTime>("RevisionDate") b.Property<DateTime>("RevisionDate")
.HasColumnType("timestamp with time zone"); .HasColumnType("timestamp without time zone");
b.Property<byte>("Type") b.Property<byte>("Type")
.HasColumnType("smallint"); .HasColumnType("smallint");
@ -656,7 +656,7 @@ namespace Bit.PostgresMigrations.Migrations
.HasColumnType("character varying(256)"); .HasColumnType("character varying(256)");
b.Property<DateTime?>("LastSyncDate") b.Property<DateTime?>("LastSyncDate")
.HasColumnType("timestamp with time zone"); .HasColumnType("timestamp without time zone");
b.Property<string>("OfferedToEmail") b.Property<string>("OfferedToEmail")
.HasMaxLength(256) .HasMaxLength(256)
@ -678,7 +678,7 @@ namespace Bit.PostgresMigrations.Migrations
.HasColumnType("boolean"); .HasColumnType("boolean");
b.Property<DateTime?>("ValidUntil") b.Property<DateTime?>("ValidUntil")
.HasColumnType("timestamp with time zone"); .HasColumnType("timestamp without time zone");
b.HasKey("Id"); b.HasKey("Id");
@ -698,7 +698,7 @@ namespace Bit.PostgresMigrations.Migrations
.HasColumnType("boolean"); .HasColumnType("boolean");
b.Property<DateTime>("CreationDate") b.Property<DateTime>("CreationDate")
.HasColumnType("timestamp with time zone"); .HasColumnType("timestamp without time zone");
b.Property<string>("Email") b.Property<string>("Email")
.HasMaxLength(256) .HasMaxLength(256)
@ -721,7 +721,7 @@ namespace Bit.PostgresMigrations.Migrations
.HasColumnType("text"); .HasColumnType("text");
b.Property<DateTime>("RevisionDate") b.Property<DateTime>("RevisionDate")
.HasColumnType("timestamp with time zone"); .HasColumnType("timestamp without time zone");
b.Property<short>("Status") b.Property<short>("Status")
.HasColumnType("smallint"); .HasColumnType("smallint");
@ -747,7 +747,7 @@ namespace Bit.PostgresMigrations.Migrations
.HasColumnType("uuid"); .HasColumnType("uuid");
b.Property<DateTime>("CreationDate") b.Property<DateTime>("CreationDate")
.HasColumnType("timestamp with time zone"); .HasColumnType("timestamp without time zone");
b.Property<string>("Data") b.Property<string>("Data")
.HasColumnType("text"); .HasColumnType("text");
@ -759,7 +759,7 @@ namespace Bit.PostgresMigrations.Migrations
.HasColumnType("uuid"); .HasColumnType("uuid");
b.Property<DateTime>("RevisionDate") b.Property<DateTime>("RevisionDate")
.HasColumnType("timestamp with time zone"); .HasColumnType("timestamp without time zone");
b.Property<byte>("Type") b.Property<byte>("Type")
.HasColumnType("smallint"); .HasColumnType("smallint");
@ -798,7 +798,7 @@ namespace Bit.PostgresMigrations.Migrations
.HasColumnType("text"); .HasColumnType("text");
b.Property<DateTime>("CreationDate") b.Property<DateTime>("CreationDate")
.HasColumnType("timestamp with time zone"); .HasColumnType("timestamp without time zone");
b.Property<bool>("Enabled") b.Property<bool>("Enabled")
.HasColumnType("boolean"); .HasColumnType("boolean");
@ -807,7 +807,7 @@ namespace Bit.PostgresMigrations.Migrations
.HasColumnType("text"); .HasColumnType("text");
b.Property<DateTime>("RevisionDate") b.Property<DateTime>("RevisionDate")
.HasColumnType("timestamp with time zone"); .HasColumnType("timestamp without time zone");
b.Property<byte>("Status") b.Property<byte>("Status")
.HasColumnType("smallint"); .HasColumnType("smallint");
@ -826,7 +826,7 @@ namespace Bit.PostgresMigrations.Migrations
.HasColumnType("uuid"); .HasColumnType("uuid");
b.Property<DateTime>("CreationDate") b.Property<DateTime>("CreationDate")
.HasColumnType("timestamp with time zone"); .HasColumnType("timestamp without time zone");
b.Property<string>("Key") b.Property<string>("Key")
.HasColumnType("text"); .HasColumnType("text");
@ -838,7 +838,7 @@ namespace Bit.PostgresMigrations.Migrations
.HasColumnType("uuid"); .HasColumnType("uuid");
b.Property<DateTime>("RevisionDate") b.Property<DateTime>("RevisionDate")
.HasColumnType("timestamp with time zone"); .HasColumnType("timestamp without time zone");
b.Property<string>("Settings") b.Property<string>("Settings")
.HasColumnType("text"); .HasColumnType("text");
@ -858,7 +858,7 @@ namespace Bit.PostgresMigrations.Migrations
.HasColumnType("uuid"); .HasColumnType("uuid");
b.Property<DateTime>("CreationDate") b.Property<DateTime>("CreationDate")
.HasColumnType("timestamp with time zone"); .HasColumnType("timestamp without time zone");
b.Property<string>("Email") b.Property<string>("Email")
.HasColumnType("text"); .HasColumnType("text");
@ -873,7 +873,7 @@ namespace Bit.PostgresMigrations.Migrations
.HasColumnType("uuid"); .HasColumnType("uuid");
b.Property<DateTime>("RevisionDate") b.Property<DateTime>("RevisionDate")
.HasColumnType("timestamp with time zone"); .HasColumnType("timestamp without time zone");
b.Property<byte>("Status") b.Property<byte>("Status")
.HasColumnType("smallint"); .HasColumnType("smallint");
@ -902,19 +902,19 @@ namespace Bit.PostgresMigrations.Migrations
.HasColumnType("integer"); .HasColumnType("integer");
b.Property<DateTime>("CreationDate") b.Property<DateTime>("CreationDate")
.HasColumnType("timestamp with time zone"); .HasColumnType("timestamp without time zone");
b.Property<string>("Data") b.Property<string>("Data")
.HasColumnType("text"); .HasColumnType("text");
b.Property<DateTime>("DeletionDate") b.Property<DateTime>("DeletionDate")
.HasColumnType("timestamp with time zone"); .HasColumnType("timestamp without time zone");
b.Property<bool>("Disabled") b.Property<bool>("Disabled")
.HasColumnType("boolean"); .HasColumnType("boolean");
b.Property<DateTime?>("ExpirationDate") b.Property<DateTime?>("ExpirationDate")
.HasColumnType("timestamp with time zone"); .HasColumnType("timestamp without time zone");
b.Property<bool?>("HideEmail") b.Property<bool?>("HideEmail")
.HasColumnType("boolean"); .HasColumnType("boolean");
@ -933,7 +933,7 @@ namespace Bit.PostgresMigrations.Migrations
.HasColumnType("character varying(300)"); .HasColumnType("character varying(300)");
b.Property<DateTime>("RevisionDate") b.Property<DateTime>("RevisionDate")
.HasColumnType("timestamp with time zone"); .HasColumnType("timestamp without time zone");
b.Property<byte>("Type") b.Property<byte>("Type")
.HasColumnType("smallint"); .HasColumnType("smallint");
@ -959,7 +959,7 @@ namespace Bit.PostgresMigrations.Migrations
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<long>("Id")); NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<long>("Id"));
b.Property<DateTime>("CreationDate") b.Property<DateTime>("CreationDate")
.HasColumnType("timestamp with time zone"); .HasColumnType("timestamp without time zone");
b.Property<string>("Data") b.Property<string>("Data")
.HasColumnType("text"); .HasColumnType("text");
@ -971,7 +971,7 @@ namespace Bit.PostgresMigrations.Migrations
.HasColumnType("uuid"); .HasColumnType("uuid");
b.Property<DateTime>("RevisionDate") b.Property<DateTime>("RevisionDate")
.HasColumnType("timestamp with time zone"); .HasColumnType("timestamp without time zone");
b.HasKey("Id"); b.HasKey("Id");
@ -989,7 +989,7 @@ namespace Bit.PostgresMigrations.Migrations
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<long>("Id")); NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<long>("Id"));
b.Property<DateTime>("CreationDate") b.Property<DateTime>("CreationDate")
.HasColumnType("timestamp with time zone"); .HasColumnType("timestamp without time zone");
b.Property<string>("ExternalId") b.Property<string>("ExternalId")
.HasMaxLength(50) .HasMaxLength(50)
@ -1049,7 +1049,7 @@ namespace Bit.PostgresMigrations.Migrations
.HasColumnType("numeric"); .HasColumnType("numeric");
b.Property<DateTime>("CreationDate") b.Property<DateTime>("CreationDate")
.HasColumnType("timestamp with time zone"); .HasColumnType("timestamp without time zone");
b.Property<string>("Details") b.Property<string>("Details")
.HasMaxLength(100) .HasMaxLength(100)
@ -1095,7 +1095,7 @@ namespace Bit.PostgresMigrations.Migrations
.HasColumnType("uuid"); .HasColumnType("uuid");
b.Property<DateTime>("AccountRevisionDate") b.Property<DateTime>("AccountRevisionDate")
.HasColumnType("timestamp with time zone"); .HasColumnType("timestamp without time zone");
b.Property<string>("ApiKey") b.Property<string>("ApiKey")
.IsRequired() .IsRequired()
@ -1103,7 +1103,7 @@ namespace Bit.PostgresMigrations.Migrations
.HasColumnType("character varying(30)"); .HasColumnType("character varying(30)");
b.Property<DateTime>("CreationDate") b.Property<DateTime>("CreationDate")
.HasColumnType("timestamp with time zone"); .HasColumnType("timestamp without time zone");
b.Property<string>("Culture") b.Property<string>("Culture")
.HasMaxLength(10) .HasMaxLength(10)
@ -1151,7 +1151,7 @@ namespace Bit.PostgresMigrations.Migrations
.HasColumnType("text"); .HasColumnType("text");
b.Property<DateTime?>("LastFailedLoginDate") b.Property<DateTime?>("LastFailedLoginDate")
.HasColumnType("timestamp with time zone"); .HasColumnType("timestamp without time zone");
b.Property<string>("LicenseKey") b.Property<string>("LicenseKey")
.HasMaxLength(100) .HasMaxLength(100)
@ -1176,7 +1176,7 @@ namespace Bit.PostgresMigrations.Migrations
.HasColumnType("boolean"); .HasColumnType("boolean");
b.Property<DateTime?>("PremiumExpirationDate") b.Property<DateTime?>("PremiumExpirationDate")
.HasColumnType("timestamp with time zone"); .HasColumnType("timestamp without time zone");
b.Property<string>("PrivateKey") b.Property<string>("PrivateKey")
.HasColumnType("text"); .HasColumnType("text");
@ -1188,10 +1188,10 @@ namespace Bit.PostgresMigrations.Migrations
.HasColumnType("text"); .HasColumnType("text");
b.Property<DateTime?>("RenewalReminderDate") b.Property<DateTime?>("RenewalReminderDate")
.HasColumnType("timestamp with time zone"); .HasColumnType("timestamp without time zone");
b.Property<DateTime>("RevisionDate") b.Property<DateTime>("RevisionDate")
.HasColumnType("timestamp with time zone"); .HasColumnType("timestamp without time zone");
b.Property<string>("SecurityStamp") b.Property<string>("SecurityStamp")
.IsRequired() .IsRequired()