using System; using Microsoft.EntityFrameworkCore.Migrations; #nullable disable namespace mws.backend.dotnet.infrastructure.Migrations { /// public partial class InitialCreate : Migration { /// protected override void Up(MigrationBuilder migrationBuilder) { migrationBuilder.CreateTable( name: "documents", columns: table => new { Id = table.Column(type: "uuid", nullable: false), ProjectId = table.Column(type: "uuid", nullable: false), ParentId = table.Column(type: "uuid", nullable: true), Title = table.Column(type: "character varying(300)", maxLength: 300, nullable: false), Content = table.Column(type: "text", nullable: true), Type = table.Column(type: "character varying(20)", maxLength: 20, nullable: false), CreatedBy = table.Column(type: "uuid", nullable: false), CreatedAt = table.Column(type: "timestamp with time zone", nullable: false), UpdatedBy = table.Column(type: "uuid", nullable: true), UpdatedAt = table.Column(type: "timestamp with time zone", nullable: false) }, constraints: table => { table.PrimaryKey("PK_documents", x => x.Id); table.ForeignKey( name: "FK_documents_documents_ParentId", column: x => x.ParentId, principalTable: "documents", principalColumn: "Id", onDelete: ReferentialAction.Restrict); }); migrationBuilder.CreateTable( name: "projects", columns: table => new { Id = table.Column(type: "uuid", nullable: false), Name = table.Column(type: "character varying(200)", maxLength: 200, nullable: false), Description = table.Column(type: "character varying(2000)", maxLength: 2000, nullable: true), Status = table.Column(type: "character varying(20)", maxLength: 20, nullable: false), CreatedAt = table.Column(type: "timestamp with time zone", nullable: false), UpdatedAt = table.Column(type: "timestamp with time zone", nullable: false) }, constraints: table => { table.PrimaryKey("PK_projects", x => x.Id); }); migrationBuilder.CreateTable( name: "users", columns: table => new { Id = table.Column(type: "uuid", nullable: false), Username = table.Column(type: "character varying(100)", maxLength: 100, nullable: false), PasswordHash = table.Column(type: "character varying(200)", maxLength: 200, nullable: false), DisplayName = table.Column(type: "character varying(150)", maxLength: 150, nullable: false), CreatedAt = table.Column(type: "timestamp with time zone", nullable: false), UpdatedAt = table.Column(type: "timestamp with time zone", nullable: false) }, constraints: table => { table.PrimaryKey("PK_users", x => x.Id); }); migrationBuilder.CreateTable( name: "project_members", columns: table => new { ProjectId = table.Column(type: "uuid", nullable: false), UserId = table.Column(type: "uuid", nullable: false), Role = table.Column(type: "character varying(20)", maxLength: 20, nullable: false) }, constraints: table => { table.PrimaryKey("PK_project_members", x => new { x.ProjectId, x.UserId }); table.ForeignKey( name: "FK_project_members_projects_ProjectId", column: x => x.ProjectId, principalTable: "projects", principalColumn: "Id", onDelete: ReferentialAction.Cascade); table.ForeignKey( name: "FK_project_members_users_UserId", column: x => x.UserId, principalTable: "users", principalColumn: "Id", onDelete: ReferentialAction.Cascade); }); migrationBuilder.CreateTable( name: "tasks", columns: table => new { Id = table.Column(type: "uuid", nullable: false), ProjectId = table.Column(type: "uuid", nullable: false), Title = table.Column(type: "character varying(300)", maxLength: 300, nullable: false), Description = table.Column(type: "text", nullable: true), Status = table.Column(type: "character varying(20)", maxLength: 20, nullable: false), Priority = table.Column(type: "character varying(20)", maxLength: 20, nullable: false), AssigneeId = table.Column(type: "uuid", nullable: true), DueDate = table.Column(type: "timestamp with time zone", nullable: true), CreatedBy = table.Column(type: "uuid", nullable: false), CreatedAt = table.Column(type: "timestamp with time zone", nullable: false), UpdatedAt = table.Column(type: "timestamp with time zone", nullable: false) }, constraints: table => { table.PrimaryKey("PK_tasks", x => x.Id); table.ForeignKey( name: "FK_tasks_users_AssigneeId", column: x => x.AssigneeId, principalTable: "users", principalColumn: "Id", onDelete: ReferentialAction.SetNull); }); migrationBuilder.CreateIndex( name: "IX_documents_ParentId", table: "documents", column: "ParentId"); migrationBuilder.CreateIndex( name: "IX_documents_ProjectId_ParentId", table: "documents", columns: new[] { "ProjectId", "ParentId" }); migrationBuilder.CreateIndex( name: "IX_project_members_UserId", table: "project_members", column: "UserId"); migrationBuilder.CreateIndex( name: "IX_tasks_AssigneeId", table: "tasks", column: "AssigneeId"); migrationBuilder.CreateIndex( name: "IX_tasks_ProjectId", table: "tasks", column: "ProjectId"); migrationBuilder.CreateIndex( name: "IX_tasks_Status", table: "tasks", column: "Status"); migrationBuilder.CreateIndex( name: "IX_users_Username", table: "users", column: "Username", unique: true); } /// protected override void Down(MigrationBuilder migrationBuilder) { migrationBuilder.DropTable( name: "documents"); migrationBuilder.DropTable( name: "project_members"); migrationBuilder.DropTable( name: "tasks"); migrationBuilder.DropTable( name: "projects"); migrationBuilder.DropTable( name: "users"); } } }