diff --git a/RelationshipAnalysis/Migrations/20240907090417_InitialCreate.Designer.cs b/RelationshipAnalysis/Migrations/20240907090417_InitialCreate.Designer.cs new file mode 100644 index 0000000..adf7560 --- /dev/null +++ b/RelationshipAnalysis/Migrations/20240907090417_InitialCreate.Designer.cs @@ -0,0 +1,427 @@ +// +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Migrations; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; +using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata; +using RelationshipAnalysis.Context; + +#nullable disable + +namespace RelationshipAnalysis.Migrations +{ + [DbContext(typeof(ApplicationDbContext))] + [Migration("20240907090417_InitialCreate")] + partial class InitialCreate + { + /// + protected override void BuildTargetModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder + .HasAnnotation("ProductVersion", "8.0.8") + .HasAnnotation("Proxies:ChangeTracking", false) + .HasAnnotation("Proxies:CheckEquality", false) + .HasAnnotation("Proxies:LazyLoading", true) + .HasAnnotation("Relational:MaxIdentifierLength", 63); + + NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder); + + modelBuilder.Entity("RelationshipAnalysis.Models.Auth.Role", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("Name") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("character varying(50)"); + + b.Property("Permissions") + .IsRequired() + .HasColumnType("text"); + + b.HasKey("Id"); + + b.ToTable("Roles"); + }); + + modelBuilder.Entity("RelationshipAnalysis.Models.Auth.User", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("Email") + .IsRequired() + .HasColumnType("text"); + + b.Property("FirstName") + .IsRequired() + .HasColumnType("text"); + + b.Property("LastName") + .IsRequired() + .HasColumnType("text"); + + b.Property("PasswordHash") + .IsRequired() + .HasMaxLength(256) + .HasColumnType("character varying(256)"); + + b.Property("Username") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("character varying(50)"); + + b.HasKey("Id"); + + b.ToTable("Users"); + }); + + modelBuilder.Entity("RelationshipAnalysis.Models.Auth.UserRole", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("RoleId") + .HasColumnType("integer"); + + b.Property("UserId") + .HasColumnType("integer"); + + b.HasKey("Id"); + + b.HasIndex("RoleId"); + + b.HasIndex("UserId"); + + b.ToTable("UserRoles"); + }); + + modelBuilder.Entity("RelationshipAnalysis.Models.Graph.Edge.Edge", b => + { + b.Property("EdgeId") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("EdgeId")); + + b.Property("EdgeCategoryId") + .HasColumnType("integer"); + + b.Property("EdgeDestinationNodeId") + .HasColumnType("integer"); + + b.Property("EdgeSourceNodeId") + .HasColumnType("integer"); + + b.Property("EdgeUniqueString") + .IsRequired() + .HasColumnType("text"); + + b.HasKey("EdgeId"); + + b.HasIndex("EdgeCategoryId"); + + b.HasIndex("EdgeDestinationNodeId"); + + b.HasIndex("EdgeSourceNodeId"); + + b.ToTable("Edges"); + }); + + modelBuilder.Entity("RelationshipAnalysis.Models.Graph.Edge.EdgeAttribute", b => + { + b.Property("EdgeAttributeId") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("EdgeAttributeId")); + + b.Property("EdgeAttributeName") + .IsRequired() + .HasColumnType("text"); + + b.HasKey("EdgeAttributeId"); + + b.ToTable("EdgeAttributes"); + }); + + modelBuilder.Entity("RelationshipAnalysis.Models.Graph.Edge.EdgeCategory", b => + { + b.Property("EdgeCategoryId") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("EdgeCategoryId")); + + b.Property("EdgeCategoryName") + .IsRequired() + .HasColumnType("text"); + + b.HasKey("EdgeCategoryId"); + + b.ToTable("EdgeCategories"); + }); + + modelBuilder.Entity("RelationshipAnalysis.Models.Graph.Edge.EdgeValue", b => + { + b.Property("ValueId") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("ValueId")); + + b.Property("EdgeAttributeId") + .HasColumnType("integer"); + + b.Property("EdgeId") + .HasColumnType("integer"); + + b.Property("ValueData") + .IsRequired() + .HasColumnType("text"); + + b.HasKey("ValueId"); + + b.HasIndex("EdgeAttributeId"); + + b.HasIndex("EdgeId"); + + b.ToTable("EdgeValues"); + }); + + modelBuilder.Entity("RelationshipAnalysis.Models.Graph.Node.Node", b => + { + b.Property("NodeId") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("NodeId")); + + b.Property("NodeCategoryId") + .HasColumnType("integer"); + + b.Property("NodeUniqueString") + .IsRequired() + .HasColumnType("text"); + + b.HasKey("NodeId"); + + b.HasIndex("NodeCategoryId"); + + b.ToTable("Nodes"); + }); + + modelBuilder.Entity("RelationshipAnalysis.Models.Graph.Node.NodeAttribute", b => + { + b.Property("NodeAttributeId") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("NodeAttributeId")); + + b.Property("NodeAttributeName") + .IsRequired() + .HasColumnType("text"); + + b.HasKey("NodeAttributeId"); + + b.ToTable("NodeAttributes"); + }); + + modelBuilder.Entity("RelationshipAnalysis.Models.Graph.Node.NodeCategory", b => + { + b.Property("NodeCategoryId") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("NodeCategoryId")); + + b.Property("NodeCategoryName") + .IsRequired() + .HasColumnType("text"); + + b.HasKey("NodeCategoryId"); + + b.ToTable("NodeCategories"); + }); + + modelBuilder.Entity("RelationshipAnalysis.Models.Graph.Node.NodeValue", b => + { + b.Property("ValueId") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("ValueId")); + + b.Property("NodeAttributeId") + .HasColumnType("integer"); + + b.Property("NodeId") + .HasColumnType("integer"); + + b.Property("ValueData") + .IsRequired() + .HasColumnType("text"); + + b.HasKey("ValueId"); + + b.HasIndex("NodeAttributeId"); + + b.HasIndex("NodeId"); + + b.ToTable("NodeValues"); + }); + + modelBuilder.Entity("RelationshipAnalysis.Models.Auth.UserRole", b => + { + b.HasOne("RelationshipAnalysis.Models.Auth.Role", "Role") + .WithMany("UserRoles") + .HasForeignKey("RoleId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("RelationshipAnalysis.Models.Auth.User", "User") + .WithMany("UserRoles") + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Role"); + + b.Navigation("User"); + }); + + modelBuilder.Entity("RelationshipAnalysis.Models.Graph.Edge.Edge", b => + { + b.HasOne("RelationshipAnalysis.Models.Graph.Edge.EdgeCategory", "EdgeCategory") + .WithMany("Edges") + .HasForeignKey("EdgeCategoryId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("RelationshipAnalysis.Models.Graph.Node.Node", "NodeDestination") + .WithMany("DestinationEdges") + .HasForeignKey("EdgeDestinationNodeId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.HasOne("RelationshipAnalysis.Models.Graph.Node.Node", "NodeSource") + .WithMany("SourceEdges") + .HasForeignKey("EdgeSourceNodeId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.Navigation("EdgeCategory"); + + b.Navigation("NodeDestination"); + + b.Navigation("NodeSource"); + }); + + modelBuilder.Entity("RelationshipAnalysis.Models.Graph.Edge.EdgeValue", b => + { + b.HasOne("RelationshipAnalysis.Models.Graph.Edge.EdgeAttribute", "EdgeAttribute") + .WithMany("EdgeValues") + .HasForeignKey("EdgeAttributeId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("RelationshipAnalysis.Models.Graph.Edge.Edge", "Edge") + .WithMany("EdgeValues") + .HasForeignKey("EdgeId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Edge"); + + b.Navigation("EdgeAttribute"); + }); + + modelBuilder.Entity("RelationshipAnalysis.Models.Graph.Node.Node", b => + { + b.HasOne("RelationshipAnalysis.Models.Graph.Node.NodeCategory", "NodeCategory") + .WithMany("Nodes") + .HasForeignKey("NodeCategoryId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("NodeCategory"); + }); + + modelBuilder.Entity("RelationshipAnalysis.Models.Graph.Node.NodeValue", b => + { + b.HasOne("RelationshipAnalysis.Models.Graph.Node.NodeAttribute", "NodeAttribute") + .WithMany("Values") + .HasForeignKey("NodeAttributeId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("RelationshipAnalysis.Models.Graph.Node.Node", "Node") + .WithMany("Values") + .HasForeignKey("NodeId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Node"); + + b.Navigation("NodeAttribute"); + }); + + modelBuilder.Entity("RelationshipAnalysis.Models.Auth.Role", b => + { + b.Navigation("UserRoles"); + }); + + modelBuilder.Entity("RelationshipAnalysis.Models.Auth.User", b => + { + b.Navigation("UserRoles"); + }); + + modelBuilder.Entity("RelationshipAnalysis.Models.Graph.Edge.Edge", b => + { + b.Navigation("EdgeValues"); + }); + + modelBuilder.Entity("RelationshipAnalysis.Models.Graph.Edge.EdgeAttribute", b => + { + b.Navigation("EdgeValues"); + }); + + modelBuilder.Entity("RelationshipAnalysis.Models.Graph.Edge.EdgeCategory", b => + { + b.Navigation("Edges"); + }); + + modelBuilder.Entity("RelationshipAnalysis.Models.Graph.Node.Node", b => + { + b.Navigation("DestinationEdges"); + + b.Navigation("SourceEdges"); + + b.Navigation("Values"); + }); + + modelBuilder.Entity("RelationshipAnalysis.Models.Graph.Node.NodeAttribute", b => + { + b.Navigation("Values"); + }); + + modelBuilder.Entity("RelationshipAnalysis.Models.Graph.Node.NodeCategory", b => + { + b.Navigation("Nodes"); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/RelationshipAnalysis/Migrations/20240907090417_InitialCreate.cs b/RelationshipAnalysis/Migrations/20240907090417_InitialCreate.cs new file mode 100644 index 0000000..c5eb62a --- /dev/null +++ b/RelationshipAnalysis/Migrations/20240907090417_InitialCreate.cs @@ -0,0 +1,319 @@ +using Microsoft.EntityFrameworkCore.Migrations; +using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata; + +#nullable disable + +namespace RelationshipAnalysis.Migrations +{ + /// + public partial class InitialCreate : Migration + { + /// + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.CreateTable( + name: "EdgeAttributes", + columns: table => new + { + EdgeAttributeId = table.Column(type: "integer", nullable: false) + .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), + EdgeAttributeName = table.Column(type: "text", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_EdgeAttributes", x => x.EdgeAttributeId); + }); + + migrationBuilder.CreateTable( + name: "EdgeCategories", + columns: table => new + { + EdgeCategoryId = table.Column(type: "integer", nullable: false) + .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), + EdgeCategoryName = table.Column(type: "text", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_EdgeCategories", x => x.EdgeCategoryId); + }); + + migrationBuilder.CreateTable( + name: "NodeAttributes", + columns: table => new + { + NodeAttributeId = table.Column(type: "integer", nullable: false) + .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), + NodeAttributeName = table.Column(type: "text", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_NodeAttributes", x => x.NodeAttributeId); + }); + + migrationBuilder.CreateTable( + name: "NodeCategories", + columns: table => new + { + NodeCategoryId = table.Column(type: "integer", nullable: false) + .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), + NodeCategoryName = table.Column(type: "text", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_NodeCategories", x => x.NodeCategoryId); + }); + + migrationBuilder.CreateTable( + name: "Roles", + columns: table => new + { + Id = table.Column(type: "integer", nullable: false) + .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), + Name = table.Column(type: "character varying(50)", maxLength: 50, nullable: false), + Permissions = table.Column(type: "text", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_Roles", x => x.Id); + }); + + migrationBuilder.CreateTable( + name: "Users", + columns: table => new + { + Id = table.Column(type: "integer", nullable: false) + .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), + Username = table.Column(type: "character varying(50)", maxLength: 50, nullable: false), + PasswordHash = table.Column(type: "character varying(256)", maxLength: 256, nullable: false), + FirstName = table.Column(type: "text", nullable: false), + LastName = table.Column(type: "text", nullable: false), + Email = table.Column(type: "text", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_Users", x => x.Id); + }); + + migrationBuilder.CreateTable( + name: "Nodes", + columns: table => new + { + NodeId = table.Column(type: "integer", nullable: false) + .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), + NodeUniqueString = table.Column(type: "text", nullable: false), + NodeCategoryId = table.Column(type: "integer", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_Nodes", x => x.NodeId); + table.ForeignKey( + name: "FK_Nodes_NodeCategories_NodeCategoryId", + column: x => x.NodeCategoryId, + principalTable: "NodeCategories", + principalColumn: "NodeCategoryId", + onDelete: ReferentialAction.Cascade); + }); + + migrationBuilder.CreateTable( + name: "UserRoles", + columns: table => new + { + Id = table.Column(type: "integer", nullable: false) + .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), + UserId = table.Column(type: "integer", nullable: false), + RoleId = table.Column(type: "integer", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_UserRoles", x => x.Id); + table.ForeignKey( + name: "FK_UserRoles_Roles_RoleId", + column: x => x.RoleId, + principalTable: "Roles", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + table.ForeignKey( + name: "FK_UserRoles_Users_UserId", + column: x => x.UserId, + principalTable: "Users", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + }); + + migrationBuilder.CreateTable( + name: "Edges", + columns: table => new + { + EdgeId = table.Column(type: "integer", nullable: false) + .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), + EdgeSourceNodeId = table.Column(type: "integer", nullable: false), + EdgeDestinationNodeId = table.Column(type: "integer", nullable: false), + EdgeCategoryId = table.Column(type: "integer", nullable: false), + EdgeUniqueString = table.Column(type: "text", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_Edges", x => x.EdgeId); + table.ForeignKey( + name: "FK_Edges_EdgeCategories_EdgeCategoryId", + column: x => x.EdgeCategoryId, + principalTable: "EdgeCategories", + principalColumn: "EdgeCategoryId", + onDelete: ReferentialAction.Cascade); + table.ForeignKey( + name: "FK_Edges_Nodes_EdgeDestinationNodeId", + column: x => x.EdgeDestinationNodeId, + principalTable: "Nodes", + principalColumn: "NodeId", + onDelete: ReferentialAction.Restrict); + table.ForeignKey( + name: "FK_Edges_Nodes_EdgeSourceNodeId", + column: x => x.EdgeSourceNodeId, + principalTable: "Nodes", + principalColumn: "NodeId", + onDelete: ReferentialAction.Restrict); + }); + + migrationBuilder.CreateTable( + name: "NodeValues", + columns: table => new + { + ValueId = table.Column(type: "integer", nullable: false) + .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), + NodeId = table.Column(type: "integer", nullable: false), + NodeAttributeId = table.Column(type: "integer", nullable: false), + ValueData = table.Column(type: "text", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_NodeValues", x => x.ValueId); + table.ForeignKey( + name: "FK_NodeValues_NodeAttributes_NodeAttributeId", + column: x => x.NodeAttributeId, + principalTable: "NodeAttributes", + principalColumn: "NodeAttributeId", + onDelete: ReferentialAction.Cascade); + table.ForeignKey( + name: "FK_NodeValues_Nodes_NodeId", + column: x => x.NodeId, + principalTable: "Nodes", + principalColumn: "NodeId", + onDelete: ReferentialAction.Cascade); + }); + + migrationBuilder.CreateTable( + name: "EdgeValues", + columns: table => new + { + ValueId = table.Column(type: "integer", nullable: false) + .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), + EdgeId = table.Column(type: "integer", nullable: false), + EdgeAttributeId = table.Column(type: "integer", nullable: false), + ValueData = table.Column(type: "text", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_EdgeValues", x => x.ValueId); + table.ForeignKey( + name: "FK_EdgeValues_EdgeAttributes_EdgeAttributeId", + column: x => x.EdgeAttributeId, + principalTable: "EdgeAttributes", + principalColumn: "EdgeAttributeId", + onDelete: ReferentialAction.Cascade); + table.ForeignKey( + name: "FK_EdgeValues_Edges_EdgeId", + column: x => x.EdgeId, + principalTable: "Edges", + principalColumn: "EdgeId", + onDelete: ReferentialAction.Cascade); + }); + + migrationBuilder.CreateIndex( + name: "IX_Edges_EdgeCategoryId", + table: "Edges", + column: "EdgeCategoryId"); + + migrationBuilder.CreateIndex( + name: "IX_Edges_EdgeDestinationNodeId", + table: "Edges", + column: "EdgeDestinationNodeId"); + + migrationBuilder.CreateIndex( + name: "IX_Edges_EdgeSourceNodeId", + table: "Edges", + column: "EdgeSourceNodeId"); + + migrationBuilder.CreateIndex( + name: "IX_EdgeValues_EdgeAttributeId", + table: "EdgeValues", + column: "EdgeAttributeId"); + + migrationBuilder.CreateIndex( + name: "IX_EdgeValues_EdgeId", + table: "EdgeValues", + column: "EdgeId"); + + migrationBuilder.CreateIndex( + name: "IX_Nodes_NodeCategoryId", + table: "Nodes", + column: "NodeCategoryId"); + + migrationBuilder.CreateIndex( + name: "IX_NodeValues_NodeAttributeId", + table: "NodeValues", + column: "NodeAttributeId"); + + migrationBuilder.CreateIndex( + name: "IX_NodeValues_NodeId", + table: "NodeValues", + column: "NodeId"); + + migrationBuilder.CreateIndex( + name: "IX_UserRoles_RoleId", + table: "UserRoles", + column: "RoleId"); + + migrationBuilder.CreateIndex( + name: "IX_UserRoles_UserId", + table: "UserRoles", + column: "UserId"); + } + + /// + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropTable( + name: "EdgeValues"); + + migrationBuilder.DropTable( + name: "NodeValues"); + + migrationBuilder.DropTable( + name: "UserRoles"); + + migrationBuilder.DropTable( + name: "EdgeAttributes"); + + migrationBuilder.DropTable( + name: "Edges"); + + migrationBuilder.DropTable( + name: "NodeAttributes"); + + migrationBuilder.DropTable( + name: "Roles"); + + migrationBuilder.DropTable( + name: "Users"); + + migrationBuilder.DropTable( + name: "EdgeCategories"); + + migrationBuilder.DropTable( + name: "Nodes"); + + migrationBuilder.DropTable( + name: "NodeCategories"); + } + } +}