using System; using Microsoft.EntityFrameworkCore.Migrations; using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata; #nullable disable namespace Brizco.Repository.Migrations { /// public partial class init : Migration { /// protected override void Up(MigrationBuilder migrationBuilder) { migrationBuilder.EnsureSchema( name: "public"); migrationBuilder.CreateTable( name: "Complexes", schema: "public", columns: table => new { Id = table.Column(type: "uuid", nullable: false), Name = table.Column(type: "text", nullable: false), Address = table.Column(type: "text", nullable: false), SupportPhone = table.Column(type: "text", nullable: false), RemovedAt = table.Column(type: "timestamp without time zone", nullable: false), CreatedAt = table.Column(type: "timestamp without time zone", nullable: false), CreatedBy = table.Column(type: "text", nullable: false), IsRemoved = table.Column(type: "boolean", nullable: false), RemovedBy = table.Column(type: "text", nullable: false), ModifiedAt = table.Column(type: "timestamp without time zone", nullable: false), ModifiedBy = table.Column(type: "text", nullable: false) }, constraints: table => { table.PrimaryKey("PK_Complexes", x => x.Id); }); migrationBuilder.CreateTable( name: "Users", schema: "public", columns: table => new { Id = table.Column(type: "uuid", nullable: false), FirstName = table.Column(type: "text", nullable: false), LastName = table.Column(type: "text", nullable: false), NationalId = table.Column(type: "text", nullable: false), SelectedComplexUserRoleId = table.Column(type: "uuid", nullable: false), BirthDate = table.Column(type: "timestamp without time zone", nullable: false), Gender = table.Column(type: "integer", nullable: false), SignUpStatus = table.Column(type: "integer", nullable: false), UserName = table.Column(type: "character varying(256)", maxLength: 256, nullable: true), NormalizedUserName = table.Column(type: "character varying(256)", maxLength: 256, nullable: true), Email = table.Column(type: "character varying(256)", maxLength: 256, nullable: true), NormalizedEmail = table.Column(type: "character varying(256)", maxLength: 256, nullable: true), EmailConfirmed = table.Column(type: "boolean", nullable: false), PasswordHash = table.Column(type: "text", nullable: true), SecurityStamp = table.Column(type: "text", nullable: true), ConcurrencyStamp = table.Column(type: "text", nullable: true), PhoneNumber = table.Column(type: "text", nullable: true), PhoneNumberConfirmed = table.Column(type: "boolean", nullable: false), TwoFactorEnabled = table.Column(type: "boolean", nullable: false), LockoutEnd = table.Column(type: "timestamp with time zone", nullable: true), LockoutEnabled = table.Column(type: "boolean", nullable: false), AccessFailedCount = table.Column(type: "integer", nullable: false) }, constraints: table => { table.PrimaryKey("PK_Users", x => x.Id); }); migrationBuilder.CreateTable( name: "Roles", schema: "public", columns: table => new { Id = table.Column(type: "uuid", nullable: false), Description = table.Column(type: "text", nullable: false), EnglishName = table.Column(type: "text", nullable: false), PersianName = table.Column(type: "text", nullable: false), ComplexId = table.Column(type: "uuid", nullable: true), Name = table.Column(type: "character varying(256)", maxLength: 256, nullable: true), NormalizedName = table.Column(type: "character varying(256)", maxLength: 256, nullable: true), ConcurrencyStamp = table.Column(type: "text", nullable: true) }, constraints: table => { table.PrimaryKey("PK_Roles", x => x.Id); table.ForeignKey( name: "FK_Roles_Complexes_ComplexId", column: x => x.ComplexId, principalSchema: "public", principalTable: "Complexes", principalColumn: "Id"); }); migrationBuilder.CreateTable( name: "Routines", schema: "public", columns: table => new { Id = table.Column(type: "uuid", nullable: false), Name = table.Column(type: "text", nullable: false), Description = table.Column(type: "text", nullable: false), ComplexId = table.Column(type: "uuid", nullable: false), RemovedAt = table.Column(type: "timestamp without time zone", nullable: false), CreatedAt = table.Column(type: "timestamp without time zone", nullable: false), CreatedBy = table.Column(type: "text", nullable: false), IsRemoved = table.Column(type: "boolean", nullable: false), RemovedBy = table.Column(type: "text", nullable: false), ModifiedAt = table.Column(type: "timestamp without time zone", nullable: false), ModifiedBy = table.Column(type: "text", nullable: false) }, constraints: table => { table.PrimaryKey("PK_Routines", x => x.Id); table.ForeignKey( name: "FK_Routines_Complexes_ComplexId", column: x => x.ComplexId, principalSchema: "public", principalTable: "Complexes", principalColumn: "Id", onDelete: ReferentialAction.Restrict); }); migrationBuilder.CreateTable( name: "Sections", schema: "public", columns: table => new { Id = table.Column(type: "uuid", nullable: false), Name = table.Column(type: "text", nullable: false), Description = table.Column(type: "text", nullable: false), ComplexId = table.Column(type: "uuid", nullable: false), RemovedAt = table.Column(type: "timestamp without time zone", nullable: false), CreatedAt = table.Column(type: "timestamp without time zone", nullable: false), CreatedBy = table.Column(type: "text", nullable: false), IsRemoved = table.Column(type: "boolean", nullable: false), RemovedBy = table.Column(type: "text", nullable: false), ModifiedAt = table.Column(type: "timestamp without time zone", nullable: false), ModifiedBy = table.Column(type: "text", nullable: false) }, constraints: table => { table.PrimaryKey("PK_Sections", x => x.Id); table.ForeignKey( name: "FK_Sections_Complexes_ComplexId", column: x => x.ComplexId, principalSchema: "public", principalTable: "Complexes", principalColumn: "Id", onDelete: ReferentialAction.Restrict); }); migrationBuilder.CreateTable( name: "Shifts", schema: "public", columns: table => new { Id = table.Column(type: "uuid", nullable: false), Title = table.Column(type: "text", nullable: false), StartAt = table.Column(type: "interval", nullable: false), EndAt = table.Column(type: "interval", nullable: false), Description = table.Column(type: "text", nullable: false), ComplexId = table.Column(type: "uuid", nullable: false), RemovedAt = table.Column(type: "timestamp without time zone", nullable: false), CreatedAt = table.Column(type: "timestamp without time zone", nullable: false), CreatedBy = table.Column(type: "text", nullable: false), IsRemoved = table.Column(type: "boolean", nullable: false), RemovedBy = table.Column(type: "text", nullable: false), ModifiedAt = table.Column(type: "timestamp without time zone", nullable: false), ModifiedBy = table.Column(type: "text", nullable: false) }, constraints: table => { table.PrimaryKey("PK_Shifts", x => x.Id); table.ForeignKey( name: "FK_Shifts_Complexes_ComplexId", column: x => x.ComplexId, principalSchema: "public", principalTable: "Complexes", principalColumn: "Id", onDelete: ReferentialAction.Restrict); }); migrationBuilder.CreateTable( name: "Tasks", schema: "public", columns: table => new { Id = table.Column(type: "uuid", nullable: false), Type = table.Column(type: "integer", nullable: false), Title = table.Column(type: "text", nullable: false), Description = table.Column(type: "text", nullable: false), IsDisposable = table.Column(type: "boolean", nullable: false), SetFor = table.Column(type: "timestamp without time zone", nullable: false), HasDisposed = table.Column(type: "boolean", nullable: false), ComplexId = table.Column(type: "uuid", nullable: false), Amount = table.Column(type: "integer", nullable: false), AmountType = table.Column(type: "integer", nullable: false), Discriminator = table.Column(type: "text", nullable: false), Status = table.Column(type: "integer", nullable: true), DoneAt = table.Column(type: "timestamp without time zone", nullable: true), IsDone = table.Column(type: "boolean", nullable: true), PerformanceDescription = table.Column(type: "text", nullable: true), RemovedAt = table.Column(type: "timestamp without time zone", nullable: false), CreatedAt = table.Column(type: "timestamp without time zone", nullable: false), CreatedBy = table.Column(type: "text", nullable: false), IsRemoved = table.Column(type: "boolean", nullable: false), RemovedBy = table.Column(type: "text", nullable: false), ModifiedAt = table.Column(type: "timestamp without time zone", nullable: false), ModifiedBy = table.Column(type: "text", nullable: false) }, constraints: table => { table.PrimaryKey("PK_Tasks", x => x.Id); table.ForeignKey( name: "FK_Tasks_Complexes_ComplexId", column: x => x.ComplexId, principalSchema: "public", principalTable: "Complexes", principalColumn: "Id", onDelete: ReferentialAction.Restrict); }); migrationBuilder.CreateTable( name: "Claims", schema: "public", columns: table => new { Id = table.Column(type: "integer", nullable: false) .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), UserId = table.Column(type: "uuid", nullable: false), ClaimType = table.Column(type: "text", nullable: true), ClaimValue = table.Column(type: "text", nullable: true) }, constraints: table => { table.PrimaryKey("PK_Claims", x => x.Id); table.ForeignKey( name: "FK_Claims_Users_UserId", column: x => x.UserId, principalSchema: "public", principalTable: "Users", principalColumn: "Id", onDelete: ReferentialAction.Restrict); }); migrationBuilder.CreateTable( name: "ComplexUsers", schema: "public", columns: table => new { Id = table.Column(type: "uuid", nullable: false), UserId = table.Column(type: "uuid", nullable: false), ComplexId = table.Column(type: "uuid", nullable: false), RemovedAt = table.Column(type: "timestamp without time zone", nullable: false), CreatedAt = table.Column(type: "timestamp without time zone", nullable: false), CreatedBy = table.Column(type: "text", nullable: false), IsRemoved = table.Column(type: "boolean", nullable: false), RemovedBy = table.Column(type: "text", nullable: false), ModifiedAt = table.Column(type: "timestamp without time zone", nullable: false), ModifiedBy = table.Column(type: "text", nullable: false) }, constraints: table => { table.PrimaryKey("PK_ComplexUsers", x => x.Id); table.ForeignKey( name: "FK_ComplexUsers_Complexes_ComplexId", column: x => x.ComplexId, principalSchema: "public", principalTable: "Complexes", principalColumn: "Id", onDelete: ReferentialAction.Restrict); table.ForeignKey( name: "FK_ComplexUsers_Users_UserId", column: x => x.UserId, principalSchema: "public", principalTable: "Users", principalColumn: "Id", onDelete: ReferentialAction.Restrict); }); migrationBuilder.CreateTable( name: "Logins", schema: "public", columns: table => new { LoginProvider = table.Column(type: "text", nullable: false), ProviderKey = table.Column(type: "text", nullable: false), ProviderDisplayName = table.Column(type: "text", nullable: true), UserId = table.Column(type: "uuid", nullable: false) }, constraints: table => { table.PrimaryKey("PK_Logins", x => new { x.LoginProvider, x.ProviderKey }); table.ForeignKey( name: "FK_Logins_Users_UserId", column: x => x.UserId, principalSchema: "public", principalTable: "Users", principalColumn: "Id", onDelete: ReferentialAction.Restrict); }); migrationBuilder.CreateTable( name: "Tokens", schema: "public", columns: table => new { UserId = table.Column(type: "uuid", nullable: false), LoginProvider = table.Column(type: "text", nullable: false), Name = table.Column(type: "text", nullable: false), Value = table.Column(type: "text", nullable: true) }, constraints: table => { table.PrimaryKey("PK_Tokens", x => new { x.UserId, x.LoginProvider, x.Name }); table.ForeignKey( name: "FK_Tokens_Users_UserId", column: x => x.UserId, principalSchema: "public", principalTable: "Users", principalColumn: "Id", onDelete: ReferentialAction.Restrict); }); migrationBuilder.CreateTable( name: "RoleClaims", schema: "public", columns: table => new { Id = table.Column(type: "integer", nullable: false) .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), RoleId = table.Column(type: "uuid", nullable: false), ClaimType = table.Column(type: "text", nullable: true), ClaimValue = table.Column(type: "text", nullable: true) }, constraints: table => { table.PrimaryKey("PK_RoleClaims", x => x.Id); table.ForeignKey( name: "FK_RoleClaims_Roles_RoleId", column: x => x.RoleId, principalSchema: "public", principalTable: "Roles", principalColumn: "Id", onDelete: ReferentialAction.Restrict); }); migrationBuilder.CreateTable( name: "UserRoles", schema: "public", columns: table => new { UserId = table.Column(type: "uuid", nullable: false), RoleId = table.Column(type: "uuid", nullable: false) }, constraints: table => { table.PrimaryKey("PK_UserRoles", x => new { x.UserId, x.RoleId }); table.ForeignKey( name: "FK_UserRoles_Roles_RoleId", column: x => x.RoleId, principalSchema: "public", principalTable: "Roles", principalColumn: "Id", onDelete: ReferentialAction.Restrict); table.ForeignKey( name: "FK_UserRoles_Users_UserId", column: x => x.UserId, principalSchema: "public", principalTable: "Users", principalColumn: "Id", onDelete: ReferentialAction.Restrict); }); migrationBuilder.CreateTable( name: "Positions", schema: "public", columns: table => new { Id = table.Column(type: "uuid", nullable: false), Name = table.Column(type: "text", nullable: false), Description = table.Column(type: "text", nullable: false), ComplexId = table.Column(type: "uuid", nullable: false), SectionId = table.Column(type: "uuid", nullable: false), RemovedAt = table.Column(type: "timestamp without time zone", nullable: false), CreatedAt = table.Column(type: "timestamp without time zone", nullable: false), CreatedBy = table.Column(type: "text", nullable: false), IsRemoved = table.Column(type: "boolean", nullable: false), RemovedBy = table.Column(type: "text", nullable: false), ModifiedAt = table.Column(type: "timestamp without time zone", nullable: false), ModifiedBy = table.Column(type: "text", nullable: false) }, constraints: table => { table.PrimaryKey("PK_Positions", x => x.Id); table.ForeignKey( name: "FK_Positions_Complexes_ComplexId", column: x => x.ComplexId, principalSchema: "public", principalTable: "Complexes", principalColumn: "Id", onDelete: ReferentialAction.Restrict); table.ForeignKey( name: "FK_Positions_Sections_SectionId", column: x => x.SectionId, principalSchema: "public", principalTable: "Sections", principalColumn: "Id", onDelete: ReferentialAction.Restrict); }); migrationBuilder.CreateTable( name: "ShiftDays", schema: "public", columns: table => new { Id = table.Column(type: "uuid", nullable: false), DayOfWeek = table.Column(type: "integer", nullable: false), ShiftId = table.Column(type: "uuid", nullable: false), RemovedAt = table.Column(type: "timestamp without time zone", nullable: false), CreatedAt = table.Column(type: "timestamp without time zone", nullable: false), CreatedBy = table.Column(type: "text", nullable: false), IsRemoved = table.Column(type: "boolean", nullable: false), RemovedBy = table.Column(type: "text", nullable: false), ModifiedAt = table.Column(type: "timestamp without time zone", nullable: false), ModifiedBy = table.Column(type: "text", nullable: false) }, constraints: table => { table.PrimaryKey("PK_ShiftDays", x => x.Id); table.ForeignKey( name: "FK_ShiftDays_Shifts_ShiftId", column: x => x.ShiftId, principalSchema: "public", principalTable: "Shifts", principalColumn: "Id", onDelete: ReferentialAction.Restrict); }); migrationBuilder.CreateTable( name: "ShiftPlans", schema: "public", columns: table => new { Id = table.Column(type: "uuid", nullable: false), PlanDate = table.Column(type: "timestamp without time zone", nullable: false), ShiftId = table.Column(type: "uuid", nullable: false), RemovedAt = table.Column(type: "timestamp without time zone", nullable: false), CreatedAt = table.Column(type: "timestamp without time zone", nullable: false), CreatedBy = table.Column(type: "text", nullable: false), IsRemoved = table.Column(type: "boolean", nullable: false), RemovedBy = table.Column(type: "text", nullable: false), ModifiedAt = table.Column(type: "timestamp without time zone", nullable: false), ModifiedBy = table.Column(type: "text", nullable: false) }, constraints: table => { table.PrimaryKey("PK_ShiftPlans", x => x.Id); table.ForeignKey( name: "FK_ShiftPlans_Shifts_ShiftId", column: x => x.ShiftId, principalSchema: "public", principalTable: "Shifts", principalColumn: "Id", onDelete: ReferentialAction.Restrict); }); migrationBuilder.CreateTable( name: "ShiftRoutines", schema: "public", columns: table => new { Id = table.Column(type: "uuid", nullable: false), RoutineId = table.Column(type: "uuid", nullable: false), ShiftId = table.Column(type: "uuid", nullable: false), RemovedAt = table.Column(type: "timestamp without time zone", nullable: false), CreatedAt = table.Column(type: "timestamp without time zone", nullable: false), CreatedBy = table.Column(type: "text", nullable: false), IsRemoved = table.Column(type: "boolean", nullable: false), RemovedBy = table.Column(type: "text", nullable: false), ModifiedAt = table.Column(type: "timestamp without time zone", nullable: false), ModifiedBy = table.Column(type: "text", nullable: false) }, constraints: table => { table.PrimaryKey("PK_ShiftRoutines", x => x.Id); table.ForeignKey( name: "FK_ShiftRoutines_Routines_RoutineId", column: x => x.RoutineId, principalSchema: "public", principalTable: "Routines", principalColumn: "Id", onDelete: ReferentialAction.Restrict); table.ForeignKey( name: "FK_ShiftRoutines_Shifts_ShiftId", column: x => x.ShiftId, principalSchema: "public", principalTable: "Shifts", principalColumn: "Id", onDelete: ReferentialAction.Restrict); }); migrationBuilder.CreateTable( name: "TaskDays", schema: "public", columns: table => new { Id = table.Column(type: "uuid", nullable: false), DayOfWeek = table.Column(type: "integer", nullable: false), TaskId = table.Column(type: "uuid", nullable: false), RemovedAt = table.Column(type: "timestamp without time zone", nullable: false), CreatedAt = table.Column(type: "timestamp without time zone", nullable: false), CreatedBy = table.Column(type: "text", nullable: false), IsRemoved = table.Column(type: "boolean", nullable: false), RemovedBy = table.Column(type: "text", nullable: false), ModifiedAt = table.Column(type: "timestamp without time zone", nullable: false), ModifiedBy = table.Column(type: "text", nullable: false) }, constraints: table => { table.PrimaryKey("PK_TaskDays", x => x.Id); table.ForeignKey( name: "FK_TaskDays_Tasks_TaskId", column: x => x.TaskId, principalSchema: "public", principalTable: "Tasks", principalColumn: "Id", onDelete: ReferentialAction.Restrict); }); migrationBuilder.CreateTable( name: "TaskRoutines", schema: "public", columns: table => new { Id = table.Column(type: "uuid", nullable: false), TaskId = table.Column(type: "uuid", nullable: false), RoutineId = table.Column(type: "uuid", nullable: false), RemovedAt = table.Column(type: "timestamp without time zone", nullable: false), CreatedAt = table.Column(type: "timestamp without time zone", nullable: false), CreatedBy = table.Column(type: "text", nullable: false), IsRemoved = table.Column(type: "boolean", nullable: false), RemovedBy = table.Column(type: "text", nullable: false), ModifiedAt = table.Column(type: "timestamp without time zone", nullable: false), ModifiedBy = table.Column(type: "text", nullable: false) }, constraints: table => { table.PrimaryKey("PK_TaskRoutines", x => x.Id); table.ForeignKey( name: "FK_TaskRoutines_Routines_RoutineId", column: x => x.RoutineId, principalSchema: "public", principalTable: "Routines", principalColumn: "Id", onDelete: ReferentialAction.Restrict); table.ForeignKey( name: "FK_TaskRoutines_Tasks_TaskId", column: x => x.TaskId, principalSchema: "public", principalTable: "Tasks", principalColumn: "Id", onDelete: ReferentialAction.Restrict); }); migrationBuilder.CreateTable( name: "TaskShifts", schema: "public", columns: table => new { Id = table.Column(type: "uuid", nullable: false), TaskId = table.Column(type: "uuid", nullable: false), ShiftId = table.Column(type: "uuid", nullable: false), RemovedAt = table.Column(type: "timestamp without time zone", nullable: false), CreatedAt = table.Column(type: "timestamp without time zone", nullable: false), CreatedBy = table.Column(type: "text", nullable: false), IsRemoved = table.Column(type: "boolean", nullable: false), RemovedBy = table.Column(type: "text", nullable: false), ModifiedAt = table.Column(type: "timestamp without time zone", nullable: false), ModifiedBy = table.Column(type: "text", nullable: false) }, constraints: table => { table.PrimaryKey("PK_TaskShifts", x => x.Id); table.ForeignKey( name: "FK_TaskShifts_Shifts_ShiftId", column: x => x.ShiftId, principalSchema: "public", principalTable: "Shifts", principalColumn: "Id", onDelete: ReferentialAction.Restrict); table.ForeignKey( name: "FK_TaskShifts_Tasks_TaskId", column: x => x.TaskId, principalSchema: "public", principalTable: "Tasks", principalColumn: "Id", onDelete: ReferentialAction.Restrict); }); migrationBuilder.CreateTable( name: "ComplexUserRoles", schema: "public", columns: table => new { Id = table.Column(type: "uuid", nullable: false), ComplexUserId = table.Column(type: "uuid", nullable: false), RoleId = table.Column(type: "uuid", nullable: false), RemovedAt = table.Column(type: "timestamp without time zone", nullable: false), CreatedAt = table.Column(type: "timestamp without time zone", nullable: false), CreatedBy = table.Column(type: "text", nullable: false), IsRemoved = table.Column(type: "boolean", nullable: false), RemovedBy = table.Column(type: "text", nullable: false), ModifiedAt = table.Column(type: "timestamp without time zone", nullable: false), ModifiedBy = table.Column(type: "text", nullable: false) }, constraints: table => { table.PrimaryKey("PK_ComplexUserRoles", x => x.Id); table.ForeignKey( name: "FK_ComplexUserRoles_ComplexUsers_ComplexUserId", column: x => x.ComplexUserId, principalSchema: "public", principalTable: "ComplexUsers", principalColumn: "Id", onDelete: ReferentialAction.Restrict); table.ForeignKey( name: "FK_ComplexUserRoles_Roles_RoleId", column: x => x.RoleId, principalSchema: "public", principalTable: "Roles", principalColumn: "Id", onDelete: ReferentialAction.Restrict); }); migrationBuilder.CreateTable( name: "PositionUsers", schema: "public", columns: table => new { Id = table.Column(type: "uuid", nullable: false), ApplicationUserId = table.Column(type: "uuid", nullable: false), PositionId = table.Column(type: "uuid", nullable: false), RemovedAt = table.Column(type: "timestamp without time zone", nullable: false), CreatedAt = table.Column(type: "timestamp without time zone", nullable: false), CreatedBy = table.Column(type: "text", nullable: false), IsRemoved = table.Column(type: "boolean", nullable: false), RemovedBy = table.Column(type: "text", nullable: false), ModifiedAt = table.Column(type: "timestamp without time zone", nullable: false), ModifiedBy = table.Column(type: "text", nullable: false) }, constraints: table => { table.PrimaryKey("PK_PositionUsers", x => x.Id); table.ForeignKey( name: "FK_PositionUsers_Positions_PositionId", column: x => x.PositionId, principalSchema: "public", principalTable: "Positions", principalColumn: "Id", onDelete: ReferentialAction.Restrict); table.ForeignKey( name: "FK_PositionUsers_Users_ApplicationUserId", column: x => x.ApplicationUserId, principalSchema: "public", principalTable: "Users", principalColumn: "Id", onDelete: ReferentialAction.Restrict); }); migrationBuilder.CreateTable( name: "TaskPositions", schema: "public", columns: table => new { Id = table.Column(type: "uuid", nullable: false), PositionId = table.Column(type: "uuid", nullable: false), TaskId = table.Column(type: "uuid", nullable: false), RemovedAt = table.Column(type: "timestamp without time zone", nullable: false), CreatedAt = table.Column(type: "timestamp without time zone", nullable: false), CreatedBy = table.Column(type: "text", nullable: false), IsRemoved = table.Column(type: "boolean", nullable: false), RemovedBy = table.Column(type: "text", nullable: false), ModifiedAt = table.Column(type: "timestamp without time zone", nullable: false), ModifiedBy = table.Column(type: "text", nullable: false) }, constraints: table => { table.PrimaryKey("PK_TaskPositions", x => x.Id); table.ForeignKey( name: "FK_TaskPositions_Positions_PositionId", column: x => x.PositionId, principalSchema: "public", principalTable: "Positions", principalColumn: "Id", onDelete: ReferentialAction.Restrict); table.ForeignKey( name: "FK_TaskPositions_Tasks_TaskId", column: x => x.TaskId, principalSchema: "public", principalTable: "Tasks", principalColumn: "Id", onDelete: ReferentialAction.Restrict); }); migrationBuilder.CreateTable( name: "ShiftPlanUsers", schema: "public", columns: table => new { Id = table.Column(type: "uuid", nullable: false), ShiftPlanId = table.Column(type: "uuid", nullable: false), ApplicationUserId = table.Column(type: "uuid", nullable: false), RemovedAt = table.Column(type: "timestamp without time zone", nullable: false), CreatedAt = table.Column(type: "timestamp without time zone", nullable: false), CreatedBy = table.Column(type: "text", nullable: false), IsRemoved = table.Column(type: "boolean", nullable: false), RemovedBy = table.Column(type: "text", nullable: false), ModifiedAt = table.Column(type: "timestamp without time zone", nullable: false), ModifiedBy = table.Column(type: "text", nullable: false) }, constraints: table => { table.PrimaryKey("PK_ShiftPlanUsers", x => x.Id); table.ForeignKey( name: "FK_ShiftPlanUsers_ShiftPlans_ShiftPlanId", column: x => x.ShiftPlanId, principalSchema: "public", principalTable: "ShiftPlans", principalColumn: "Id", onDelete: ReferentialAction.Restrict); table.ForeignKey( name: "FK_ShiftPlanUsers_Users_ApplicationUserId", column: x => x.ApplicationUserId, principalSchema: "public", principalTable: "Users", principalColumn: "Id", onDelete: ReferentialAction.Restrict); }); migrationBuilder.CreateIndex( name: "IX_Claims_UserId", schema: "public", table: "Claims", column: "UserId"); migrationBuilder.CreateIndex( name: "IX_ComplexUserRoles_ComplexUserId", schema: "public", table: "ComplexUserRoles", column: "ComplexUserId"); migrationBuilder.CreateIndex( name: "IX_ComplexUserRoles_RoleId", schema: "public", table: "ComplexUserRoles", column: "RoleId"); migrationBuilder.CreateIndex( name: "IX_ComplexUsers_ComplexId", schema: "public", table: "ComplexUsers", column: "ComplexId"); migrationBuilder.CreateIndex( name: "IX_ComplexUsers_UserId", schema: "public", table: "ComplexUsers", column: "UserId"); migrationBuilder.CreateIndex( name: "IX_Logins_UserId", schema: "public", table: "Logins", column: "UserId"); migrationBuilder.CreateIndex( name: "IX_Positions_ComplexId", schema: "public", table: "Positions", column: "ComplexId"); migrationBuilder.CreateIndex( name: "IX_Positions_SectionId", schema: "public", table: "Positions", column: "SectionId"); migrationBuilder.CreateIndex( name: "IX_PositionUsers_ApplicationUserId", schema: "public", table: "PositionUsers", column: "ApplicationUserId"); migrationBuilder.CreateIndex( name: "IX_PositionUsers_PositionId", schema: "public", table: "PositionUsers", column: "PositionId"); migrationBuilder.CreateIndex( name: "IX_RoleClaims_RoleId", schema: "public", table: "RoleClaims", column: "RoleId"); migrationBuilder.CreateIndex( name: "IX_Roles_ComplexId", schema: "public", table: "Roles", column: "ComplexId"); migrationBuilder.CreateIndex( name: "RoleNameIndex", schema: "public", table: "Roles", column: "NormalizedName", unique: true); migrationBuilder.CreateIndex( name: "IX_Routines_ComplexId", schema: "public", table: "Routines", column: "ComplexId"); migrationBuilder.CreateIndex( name: "IX_Sections_ComplexId", schema: "public", table: "Sections", column: "ComplexId"); migrationBuilder.CreateIndex( name: "IX_ShiftDays_ShiftId", schema: "public", table: "ShiftDays", column: "ShiftId"); migrationBuilder.CreateIndex( name: "IX_ShiftPlans_ShiftId", schema: "public", table: "ShiftPlans", column: "ShiftId"); migrationBuilder.CreateIndex( name: "IX_ShiftPlanUsers_ApplicationUserId", schema: "public", table: "ShiftPlanUsers", column: "ApplicationUserId"); migrationBuilder.CreateIndex( name: "IX_ShiftPlanUsers_ShiftPlanId", schema: "public", table: "ShiftPlanUsers", column: "ShiftPlanId"); migrationBuilder.CreateIndex( name: "IX_ShiftRoutines_RoutineId", schema: "public", table: "ShiftRoutines", column: "RoutineId"); migrationBuilder.CreateIndex( name: "IX_ShiftRoutines_ShiftId", schema: "public", table: "ShiftRoutines", column: "ShiftId"); migrationBuilder.CreateIndex( name: "IX_Shifts_ComplexId", schema: "public", table: "Shifts", column: "ComplexId"); migrationBuilder.CreateIndex( name: "IX_TaskDays_TaskId", schema: "public", table: "TaskDays", column: "TaskId"); migrationBuilder.CreateIndex( name: "IX_TaskPositions_PositionId", schema: "public", table: "TaskPositions", column: "PositionId"); migrationBuilder.CreateIndex( name: "IX_TaskPositions_TaskId", schema: "public", table: "TaskPositions", column: "TaskId"); migrationBuilder.CreateIndex( name: "IX_TaskRoutines_RoutineId", schema: "public", table: "TaskRoutines", column: "RoutineId"); migrationBuilder.CreateIndex( name: "IX_TaskRoutines_TaskId", schema: "public", table: "TaskRoutines", column: "TaskId"); migrationBuilder.CreateIndex( name: "IX_Tasks_ComplexId", schema: "public", table: "Tasks", column: "ComplexId"); migrationBuilder.CreateIndex( name: "IX_TaskShifts_ShiftId", schema: "public", table: "TaskShifts", column: "ShiftId"); migrationBuilder.CreateIndex( name: "IX_TaskShifts_TaskId", schema: "public", table: "TaskShifts", column: "TaskId"); migrationBuilder.CreateIndex( name: "IX_UserRoles_RoleId", schema: "public", table: "UserRoles", column: "RoleId"); migrationBuilder.CreateIndex( name: "EmailIndex", schema: "public", table: "Users", column: "NormalizedEmail"); migrationBuilder.CreateIndex( name: "UserNameIndex", schema: "public", table: "Users", column: "NormalizedUserName", unique: true); } /// protected override void Down(MigrationBuilder migrationBuilder) { migrationBuilder.DropTable( name: "Claims", schema: "public"); migrationBuilder.DropTable( name: "ComplexUserRoles", schema: "public"); migrationBuilder.DropTable( name: "Logins", schema: "public"); migrationBuilder.DropTable( name: "PositionUsers", schema: "public"); migrationBuilder.DropTable( name: "RoleClaims", schema: "public"); migrationBuilder.DropTable( name: "ShiftDays", schema: "public"); migrationBuilder.DropTable( name: "ShiftPlanUsers", schema: "public"); migrationBuilder.DropTable( name: "ShiftRoutines", schema: "public"); migrationBuilder.DropTable( name: "TaskDays", schema: "public"); migrationBuilder.DropTable( name: "TaskPositions", schema: "public"); migrationBuilder.DropTable( name: "TaskRoutines", schema: "public"); migrationBuilder.DropTable( name: "TaskShifts", schema: "public"); migrationBuilder.DropTable( name: "Tokens", schema: "public"); migrationBuilder.DropTable( name: "UserRoles", schema: "public"); migrationBuilder.DropTable( name: "ComplexUsers", schema: "public"); migrationBuilder.DropTable( name: "ShiftPlans", schema: "public"); migrationBuilder.DropTable( name: "Positions", schema: "public"); migrationBuilder.DropTable( name: "Routines", schema: "public"); migrationBuilder.DropTable( name: "Tasks", schema: "public"); migrationBuilder.DropTable( name: "Roles", schema: "public"); migrationBuilder.DropTable( name: "Users", schema: "public"); migrationBuilder.DropTable( name: "Shifts", schema: "public"); migrationBuilder.DropTable( name: "Sections", schema: "public"); migrationBuilder.DropTable( name: "Complexes", schema: "public"); } } }