Skip to content

Commit

Permalink
Merge branch 'main' into 14004-when-a-component-id-is-updated-any-mat…
Browse files Browse the repository at this point in the history
…ching-json-key-eg-id-type-datamodelbindings--is-also-updated
  • Loading branch information
mlqn authored Nov 11, 2024
2 parents 2f71dfb + 1fc22c5 commit 5857719
Show file tree
Hide file tree
Showing 70 changed files with 1,399 additions and 277 deletions.
2 changes: 1 addition & 1 deletion .github/scripts/release.sh
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ while [[ $# -gt 0 ]]; do
esac
done

CURRENT_VERSION=$(git describe --abbrev=0 --tags 2>/dev/null)
CURRENT_VERSION=$(curl -s https://api.github.com/repos/Altinn/altinn-studio/releases/latest | jq -r .tag_name)
CURRENT_VERSION_PARTS=(${CURRENT_VERSION//./ })
FIRST_PART=${CURRENT_VERSION_PARTS[0]:1}
SECOND_PART=${CURRENT_VERSION_PARTS[1]}
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
name: Generate release for Altinn Studio
on:
schedule:
# run every friday at 14:45
- cron: '45 14 * * 5'
# run every friday at 14:15 UTC (15:15 Oslo time)
- cron: '15 14 * * 5'

workflow_dispatch:
inputs:
Expand Down
1 change: 1 addition & 0 deletions backend/packagegroups/NuGet.props
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
<PackageReference Update="DotNetEnv" Version="3.1.1" />
<PackageReference Update="NuGet.Versioning" Version="6.11.1" />
<PackageReference Update="DistributedLock.Postgres" Version="1.2.0" />
<PackageReference Update="Community.Microsoft.Extensions.Caching.PostgreSql" Version="4.0.6" />
</ItemGroup>

<ItemGroup Label="Packages used for testing">
Expand Down
3 changes: 2 additions & 1 deletion backend/src/Designer/Designer.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
<PackageReference Include="Altinn.Common.AccessTokenClient" />
<PackageReference Include="Altinn.Platform.Storage.Interface" />
<PackageReference Include="Azure.Security.KeyVault.Secrets" />
<PackageReference Include="Community.Microsoft.Extensions.Caching.PostgreSql" />
<PackageReference Include="CompilerAttributes" />
<PackageReference Include="DistributedLock.Postgres" />
<PackageReference Include="DotNetEnv" />
Expand Down Expand Up @@ -167,7 +168,7 @@
</ItemGroup>

<ItemGroup>
<EmbeddedResource Include="Migrations/InitialSqlScripts/*.sql" />
<EmbeddedResource Include="Migrations/SqlScripts/**/*.sql" />
</ItemGroup>

<Target Name="AfterPublishScript" AfterTargets="Publish">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,10 @@ public class PostgreSQLSettings : ISettingsMarker
/// Password for app user for the postgres db
/// </summary>
public string DesignerDbPwd { get; set; }

public string FormattedConnectionString()
{
return string.Format(ConnectionString, DesignerDbPwd);
}
}
}
5 changes: 1 addition & 4 deletions backend/src/Designer/Infrastructure/ServiceRegistration.cs
Original file line number Diff line number Diff line change
Expand Up @@ -48,10 +48,7 @@ public static IServiceCollection RegisterServiceImplementations(this IServiceCol
services.AddDbContext<DesignerdbContext>(options =>
{
PostgreSQLSettings postgresSettings = configuration.GetSection(nameof(PostgreSQLSettings)).Get<PostgreSQLSettings>();
string connectionString = string.Format(
postgresSettings.ConnectionString,
postgresSettings.DesignerDbPwd);
options.UseNpgsql(connectionString);
options.UseNpgsql(postgresSettings.FormattedConnectionString());
});

services.AddScoped<IReleaseRepository, ORMReleaseRepository>();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,7 @@ public static IServiceCollection RegisterSynchronizationServices(this IServiceCo
services.AddSingleton<IDistributedLockProvider>(_ =>
{
PostgreSQLSettings postgresSettings = configuration.GetSection(nameof(PostgreSQLSettings)).Get<PostgreSQLSettings>();
string connectionString = string.Format(
postgresSettings.ConnectionString,
postgresSettings.DesignerDbPwd);
return new PostgresDistributedSynchronizationProvider(connectionString);
return new PostgresDistributedSynchronizationProvider(postgresSettings.FormattedConnectionString());
});
return services;
}
Expand Down
12 changes: 6 additions & 6 deletions backend/src/Designer/Migrations/20240409201554_InitMigration.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using Altinn.Studio.Designer.Migrations.InitialSqlScripts;
using Altinn.Studio.Designer.Migrations.SqlScripts;
using Microsoft.EntityFrameworkCore.Migrations;

#nullable disable
Expand All @@ -12,11 +12,11 @@ public partial class InitMigration : Migration
protected override void Up(MigrationBuilder migrationBuilder)
{
// initial sql used in yuniql migration are idempotent so it is safe to execute them as initial ef-core migration
migrationBuilder.Sql(InitialScriptsReadHelper.ReadInitialSqlScript("01-setup-tables.sql"));
migrationBuilder.Sql(InitialScriptsReadHelper.ReadInitialSqlScript("02-setup-deployments.sql"));
migrationBuilder.Sql(InitialScriptsReadHelper.ReadInitialSqlScript("03-setup-releases.sql"));
migrationBuilder.Sql(InitialScriptsReadHelper.ReadInitialSqlScript("04-setup-grants.sql"));
migrationBuilder.Sql(InitialScriptsReadHelper.ReadInitialSqlScript("05-setup-index.sql"));
migrationBuilder.Sql(SqlScriptsReadHelper.ReadSqlScript("InitialSqlScripts/01-setup-tables.sql"));
migrationBuilder.Sql(SqlScriptsReadHelper.ReadSqlScript("InitialSqlScripts/02-setup-deployments.sql"));
migrationBuilder.Sql(SqlScriptsReadHelper.ReadSqlScript("InitialSqlScripts/03-setup-releases.sql"));
migrationBuilder.Sql(SqlScriptsReadHelper.ReadSqlScript("InitialSqlScripts/04-setup-grants.sql"));
migrationBuilder.Sql(SqlScriptsReadHelper.ReadSqlScript("InitialSqlScripts/05-setup-index.sql"));
}

/// <inheritdoc />
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

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"));
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ protected override void BuildModel(ModelBuilder modelBuilder)
{
#pragma warning disable 612, 618
modelBuilder
.HasAnnotation("ProductVersion", "8.0.8")
.HasAnnotation("ProductVersion", "8.0.10")
.HasAnnotation("Relational:MaxIdentifierLength", 63);

NpgsqlModelBuilderExtensions.UseSerialColumns(modelBuilder);
Expand All @@ -36,7 +36,7 @@ protected override void BuildModel(ModelBuilder modelBuilder)
.HasColumnType("character varying")
.HasColumnName("app");

b.Property<DateTime>("Created")
b.Property<DateTimeOffset>("Created")
.HasColumnType("timestamptz")
.HasColumnName("created");

Expand All @@ -58,6 +58,12 @@ protected override void BuildModel(ModelBuilder modelBuilder)
.HasColumnType("jsonb")
.HasColumnName("scopes");

b.Property<uint>("Version")
.IsConcurrencyToken()
.ValueGeneratedOnAddOrUpdate()
.HasColumnType("xid")
.HasColumnName("xmin");

b.HasKey("Id")
.HasName("app_scopes_pkey");

Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
DROP TABLE IF EXISTS designer.distributedcache;
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;
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;
25 changes: 25 additions & 0 deletions backend/src/Designer/Migrations/SqlScripts/SqlScriptsReadHelper.cs
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();
}
}
Loading

0 comments on commit 5857719

Please sign in to comment.