-
Notifications
You must be signed in to change notification settings - Fork 71
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: pg distributed cache (#14031)
- Loading branch information
1 parent
ec7e741
commit c78d0a9
Showing
24 changed files
with
301 additions
and
55 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
175 changes: 175 additions & 0 deletions
175
backend/src/Designer/Migrations/20241111093515_DistributedCacheTable.Designer.cs
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
24 changes: 24 additions & 0 deletions
24
backend/src/Designer/Migrations/20241111093515_DistributedCacheTable.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
using Altinn.Studio.Designer.Migrations.SqlScripts; | ||
using Microsoft.EntityFrameworkCore.Migrations; | ||
|
||
#nullable disable | ||
|
||
namespace Altinn.Studio.Designer.Migrations | ||
{ | ||
/// <inheritdoc /> | ||
public partial class DistributedCacheTable : Migration | ||
{ | ||
/// <inheritdoc /> | ||
protected override void Up(MigrationBuilder migrationBuilder) | ||
{ | ||
migrationBuilder.Sql(SqlScriptsReadHelper.ReadSqlScript("DistributedCache/Up/01-setup-distributedcache-table.sql")); | ||
migrationBuilder.Sql(SqlScriptsReadHelper.ReadSqlScript("DistributedCache/Up/02-setup-grants.sql")); | ||
} | ||
|
||
/// <inheritdoc /> | ||
protected override void Down(MigrationBuilder migrationBuilder) | ||
{ | ||
migrationBuilder.Sql(SqlScriptsReadHelper.ReadSqlScript("DistributedCache/Down/01-drop-distributedcache-table.sql")); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
18 changes: 0 additions & 18 deletions
18
backend/src/Designer/Migrations/InitialSqlScripts/InitialScriptsReadHelper.cs
This file was deleted.
Oops, something went wrong.
1 change: 1 addition & 0 deletions
1
...c/Designer/Migrations/SqlScripts/DistributedCache/Down/01-drop-distributedcache-table.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
DROP TABLE IF EXISTS designer.distributedcache; |
11 changes: 11 additions & 0 deletions
11
...rc/Designer/Migrations/SqlScripts/DistributedCache/Up/01-setup-distributedcache-table.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
CREATE TABLE IF NOT EXISTS designer.distributedcache | ||
( | ||
"Id" text COLLATE pg_catalog."default" NOT NULL, | ||
"Value" bytea, | ||
"ExpiresAtTime" timestamp with time zone, | ||
"SlidingExpirationInSeconds" double precision, | ||
"AbsoluteExpiration" timestamp with time zone, | ||
CONSTRAINT "DistCache_pkey" PRIMARY KEY ("Id") | ||
) | ||
|
||
TABLESPACE pg_default; |
1 change: 1 addition & 0 deletions
1
backend/src/Designer/Migrations/SqlScripts/DistributedCache/Up/02-setup-grants.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
GRANT SELECT,INSERT,UPDATE,DELETE ON ALL TABLES IN SCHEMA designer TO designer; |
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
25 changes: 25 additions & 0 deletions
25
backend/src/Designer/Migrations/SqlScripts/SqlScriptsReadHelper.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
using System; | ||
using System.IO; | ||
using System.Linq; | ||
|
||
namespace Altinn.Studio.Designer.Migrations.SqlScripts; | ||
|
||
public class SqlScriptsReadHelper | ||
{ | ||
public static string ReadSqlScript(string scriptName) | ||
{ | ||
string resourceNameEnding = scriptName.Replace('/', '.'); | ||
if (!resourceNameEnding.EndsWith(".sql")) | ||
{ | ||
throw new ArgumentException("Invalid script name"); | ||
} | ||
|
||
var assembly = typeof(SqlScriptsReadHelper).Assembly; | ||
string resourceName = assembly.GetManifestResourceNames() | ||
.Single(x => x.EndsWith(resourceNameEnding)); | ||
|
||
using Stream stream = assembly.GetManifestResourceStream(resourceName); | ||
using StreamReader reader = new(stream!); | ||
return reader.ReadToEnd(); | ||
} | ||
} |
Oops, something went wrong.