From e94a72795c7349abead76a3566614c4dcb01e98f Mon Sep 17 00:00:00 2001 From: Phil Schneider Date: Wed, 31 Jan 2024 10:35:33 +0100 Subject: [PATCH] feat(db): add database schema Refs: #7 --- src/Directory.Build.props | 25 +++ src/SsiAuthoritySchemaRegistry.sln | 37 ++++ ...thoritySchemaRegistry.sln.DotSettings.user | 6 + .../Entities/Authority.cs | 8 + .../Entities/Credential.cs | 32 +++ .../Entities/CredentialAuthority.cs | 30 +++ .../Entities/CredentialType.cs | 37 ++++ .../Enums/CredentialTypeId.cs | 28 +++ .../RegistryContext.cs | 87 ++++++++ ...SsiAuthoritySchemaRegistry.Entities.csproj | 35 ++++ .../20240131122429_0.1.0-rc1.Designer.cs | 192 ++++++++++++++++++ .../Migrations/20240131122429_0.1.0-rc1.cs | 154 ++++++++++++++ .../RegistryContextModelSnapshot.cs | 189 +++++++++++++++++ .../Program.cs | 58 ++++++ .../Properties/launchSettings.json | 10 + .../Seeder/BatchInsertSeeder.cs | 88 ++++++++ .../Seeder/Data/authorities.json | 8 + .../Seeder/Data/credential_authorities.json | 34 ++++ .../Seeder/Data/credentials.json | 37 ++++ ...iAuthoritySchemaRegistry.Migrations.csproj | 81 ++++++++ .../appsettings.json | 36 ++++ .../Program.cs | 21 ++ .../SsiAuthoritySchemaRegistry.Service.csproj | 53 +++++ src/settings-coverage.xml | 115 +++++++++++ 24 files changed, 1401 insertions(+) create mode 100644 src/Directory.Build.props create mode 100644 src/SsiAuthoritySchemaRegistry.sln create mode 100644 src/SsiAuthoritySchemaRegistry.sln.DotSettings.user create mode 100644 src/database/SsiAuthoritySchemaRegistry.Entities/Entities/Authority.cs create mode 100644 src/database/SsiAuthoritySchemaRegistry.Entities/Entities/Credential.cs create mode 100644 src/database/SsiAuthoritySchemaRegistry.Entities/Entities/CredentialAuthority.cs create mode 100644 src/database/SsiAuthoritySchemaRegistry.Entities/Entities/CredentialType.cs create mode 100644 src/database/SsiAuthoritySchemaRegistry.Entities/Enums/CredentialTypeId.cs create mode 100644 src/database/SsiAuthoritySchemaRegistry.Entities/RegistryContext.cs create mode 100644 src/database/SsiAuthoritySchemaRegistry.Entities/SsiAuthoritySchemaRegistry.Entities.csproj create mode 100644 src/database/SsiAuthoritySchemaRegistry.Migrations/Migrations/20240131122429_0.1.0-rc1.Designer.cs create mode 100644 src/database/SsiAuthoritySchemaRegistry.Migrations/Migrations/20240131122429_0.1.0-rc1.cs create mode 100644 src/database/SsiAuthoritySchemaRegistry.Migrations/Migrations/RegistryContextModelSnapshot.cs create mode 100644 src/database/SsiAuthoritySchemaRegistry.Migrations/Program.cs create mode 100644 src/database/SsiAuthoritySchemaRegistry.Migrations/Properties/launchSettings.json create mode 100644 src/database/SsiAuthoritySchemaRegistry.Migrations/Seeder/BatchInsertSeeder.cs create mode 100644 src/database/SsiAuthoritySchemaRegistry.Migrations/Seeder/Data/authorities.json create mode 100644 src/database/SsiAuthoritySchemaRegistry.Migrations/Seeder/Data/credential_authorities.json create mode 100644 src/database/SsiAuthoritySchemaRegistry.Migrations/Seeder/Data/credentials.json create mode 100644 src/database/SsiAuthoritySchemaRegistry.Migrations/SsiAuthoritySchemaRegistry.Migrations.csproj create mode 100644 src/database/SsiAuthoritySchemaRegistry.Migrations/appsettings.json create mode 100644 src/registry/SsiAuthoritySchemaRegistry.Service/Program.cs create mode 100644 src/registry/SsiAuthoritySchemaRegistry.Service/SsiAuthoritySchemaRegistry.Service.csproj create mode 100644 src/settings-coverage.xml diff --git a/src/Directory.Build.props b/src/Directory.Build.props new file mode 100644 index 0000000..9e78a55 --- /dev/null +++ b/src/Directory.Build.props @@ -0,0 +1,25 @@ + + + + + 0.1.0 + rc.1 + + diff --git a/src/SsiAuthoritySchemaRegistry.sln b/src/SsiAuthoritySchemaRegistry.sln new file mode 100644 index 0000000..feea64e --- /dev/null +++ b/src/SsiAuthoritySchemaRegistry.sln @@ -0,0 +1,37 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "database", "database", "{CD0CFEEC-AE1A-4861-A9DA-1A6985271A2C}" +EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "issuer", "issuer", "{F4C71A62-F592-42D1-981E-253B3C5F80D6}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SsiAuthoritySchemaRegistry.Entities", "database\SsiAuthoritySchemaRegistry.Entities\SsiAuthoritySchemaRegistry.Entities.csproj", "{FA3B20E3-D396-467E-A05C-B16808055B33}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SsiAuthoritySchemaRegistry.Migrations", "database\SsiAuthoritySchemaRegistry.Migrations\SsiAuthoritySchemaRegistry.Migrations.csproj", "{F68BA7A9-AD67-4E0B-B859-1505671304E9}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SsiAuthoritySchemaRegistry.Service", "registry\SsiAuthoritySchemaRegistry.Service\SsiAuthoritySchemaRegistry.Service.csproj", "{1AA22A40-802C-407B-AABF-E250931E4673}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {FA3B20E3-D396-467E-A05C-B16808055B33}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {FA3B20E3-D396-467E-A05C-B16808055B33}.Debug|Any CPU.Build.0 = Debug|Any CPU + {FA3B20E3-D396-467E-A05C-B16808055B33}.Release|Any CPU.ActiveCfg = Release|Any CPU + {FA3B20E3-D396-467E-A05C-B16808055B33}.Release|Any CPU.Build.0 = Release|Any CPU + {F68BA7A9-AD67-4E0B-B859-1505671304E9}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {F68BA7A9-AD67-4E0B-B859-1505671304E9}.Debug|Any CPU.Build.0 = Debug|Any CPU + {F68BA7A9-AD67-4E0B-B859-1505671304E9}.Release|Any CPU.ActiveCfg = Release|Any CPU + {F68BA7A9-AD67-4E0B-B859-1505671304E9}.Release|Any CPU.Build.0 = Release|Any CPU + {1AA22A40-802C-407B-AABF-E250931E4673}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {1AA22A40-802C-407B-AABF-E250931E4673}.Debug|Any CPU.Build.0 = Debug|Any CPU + {1AA22A40-802C-407B-AABF-E250931E4673}.Release|Any CPU.ActiveCfg = Release|Any CPU + {1AA22A40-802C-407B-AABF-E250931E4673}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(NestedProjects) = preSolution + {FA3B20E3-D396-467E-A05C-B16808055B33} = {CD0CFEEC-AE1A-4861-A9DA-1A6985271A2C} + {F68BA7A9-AD67-4E0B-B859-1505671304E9} = {CD0CFEEC-AE1A-4861-A9DA-1A6985271A2C} + {1AA22A40-802C-407B-AABF-E250931E4673} = {F4C71A62-F592-42D1-981E-253B3C5F80D6} + EndGlobalSection +EndGlobal diff --git a/src/SsiAuthoritySchemaRegistry.sln.DotSettings.user b/src/SsiAuthoritySchemaRegistry.sln.DotSettings.user new file mode 100644 index 0000000..dc8196c --- /dev/null +++ b/src/SsiAuthoritySchemaRegistry.sln.DotSettings.user @@ -0,0 +1,6 @@ + + C:\Program Files\dotnet\sdk\8.0.101\MSBuild.dll + 1114112 + <SessionState ContinuousTestingMode="0" IsActive="True" Name="All tests from &lt;tests&gt;" xmlns="urn:schemas-jetbrains-com:jetbrains-ut-session"> + <Project Location="C:\projects\customers\bmw\policy-hub\src" Presentation="&lt;tests&gt;" /> +</SessionState> \ No newline at end of file diff --git a/src/database/SsiAuthoritySchemaRegistry.Entities/Entities/Authority.cs b/src/database/SsiAuthoritySchemaRegistry.Entities/Entities/Authority.cs new file mode 100644 index 0000000..d066334 --- /dev/null +++ b/src/database/SsiAuthoritySchemaRegistry.Entities/Entities/Authority.cs @@ -0,0 +1,8 @@ +namespace Org.Eclipse.TractusX.SsiAuthoritySchemaRegistry.Entities.Entities; + +public class Authority(string bpn) +{ + public string Bpn { get; set; } = bpn; + + public ICollection CredentialAuthorities { get; private set; } = new HashSet(); +} diff --git a/src/database/SsiAuthoritySchemaRegistry.Entities/Entities/Credential.cs b/src/database/SsiAuthoritySchemaRegistry.Entities/Entities/Credential.cs new file mode 100644 index 0000000..70dd63f --- /dev/null +++ b/src/database/SsiAuthoritySchemaRegistry.Entities/Entities/Credential.cs @@ -0,0 +1,32 @@ +/******************************************************************************** + * Copyright (c) 2024 Contributors to the Eclipse Foundation + * + * See the NOTICE file(s) distributed with this work for additional + * information regarding copyright ownership. + * + * This program and the accompanying materials are made available under the + * terms of the Apache License, Version 2.0 which is available at + * https://www.apache.org/licenses/LICENSE-2.0. + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations + * under the License. + * + * SPDX-License-Identifier: Apache-2.0 + ********************************************************************************/ + +using Org.Eclipse.TractusX.SsiAuthoritySchemaRegistry.Entities.Enums; + +namespace Org.Eclipse.TractusX.SsiAuthoritySchemaRegistry.Entities.Entities; + +public class Credential(Guid id, CredentialTypeId typeId, string name) +{ + public Guid Id { get; set; } = id; + public CredentialTypeId TypeId { get; set; } = typeId; + public string Name { get; set; } = name; + + public ICollection Authorities { get; private set; } = new HashSet(); + public virtual CredentialType? Type { get; private set; } +} diff --git a/src/database/SsiAuthoritySchemaRegistry.Entities/Entities/CredentialAuthority.cs b/src/database/SsiAuthoritySchemaRegistry.Entities/Entities/CredentialAuthority.cs new file mode 100644 index 0000000..ab990e9 --- /dev/null +++ b/src/database/SsiAuthoritySchemaRegistry.Entities/Entities/CredentialAuthority.cs @@ -0,0 +1,30 @@ +/******************************************************************************** + * Copyright (c) 2024 Contributors to the Eclipse Foundation + * + * See the NOTICE file(s) distributed with this work for additional + * information regarding copyright ownership. + * + * This program and the accompanying materials are made available under the + * terms of the Apache License, Version 2.0 which is available at + * https://www.apache.org/licenses/LICENSE-2.0. + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations + * under the License. + * + * SPDX-License-Identifier: Apache-2.0 + ********************************************************************************/ + +namespace Org.Eclipse.TractusX.SsiAuthoritySchemaRegistry.Entities.Entities; + +public class CredentialAuthority(Guid credentialId, string bpn) +{ + public Guid CredentialId { get; set; } = credentialId; + public string Bpn { get; set; } = bpn; + + public virtual Credential? Credential { get; private set; } + + public virtual Authority? Authority { get; private set; } +} diff --git a/src/database/SsiAuthoritySchemaRegistry.Entities/Entities/CredentialType.cs b/src/database/SsiAuthoritySchemaRegistry.Entities/Entities/CredentialType.cs new file mode 100644 index 0000000..3677ec1 --- /dev/null +++ b/src/database/SsiAuthoritySchemaRegistry.Entities/Entities/CredentialType.cs @@ -0,0 +1,37 @@ +/******************************************************************************** + * Copyright (c) 2024 Contributors to the Eclipse Foundation + * + * See the NOTICE file(s) distributed with this work for additional + * information regarding copyright ownership. + * + * This program and the accompanying materials are made available under the + * terms of the Apache License, Version 2.0 which is available at + * https://www.apache.org/licenses/LICENSE-2.0. + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations + * under the License. + * + * SPDX-License-Identifier: Apache-2.0 + ********************************************************************************/ + +using Org.Eclipse.TractusX.SsiAuthoritySchemaRegistry.Entities.Enums; + +namespace Org.Eclipse.TractusX.SsiAuthoritySchemaRegistry.Entities.Entities; + +public class CredentialType() +{ + public CredentialType(CredentialTypeId typeId) + : this() + { + Id = typeId; + Label = typeId.ToString(); + } + + public CredentialTypeId Id { get; set; } + public string Label { get; set; } = null!; + + public ICollection Credentials { get; private set; } = new HashSet(); +} diff --git a/src/database/SsiAuthoritySchemaRegistry.Entities/Enums/CredentialTypeId.cs b/src/database/SsiAuthoritySchemaRegistry.Entities/Enums/CredentialTypeId.cs new file mode 100644 index 0000000..776abc8 --- /dev/null +++ b/src/database/SsiAuthoritySchemaRegistry.Entities/Enums/CredentialTypeId.cs @@ -0,0 +1,28 @@ +/******************************************************************************** + * Copyright (c) 2024 Contributors to the Eclipse Foundation + * + * See the NOTICE file(s) distributed with this work for additional + * information regarding copyright ownership. + * + * This program and the accompanying materials are made available under the + * terms of the Apache License, Version 2.0 which is available at + * https://www.apache.org/licenses/LICENSE-2.0. + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations + * under the License. + * + * SPDX-License-Identifier: Apache-2.0 + ********************************************************************************/ + +namespace Org.Eclipse.TractusX.SsiAuthoritySchemaRegistry.Entities.Enums; + +public enum CredentialTypeId +{ + BusinessPartnerNumber = 1, + Membership = 2, + Framework = 3, + CompanyRole = 4 +} diff --git a/src/database/SsiAuthoritySchemaRegistry.Entities/RegistryContext.cs b/src/database/SsiAuthoritySchemaRegistry.Entities/RegistryContext.cs new file mode 100644 index 0000000..071c797 --- /dev/null +++ b/src/database/SsiAuthoritySchemaRegistry.Entities/RegistryContext.cs @@ -0,0 +1,87 @@ +/******************************************************************************** + * Copyright (c) 2024 Contributors to the Eclipse Foundation + * + * See the NOTICE file(s) distributed with this work for additional + * information regarding copyright ownership. + * + * This program and the accompanying materials are made available under the + * terms of the Apache License, Version 2.0 which is available at + * https://www.apache.org/licenses/LICENSE-2.0. + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations + * under the License. + * + * SPDX-License-Identifier: Apache-2.0 + ********************************************************************************/ + +using Microsoft.EntityFrameworkCore; +using Org.Eclipse.TractusX.SsiAuthoritySchemaRegistry.Entities.Entities; +using Org.Eclipse.TractusX.SsiAuthoritySchemaRegistry.Entities.Enums; + +namespace Org.Eclipse.TractusX.SsiAuthoritySchemaRegistry.Entities; + +public class RegistryContext : DbContext +{ + public RegistryContext() + { + } + + public RegistryContext(DbContextOptions options) + : base(options) + { + } + + public virtual DbSet Credentials { get; set; } = default!; + public virtual DbSet CredentialAuthorities { get; set; } = default!; + public virtual DbSet Authorities { get; set; } = default!; + public virtual DbSet CredentialTypes { get; set; } = default!; + + protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder) + { + optionsBuilder.UseSnakeCaseNamingConvention(); + } + + protected override void OnModelCreating(ModelBuilder modelBuilder) + { + modelBuilder.HasAnnotation("Relational:Collation", "en_US.utf8"); + modelBuilder.HasDefaultSchema("ssi-authority-schema-registry"); + + modelBuilder.Entity(e => + { + e.HasKey(a => a.Bpn); + }); + + modelBuilder.Entity(e => + { + e.HasMany(c => c.Authorities) + .WithOne(c => c.Credential) + .HasForeignKey(c => c.CredentialId) + .OnDelete(DeleteBehavior.ClientSetNull); + } + ); + + modelBuilder.Entity(e => + { + e.HasKey(ca => new { ca.CredentialId, ca.Bpn }); + + e.HasOne(ca => ca.Credential) + .WithMany(c => c.Authorities) + .HasForeignKey(ca => ca.CredentialId) + .OnDelete(DeleteBehavior.ClientSetNull); + + e.HasOne(ca => ca.Authority) + .WithMany(c => c.CredentialAuthorities) + .HasForeignKey(ca => ca.Bpn) + .OnDelete(DeleteBehavior.ClientSetNull); + }); + + modelBuilder.Entity().HasData( + Enum.GetValues(typeof(CredentialTypeId)) + .Cast() + .Select(e => new CredentialType(e)) + ); + } +} diff --git a/src/database/SsiAuthoritySchemaRegistry.Entities/SsiAuthoritySchemaRegistry.Entities.csproj b/src/database/SsiAuthoritySchemaRegistry.Entities/SsiAuthoritySchemaRegistry.Entities.csproj new file mode 100644 index 0000000..7d9bf1a --- /dev/null +++ b/src/database/SsiAuthoritySchemaRegistry.Entities/SsiAuthoritySchemaRegistry.Entities.csproj @@ -0,0 +1,35 @@ + + + + + + Org.Eclipse.TractusX.SsiAuthoritySchemaRegistry.Entities + Org.Eclipse.TractusX.SsiAuthoritySchemaRegistry.Entities + net8.0 + enable + enable + + + + + + + + diff --git a/src/database/SsiAuthoritySchemaRegistry.Migrations/Migrations/20240131122429_0.1.0-rc1.Designer.cs b/src/database/SsiAuthoritySchemaRegistry.Migrations/Migrations/20240131122429_0.1.0-rc1.Designer.cs new file mode 100644 index 0000000..da0a127 --- /dev/null +++ b/src/database/SsiAuthoritySchemaRegistry.Migrations/Migrations/20240131122429_0.1.0-rc1.Designer.cs @@ -0,0 +1,192 @@ +/******************************************************************************** +// * Copyright (c) 2024 Contributors to the Eclipse Foundation +// * +// * See the NOTICE file(s) distributed with this work for additional +// * information regarding copyright ownership. +// * +// * This program and the accompanying materials are made available under the +// * terms of the Apache License, Version 2.0 which is available at +// * https://www.apache.org/licenses/LICENSE-2.0. +// * +// * Unless required by applicable law or agreed to in writing, software +// * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +// * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +// * License for the specific language governing permissions and limitations +// * under the License. +// * +// * SPDX-License-Identifier: Apache-2.0 +// ********************************************************************************/ + +// +using System; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Migrations; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; +using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata; +using Org.Eclipse.TractusX.SsiAuthoritySchemaRegistry.Entities; + +#nullable disable + +namespace Org.Eclipse.TractusX.SsiAuthoritySchemaRegistry.Migrations.Migrations +{ + [DbContext(typeof(RegistryContext))] + [Migration("20240131122429_0.1.0-rc1")] + partial class _010rc1 + { + /// + protected override void BuildTargetModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder + .HasDefaultSchema("ssi-authority-schema-registry") + .UseCollation("en_US.utf8") + .HasAnnotation("ProductVersion", "8.0.1") + .HasAnnotation("Relational:MaxIdentifierLength", 63); + + NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder); + + modelBuilder.Entity("Org.Eclipse.TractusX.SsiAuthoritySchemaRegistry.Entities.Entities.Authority", b => + { + b.Property("Bpn") + .HasColumnType("text") + .HasColumnName("bpn"); + + b.HasKey("Bpn") + .HasName("pk_authorities"); + + b.ToTable("authorities", "ssi-authority-schema-registry"); + }); + + modelBuilder.Entity("Org.Eclipse.TractusX.SsiAuthoritySchemaRegistry.Entities.Entities.Credential", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid") + .HasColumnName("id"); + + b.Property("Name") + .IsRequired() + .HasColumnType("text") + .HasColumnName("name"); + + b.Property("TypeId") + .HasColumnType("integer") + .HasColumnName("type_id"); + + b.HasKey("Id") + .HasName("pk_credentials"); + + b.HasIndex("TypeId") + .HasDatabaseName("ix_credentials_type_id"); + + b.ToTable("credentials", "ssi-authority-schema-registry"); + }); + + modelBuilder.Entity("Org.Eclipse.TractusX.SsiAuthoritySchemaRegistry.Entities.Entities.CredentialAuthority", b => + { + b.Property("CredentialId") + .HasColumnType("uuid") + .HasColumnName("credential_id"); + + b.Property("Bpn") + .HasColumnType("text") + .HasColumnName("bpn"); + + b.HasKey("CredentialId", "Bpn") + .HasName("pk_credential_authorities"); + + b.HasIndex("Bpn") + .HasDatabaseName("ix_credential_authorities_bpn"); + + b.ToTable("credential_authorities", "ssi-authority-schema-registry"); + }); + + modelBuilder.Entity("Org.Eclipse.TractusX.SsiAuthoritySchemaRegistry.Entities.Entities.CredentialType", b => + { + b.Property("Id") + .HasColumnType("integer") + .HasColumnName("id"); + + b.Property("Label") + .IsRequired() + .HasColumnType("text") + .HasColumnName("label"); + + b.HasKey("Id") + .HasName("pk_credential_types"); + + b.ToTable("credential_types", "ssi-authority-schema-registry"); + + b.HasData( + new + { + Id = 1, + Label = "BusinessPartnerNumber" + }, + new + { + Id = 2, + Label = "Membership" + }, + new + { + Id = 3, + Label = "Framework" + }, + new + { + Id = 4, + Label = "CompanyRole" + }); + }); + + modelBuilder.Entity("Org.Eclipse.TractusX.SsiAuthoritySchemaRegistry.Entities.Entities.Credential", b => + { + b.HasOne("Org.Eclipse.TractusX.SsiAuthoritySchemaRegistry.Entities.Entities.CredentialType", "Type") + .WithMany("Credentials") + .HasForeignKey("TypeId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired() + .HasConstraintName("fk_credentials_credential_types_type_id"); + + b.Navigation("Type"); + }); + + modelBuilder.Entity("Org.Eclipse.TractusX.SsiAuthoritySchemaRegistry.Entities.Entities.CredentialAuthority", b => + { + b.HasOne("Org.Eclipse.TractusX.SsiAuthoritySchemaRegistry.Entities.Entities.Authority", "Authority") + .WithMany("CredentialAuthorities") + .HasForeignKey("Bpn") + .IsRequired() + .HasConstraintName("fk_credential_authorities_authorities_bpn"); + + b.HasOne("Org.Eclipse.TractusX.SsiAuthoritySchemaRegistry.Entities.Entities.Credential", "Credential") + .WithMany("Authorities") + .HasForeignKey("CredentialId") + .IsRequired() + .HasConstraintName("fk_credential_authorities_credentials_credential_id"); + + b.Navigation("Authority"); + + b.Navigation("Credential"); + }); + + modelBuilder.Entity("Org.Eclipse.TractusX.SsiAuthoritySchemaRegistry.Entities.Entities.Authority", b => + { + b.Navigation("CredentialAuthorities"); + }); + + modelBuilder.Entity("Org.Eclipse.TractusX.SsiAuthoritySchemaRegistry.Entities.Entities.Credential", b => + { + b.Navigation("Authorities"); + }); + + modelBuilder.Entity("Org.Eclipse.TractusX.SsiAuthoritySchemaRegistry.Entities.Entities.CredentialType", b => + { + b.Navigation("Credentials"); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/src/database/SsiAuthoritySchemaRegistry.Migrations/Migrations/20240131122429_0.1.0-rc1.cs b/src/database/SsiAuthoritySchemaRegistry.Migrations/Migrations/20240131122429_0.1.0-rc1.cs new file mode 100644 index 0000000..b3f7b89 --- /dev/null +++ b/src/database/SsiAuthoritySchemaRegistry.Migrations/Migrations/20240131122429_0.1.0-rc1.cs @@ -0,0 +1,154 @@ +/******************************************************************************** + * Copyright (c) 2024 Contributors to the Eclipse Foundation + * + * See the NOTICE file(s) distributed with this work for additional + * information regarding copyright ownership. + * + * This program and the accompanying materials are made available under the + * terms of the Apache License, Version 2.0 which is available at + * https://www.apache.org/licenses/LICENSE-2.0. + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations + * under the License. + * + * SPDX-License-Identifier: Apache-2.0 + ********************************************************************************/ + +using Microsoft.EntityFrameworkCore.Migrations; +using System; + +#nullable disable + +#pragma warning disable CA1814 // Prefer jagged arrays over multidimensional + +namespace Org.Eclipse.TractusX.SsiAuthoritySchemaRegistry.Migrations.Migrations +{ + /// + public partial class _010rc1 : Migration + { + /// + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.EnsureSchema( + name: "ssi-authority-schema-registry"); + + migrationBuilder.CreateTable( + name: "authorities", + schema: "ssi-authority-schema-registry", + columns: table => new + { + bpn = table.Column(type: "text", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("pk_authorities", x => x.bpn); + }); + + migrationBuilder.CreateTable( + name: "credential_types", + schema: "ssi-authority-schema-registry", + columns: table => new + { + id = table.Column(type: "integer", nullable: false), + label = table.Column(type: "text", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("pk_credential_types", x => x.id); + }); + + migrationBuilder.CreateTable( + name: "credentials", + schema: "ssi-authority-schema-registry", + columns: table => new + { + id = table.Column(type: "uuid", nullable: false), + type_id = table.Column(type: "integer", nullable: false), + name = table.Column(type: "text", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("pk_credentials", x => x.id); + table.ForeignKey( + name: "fk_credentials_credential_types_type_id", + column: x => x.type_id, + principalSchema: "ssi-authority-schema-registry", + principalTable: "credential_types", + principalColumn: "id", + onDelete: ReferentialAction.Cascade); + }); + + migrationBuilder.CreateTable( + name: "credential_authorities", + schema: "ssi-authority-schema-registry", + columns: table => new + { + credential_id = table.Column(type: "uuid", nullable: false), + bpn = table.Column(type: "text", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("pk_credential_authorities", x => new { x.credential_id, x.bpn }); + table.ForeignKey( + name: "fk_credential_authorities_authorities_bpn", + column: x => x.bpn, + principalSchema: "ssi-authority-schema-registry", + principalTable: "authorities", + principalColumn: "bpn"); + table.ForeignKey( + name: "fk_credential_authorities_credentials_credential_id", + column: x => x.credential_id, + principalSchema: "ssi-authority-schema-registry", + principalTable: "credentials", + principalColumn: "id"); + }); + + migrationBuilder.InsertData( + schema: "ssi-authority-schema-registry", + table: "credential_types", + columns: new[] { "id", "label" }, + values: new object[,] + { + { 1, "BusinessPartnerNumber" }, + { 2, "Membership" }, + { 3, "Framework" }, + { 4, "CompanyRole" } + }); + + migrationBuilder.CreateIndex( + name: "ix_credential_authorities_bpn", + schema: "ssi-authority-schema-registry", + table: "credential_authorities", + column: "bpn"); + + migrationBuilder.CreateIndex( + name: "ix_credentials_type_id", + schema: "ssi-authority-schema-registry", + table: "credentials", + column: "type_id"); + } + + /// + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropTable( + name: "credential_authorities", + schema: "ssi-authority-schema-registry"); + + migrationBuilder.DropTable( + name: "authorities", + schema: "ssi-authority-schema-registry"); + + migrationBuilder.DropTable( + name: "credentials", + schema: "ssi-authority-schema-registry"); + + migrationBuilder.DropTable( + name: "credential_types", + schema: "ssi-authority-schema-registry"); + } + } +} diff --git a/src/database/SsiAuthoritySchemaRegistry.Migrations/Migrations/RegistryContextModelSnapshot.cs b/src/database/SsiAuthoritySchemaRegistry.Migrations/Migrations/RegistryContextModelSnapshot.cs new file mode 100644 index 0000000..fd6ce38 --- /dev/null +++ b/src/database/SsiAuthoritySchemaRegistry.Migrations/Migrations/RegistryContextModelSnapshot.cs @@ -0,0 +1,189 @@ +// +/******************************************************************************** + * Copyright (c) 2024 Contributors to the Eclipse Foundation + * + * See the NOTICE file(s) distributed with this work for additional + * information regarding copyright ownership. + * + * This program and the accompanying materials are made available under the + * terms of the Apache License, Version 2.0 which is available at + * https://www.apache.org/licenses/LICENSE-2.0. + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations + * under the License. + * + * SPDX-License-Identifier: Apache-2.0 + ********************************************************************************/ + +using System; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; +using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata; +using Org.Eclipse.TractusX.SsiAuthoritySchemaRegistry.Entities; + +#nullable disable + +namespace Org.Eclipse.TractusX.SsiAuthoritySchemaRegistry.Migrations.Migrations +{ + [DbContext(typeof(RegistryContext))] + partial class RegistryContextModelSnapshot : ModelSnapshot + { + protected override void BuildModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder + .HasDefaultSchema("ssi-authority-schema-registry") + .UseCollation("en_US.utf8") + .HasAnnotation("ProductVersion", "8.0.1") + .HasAnnotation("Relational:MaxIdentifierLength", 63); + + NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder); + + modelBuilder.Entity("Org.Eclipse.TractusX.SsiAuthoritySchemaRegistry.Entities.Entities.Authority", b => + { + b.Property("Bpn") + .HasColumnType("text") + .HasColumnName("bpn"); + + b.HasKey("Bpn") + .HasName("pk_authorities"); + + b.ToTable("authorities", "ssi-authority-schema-registry"); + }); + + modelBuilder.Entity("Org.Eclipse.TractusX.SsiAuthoritySchemaRegistry.Entities.Entities.Credential", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid") + .HasColumnName("id"); + + b.Property("Name") + .IsRequired() + .HasColumnType("text") + .HasColumnName("name"); + + b.Property("TypeId") + .HasColumnType("integer") + .HasColumnName("type_id"); + + b.HasKey("Id") + .HasName("pk_credentials"); + + b.HasIndex("TypeId") + .HasDatabaseName("ix_credentials_type_id"); + + b.ToTable("credentials", "ssi-authority-schema-registry"); + }); + + modelBuilder.Entity("Org.Eclipse.TractusX.SsiAuthoritySchemaRegistry.Entities.Entities.CredentialAuthority", b => + { + b.Property("CredentialId") + .HasColumnType("uuid") + .HasColumnName("credential_id"); + + b.Property("Bpn") + .HasColumnType("text") + .HasColumnName("bpn"); + + b.HasKey("CredentialId", "Bpn") + .HasName("pk_credential_authorities"); + + b.HasIndex("Bpn") + .HasDatabaseName("ix_credential_authorities_bpn"); + + b.ToTable("credential_authorities", "ssi-authority-schema-registry"); + }); + + modelBuilder.Entity("Org.Eclipse.TractusX.SsiAuthoritySchemaRegistry.Entities.Entities.CredentialType", b => + { + b.Property("Id") + .HasColumnType("integer") + .HasColumnName("id"); + + b.Property("Label") + .IsRequired() + .HasColumnType("text") + .HasColumnName("label"); + + b.HasKey("Id") + .HasName("pk_credential_types"); + + b.ToTable("credential_types", "ssi-authority-schema-registry"); + + b.HasData( + new + { + Id = 1, + Label = "BusinessPartnerNumber" + }, + new + { + Id = 2, + Label = "Membership" + }, + new + { + Id = 3, + Label = "Framework" + }, + new + { + Id = 4, + Label = "CompanyRole" + }); + }); + + modelBuilder.Entity("Org.Eclipse.TractusX.SsiAuthoritySchemaRegistry.Entities.Entities.Credential", b => + { + b.HasOne("Org.Eclipse.TractusX.SsiAuthoritySchemaRegistry.Entities.Entities.CredentialType", "Type") + .WithMany("Credentials") + .HasForeignKey("TypeId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired() + .HasConstraintName("fk_credentials_credential_types_type_id"); + + b.Navigation("Type"); + }); + + modelBuilder.Entity("Org.Eclipse.TractusX.SsiAuthoritySchemaRegistry.Entities.Entities.CredentialAuthority", b => + { + b.HasOne("Org.Eclipse.TractusX.SsiAuthoritySchemaRegistry.Entities.Entities.Authority", "Authority") + .WithMany("CredentialAuthorities") + .HasForeignKey("Bpn") + .IsRequired() + .HasConstraintName("fk_credential_authorities_authorities_bpn"); + + b.HasOne("Org.Eclipse.TractusX.SsiAuthoritySchemaRegistry.Entities.Entities.Credential", "Credential") + .WithMany("Authorities") + .HasForeignKey("CredentialId") + .IsRequired() + .HasConstraintName("fk_credential_authorities_credentials_credential_id"); + + b.Navigation("Authority"); + + b.Navigation("Credential"); + }); + + modelBuilder.Entity("Org.Eclipse.TractusX.SsiAuthoritySchemaRegistry.Entities.Entities.Authority", b => + { + b.Navigation("CredentialAuthorities"); + }); + + modelBuilder.Entity("Org.Eclipse.TractusX.SsiAuthoritySchemaRegistry.Entities.Entities.Credential", b => + { + b.Navigation("Authorities"); + }); + + modelBuilder.Entity("Org.Eclipse.TractusX.SsiAuthoritySchemaRegistry.Entities.Entities.CredentialType", b => + { + b.Navigation("Credentials"); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/src/database/SsiAuthoritySchemaRegistry.Migrations/Program.cs b/src/database/SsiAuthoritySchemaRegistry.Migrations/Program.cs new file mode 100644 index 0000000..29504b8 --- /dev/null +++ b/src/database/SsiAuthoritySchemaRegistry.Migrations/Program.cs @@ -0,0 +1,58 @@ +/******************************************************************************** + * Copyright (c) 2024 Contributors to the Eclipse Foundation + * + * See the NOTICE file(s) distributed with this work for additional + * information regarding copyright ownership. + * + * This program and the accompanying materials are made available under the + * terms of the Apache License, Version 2.0 which is available at + * https://www.apache.org/licenses/LICENSE-2.0. + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations + * under the License. + * + * SPDX-License-Identifier: Apache-2.0 + ********************************************************************************/ + +using Microsoft.EntityFrameworkCore; +using Microsoft.Extensions.Configuration; +using Microsoft.Extensions.DependencyInjection; +using Microsoft.Extensions.Hosting; +using Org.Eclipse.TractusX.Portal.Backend.Framework.Logging; +using Org.Eclipse.TractusX.Portal.Backend.Framework.Seeding.DependencyInjection; +using Org.Eclipse.TractusX.SsiAuthoritySchemaRegistry.Entities; +using Serilog; +using System.Reflection; + +LoggingExtensions.EnsureInitialized(); +Log.Information("Starting process"); +try +{ + var host = Host.CreateDefaultBuilder(args) + .ConfigureServices((hostContext, services) => + { + services + .AddDbContext(o => + o.UseNpgsql(hostContext.Configuration.GetConnectionString("RegistryDb"), + x => x.MigrationsAssembly(Assembly.GetExecutingAssembly().GetName().Name) + .MigrationsHistoryTable("__efmigrations_history_authority_schema_registry", "public"))) + .AddDatabaseInitializer(hostContext.Configuration.GetSection("Seeding")); + }) + .AddLogging() + .Build(); + + await host.Services.InitializeDatabasesAsync(); // We don't actually run anything here. The magic happens in InitializeDatabasesAsync +} +catch (Exception ex) when (!ex.GetType().Name.Equals("StopTheHostException", StringComparison.Ordinal)) +{ + Log.Fatal("Unhandled exception {Exception}", ex); + throw; +} +finally +{ + Log.Information("Process Shutting down..."); + Log.CloseAndFlush(); +} diff --git a/src/database/SsiAuthoritySchemaRegistry.Migrations/Properties/launchSettings.json b/src/database/SsiAuthoritySchemaRegistry.Migrations/Properties/launchSettings.json new file mode 100644 index 0000000..ad69a62 --- /dev/null +++ b/src/database/SsiAuthoritySchemaRegistry.Migrations/Properties/launchSettings.json @@ -0,0 +1,10 @@ +{ + "profiles": { + "PortalBackend.Migrations": { + "commandName": "Project", + "environmentVariables": { + "DOTNET_ENVIRONMENT": "Development" + } + } + } +} \ No newline at end of file diff --git a/src/database/SsiAuthoritySchemaRegistry.Migrations/Seeder/BatchInsertSeeder.cs b/src/database/SsiAuthoritySchemaRegistry.Migrations/Seeder/BatchInsertSeeder.cs new file mode 100644 index 0000000..7c57ccc --- /dev/null +++ b/src/database/SsiAuthoritySchemaRegistry.Migrations/Seeder/BatchInsertSeeder.cs @@ -0,0 +1,88 @@ +/******************************************************************************** + * Copyright (c) 2024 Contributors to the Eclipse Foundation + * + * See the NOTICE file(s) distributed with this work for additional + * information regarding copyright ownership. + * + * This program and the accompanying materials are made available under the + * terms of the Apache License, Version 2.0 which is available at + * https://www.apache.org/licenses/LICENSE-2.0. + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations + * under the License. + * + * SPDX-License-Identifier: Apache-2.0 + ********************************************************************************/ + +using Microsoft.Extensions.Logging; +using Microsoft.Extensions.Options; +using Org.Eclipse.TractusX.Portal.Backend.Framework.Seeding; +using Org.Eclipse.TractusX.SsiAuthoritySchemaRegistry.Entities; +using Org.Eclipse.TractusX.SsiAuthoritySchemaRegistry.Entities.Entities; + +namespace Org.Eclipse.TractusX.SsiAuthoritySchemaRegistry.Migrations.Seeder; + +/// +/// Seeder to seed the all configured entities +/// +public class BatchInsertSeeder : ICustomSeeder +{ + private readonly RegistryContext _context; + private readonly ILogger _logger; + private readonly SeederSettings _settings; + + /// + /// Constructor + /// + /// The database context + /// The logger + /// The options + public BatchInsertSeeder(RegistryContext context, ILogger logger, IOptions options) + { + _context = context; + _logger = logger; + _settings = options.Value; + } + + /// + public int Order => 1; + + /// + public async Task ExecuteAsync(CancellationToken cancellationToken) + { + if (!_settings.DataPaths.Any()) + { + _logger.LogInformation("There a no data paths configured, therefore the {SeederName} will be skipped", nameof(BatchInsertSeeder)); + return; + } + + await SeedTable("authorities", x => x.Bpn, cancellationToken).ConfigureAwait(false); + await SeedTable("credentials", x => x.Id, cancellationToken).ConfigureAwait(false); + await SeedTable("credential_authorities", x => new { x.CredentialId, x.Bpn }, cancellationToken).ConfigureAwait(false); + + await _context.SaveChangesAsync(cancellationToken).ConfigureAwait(false); + } + + private async Task SeedTable(string fileName, Func keySelector, CancellationToken cancellationToken) where T : class + { + _logger.LogDebug("Start seeding {Filename}", fileName); + var additionalEnvironments = _settings.TestDataEnvironments ?? Enumerable.Empty(); + var data = await SeederHelper.GetSeedData(_logger, fileName, _settings.DataPaths, cancellationToken, additionalEnvironments.ToArray()).ConfigureAwait(false); + _logger.LogDebug("Found {ElementCount} data", data.Count); + if (data.Any()) + { + var typeName = typeof(T).Name; + _logger.LogDebug("Started to Seed {TableName}", typeName); + data = data.GroupJoin(_context.Set(), keySelector, keySelector, (d, dbEntry) => new { d, dbEntry }) + .SelectMany(t => t.dbEntry.DefaultIfEmpty(), (t, x) => new { t, x }) + .Where(t => t.x == null) + .Select(t => t.t.d).ToList(); + _logger.LogDebug("Seeding {DataCount} {TableName}", data.Count, typeName); + await _context.Set().AddRangeAsync(data, cancellationToken).ConfigureAwait(false); + _logger.LogDebug("Seeded {TableName}", typeName); + } + } +} diff --git a/src/database/SsiAuthoritySchemaRegistry.Migrations/Seeder/Data/authorities.json b/src/database/SsiAuthoritySchemaRegistry.Migrations/Seeder/Data/authorities.json new file mode 100644 index 0000000..46d3460 --- /dev/null +++ b/src/database/SsiAuthoritySchemaRegistry.Migrations/Seeder/Data/authorities.json @@ -0,0 +1,8 @@ +[ + { + "bpn": "BPNL00000003CRHK" + }, + { + "bpn": "BPNL00000003CRHL" + } +] \ No newline at end of file diff --git a/src/database/SsiAuthoritySchemaRegistry.Migrations/Seeder/Data/credential_authorities.json b/src/database/SsiAuthoritySchemaRegistry.Migrations/Seeder/Data/credential_authorities.json new file mode 100644 index 0000000..c7d46ac --- /dev/null +++ b/src/database/SsiAuthoritySchemaRegistry.Migrations/Seeder/Data/credential_authorities.json @@ -0,0 +1,34 @@ +[ + { + "credential_id": "255e01fc-65f6-43cd-8dfa-95e95fa95f60", + "bpn": "BPNL00000003CRHK" + }, + { + "credential_id": "255e01fc-65f6-43cd-8dfa-95e95fa95f61", + "bpn": "BPNL00000003CRHK" + }, + { + "credential_id": "255e01fc-65f6-43cd-8dfa-95e95fa95f62", + "bpn": "BPNL00000003CRHK" + }, + { + "credential_id": "255e01fc-65f6-43cd-8dfa-95e95fa95f63", + "bpn": "BPNL00000003CRHK" + }, + { + "credential_id": "255e01fc-65f6-43cd-8dfa-95e95fa95f64", + "bpn": "BPNL00000003CRHK" + }, + { + "credential_id": "255e01fc-65f6-43cd-8dfa-95e95fa95f65", + "bpn": "BPNL00000003CRHK" + }, + { + "credential_id": "255e01fc-65f6-43cd-8dfa-95e95fa95f66", + "bpn": "BPNL00000003CRHK" + }, + { + "credential_id": "255e01fc-65f6-43cd-8dfa-95e95fa95f66", + "bpn": "BPNL00000003CRHL" + } +] \ No newline at end of file diff --git a/src/database/SsiAuthoritySchemaRegistry.Migrations/Seeder/Data/credentials.json b/src/database/SsiAuthoritySchemaRegistry.Migrations/Seeder/Data/credentials.json new file mode 100644 index 0000000..9edcd38 --- /dev/null +++ b/src/database/SsiAuthoritySchemaRegistry.Migrations/Seeder/Data/credentials.json @@ -0,0 +1,37 @@ +[ + { + "id": "255e01fc-65f6-43cd-8dfa-95e95fa95f60", + "type_id": 1, + "name": "BPNL" + }, + { + "id": "255e01fc-65f6-43cd-8dfa-95e95fa95f61", + "type_id": 2, + "name": "CX Membership" + }, + { + "id": "255e01fc-65f6-43cd-8dfa-95e95fa95f62", + "type_id": 3, + "name": "Framework Traceability" + }, + { + "id": "255e01fc-65f6-43cd-8dfa-95e95fa95f63", + "type_id": 3, + "name": "Framework Sustainability" + }, + { + "id": "255e01fc-65f6-43cd-8dfa-95e95fa95f64", + "type_id": 3, + "name": "Framework Quality" + }, + { + "id": "255e01fc-65f6-43cd-8dfa-95e95fa95f65", + "type_id": 3, + "name": "Framework ...." + }, + { + "id": "255e01fc-65f6-43cd-8dfa-95e95fa95f66", + "type_id": 4, + "name": "Dismantler" + } +] \ No newline at end of file diff --git a/src/database/SsiAuthoritySchemaRegistry.Migrations/SsiAuthoritySchemaRegistry.Migrations.csproj b/src/database/SsiAuthoritySchemaRegistry.Migrations/SsiAuthoritySchemaRegistry.Migrations.csproj new file mode 100644 index 0000000..9ff7cab --- /dev/null +++ b/src/database/SsiAuthoritySchemaRegistry.Migrations/SsiAuthoritySchemaRegistry.Migrations.csproj @@ -0,0 +1,81 @@ + + + + + Org.Eclipse.TractusX.SsiAuthoritySchemaRegistry.Migrations + Org.Eclipse.TractusX.SsiAuthoritySchemaRegistry.Migrations + net8.0 + enable + enable + Linux + ..\..\.. + True + Exe + c81e2f63-47d8-4727-9259-eaffdb566b4d + + true + + + + + all + runtime; build; native; contentfiles; analyzers; buildtransitive + + + + + + + + + + + + + + + + + + + + + + + Always + + + + + + + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + + \ No newline at end of file diff --git a/src/database/SsiAuthoritySchemaRegistry.Migrations/appsettings.json b/src/database/SsiAuthoritySchemaRegistry.Migrations/appsettings.json new file mode 100644 index 0000000..332e447 --- /dev/null +++ b/src/database/SsiAuthoritySchemaRegistry.Migrations/appsettings.json @@ -0,0 +1,36 @@ +{ + "Serilog": { + "Using": [ "Serilog.Sinks.Console" ], + "MinimumLevel": { + "Default": "Information", + "Override": { + "Microsoft": "Warning", + "System": "Information", + "Microsoft.Hosting.Lifetime": "Information", + "Org.Eclipse.TractusX.SsiAuthoritySchemaRegistry": "Information", + "Org.Eclipse.TractusX.SsiAuthoritySchemaRegistry.Migrations": "Warning" + } + }, + "WriteTo": [ + { "Name": "Console" } + ], + "Enrich": [ + "FromLogContext", + "WithMachineName", + "WithProcessId", + "WithThreadId" + ], + "Properties": { + "Application": "SsiAutoritySchemaRegistry.Migrations" + } + }, + "ConnectionStrings": { + "RegistryDb": "placeholder" + }, + "Seeding": { + "DataPaths": [ + "Seeder/Data" + ], + "TestDataEnvironments": [] + } +} diff --git a/src/registry/SsiAuthoritySchemaRegistry.Service/Program.cs b/src/registry/SsiAuthoritySchemaRegistry.Service/Program.cs new file mode 100644 index 0000000..f28b347 --- /dev/null +++ b/src/registry/SsiAuthoritySchemaRegistry.Service/Program.cs @@ -0,0 +1,21 @@ +/******************************************************************************** + * Copyright (c) 2024 Contributors to the Eclipse Foundation + * + * See the NOTICE file(s) distributed with this work for additional + * information regarding copyright ownership. + * + * This program and the accompanying materials are made available under the + * terms of the Apache License, Version 2.0 which is available at + * https://www.apache.org/licenses/LICENSE-2.0. + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations + * under the License. + * + * SPDX-License-Identifier: Apache-2.0 + ********************************************************************************/ + +var builder = Host.CreateDefaultBuilder().Build(); +builder.Run(); diff --git a/src/registry/SsiAuthoritySchemaRegistry.Service/SsiAuthoritySchemaRegistry.Service.csproj b/src/registry/SsiAuthoritySchemaRegistry.Service/SsiAuthoritySchemaRegistry.Service.csproj new file mode 100644 index 0000000..d479839 --- /dev/null +++ b/src/registry/SsiAuthoritySchemaRegistry.Service/SsiAuthoritySchemaRegistry.Service.csproj @@ -0,0 +1,53 @@ + + + + + + Org.Eclipse.TractusX.SsiAuthoritySchemaRegistry.Service + Org.Eclipse.TractusX.SsiAuthoritySchemaRegistry.Service + net8.0 + enable + enable + Linux + ..\..\.. + True + CS1591 + 0e157b48-9f59-4c9b-b8fc-40ed582cdcf0 + + + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + + + + Program.cs + + + + diff --git a/src/settings-coverage.xml b/src/settings-coverage.xml new file mode 100644 index 0000000..0e880c6 --- /dev/null +++ b/src/settings-coverage.xml @@ -0,0 +1,115 @@ + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file