1
0
mirror of https://github.com/bitwarden/server.git synced 2024-11-22 12:15:36 +01:00
bitwarden-server/util/SqliteMigrations/Migrations/20240702142228_DistributedCache.cs
Kyle Spearrin 0d3a7b3dd5
[PM-5518] Sql-backed IDistributedCache (#3791)
* Sql-backed IDistributedCache

* sqlserver cache table

* remove unused using

* setup EF entity

* cache indexes

* add back cipher

* revert SetupEntityFramework change

* ef cache

* EntityFrameworkCache

* IServiceScopeFactory for db context

* implement EntityFrameworkCache

* move to _serviceScopeFactory

* move to config file

* ef migrations

* fixes

* datetime and error codes

* revert migrations

* migrations

* format

* static and namespace fix

* use time provider

* Move SQL migration and remove EF one for the moment

* Add clean migration of just the new table

* Formatting

* Test Custom `IDistributedCache` Implementation

* Add Back Logging

* Remove Double Logging

* Skip Test When Not EntityFrameworkCache

* Format

---------

Co-authored-by: Matt Bishop <mbishop@bitwarden.com>
Co-authored-by: Justin Baur <19896123+justindbaur@users.noreply.github.com>
2024-07-03 12:48:23 -04:00

41 lines
1.3 KiB
C#

using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace Bit.SqliteMigrations.Migrations;
/// <inheritdoc />
public partial class DistributedCache : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.CreateTable(
name: "Cache",
columns: table => new
{
Id = table.Column<string>(type: "TEXT", maxLength: 449, nullable: false),
Value = table.Column<byte[]>(type: "BLOB", nullable: true),
ExpiresAtTime = table.Column<DateTime>(type: "TEXT", nullable: false),
SlidingExpirationInSeconds = table.Column<long>(type: "INTEGER", nullable: true),
AbsoluteExpiration = table.Column<DateTime>(type: "TEXT", nullable: true)
},
constraints: table =>
{
table.PrimaryKey("PK_Cache", x => x.Id);
});
migrationBuilder.CreateIndex(
name: "IX_Cache_ExpiresAtTime",
table: "Cache",
column: "ExpiresAtTime");
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropTable(
name: "Cache");
}
}