< Summary

Line coverage
94%
Covered lines: 180
Uncovered lines: 10
Coverable lines: 190
Total lines: 247
Line coverage: 94.7%
Branch coverage
50%
Covered branches: 1
Total branches: 2
Branch coverage: 50%
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity Line coverage
File 1: .ctor(...)50%22100%
File 1: Up(...)100%11100%
File 1: Down(...)100%210%
File 2: BuildTargetModel(...)100%11100%

File(s)

/home/runner/work/elsa-core/elsa-core/src/modules/Elsa.Persistence.EFCore.PostgreSql/Migrations/Identity/20231015122250_Initial.cs

#LineLine coverage
 1
 2using Microsoft.EntityFrameworkCore.Migrations;
 3
 4#nullable disable
 5
 6namespace Elsa.Persistence.EFCore.PostgreSql.Migrations.Identity
 7{
 8    /// <inheritdoc />
 9    public partial class Initial : Migration
 10    {
 11        private readonly IElsaDbContextSchema _schema;
 212        public Initial(IElsaDbContextSchema schema)
 13        {
 214            _schema = schema ?? throw new ArgumentNullException(nameof(schema));
 215        }
 16        /// <inheritdoc />
 17        protected override void Up(MigrationBuilder migrationBuilder)
 18        {
 219            migrationBuilder.EnsureSchema(
 220                name: _schema.Schema);
 21
 222            migrationBuilder.CreateTable(
 223                name: "Applications",
 224                schema: _schema.Schema,
 225                columns: table => new
 226                {
 227                    Id = table.Column<string>(type: "text", nullable: false),
 228                    ClientId = table.Column<string>(type: "text", nullable: false),
 229                    HashedClientSecret = table.Column<string>(type: "text", nullable: false),
 230                    HashedClientSecretSalt = table.Column<string>(type: "text", nullable: false),
 231                    Name = table.Column<string>(type: "text", nullable: false),
 232                    HashedApiKey = table.Column<string>(type: "text", nullable: false),
 233                    HashedApiKeySalt = table.Column<string>(type: "text", nullable: false),
 234                    Roles = table.Column<string>(type: "text", nullable: false)
 235                },
 236                constraints: table =>
 237                {
 238                    table.PrimaryKey("PK_Applications", x => x.Id);
 439                });
 40
 241            migrationBuilder.CreateTable(
 242                name: "Roles",
 243                schema: _schema.Schema,
 244                columns: table => new
 245                {
 246                    Id = table.Column<string>(type: "text", nullable: false),
 247                    Name = table.Column<string>(type: "text", nullable: false),
 248                    Permissions = table.Column<string>(type: "text", nullable: false)
 249                },
 250                constraints: table =>
 251                {
 252                    table.PrimaryKey("PK_Roles", x => x.Id);
 453                });
 54
 255            migrationBuilder.CreateTable(
 256                name: "Users",
 257                schema: _schema.Schema,
 258                columns: table => new
 259                {
 260                    Id = table.Column<string>(type: "text", nullable: false),
 261                    Name = table.Column<string>(type: "text", nullable: false),
 262                    HashedPassword = table.Column<string>(type: "text", nullable: false),
 263                    HashedPasswordSalt = table.Column<string>(type: "text", nullable: false),
 264                    Roles = table.Column<string>(type: "text", nullable: false)
 265                },
 266                constraints: table =>
 267                {
 268                    table.PrimaryKey("PK_Users", x => x.Id);
 469                });
 70
 271            migrationBuilder.CreateIndex(
 272                name: "IX_Application_ClientId",
 273                schema: _schema.Schema,
 274                table: "Applications",
 275                column: "ClientId",
 276                unique: true);
 77
 278            migrationBuilder.CreateIndex(
 279                name: "IX_Application_Name",
 280                schema: _schema.Schema,
 281                table: "Applications",
 282                column: "Name",
 283                unique: true);
 84
 285            migrationBuilder.CreateIndex(
 286                name: "IX_Role_Name",
 287                schema: _schema.Schema,
 288                table: "Roles",
 289                column: "Name",
 290                unique: true);
 91
 292            migrationBuilder.CreateIndex(
 293                name: "IX_User_Name",
 294                schema: _schema.Schema,
 295                table: "Users",
 296                column: "Name",
 297                unique: true);
 298        }
 99
 100        /// <inheritdoc />
 101        protected override void Down(MigrationBuilder migrationBuilder)
 102        {
 0103            migrationBuilder.DropTable(
 0104                name: "Applications",
 0105                schema: _schema.Schema);
 106
 0107            migrationBuilder.DropTable(
 0108                name: "Roles",
 0109                schema: _schema.Schema);
 110
 0111            migrationBuilder.DropTable(
 0112                name: "Users",
 0113                schema: _schema.Schema);
 0114        }
 115    }
 116}

/home/runner/work/elsa-core/elsa-core/src/modules/Elsa.Persistence.EFCore.PostgreSql/Migrations/Identity/20231015122250_Initial.Designer.cs

#LineLine coverage
 1// <auto-generated />
 2using Elsa.Persistence.EFCore.Modules.Identity;
 3using Microsoft.EntityFrameworkCore;
 4using Microsoft.EntityFrameworkCore.Infrastructure;
 5using Microsoft.EntityFrameworkCore.Migrations;
 6using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
 7using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
 8
 9#nullable disable
 10
 11namespace Elsa.Persistence.EFCore.PostgreSql.Migrations.Identity
 12{
 13    [DbContext(typeof(IdentityElsaDbContext))]
 14    [Migration("20231015122250_Initial")]
 15    partial class Initial
 16    {
 17        /// <inheritdoc />
 18        protected override void BuildTargetModel(ModelBuilder modelBuilder)
 19        {
 20#pragma warning disable 612, 618
 121            modelBuilder
 122                .HasDefaultSchema("Elsa")
 123                .HasAnnotation("ProductVersion", "7.0.11")
 124                .HasAnnotation("Relational:MaxIdentifierLength", 63);
 25
 126            NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder);
 27
 128            modelBuilder.Entity("Elsa.Identity.Entities.Application", b =>
 129                {
 130                    b.Property<string>("Id")
 131                        .HasColumnType("text");
 132
 133                    b.Property<string>("ClientId")
 134                        .IsRequired()
 135                        .HasColumnType("text");
 136
 137                    b.Property<string>("HashedApiKey")
 138                        .IsRequired()
 139                        .HasColumnType("text");
 140
 141                    b.Property<string>("HashedApiKeySalt")
 142                        .IsRequired()
 143                        .HasColumnType("text");
 144
 145                    b.Property<string>("HashedClientSecret")
 146                        .IsRequired()
 147                        .HasColumnType("text");
 148
 149                    b.Property<string>("HashedClientSecretSalt")
 150                        .IsRequired()
 151                        .HasColumnType("text");
 152
 153                    b.Property<string>("Name")
 154                        .IsRequired()
 155                        .HasColumnType("text");
 156
 157                    b.Property<string>("Roles")
 158                        .IsRequired()
 159                        .HasColumnType("text")
 160                        .HasColumnName("Roles");
 161
 162                    b.HasKey("Id");
 163
 164                    b.HasIndex("ClientId")
 165                        .IsUnique()
 166                        .HasDatabaseName("IX_Application_ClientId");
 167
 168                    b.HasIndex("Name")
 169                        .IsUnique()
 170                        .HasDatabaseName("IX_Application_Name");
 171
 172                    b.ToTable("Applications", "Elsa");
 273                });
 74
 175            modelBuilder.Entity("Elsa.Identity.Entities.Role", b =>
 176                {
 177                    b.Property<string>("Id")
 178                        .HasColumnType("text");
 179
 180                    b.Property<string>("Name")
 181                        .IsRequired()
 182                        .HasColumnType("text");
 183
 184                    b.Property<string>("Permissions")
 185                        .IsRequired()
 186                        .HasColumnType("text")
 187                        .HasColumnName("Permissions");
 188
 189                    b.HasKey("Id");
 190
 191                    b.HasIndex("Name")
 192                        .IsUnique()
 193                        .HasDatabaseName("IX_Role_Name");
 194
 195                    b.ToTable("Roles", "Elsa");
 296                });
 97
 198            modelBuilder.Entity("Elsa.Identity.Entities.User", b =>
 199                {
 1100                    b.Property<string>("Id")
 1101                        .HasColumnType("text");
 1102
 1103                    b.Property<string>("HashedPassword")
 1104                        .IsRequired()
 1105                        .HasColumnType("text");
 1106
 1107                    b.Property<string>("HashedPasswordSalt")
 1108                        .IsRequired()
 1109                        .HasColumnType("text");
 1110
 1111                    b.Property<string>("Name")
 1112                        .IsRequired()
 1113                        .HasColumnType("text");
 1114
 1115                    b.Property<string>("Roles")
 1116                        .IsRequired()
 1117                        .HasColumnType("text")
 1118                        .HasColumnName("Roles");
 1119
 1120                    b.HasKey("Id");
 1121
 1122                    b.HasIndex("Name")
 1123                        .IsUnique()
 1124                        .HasDatabaseName("IX_User_Name");
 1125
 1126                    b.ToTable("Users", "Elsa");
 2127                });
 128#pragma warning restore 612, 618
 1129        }
 130    }
 131}