protected override void Up(MigrationBuilder migrationBuilder) { migrationBuilder.AlterDatabase( collation: "Latin1_General_CI_AS"); migrationBuilder.CreateTable( name: "Admin", columns: table => new { NID = table.Column <int>(type: "int", nullable: false), Name = table.Column <string>(type: "nvarchar(50)", maxLength: 50, nullable: false), Gender = table.Column <string>(type: "nvarchar(50)", maxLength: 50, nullable: false), BitrhDate = table.Column <DateTime>(type: "date", nullable: true), Address = table.Column <string>(type: "nvarchar(50)", maxLength: 50, nullable: false), Phone = table.Column <int>(type: "int", nullable: true), Email = table.Column <string>(type: "nvarchar(50)", maxLength: 50, nullable: true), UserName = table.Column <string>(type: "nvarchar(50)", maxLength: 50, nullable: false), Password = table.Column <string>(type: "nvarchar(50)", maxLength: 50, nullable: false), ImageUrl = table.Column <string>(type: "nvarchar(max)", nullable: true), Position = table.Column <string>(type: "nchar(10)", fixedLength: true, maxLength: 10, nullable: false) }, constraints: table => { table.PrimaryKey("PK_Admin", x => x.NID); }); migrationBuilder.CreateTable( name: "Doctor", columns: table => new { NID = table.Column <int>(type: "int", nullable: false), Name = table.Column <string>(type: "nvarchar(50)", maxLength: 50, nullable: false), Gender = table.Column <string>(type: "nvarchar(50)", maxLength: 50, nullable: false), BitrhDate = table.Column <DateTime>(type: "date", nullable: true), Address = table.Column <string>(type: "nvarchar(50)", maxLength: 50, nullable: false), Phone = table.Column <int>(type: "int", nullable: true), Email = table.Column <string>(type: "nvarchar(50)", maxLength: 50, nullable: true), UserName = table.Column <string>(type: "nvarchar(50)", maxLength: 50, nullable: false), Password = table.Column <string>(type: "nvarchar(50)", maxLength: 50, nullable: false), Specialty = table.Column <string>(type: "nvarchar(50)", maxLength: 50, nullable: false), Degree = table.Column <string>(type: "nvarchar(50)", maxLength: 50, nullable: false), ImageUrl = table.Column <string>(type: "nvarchar(max)", nullable: true) }, constraints: table => { table.PrimaryKey("PK_Doctor", x => x.NID); }); migrationBuilder.CreateTable( name: "Medicine", columns: table => new { ID = table.Column <int>(type: "int", nullable: false) .Annotation("SqlServer:Identity", "1, 1"), Name = table.Column <string>(type: "nvarchar(50)", maxLength: 50, nullable: false), Specialty = table.Column <string>(type: "nvarchar(50)", maxLength: 50, nullable: false), Description = table.Column <string>(type: "nvarchar(max)", nullable: true) }, constraints: table => { table.PrimaryKey("PK_Medicine", x => x.ID); }); migrationBuilder.CreateTable( name: "Patient", columns: table => new { NID = table.Column <int>(type: "int", nullable: false), Name = table.Column <string>(type: "nvarchar(50)", maxLength: 50, nullable: false), Gender = table.Column <string>(type: "nvarchar(50)", maxLength: 50, nullable: false), BitrhDate = table.Column <DateTime>(type: "date", nullable: true), Address = table.Column <string>(type: "nvarchar(50)", maxLength: 50, nullable: false), Phone = table.Column <int>(type: "int", nullable: true), Email = table.Column <string>(type: "nvarchar(50)", maxLength: 50, nullable: true), Password = table.Column <string>(type: "nvarchar(50)", maxLength: 50, nullable: false), ImageUrl = table.Column <string>(type: "nvarchar(max)", nullable: true) }, constraints: table => { table.PrimaryKey("PK_Patient_1", x => x.NID); }); migrationBuilder.CreateTable( name: "Analysis", columns: table => new { ID = table.Column <int>(type: "int", nullable: false) .Annotation("SqlServer:Identity", "1, 1"), Type = table.Column <string>(type: "nvarchar(50)", maxLength: 50, nullable: false), DateAndTime = table.Column <DateTime>(type: "datetime", nullable: true), PatientID = table.Column <int>(type: "int", nullable: false), DocID = table.Column <int>(type: "int", nullable: false), Report = table.Column <string>(type: "nvarchar(max)", nullable: false), Note = table.Column <string>(type: "nvarchar(max)", nullable: true), AttachURL = table.Column <string>(type: "nvarchar(max)", nullable: false) }, constraints: table => { table.PrimaryKey("PK_Analysis", x => x.ID); table.ForeignKey( name: "FK_Analyses_Doctor", column: x => x.DocID, principalTable: "Doctor", principalColumn: "NID", onDelete: ReferentialAction.Restrict); table.ForeignKey( name: "FK_Analyses_Patient", column: x => x.PatientID, principalTable: "Patient", principalColumn: "NID", onDelete: ReferentialAction.Restrict); }); migrationBuilder.CreateTable( name: "Appointment", columns: table => new { ID = table.Column <int>(type: "int", nullable: false) .Annotation("SqlServer:Identity", "1, 1"), PatientID = table.Column <int>(type: "int", nullable: false), DocID = table.Column <int>(type: "int", nullable: false), AppointmetDateTime = table.Column <DateTime>(type: "datetime", nullable: false), Note = table.Column <string>(type: "nvarchar(max)", nullable: true), Accepted = table.Column <string>(type: "nchar(10)", fixedLength: true, maxLength: 10, nullable: false, defaultValueSql: "(N'NO')") }, constraints: table => { table.PrimaryKey("PK_Appointment", x => x.ID); table.ForeignKey( name: "FK_Appointment_Doctor", column: x => x.DocID, principalTable: "Doctor", principalColumn: "NID", onDelete: ReferentialAction.Restrict); table.ForeignKey( name: "FK_Appointment_Patient", column: x => x.PatientID, principalTable: "Patient", principalColumn: "NID", onDelete: ReferentialAction.Restrict); }); migrationBuilder.CreateTable( name: "Chat", columns: table => new { ID = table.Column <int>(type: "int", nullable: false) .Annotation("SqlServer:Identity", "1, 1"), PatientID = table.Column <int>(type: "int", nullable: false), DocID = table.Column <int>(type: "int", nullable: false), DateAndTime = table.Column <DateTime>(type: "datetime", nullable: false), Message = table.Column <string>(type: "nvarchar(max)", nullable: false) }, constraints: table => { table.PrimaryKey("PK_Chat", x => x.ID); table.ForeignKey( name: "FK_Chat_Doctor", column: x => x.DocID, principalTable: "Doctor", principalColumn: "NID", onDelete: ReferentialAction.Restrict); table.ForeignKey( name: "FK_Chat_Patient", column: x => x.PatientID, principalTable: "Patient", principalColumn: "NID", onDelete: ReferentialAction.Restrict); }); migrationBuilder.CreateTable( name: "Diagnose", columns: table => new { ID = table.Column <int>(type: "int", nullable: false) .Annotation("SqlServer:Identity", "1, 1"), DiagnoseDateTime = table.Column <DateTime>(type: "datetime", nullable: false), DiagnoseDescription = table.Column <string>(type: "nvarchar(max)", nullable: false), RequiredRadiation = table.Column <string>(type: "nvarchar(50)", maxLength: 50, nullable: true), RequiredAnalyses = table.Column <string>(type: "nvarchar(50)", maxLength: 50, nullable: true), PatientID = table.Column <int>(type: "int", nullable: false), DocID = table.Column <int>(type: "int", nullable: false) }, constraints: table => { table.PrimaryKey("PK_Diagnose", x => x.ID); table.ForeignKey( name: "FK_Diagnose_Doctor", column: x => x.DocID, principalTable: "Doctor", principalColumn: "NID", onDelete: ReferentialAction.Restrict); table.ForeignKey( name: "FK_Diagnose_Patient", column: x => x.PatientID, principalTable: "Patient", principalColumn: "NID", onDelete: ReferentialAction.Restrict); }); migrationBuilder.CreateTable( name: "Radiation", columns: table => new { ID = table.Column <int>(type: "int", nullable: false) .Annotation("SqlServer:Identity", "1, 1"), Type = table.Column <string>(type: "nvarchar(50)", maxLength: 50, nullable: false), DateAndTime = table.Column <DateTime>(type: "datetime", nullable: true), PatientID = table.Column <int>(type: "int", nullable: false), DocID = table.Column <int>(type: "int", nullable: false), Report = table.Column <string>(type: "nvarchar(max)", nullable: false), Note = table.Column <string>(type: "nvarchar(max)", nullable: true), AttachURL = table.Column <string>(type: "nvarchar(max)", nullable: false) }, constraints: table => { table.PrimaryKey("PK_Radiation", x => x.ID); table.ForeignKey( name: "FK_Radiation_Doctor", column: x => x.DocID, principalTable: "Doctor", principalColumn: "NID", onDelete: ReferentialAction.Restrict); table.ForeignKey( name: "FK_Radiation_Patient", column: x => x.PatientID, principalTable: "Patient", principalColumn: "NID", onDelete: ReferentialAction.Restrict); }); migrationBuilder.CreateTable( name: "Diagnose_Prescription", columns: table => new { PrescriptionID = table.Column <int>(type: "int", nullable: false) .Annotation("SqlServer:Identity", "1, 1"), DiagnoseID = table.Column <int>(type: "int", nullable: false) }, constraints: table => { table.PrimaryKey("PK_Diagnose_Prescription", x => x.PrescriptionID); table.ForeignKey( name: "FK_Diagnose_Prescription_Diagnose", column: x => x.DiagnoseID, principalTable: "Diagnose", principalColumn: "ID", onDelete: ReferentialAction.Restrict); }); migrationBuilder.CreateTable( name: "Prescription_Medicine", columns: table => new { PrescriptionID = table.Column <int>(type: "int", nullable: false), MedicineID = table.Column <int>(type: "int", nullable: false), Dose = table.Column <string>(type: "nvarchar(50)", maxLength: 50, nullable: true), Note = table.Column <string>(type: "nvarchar(50)", maxLength: 50, nullable: true) }, constraints: table => { table.ForeignKey( name: "FK_Prescription_Medicine_Diagnose_Prescription", column: x => x.PrescriptionID, principalTable: "Diagnose_Prescription", principalColumn: "PrescriptionID", onDelete: ReferentialAction.Restrict); table.ForeignKey( name: "FK_Prescription_Medicine_Medicine", column: x => x.MedicineID, principalTable: "Medicine", principalColumn: "ID", onDelete: ReferentialAction.Restrict); }); migrationBuilder.CreateIndex( name: "IX_Analysis_DocID", table: "Analysis", column: "DocID"); migrationBuilder.CreateIndex( name: "IX_Analysis_PatientID", table: "Analysis", column: "PatientID"); migrationBuilder.CreateIndex( name: "IX_Appointment_DocID", table: "Appointment", column: "DocID"); migrationBuilder.CreateIndex( name: "IX_Appointment_PatientID", table: "Appointment", column: "PatientID"); migrationBuilder.CreateIndex( name: "IX_Chat_DocID", table: "Chat", column: "DocID"); migrationBuilder.CreateIndex( name: "IX_Chat_PatientID", table: "Chat", column: "PatientID"); migrationBuilder.CreateIndex( name: "IX_Diagnose_DocID", table: "Diagnose", column: "DocID"); migrationBuilder.CreateIndex( name: "IX_Diagnose_PatientID", table: "Diagnose", column: "PatientID"); migrationBuilder.CreateIndex( name: "IX_Diagnose_Prescription_DiagnoseID", table: "Diagnose_Prescription", column: "DiagnoseID"); migrationBuilder.CreateIndex( name: "Unique_Username", table: "Doctor", column: "UserName", unique: true); migrationBuilder.CreateIndex( name: "IX_Prescription_Medicine_MedicineID", table: "Prescription_Medicine", column: "MedicineID"); migrationBuilder.CreateIndex( name: "IX_Prescription_Medicine_PrescriptionID", table: "Prescription_Medicine", column: "PrescriptionID"); migrationBuilder.CreateIndex( name: "IX_Radiation_DocID", table: "Radiation", column: "DocID"); migrationBuilder.CreateIndex( name: "IX_Radiation_PatientID", table: "Radiation", column: "PatientID"); }
protected override void Up(MigrationBuilder migrationBuilder) { migrationBuilder.AlterDatabase() .Annotation("MySql:CharSet", "utf8mb4"); migrationBuilder.CreateTable( name: "notification_status", columns: table => new { Id = table.Column <long>(type: "bigint", nullable: false) .Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn), StatusName = table.Column <string>(type: "varchar(100)", maxLength: 100, nullable: true) .Annotation("MySql:CharSet", "utf8mb4"), StatusDescription = table.Column <string>(type: "varchar(100)", maxLength: 100, nullable: true) .Annotation("MySql:CharSet", "utf8mb4"), CreatedBy = table.Column <string>(type: "varchar(50)", maxLength: 50, nullable: true) .Annotation("MySql:CharSet", "utf8mb4"), CreatedDate = table.Column <DateTime>(type: "datetime(6)", nullable: true), LastEditedBy = table.Column <string>(type: "varchar(50)", maxLength: 50, nullable: true) .Annotation("MySql:CharSet", "utf8mb4"), LastEditedDate = table.Column <DateTime>(type: "datetime(6)", nullable: true), DeletedBy = table.Column <string>(type: "varchar(50)", maxLength: 50, nullable: true) .Annotation("MySql:CharSet", "utf8mb4"), DeletedDate = table.Column <DateTime>(type: "datetime(6)", nullable: true) }, constraints: table => { table.PrimaryKey("PK_notification_status", x => x.Id); }) .Annotation("MySql:CharSet", "utf8mb4"); migrationBuilder.CreateTable( name: "notification_type", columns: table => new { Id = table.Column <long>(type: "bigint", nullable: false) .Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn), TypeName = table.Column <string>(type: "varchar(20)", maxLength: 20, nullable: true) .Annotation("MySql:CharSet", "utf8mb4"), TypeDescription = table.Column <string>(type: "varchar(100)", maxLength: 100, nullable: true) .Annotation("MySql:CharSet", "utf8mb4"), CreatedBy = table.Column <string>(type: "varchar(50)", maxLength: 50, nullable: true) .Annotation("MySql:CharSet", "utf8mb4"), CreatedDate = table.Column <DateTime>(type: "datetime(6)", nullable: true), LastEditedBy = table.Column <string>(type: "varchar(50)", maxLength: 50, nullable: true) .Annotation("MySql:CharSet", "utf8mb4"), LastEditedDate = table.Column <DateTime>(type: "datetime(6)", nullable: true), DeletedBy = table.Column <string>(type: "varchar(50)", maxLength: 50, nullable: true) .Annotation("MySql:CharSet", "utf8mb4"), DeletedDate = table.Column <DateTime>(type: "datetime(6)", nullable: true) }, constraints: table => { table.PrimaryKey("PK_notification_type", x => x.Id); }) .Annotation("MySql:CharSet", "utf8mb4"); migrationBuilder.CreateTable( name: "notification", columns: table => new { Id = table.Column <long>(type: "bigint", nullable: false) .Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn), Subject = table.Column <string>(type: "longtext", nullable: true) .Annotation("MySql:CharSet", "utf8mb4"), Body = table.Column <string>(type: "varchar(800)", maxLength: 800, nullable: true) .Annotation("MySql:CharSet", "utf8mb4"), Sender = table.Column <string>(type: "varchar(80)", maxLength: 80, nullable: true) .Annotation("MySql:CharSet", "utf8mb4"), Recipient = table.Column <string>(type: "varchar(400)", maxLength: 400, nullable: true) .Annotation("MySql:CharSet", "utf8mb4"), CCRecipient = table.Column <string>(type: "varchar(400)", maxLength: 400, nullable: true) .Annotation("MySql:CharSet", "utf8mb4"), BCCRecipient = table.Column <string>(type: "varchar(200)", maxLength: 200, nullable: true) .Annotation("MySql:CharSet", "utf8mb4"), StatusId = table.Column <long>(type: "bigint", nullable: false), TypeId = table.Column <long>(type: "bigint", nullable: false), CreatedBy = table.Column <string>(type: "varchar(50)", maxLength: 50, nullable: true) .Annotation("MySql:CharSet", "utf8mb4"), CreatedDate = table.Column <DateTime>(type: "datetime(6)", nullable: true), LastEditedBy = table.Column <string>(type: "varchar(50)", maxLength: 50, nullable: true) .Annotation("MySql:CharSet", "utf8mb4"), LastEditedDate = table.Column <DateTime>(type: "datetime(6)", nullable: true), DeletedBy = table.Column <string>(type: "varchar(50)", maxLength: 50, nullable: true) .Annotation("MySql:CharSet", "utf8mb4"), DeletedDate = table.Column <DateTime>(type: "datetime(6)", nullable: true) }, constraints: table => { table.PrimaryKey("PK_notification", x => x.Id); table.ForeignKey( name: "FK_notification_notification_status_StatusId", column: x => x.StatusId, principalTable: "notification_status", principalColumn: "Id", onDelete: ReferentialAction.Cascade); table.ForeignKey( name: "FK_notification_notification_type_TypeId", column: x => x.TypeId, principalTable: "notification_type", principalColumn: "Id", onDelete: ReferentialAction.Cascade); }) .Annotation("MySql:CharSet", "utf8mb4"); migrationBuilder.CreateIndex( name: "IX_notification_Sender", table: "notification", column: "Sender"); migrationBuilder.CreateIndex( name: "IX_notification_StatusId", table: "notification", column: "StatusId"); migrationBuilder.CreateIndex( name: "IX_notification_TypeId", table: "notification", column: "TypeId"); migrationBuilder.CreateIndex( name: "IX_notification_status_StatusName", table: "notification_status", column: "StatusName"); migrationBuilder.CreateIndex( name: "IX_notification_type_TypeName", table: "notification_type", column: "TypeName"); }
protected override void Up(MigrationBuilder migrationBuilder) { migrationBuilder.AlterDatabase() .Annotation("MySql:CharSet", "utf8mb4"); migrationBuilder.CreateTable( name: "AspNetRoles", columns: table => new { Id = table.Column <string>(type: "varchar(255)", nullable: false) .Annotation("MySql:CharSet", "utf8mb4"), Name = table.Column <string>(type: "varchar(256)", maxLength: 256, nullable: true) .Annotation("MySql:CharSet", "utf8mb4"), NormalizedName = table.Column <string>(type: "varchar(256)", maxLength: 256, nullable: true) .Annotation("MySql:CharSet", "utf8mb4"), ConcurrencyStamp = table.Column <string>(type: "longtext", nullable: true) .Annotation("MySql:CharSet", "utf8mb4") }, constraints: table => { table.PrimaryKey("PK_AspNetRoles", x => x.Id); }) .Annotation("MySql:CharSet", "utf8mb4"); migrationBuilder.CreateTable( name: "AspNetUsers", columns: table => new { Id = table.Column <string>(type: "varchar(255)", nullable: false) .Annotation("MySql:CharSet", "utf8mb4"), UserName = table.Column <string>(type: "varchar(256)", maxLength: 256, nullable: true) .Annotation("MySql:CharSet", "utf8mb4"), NormalizedUserName = table.Column <string>(type: "varchar(256)", maxLength: 256, nullable: true) .Annotation("MySql:CharSet", "utf8mb4"), Email = table.Column <string>(type: "varchar(256)", maxLength: 256, nullable: true) .Annotation("MySql:CharSet", "utf8mb4"), NormalizedEmail = table.Column <string>(type: "varchar(256)", maxLength: 256, nullable: true) .Annotation("MySql:CharSet", "utf8mb4"), EmailConfirmed = table.Column <bool>(type: "tinyint(1)", nullable: false), PasswordHash = table.Column <string>(type: "longtext", nullable: true) .Annotation("MySql:CharSet", "utf8mb4"), SecurityStamp = table.Column <string>(type: "longtext", nullable: true) .Annotation("MySql:CharSet", "utf8mb4"), ConcurrencyStamp = table.Column <string>(type: "longtext", nullable: true) .Annotation("MySql:CharSet", "utf8mb4"), PhoneNumber = table.Column <string>(type: "longtext", nullable: true) .Annotation("MySql:CharSet", "utf8mb4"), PhoneNumberConfirmed = table.Column <bool>(type: "tinyint(1)", nullable: false), TwoFactorEnabled = table.Column <bool>(type: "tinyint(1)", nullable: false), LockoutEnd = table.Column <DateTimeOffset>(type: "datetime(6)", nullable: true), LockoutEnabled = table.Column <bool>(type: "tinyint(1)", nullable: false), AccessFailedCount = table.Column <int>(type: "int", nullable: false) }, constraints: table => { table.PrimaryKey("PK_AspNetUsers", x => x.Id); }) .Annotation("MySql:CharSet", "utf8mb4"); migrationBuilder.CreateTable( name: "license", columns: table => new { Id = table.Column <Guid>(type: "char(36)", nullable: false, collation: "ascii_general_ci"), license_name = table.Column <string>(type: "longtext", nullable: true) .Annotation("MySql:CharSet", "utf8mb4"), DateAdded = table.Column <DateTime>(type: "datetime(6)", nullable: false) }, constraints: table => { table.PrimaryKey("PK_license", x => x.Id); }) .Annotation("MySql:CharSet", "utf8mb4"); migrationBuilder.CreateTable( name: "AspNetRoleClaims", columns: table => new { Id = table.Column <int>(type: "int", nullable: false) .Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn), RoleId = table.Column <string>(type: "varchar(255)", nullable: false) .Annotation("MySql:CharSet", "utf8mb4"), ClaimType = table.Column <string>(type: "longtext", nullable: true) .Annotation("MySql:CharSet", "utf8mb4"), ClaimValue = table.Column <string>(type: "longtext", nullable: true) .Annotation("MySql:CharSet", "utf8mb4") }, constraints: table => { table.PrimaryKey("PK_AspNetRoleClaims", x => x.Id); table.ForeignKey( name: "FK_AspNetRoleClaims_AspNetRoles_RoleId", column: x => x.RoleId, principalTable: "AspNetRoles", principalColumn: "Id", onDelete: ReferentialAction.Cascade); }) .Annotation("MySql:CharSet", "utf8mb4"); migrationBuilder.CreateTable( name: "AspNetUserClaims", columns: table => new { Id = table.Column <int>(type: "int", nullable: false) .Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn), UserId = table.Column <string>(type: "varchar(255)", nullable: false) .Annotation("MySql:CharSet", "utf8mb4"), ClaimType = table.Column <string>(type: "longtext", nullable: true) .Annotation("MySql:CharSet", "utf8mb4"), ClaimValue = table.Column <string>(type: "longtext", nullable: true) .Annotation("MySql:CharSet", "utf8mb4") }, constraints: table => { table.PrimaryKey("PK_AspNetUserClaims", x => x.Id); table.ForeignKey( name: "FK_AspNetUserClaims_AspNetUsers_UserId", column: x => x.UserId, principalTable: "AspNetUsers", principalColumn: "Id", onDelete: ReferentialAction.Cascade); }) .Annotation("MySql:CharSet", "utf8mb4"); migrationBuilder.CreateTable( name: "AspNetUserLogins", columns: table => new { LoginProvider = table.Column <string>(type: "varchar(255)", nullable: false) .Annotation("MySql:CharSet", "utf8mb4"), ProviderKey = table.Column <string>(type: "varchar(255)", nullable: false) .Annotation("MySql:CharSet", "utf8mb4"), ProviderDisplayName = table.Column <string>(type: "longtext", nullable: true) .Annotation("MySql:CharSet", "utf8mb4"), UserId = table.Column <string>(type: "varchar(255)", nullable: false) .Annotation("MySql:CharSet", "utf8mb4") }, constraints: table => { table.PrimaryKey("PK_AspNetUserLogins", x => new { x.LoginProvider, x.ProviderKey }); table.ForeignKey( name: "FK_AspNetUserLogins_AspNetUsers_UserId", column: x => x.UserId, principalTable: "AspNetUsers", principalColumn: "Id", onDelete: ReferentialAction.Cascade); }) .Annotation("MySql:CharSet", "utf8mb4"); migrationBuilder.CreateTable( name: "AspNetUserRoles", columns: table => new { UserId = table.Column <string>(type: "varchar(255)", nullable: false) .Annotation("MySql:CharSet", "utf8mb4"), RoleId = table.Column <string>(type: "varchar(255)", nullable: false) .Annotation("MySql:CharSet", "utf8mb4") }, constraints: table => { table.PrimaryKey("PK_AspNetUserRoles", x => new { x.UserId, x.RoleId }); table.ForeignKey( name: "FK_AspNetUserRoles_AspNetRoles_RoleId", column: x => x.RoleId, principalTable: "AspNetRoles", principalColumn: "Id", onDelete: ReferentialAction.Cascade); table.ForeignKey( name: "FK_AspNetUserRoles_AspNetUsers_UserId", column: x => x.UserId, principalTable: "AspNetUsers", principalColumn: "Id", onDelete: ReferentialAction.Cascade); }) .Annotation("MySql:CharSet", "utf8mb4"); migrationBuilder.CreateTable( name: "AspNetUserTokens", columns: table => new { UserId = table.Column <string>(type: "varchar(255)", nullable: false) .Annotation("MySql:CharSet", "utf8mb4"), LoginProvider = table.Column <string>(type: "varchar(255)", nullable: false) .Annotation("MySql:CharSet", "utf8mb4"), Name = table.Column <string>(type: "varchar(255)", nullable: false) .Annotation("MySql:CharSet", "utf8mb4"), Value = table.Column <string>(type: "longtext", nullable: true) .Annotation("MySql:CharSet", "utf8mb4") }, constraints: table => { table.PrimaryKey("PK_AspNetUserTokens", x => new { x.UserId, x.LoginProvider, x.Name }); table.ForeignKey( name: "FK_AspNetUserTokens_AspNetUsers_UserId", column: x => x.UserId, principalTable: "AspNetUsers", principalColumn: "Id", onDelete: ReferentialAction.Cascade); }) .Annotation("MySql:CharSet", "utf8mb4"); migrationBuilder.InsertData( table: "AspNetRoles", columns: new[] { "Id", "ConcurrencyStamp", "Name", "NormalizedName" }, values: new object[] { "34ae434f-6b24-4079-bad1-1e4b17ec15c1", "2e04d271-167a-49df-b6cd-d12b995268a6", "admin", "ADMIN" }); migrationBuilder.InsertData( table: "AspNetUsers", columns: new[] { "Id", "AccessFailedCount", "ConcurrencyStamp", "Email", "EmailConfirmed", "LockoutEnabled", "LockoutEnd", "NormalizedEmail", "NormalizedUserName", "PasswordHash", "PhoneNumber", "PhoneNumberConfirmed", "SecurityStamp", "TwoFactorEnabled", "UserName" }, values: new object[] { "995b4393-6796-4ae0-b58e-58028781f46d", 0, "cf492314-a46d-465a-9cf3-a83960e101a3", "*****@*****.**", true, false, null, "*****@*****.**", "ADMIN", "AQAAAAEAACcQAAAAELBTGE/cD4LJ/XXCA1+LwVP0kq+IkU1j1of8k9kYNwTT9wS1GoDeSQAlPfoBnZpsSA==", null, false, "", false, "admin" }); migrationBuilder.InsertData( table: "license", columns: new[] { "Id", "DateAdded", "license_name" }, values: new object[, ] { { new Guid("981c3c9e-cbdd-4594-a537-1101c23adb82"), new DateTime(2021, 4, 30, 10, 19, 23, 68, DateTimeKind.Utc).AddTicks(2571), "GPL" }, { new Guid("773ec4ed-f886-4a70-9651-a5595abcdb8e"), new DateTime(2021, 4, 30, 10, 19, 23, 68, DateTimeKind.Utc).AddTicks(4578), "Creative common BY" } }); migrationBuilder.InsertData( table: "AspNetUserRoles", columns: new[] { "RoleId", "UserId" }, values: new object[] { "34ae434f-6b24-4079-bad1-1e4b17ec15c1", "995b4393-6796-4ae0-b58e-58028781f46d" }); migrationBuilder.CreateIndex( name: "IX_AspNetRoleClaims_RoleId", table: "AspNetRoleClaims", column: "RoleId"); migrationBuilder.CreateIndex( name: "RoleNameIndex", table: "AspNetRoles", column: "NormalizedName", unique: true); migrationBuilder.CreateIndex( name: "IX_AspNetUserClaims_UserId", table: "AspNetUserClaims", column: "UserId"); migrationBuilder.CreateIndex( name: "IX_AspNetUserLogins_UserId", table: "AspNetUserLogins", column: "UserId"); migrationBuilder.CreateIndex( name: "IX_AspNetUserRoles_RoleId", table: "AspNetUserRoles", column: "RoleId"); migrationBuilder.CreateIndex( name: "EmailIndex", table: "AspNetUsers", column: "NormalizedEmail"); migrationBuilder.CreateIndex( name: "UserNameIndex", table: "AspNetUsers", column: "NormalizedUserName", unique: true); }
protected override void Up(MigrationBuilder migrationBuilder) { migrationBuilder.AlterDatabase() .Annotation("Npgsql:Enum:ImageFormat", "PNG,JPEG"); migrationBuilder.CreateTable( name: "AspNetRoles", columns: table => new { Id = table.Column <int>(nullable: false) .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), Name = table.Column <string>(maxLength: 256, nullable: true), NormalizedName = table.Column <string>(maxLength: 256, nullable: true), ConcurrencyStamp = table.Column <string>(nullable: true) }, constraints: table => { table.PrimaryKey("PK_AspNetRoles", x => x.Id); }); migrationBuilder.CreateTable( name: "AspNetUsers", columns: table => new { Id = table.Column <int>(nullable: false) .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), UserName = table.Column <string>(maxLength: 256, nullable: true), NormalizedUserName = table.Column <string>(maxLength: 256, nullable: true), Email = table.Column <string>(maxLength: 256, nullable: true), NormalizedEmail = table.Column <string>(maxLength: 256, nullable: true), EmailConfirmed = table.Column <bool>(nullable: false), PasswordHash = table.Column <string>(nullable: true), SecurityStamp = table.Column <string>(nullable: true), ConcurrencyStamp = table.Column <string>(nullable: true), PhoneNumber = table.Column <string>(nullable: true), PhoneNumberConfirmed = table.Column <bool>(nullable: false), TwoFactorEnabled = table.Column <bool>(nullable: false), LockoutEnd = table.Column <DateTimeOffset>(nullable: true), LockoutEnabled = table.Column <bool>(nullable: false), AccessFailedCount = table.Column <int>(nullable: false) }, constraints: table => { table.PrimaryKey("PK_AspNetUsers", x => x.Id); }); migrationBuilder.CreateTable( name: "Phylums", columns: table => new { Id = table.Column <int>(nullable: false) .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), Denomination = table.Column <string>(nullable: true) }, constraints: table => { table.PrimaryKey("PK_Phylums", x => x.Id); }); migrationBuilder.CreateTable( name: "Reserves", columns: table => new { Id = table.Column <int>(nullable: false) .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), Name = table.Column <string>(nullable: true), Latitude = table.Column <double>(nullable: false), Longitude = table.Column <double>(nullable: false) }, constraints: table => { table.PrimaryKey("PK_Reserves", x => x.Id); }); migrationBuilder.CreateTable( name: "AspNetRoleClaims", columns: table => new { Id = table.Column <int>(nullable: false) .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), RoleId = table.Column <int>(nullable: false), ClaimType = table.Column <string>(nullable: true), ClaimValue = table.Column <string>(nullable: true) }, constraints: table => { table.PrimaryKey("PK_AspNetRoleClaims", x => x.Id); table.ForeignKey( name: "FK_AspNetRoleClaims_AspNetRoles_RoleId", column: x => x.RoleId, principalTable: "AspNetRoles", principalColumn: "Id", onDelete: ReferentialAction.Cascade); }); migrationBuilder.CreateTable( name: "AspNetUserClaims", columns: table => new { Id = table.Column <int>(nullable: false) .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), UserId = table.Column <int>(nullable: false), ClaimType = table.Column <string>(nullable: true), ClaimValue = table.Column <string>(nullable: true) }, constraints: table => { table.PrimaryKey("PK_AspNetUserClaims", x => x.Id); table.ForeignKey( name: "FK_AspNetUserClaims_AspNetUsers_UserId", column: x => x.UserId, principalTable: "AspNetUsers", principalColumn: "Id", onDelete: ReferentialAction.Cascade); }); migrationBuilder.CreateTable( name: "AspNetUserLogins", columns: table => new { LoginProvider = table.Column <string>(nullable: false), ProviderKey = table.Column <string>(nullable: false), ProviderDisplayName = table.Column <string>(nullable: true), UserId = table.Column <int>(nullable: false) }, constraints: table => { table.PrimaryKey("PK_AspNetUserLogins", x => new { x.LoginProvider, x.ProviderKey }); table.ForeignKey( name: "FK_AspNetUserLogins_AspNetUsers_UserId", column: x => x.UserId, principalTable: "AspNetUsers", principalColumn: "Id", onDelete: ReferentialAction.Cascade); }); migrationBuilder.CreateTable( name: "AspNetUserRoles", columns: table => new { UserId = table.Column <int>(nullable: false), RoleId = table.Column <int>(nullable: false) }, constraints: table => { table.PrimaryKey("PK_AspNetUserRoles", x => new { x.UserId, x.RoleId }); table.ForeignKey( name: "FK_AspNetUserRoles_AspNetRoles_RoleId", column: x => x.RoleId, principalTable: "AspNetRoles", principalColumn: "Id", onDelete: ReferentialAction.Cascade); table.ForeignKey( name: "FK_AspNetUserRoles_AspNetUsers_UserId", column: x => x.UserId, principalTable: "AspNetUsers", principalColumn: "Id", onDelete: ReferentialAction.Cascade); }); migrationBuilder.CreateTable( name: "AspNetUserTokens", columns: table => new { UserId = table.Column <int>(nullable: false), LoginProvider = table.Column <string>(nullable: false), Name = table.Column <string>(nullable: false), Value = table.Column <string>(nullable: true) }, constraints: table => { table.PrimaryKey("PK_AspNetUserTokens", x => new { x.UserId, x.LoginProvider, x.Name }); table.ForeignKey( name: "FK_AspNetUserTokens_AspNetUsers_UserId", column: x => x.UserId, principalTable: "AspNetUsers", principalColumn: "Id", onDelete: ReferentialAction.Cascade); }); migrationBuilder.CreateTable( name: "Classes", columns: table => new { Id = table.Column <int>(nullable: false) .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), Denomination = table.Column <string>(nullable: true), PhylumId = table.Column <int>(nullable: false) }, constraints: table => { table.PrimaryKey("PK_Classes", x => x.Id); table.ForeignKey( name: "FK_Classes_Phylums_PhylumId", column: x => x.PhylumId, principalTable: "Phylums", principalColumn: "Id", onDelete: ReferentialAction.Cascade); }); migrationBuilder.CreateTable( name: "Orders", columns: table => new { Id = table.Column <int>(nullable: false) .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), Denomination = table.Column <string>(nullable: true), ClassId = table.Column <int>(nullable: false) }, constraints: table => { table.PrimaryKey("PK_Orders", x => x.Id); table.ForeignKey( name: "FK_Orders_Classes_ClassId", column: x => x.ClassId, principalTable: "Classes", principalColumn: "Id", onDelete: ReferentialAction.Cascade); }); migrationBuilder.CreateTable( name: "Families", columns: table => new { Id = table.Column <int>(nullable: false) .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), Denomination = table.Column <string>(nullable: true), OrderId = table.Column <int>(nullable: false) }, constraints: table => { table.PrimaryKey("PK_Families", x => x.Id); table.ForeignKey( name: "FK_Families_Orders_OrderId", column: x => x.OrderId, principalTable: "Orders", principalColumn: "Id", onDelete: ReferentialAction.Cascade); }); migrationBuilder.CreateTable( name: "Genuses", columns: table => new { Id = table.Column <int>(nullable: false) .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), Denomination = table.Column <string>(nullable: true), FamilyId = table.Column <int>(nullable: false) }, constraints: table => { table.PrimaryKey("PK_Genuses", x => x.Id); table.ForeignKey( name: "FK_Genuses_Families_FamilyId", column: x => x.FamilyId, principalTable: "Families", principalColumn: "Id", onDelete: ReferentialAction.Cascade); }); migrationBuilder.CreateTable( name: "Species", columns: table => new { Id = table.Column <int>(nullable: false) .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), Denomination = table.Column <string>(nullable: true), GenusId = table.Column <int>(nullable: false) }, constraints: table => { table.PrimaryKey("PK_Species", x => x.Id); table.ForeignKey( name: "FK_Species_Genuses_GenusId", column: x => x.GenusId, principalTable: "Genuses", principalColumn: "Id", onDelete: ReferentialAction.Cascade); }); migrationBuilder.CreateTable( name: "Descriptions", columns: table => new { Id = table.Column <int>(nullable: false) .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), ShortDesc = table.Column <string>(nullable: true), SpecieId = table.Column <int>(nullable: false), NaturalAreaId = table.Column <int>(nullable: false) }, constraints: table => { table.PrimaryKey("PK_Descriptions", x => x.Id); table.ForeignKey( name: "FK_Descriptions_Species_SpecieId", column: x => x.SpecieId, principalTable: "Species", principalColumn: "Id", onDelete: ReferentialAction.Cascade); }); migrationBuilder.CreateTable( name: "ReserveSpecies", columns: table => new { ReserveId = table.Column <int>(nullable: false), SpecieId = table.Column <int>(nullable: false) }, constraints: table => { table.PrimaryKey("PK_ReserveAnimals", x => new { x.ReserveId, x.SpecieId }); table.ForeignKey( name: "FK_ReserveAnimals_Reserves_ReserveId", column: x => x.ReserveId, principalTable: "Reserves", principalColumn: "Id", onDelete: ReferentialAction.Cascade); table.ForeignKey( name: "FK_ReserveAnimals_Species_SpecieId", column: x => x.SpecieId, principalTable: "Species", principalColumn: "Id", onDelete: ReferentialAction.Cascade); }); migrationBuilder.CreateTable( name: "Images", columns: table => new { Id = table.Column <int>(nullable: false) .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), ImageBytes = table.Column <byte[]>(nullable: true), DescriptionId = table.Column <int>(nullable: false) }, constraints: table => { table.PrimaryKey("PK_Images", x => x.Id); table.ForeignKey( name: "FK_Images_Descriptions_DescriptionId", column: x => x.DescriptionId, principalTable: "Descriptions", principalColumn: "Id", onDelete: ReferentialAction.Cascade); }); migrationBuilder.CreateTable( name: "NaturalAreas", columns: table => new { Id = table.Column <int>(nullable: false) .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), Denomination = table.Column <string>(nullable: true), DescriptionId = table.Column <int>(nullable: false) }, constraints: table => { table.PrimaryKey("PK_NaturalAreas", x => x.Id); table.ForeignKey( name: "FK_NaturalAreas_Descriptions_DescriptionId", column: x => x.DescriptionId, principalTable: "Descriptions", principalColumn: "Id", onDelete: ReferentialAction.Cascade); }); migrationBuilder.CreateTable( name: "TextDescriptions", columns: table => new { Id = table.Column <int>(nullable: false) .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), Text = table.Column <string>(nullable: true), DescriptionId = table.Column <int>(nullable: false) }, constraints: table => { table.PrimaryKey("PK_TextDescriptions", x => x.Id); table.ForeignKey( name: "FK_TextDescriptions_Descriptions_DescriptionId", column: x => x.DescriptionId, principalTable: "Descriptions", principalColumn: "Id", onDelete: ReferentialAction.Cascade); }); migrationBuilder.CreateIndex( name: "IX_AspNetRoleClaims_RoleId", table: "AspNetRoleClaims", column: "RoleId"); migrationBuilder.CreateIndex( name: "RoleNameIndex", table: "AspNetRoles", column: "NormalizedName", unique: true); migrationBuilder.CreateIndex( name: "IX_AspNetUserClaims_UserId", table: "AspNetUserClaims", column: "UserId"); migrationBuilder.CreateIndex( name: "IX_AspNetUserLogins_UserId", table: "AspNetUserLogins", column: "UserId"); migrationBuilder.CreateIndex( name: "IX_AspNetUserRoles_RoleId", table: "AspNetUserRoles", column: "RoleId"); migrationBuilder.CreateIndex( name: "EmailIndex", table: "AspNetUsers", column: "NormalizedEmail"); migrationBuilder.CreateIndex( name: "UserNameIndex", table: "AspNetUsers", column: "NormalizedUserName", unique: true); migrationBuilder.CreateIndex( name: "IX_Classes_Denomination", table: "Classes", column: "Denomination", unique: true); migrationBuilder.CreateIndex( name: "IX_Classes_PhylumId", table: "Classes", column: "PhylumId"); migrationBuilder.CreateIndex( name: "IX_Descriptions_SpecieId", table: "Descriptions", column: "SpecieId", unique: true); migrationBuilder.CreateIndex( name: "IX_Families_Denomination", table: "Families", column: "Denomination", unique: true); migrationBuilder.CreateIndex( name: "IX_Families_OrderId", table: "Families", column: "OrderId"); migrationBuilder.CreateIndex( name: "IX_Genuses_Denomination", table: "Genuses", column: "Denomination", unique: true); migrationBuilder.CreateIndex( name: "IX_Genuses_FamilyId", table: "Genuses", column: "FamilyId"); migrationBuilder.CreateIndex( name: "IX_Images_DescriptionId", table: "Images", column: "DescriptionId", unique: true); migrationBuilder.CreateIndex( name: "IX_NaturalAreas_Denomination", table: "NaturalAreas", column: "Denomination", unique: true); migrationBuilder.CreateIndex( name: "IX_NaturalAreas_DescriptionId", table: "NaturalAreas", column: "DescriptionId", unique: true); migrationBuilder.CreateIndex( name: "IX_Orders_ClassId", table: "Orders", column: "ClassId"); migrationBuilder.CreateIndex( name: "IX_Orders_Denomination", table: "Orders", column: "Denomination", unique: true); migrationBuilder.CreateIndex( name: "IX_Phylums_Denomination", table: "Phylums", column: "Denomination", unique: true); migrationBuilder.CreateIndex( name: "IX_ReserveAnimals_SpecieId", table: "ReserveSpecies", column: "SpecieId"); migrationBuilder.CreateIndex( name: "IX_Reserves_Name_Latitude_Longitude", table: "Reserves", columns: new[] { "Name", "Latitude", "Longitude" }, unique: true); migrationBuilder.CreateIndex( name: "IX_Species_Denomination", table: "Species", column: "Denomination", unique: true); migrationBuilder.CreateIndex( name: "IX_Species_GenusId", table: "Species", column: "GenusId"); migrationBuilder.CreateIndex( name: "IX_TextDescriptions_DescriptionId", table: "TextDescriptions", column: "DescriptionId", unique: true); }
protected override void Up(MigrationBuilder migrationBuilder) { migrationBuilder.AlterDatabase() .Annotation("Npgsql:Enum:LinkType", "normal,inter_rack,inter_local,inter_site") .Annotation("Npgsql:Enum:Operation", "insertion,suppression,modification,selection") .Annotation("Npgsql:Enum:Target_audit", "sites,local,racks,elements,liens"); migrationBuilder.CreateTable( name: "AspNetRoles", columns: table => new { Id = table.Column <string>(type: "text", nullable: false), Discriminator = table.Column <string>(type: "text", nullable: false), Name = table.Column <string>(type: "character varying(256)", maxLength: 256, nullable: true), NormalizedName = table.Column <string>(type: "character varying(256)", maxLength: 256, nullable: true), ConcurrencyStamp = table.Column <string>(type: "text", nullable: true) }, constraints: table => { table.PrimaryKey("PK_AspNetRoles", x => x.Id); }); migrationBuilder.CreateTable( name: "AspNetUsers", columns: table => new { Id = table.Column <string>(type: "text", nullable: false), UserName = table.Column <string>(type: "character varying(256)", maxLength: 256, nullable: true), NormalizedUserName = table.Column <string>(type: "character varying(256)", maxLength: 256, nullable: true), Email = table.Column <string>(type: "character varying(256)", maxLength: 256, nullable: true), NormalizedEmail = table.Column <string>(type: "character varying(256)", maxLength: 256, nullable: true), EmailConfirmed = table.Column <bool>(type: "boolean", nullable: false), PasswordHash = table.Column <string>(type: "text", nullable: true), SecurityStamp = table.Column <string>(type: "text", nullable: true), ConcurrencyStamp = table.Column <string>(type: "text", nullable: true), PhoneNumber = table.Column <string>(type: "text", nullable: true), PhoneNumberConfirmed = table.Column <bool>(type: "boolean", nullable: false), TwoFactorEnabled = table.Column <bool>(type: "boolean", nullable: false), LockoutEnd = table.Column <DateTimeOffset>(type: "timestamp with time zone", nullable: true), LockoutEnabled = table.Column <bool>(type: "boolean", nullable: false), AccessFailedCount = table.Column <int>(type: "integer", nullable: false) }, constraints: table => { table.PrimaryKey("PK_AspNetUsers", x => x.Id); }); migrationBuilder.CreateTable( name: "Audit", columns: table => new { Audit_id = table.Column <int>(type: "integer", nullable: false) .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), Target_audit = table.Column <Target_audit>(type: "\"Target_audit\"", nullable: false), Operation = table.Column <Operation>(type: "\"Operation\"", nullable: false) }, constraints: table => { table.PrimaryKey("PK_Audit", x => x.Audit_id); }); migrationBuilder.CreateTable( name: "DeviceCodes", columns: table => new { UserCode = table.Column <string>(type: "character varying(200)", maxLength: 200, nullable: false), DeviceCode = table.Column <string>(type: "character varying(200)", maxLength: 200, nullable: false), SubjectId = table.Column <string>(type: "character varying(200)", maxLength: 200, nullable: true), SessionId = table.Column <string>(type: "character varying(100)", maxLength: 100, nullable: true), ClientId = table.Column <string>(type: "character varying(200)", maxLength: 200, nullable: false), Description = table.Column <string>(type: "character varying(200)", maxLength: 200, nullable: true), CreationTime = table.Column <DateTime>(type: "timestamp without time zone", nullable: false), Expiration = table.Column <DateTime>(type: "timestamp without time zone", nullable: false), Data = table.Column <string>(type: "character varying(50000)", maxLength: 50000, nullable: false) }, constraints: table => { table.PrimaryKey("PK_DeviceCodes", x => x.UserCode); }); migrationBuilder.CreateTable( name: "Element_type", columns: table => new { Element_type_id = table.Column <short>(type: "smallint", nullable: false) .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), Label = table.Column <string>(type: "character varying(50)", maxLength: 50, nullable: true), Image = table.Column <string>(type: "character varying(50)", maxLength: 50, nullable: true) }, constraints: table => { table.PrimaryKey("PK_Element_type", x => x.Element_type_id); }); migrationBuilder.CreateTable( name: "PersistedGrants", columns: table => new { Key = table.Column <string>(type: "character varying(200)", maxLength: 200, nullable: false), Type = table.Column <string>(type: "character varying(50)", maxLength: 50, nullable: false), SubjectId = table.Column <string>(type: "character varying(200)", maxLength: 200, nullable: true), SessionId = table.Column <string>(type: "character varying(100)", maxLength: 100, nullable: true), ClientId = table.Column <string>(type: "character varying(200)", maxLength: 200, nullable: false), Description = table.Column <string>(type: "character varying(200)", maxLength: 200, nullable: true), CreationTime = table.Column <DateTime>(type: "timestamp without time zone", nullable: false), Expiration = table.Column <DateTime>(type: "timestamp without time zone", nullable: true), ConsumedTime = table.Column <DateTime>(type: "timestamp without time zone", nullable: true), Data = table.Column <string>(type: "character varying(50000)", maxLength: 50000, nullable: false) }, constraints: table => { table.PrimaryKey("PK_PersistedGrants", x => x.Key); }); migrationBuilder.CreateTable( name: "Sites", columns: table => new { Site_id = table.Column <short>(type: "smallint", nullable: false) .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), Name = table.Column <string>(type: "character varying(50)", maxLength: 50, nullable: true), Short_name = table.Column <string>(type: "character varying(3)", maxLength: 3, nullable: true), Location = table.Column <string>(type: "character varying(50)", maxLength: 50, nullable: true) }, constraints: table => { table.PrimaryKey("PK_Sites", x => x.Site_id); }); migrationBuilder.CreateTable( name: "AspNetRoleClaims", columns: table => new { Id = table.Column <int>(type: "integer", nullable: false) .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), RoleId = table.Column <string>(type: "text", nullable: false), ClaimType = table.Column <string>(type: "text", nullable: true), ClaimValue = table.Column <string>(type: "text", nullable: true) }, constraints: table => { table.PrimaryKey("PK_AspNetRoleClaims", x => x.Id); table.ForeignKey( name: "FK_AspNetRoleClaims_AspNetRoles_RoleId", column: x => x.RoleId, principalTable: "AspNetRoles", principalColumn: "Id", onDelete: ReferentialAction.Cascade); }); migrationBuilder.CreateTable( name: "AspNetUserClaims", columns: table => new { Id = table.Column <int>(type: "integer", nullable: false) .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), UserId = table.Column <string>(type: "text", nullable: false), ClaimType = table.Column <string>(type: "text", nullable: true), ClaimValue = table.Column <string>(type: "text", nullable: true) }, constraints: table => { table.PrimaryKey("PK_AspNetUserClaims", x => x.Id); table.ForeignKey( name: "FK_AspNetUserClaims_AspNetUsers_UserId", column: x => x.UserId, principalTable: "AspNetUsers", principalColumn: "Id", onDelete: ReferentialAction.Cascade); }); migrationBuilder.CreateTable( name: "AspNetUserLogins", columns: table => new { LoginProvider = table.Column <string>(type: "character varying(128)", maxLength: 128, nullable: false), ProviderKey = table.Column <string>(type: "character varying(128)", maxLength: 128, nullable: false), ProviderDisplayName = table.Column <string>(type: "text", nullable: true), UserId = table.Column <string>(type: "text", nullable: false) }, constraints: table => { table.PrimaryKey("PK_AspNetUserLogins", x => new { x.LoginProvider, x.ProviderKey }); table.ForeignKey( name: "FK_AspNetUserLogins_AspNetUsers_UserId", column: x => x.UserId, principalTable: "AspNetUsers", principalColumn: "Id", onDelete: ReferentialAction.Cascade); }); migrationBuilder.CreateTable( name: "AspNetUserRoles", columns: table => new { UserId = table.Column <string>(type: "text", nullable: false), RoleId = table.Column <string>(type: "text", nullable: false) }, constraints: table => { table.PrimaryKey("PK_AspNetUserRoles", x => new { x.UserId, x.RoleId }); table.ForeignKey( name: "FK_AspNetUserRoles_AspNetRoles_RoleId", column: x => x.RoleId, principalTable: "AspNetRoles", principalColumn: "Id", onDelete: ReferentialAction.Cascade); table.ForeignKey( name: "FK_AspNetUserRoles_AspNetUsers_UserId", column: x => x.UserId, principalTable: "AspNetUsers", principalColumn: "Id", onDelete: ReferentialAction.Cascade); }); migrationBuilder.CreateTable( name: "AspNetUserTokens", columns: table => new { UserId = table.Column <string>(type: "text", nullable: false), LoginProvider = table.Column <string>(type: "character varying(128)", maxLength: 128, nullable: false), Name = table.Column <string>(type: "character varying(128)", maxLength: 128, nullable: false), Value = table.Column <string>(type: "text", nullable: true) }, constraints: table => { table.PrimaryKey("PK_AspNetUserTokens", x => new { x.UserId, x.LoginProvider, x.Name }); table.ForeignKey( name: "FK_AspNetUserTokens_AspNetUsers_UserId", column: x => x.UserId, principalTable: "AspNetUsers", principalColumn: "Id", onDelete: ReferentialAction.Cascade); }); migrationBuilder.CreateTable( name: "Elements_audit", columns: table => new { Elements_audit_id = table.Column <int>(type: "integer", nullable: false) .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), Name = table.Column <string>(type: "character varying(80)", maxLength: 80, nullable: true), Element_id = table.Column <int>(type: "integer", nullable: false), Racks_id = table.Column <short>(type: "smallint", nullable: false), Element_type_id = table.Column <short>(type: "smallint", nullable: false), Audit_id = table.Column <int>(type: "integer", nullable: false) }, constraints: table => { table.PrimaryKey("PK_Elements_audit", x => x.Elements_audit_id); table.ForeignKey( name: "FK_Elements_audit_Audit_Audit_id", column: x => x.Audit_id, principalTable: "Audit", principalColumn: "Audit_id", onDelete: ReferentialAction.Cascade); }); migrationBuilder.CreateTable( name: "Links_audit", columns: table => new { Links_audit_id = table.Column <int>(type: "integer", nullable: false) .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), Link_id = table.Column <int>(type: "integer", nullable: false), Cable_id = table.Column <string>(type: "character varying(40)", maxLength: 40, nullable: true), Port_number = table.Column <string>(type: "character varying(18)", maxLength: 18, nullable: true), Link_type = table.Column <LinkType>(type: "\"LinkType\"", nullable: false), Element_id = table.Column <int>(type: "integer", nullable: false), Audit_id = table.Column <int>(type: "integer", nullable: false) }, constraints: table => { table.PrimaryKey("PK_Links_audit", x => x.Links_audit_id); table.ForeignKey( name: "FK_Links_audit_Audit_Audit_id", column: x => x.Audit_id, principalTable: "Audit", principalColumn: "Audit_id", onDelete: ReferentialAction.Cascade); }); migrationBuilder.CreateTable( name: "Local_audit", columns: table => new { Local_audit_id = table.Column <int>(type: "integer", nullable: false) .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), Local_id = table.Column <short>(type: "smallint", nullable: false), Name = table.Column <string>(type: "character varying(50)", maxLength: 50, nullable: true), Description = table.Column <string>(type: "character varying(300)", maxLength: 300, nullable: true), Location = table.Column <string>(type: "character varying(50)", maxLength: 50, nullable: true), Site_id = table.Column <short>(type: "smallint", nullable: false), Audit_id = table.Column <int>(type: "integer", nullable: false) }, constraints: table => { table.PrimaryKey("PK_Local_audit", x => x.Local_audit_id); table.ForeignKey( name: "FK_Local_audit_Audit_Audit_id", column: x => x.Audit_id, principalTable: "Audit", principalColumn: "Audit_id", onDelete: ReferentialAction.Cascade); }); migrationBuilder.CreateTable( name: "Logs", columns: table => new { Event_id = table.Column <int>(type: "integer", nullable: false) .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), Message = table.Column <string>(type: "character varying(255)", maxLength: 255, nullable: true), Initiator = table.Column <string>(type: "character varying(50)", maxLength: 50, nullable: true), Date = table.Column <DateTime>(type: "timestamp without time zone", nullable: false), Audit_id = table.Column <int>(type: "integer", nullable: false) }, constraints: table => { table.PrimaryKey("PK_Logs", x => x.Event_id); table.ForeignKey( name: "FK_Logs_Audit_Audit_id", column: x => x.Audit_id, principalTable: "Audit", principalColumn: "Audit_id", onDelete: ReferentialAction.Cascade); }); migrationBuilder.CreateTable( name: "Racks_audit", columns: table => new { Racks_audit_id = table.Column <int>(type: "integer", nullable: false) .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), Racks_id = table.Column <short>(type: "smallint", nullable: false), Name = table.Column <string>(type: "character varying(20)", maxLength: 20, nullable: true), Description = table.Column <string>(type: "character varying(300)", maxLength: 300, nullable: true), Local_id = table.Column <short>(type: "smallint", nullable: false), Audit_id = table.Column <int>(type: "integer", nullable: false) }, constraints: table => { table.PrimaryKey("PK_Racks_audit", x => x.Racks_audit_id); table.ForeignKey( name: "FK_Racks_audit_Audit_Audit_id", column: x => x.Audit_id, principalTable: "Audit", principalColumn: "Audit_id", onDelete: ReferentialAction.Cascade); }); migrationBuilder.CreateTable( name: "Sites_audit", columns: table => new { Site_audit_id = table.Column <int>(type: "integer", nullable: false) .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), Name = table.Column <string>(type: "character varying(50)", maxLength: 50, nullable: true), Site_id = table.Column <short>(type: "smallint", nullable: false), Short_name = table.Column <string>(type: "character varying(3)", maxLength: 3, nullable: true), Location = table.Column <string>(type: "character varying(50)", maxLength: 50, nullable: true), Audit_id = table.Column <int>(type: "integer", nullable: false) }, constraints: table => { table.PrimaryKey("PK_Sites_audit", x => x.Site_audit_id); table.ForeignKey( name: "FK_Sites_audit_Audit_Audit_id", column: x => x.Audit_id, principalTable: "Audit", principalColumn: "Audit_id", onDelete: ReferentialAction.Cascade); }); migrationBuilder.CreateTable( name: "Local", columns: table => new { Local_id = table.Column <short>(type: "smallint", nullable: false) .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), Name = table.Column <string>(type: "character varying(50)", maxLength: 50, nullable: true), Description = table.Column <string>(type: "character varying(300)", maxLength: 300, nullable: true), Location = table.Column <string>(type: "character varying(50)", maxLength: 50, nullable: true), Site_id = table.Column <short>(type: "smallint", nullable: false) }, constraints: table => { table.PrimaryKey("PK_Local", x => x.Local_id); table.ForeignKey( name: "FK_Local_Sites_Site_id", column: x => x.Site_id, principalTable: "Sites", principalColumn: "Site_id", onDelete: ReferentialAction.Cascade); }); migrationBuilder.CreateTable( name: "Racks", columns: table => new { Rack_id = table.Column <short>(type: "smallint", nullable: false) .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), Name = table.Column <string>(type: "character varying(20)", maxLength: 20, nullable: true), Description = table.Column <string>(type: "character varying(300)", maxLength: 300, nullable: true), Size = table.Column <int>(type: "integer", nullable: false), Start_size = table.Column <int>(type: "integer", nullable: false), Local_id = table.Column <short>(type: "smallint", nullable: false) }, constraints: table => { table.PrimaryKey("PK_Racks", x => x.Rack_id); table.ForeignKey( name: "FK_Racks_Local_Local_id", column: x => x.Local_id, principalTable: "Local", principalColumn: "Local_id", onDelete: ReferentialAction.Cascade); }); migrationBuilder.CreateTable( name: "Elements", columns: table => new { Element_id = table.Column <int>(type: "integer", nullable: false) .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), Name = table.Column <string>(type: "character varying(80)", maxLength: 80, nullable: true), Position = table.Column <string>(type: "character varying(18)", maxLength: 18, nullable: true), Rack_id = table.Column <short>(type: "smallint", nullable: false), Element_type_id = table.Column <short>(type: "smallint", nullable: false), IsLocked = table.Column <bool>(type: "boolean", nullable: false), LastLock = table.Column <DateTime>(type: "timestamp without time zone", nullable: false, defaultValueSql: "now()") }, constraints: table => { table.PrimaryKey("PK_Elements", x => x.Element_id); table.ForeignKey( name: "FK_Elements_Element_type_Element_type_id", column: x => x.Element_type_id, principalTable: "Element_type", principalColumn: "Element_type_id", onDelete: ReferentialAction.Cascade); table.ForeignKey( name: "FK_Elements_Racks_Rack_id", column: x => x.Rack_id, principalTable: "Racks", principalColumn: "Rack_id", onDelete: ReferentialAction.Cascade); }); migrationBuilder.CreateTable( name: "Links", columns: table => new { Link_id = table.Column <int>(type: "integer", nullable: false) .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), Cable_id = table.Column <string>(type: "character varying(40)", maxLength: 40, nullable: true), Port_number = table.Column <string>(type: "character varying(18)", maxLength: 18, nullable: true), Link_type = table.Column <LinkType>(type: "\"LinkType\"", nullable: false), Element_id = table.Column <int>(type: "integer", nullable: false) }, constraints: table => { table.PrimaryKey("PK_Links", x => x.Link_id); table.ForeignKey( name: "FK_Links_Elements_Element_id", column: x => x.Element_id, principalTable: "Elements", principalColumn: "Element_id", onDelete: ReferentialAction.Cascade); }); migrationBuilder.InsertData( table: "Element_type", columns: new[] { "Element_type_id", "Image", "Label" }, values: new object[, ] { { (short)1, "Switch.png", "Switch" }, { (short)2, "patch panel.png", "Patch panel" }, { (short)3, "Common.png", "Périphérique final" } }); migrationBuilder.InsertData( table: "Sites", columns: new[] { "Site_id", "Location", "Name", "Short_name" }, values: new object[] { (short)1, "Baudour+Epicura", "Baudour", "BR" }); migrationBuilder.InsertData( table: "Local", columns: new[] { "Local_id", "Description", "Location", "Name", "Site_id" }, values: new object[] { (short)1, "Local crée en tant que Seed de la base de données", "Seed Local.png", "Seed Local", (short)1 }); migrationBuilder.InsertData( table: "Racks", columns: new[] { "Rack_id", "Description", "Local_id", "Name", "Size", "Start_size" }, values: new object[, ] { { (short)1, "", (short)1, "7A", 50, 1 }, { (short)21, "", (short)1, "7S", 50, 1 }, { (short)20, "", (short)1, "7R", 50, 1 }, { (short)19, "", (short)1, "7Q", 50, 1 }, { (short)18, "", (short)1, "7P", 50, 1 }, { (short)17, "", (short)1, "7O", 50, 1 }, { (short)16, "", (short)1, "7N", 50, 1 }, { (short)15, "", (short)1, "7M", 50, 1 }, { (short)14, "", (short)1, "7L", 50, 1 }, { (short)13, "", (short)1, "7K", 50, 1 }, { (short)12, "", (short)1, "7J", 50, 1 }, { (short)11, "", (short)1, "7I", 50, 1 }, { (short)10, "", (short)1, "7H", 50, 1 }, { (short)9, "", (short)1, "7G Av", 50, 1 }, { (short)8, "", (short)1, "7G Ar", 50, 1 }, { (short)7, "", (short)1, "7F", 50, 1 }, { (short)6, "", (short)1, "7E", 50, 1 }, { (short)4, "", (short)1, "7D", 50, 1 }, { (short)3, "", (short)1, "7C", 50, 1 }, { (short)2, "", (short)1, "7B", 50, 1 }, { (short)22, "", (short)1, "7T", 50, 1 }, { (short)23, "", (short)1, "7U", 50, 1 } }); //Importannt!!!! Ces lignes contiennent le SQL pour générer les vues migrationBuilder.Sql("create view \"Element_listing\"\r\n (\"Element_id\", \"Name\", \"Rack_id\", \"Rack_name\", \"Position\", \"Element_type_id\", \"Element_type\", \"Site_name\",\r\n \"Site_id\", \"Local_name\", \"Local_id\")\r\nas\r\nSELECT e.\"Element_id\",\r\n e.\"Name\",\r\n e.\"Rack_id\",\r\n r.\"Name\" AS \"Rack_name\",\r\n e.\"Position\",\r\n e.\"Element_type_id\",\r\n et.\"Label\" AS \"Element_type\",\r\n s.\"Name\" AS \"Site_name\",\r\n s.\"Site_id\",\r\n l.\"Name\" AS \"Local_name\",\r\n l.\"Local_id\"\r\nFROM \"Elements\" e\r\n LEFT JOIN \"Element_type\" et ON et.\"Element_type_id\" = e.\"Element_type_id\"\r\n LEFT JOIN \"Racks\" r ON e.\"Rack_id\" = r.\"Rack_id\"\r\n LEFT JOIN \"Local\" l ON r.\"Local_id\" = l.\"Local_id\"\r\n LEFT JOIN \"Sites\" s ON s.\"Site_id\" = l.\"Site_id\"\r\nGROUP BY e.\"Element_id\", e.\"Name\", e.\"Rack_id\", r.\"Name\", e.\"Position\", e.\"Element_type_id\", et.\"Label\", s.\"Name\",\r\n s.\"Site_id\", l.\"Name\", l.\"Local_id\";\r\n\r\n"); migrationBuilder.Sql("create view \"Element_view\" (\"Element_id\", \"Name\", \"Position\", \"Rack_id\", \"Element_type_id\", \"Cables\", \"Element_type\") as\r\nSELECT e.\"Element_id\",\r\n e.\"Name\",\r\n e.\"Position\",\r\n e.\"Rack_id\",\r\n e.\"Element_type_id\",\r\n array_to_string(array_agg(l.\"Cable_id\"), ','::text) AS \"Cables\",\r\n et.\"Label\" AS \"Element_type\"\r\nFROM \"Elements\" e\r\n LEFT JOIN \"Links\" l ON e.\"Element_id\" = l.\"Element_id\"\r\n LEFT JOIN \"Element_type\" et ON et.\"Element_type_id\" = e.\"Element_type_id\"\r\nGROUP BY e.\"Element_id\", et.\"Label\";"); migrationBuilder.Sql("create view \"Elements_Links\"\r\n (\"Cable_id\", \"Ports\", \"Elements_id\", \"Elements_name\", \"Elements_position\", \"Elements_rack\",\r\n \"Elements_local\", \"Elements_site\")\r\nas\r\nSELECT l.\"Cable_id\",\r\n array_agg(l.\"Port_number\") AS \"Ports\",\r\n array_agg(l.\"Element_id\") AS \"Elements_id\",\r\n array_agg(e.\"Name\") AS \"Elements_name\",\r\n array_agg(e.\"Position\") AS \"Elements_position\",\r\n array_agg(r.\"Name\") AS \"Elements_rack\",\r\n array_agg(l2.\"Name\") AS \"Elements_local\",\r\n array_agg(s.\"Name\") AS \"Elements_site\"\r\nFROM \"Links\" l\r\n LEFT JOIN \"Elements\" e ON e.\"Element_id\" = l.\"Element_id\"\r\n LEFT JOIN \"Racks\" r ON e.\"Rack_id\" = r.\"Rack_id\"\r\n LEFT JOIN \"Local\" l2 ON l2.\"Local_id\" = r.\"Local_id\"\r\n LEFT JOIN \"Sites\" s ON l2.\"Site_id\" = s.\"Site_id\"\r\nGROUP BY l.\"Cable_id\";"); migrationBuilder.Sql("create view \"Local_on_site\" (\"Local_id\", \"Name\", \"Description\", \"Location\", \"Site_id\", \"Rack_count\") as\r\nSELECT l.\"Local_id\",\r\n l.\"Name\",\r\n l.\"Description\",\r\n l.\"Location\",\r\n l.\"Site_id\",\r\n count(r.\"Rack_id\") AS \"Rack_count\"\r\nFROM \"Local\" l\r\n LEFT JOIN \"Sites\" s ON s.\"Site_id\" = l.\"Site_id\"\r\n LEFT JOIN \"Racks\" r ON l.\"Local_id\" = r.\"Local_id\"\r\n LEFT JOIN \"Local\" l2 ON l2.\"Local_id\" = r.\"Local_id\"\r\nGROUP BY l.\"Local_id\";"); migrationBuilder.Sql("create view \"Rack_in_local\"(\"Rack_id\", \"Name\", \"Description\", \"Local_id\", \"Element_count\") as\r\nSELECT r.\"Rack_id\",\r\n r.\"Name\",\r\n r.\"Description\",\r\n r.\"Local_id\",\r\n count(e.\"Element_id\") AS \"Element_count\"\r\nFROM \"Racks\" r\r\n LEFT JOIN \"Local\" l ON l.\"Local_id\" = r.\"Local_id\"\r\n LEFT JOIN \"Elements\" e ON e.\"Rack_id\" = r.\"Rack_id\"\r\nGROUP BY r.\"Rack_id\";"); migrationBuilder.Sql("create view \"Site_listing\"(\"Name\", \"Location\", \"Id\", \"Short_name\", \"Device_count\") as\r\nSELECT s.\"Name\",\r\n s.\"Location\",\r\n s.\"Site_id\" AS \"Id\",\r\n s.\"Short_name\",\r\n count(e.*) AS \"Device_count\"\r\nFROM \"Sites\" s\r\n LEFT JOIN \"Local\" l ON s.\"Site_id\" = l.\"Site_id\"\r\n LEFT JOIN \"Racks\" r ON l.\"Local_id\" = r.\"Local_id\"\r\n LEFT JOIN \"Elements\" e ON e.\"Rack_id\" = r.\"Rack_id\"\r\nGROUP BY s.\"Name\", s.\"Site_id\";" + "" + ""); migrationBuilder.CreateIndex( name: "IX_AspNetRoleClaims_RoleId", table: "AspNetRoleClaims", column: "RoleId"); migrationBuilder.CreateIndex( name: "RoleNameIndex", table: "AspNetRoles", column: "NormalizedName", unique: true); migrationBuilder.CreateIndex( name: "IX_AspNetUserClaims_UserId", table: "AspNetUserClaims", column: "UserId"); migrationBuilder.CreateIndex( name: "IX_AspNetUserLogins_UserId", table: "AspNetUserLogins", column: "UserId"); migrationBuilder.CreateIndex( name: "IX_AspNetUserRoles_RoleId", table: "AspNetUserRoles", column: "RoleId"); migrationBuilder.CreateIndex( name: "EmailIndex", table: "AspNetUsers", column: "NormalizedEmail"); migrationBuilder.CreateIndex( name: "UserNameIndex", table: "AspNetUsers", column: "NormalizedUserName", unique: true); migrationBuilder.CreateIndex( name: "IX_DeviceCodes_DeviceCode", table: "DeviceCodes", column: "DeviceCode", unique: true); migrationBuilder.CreateIndex( name: "IX_DeviceCodes_Expiration", table: "DeviceCodes", column: "Expiration"); migrationBuilder.CreateIndex( name: "IX_Elements_Element_type_id", table: "Elements", column: "Element_type_id"); migrationBuilder.CreateIndex( name: "IX_Elements_Name", table: "Elements", column: "Name"); migrationBuilder.CreateIndex( name: "IX_Elements_Name_Rack_id", table: "Elements", columns: new[] { "Name", "Rack_id" }, unique: true); migrationBuilder.CreateIndex( name: "IX_Elements_Rack_id", table: "Elements", column: "Rack_id"); migrationBuilder.CreateIndex( name: "IX_Elements_audit_Audit_id", table: "Elements_audit", column: "Audit_id"); migrationBuilder.CreateIndex( name: "IX_Elements_audit_Element_id", table: "Elements_audit", column: "Element_id"); migrationBuilder.CreateIndex( name: "IX_Links_Cable_id_Port_number_Element_id", table: "Links", columns: new[] { "Cable_id", "Port_number", "Element_id" }, unique: true); migrationBuilder.CreateIndex( name: "IX_Links_Element_id", table: "Links", column: "Element_id"); migrationBuilder.CreateIndex( name: "IX_Links_Link_type", table: "Links", column: "Link_type"); migrationBuilder.CreateIndex( name: "IX_Links_audit_Audit_id", table: "Links_audit", column: "Audit_id"); migrationBuilder.CreateIndex( name: "IX_Links_audit_Link_id", table: "Links_audit", column: "Link_id"); migrationBuilder.CreateIndex( name: "IX_Local_Site_id", table: "Local", column: "Site_id"); migrationBuilder.CreateIndex( name: "IX_Local_audit_Audit_id", table: "Local_audit", column: "Audit_id"); migrationBuilder.CreateIndex( name: "IX_Local_audit_Local_id", table: "Local_audit", column: "Local_id"); migrationBuilder.CreateIndex( name: "IX_Logs_Audit_id", table: "Logs", column: "Audit_id", unique: true); migrationBuilder.CreateIndex( name: "IX_PersistedGrants_Expiration", table: "PersistedGrants", column: "Expiration"); migrationBuilder.CreateIndex( name: "IX_PersistedGrants_SubjectId_ClientId_Type", table: "PersistedGrants", columns: new[] { "SubjectId", "ClientId", "Type" }); migrationBuilder.CreateIndex( name: "IX_PersistedGrants_SubjectId_SessionId_Type", table: "PersistedGrants", columns: new[] { "SubjectId", "SessionId", "Type" }); migrationBuilder.CreateIndex( name: "IX_Racks_Local_id", table: "Racks", column: "Local_id"); migrationBuilder.CreateIndex( name: "IX_Racks_audit_Audit_id", table: "Racks_audit", column: "Audit_id"); migrationBuilder.CreateIndex( name: "IX_Racks_audit_Racks_id", table: "Racks_audit", column: "Racks_id"); migrationBuilder.CreateIndex( name: "IX_Sites_audit_Audit_id", table: "Sites_audit", column: "Audit_id"); migrationBuilder.CreateIndex( name: "IX_Sites_audit_Site_id", table: "Sites_audit", column: "Site_id"); }
protected override void Up(MigrationBuilder migrationBuilder) { migrationBuilder.AlterDatabase() .Annotation("MySql:CharSet", "utf8mb4"); migrationBuilder.CreateTable( name: "AspNetRoles", columns: table => new { Id = table.Column <Guid>(type: "char(36)", nullable: false, collation: "ascii_general_ci"), Name = table.Column <string>(type: "varchar(256)", maxLength: 256, nullable: true) .Annotation("MySql:CharSet", "utf8mb4"), NormalizedName = table.Column <string>(type: "varchar(256)", maxLength: 256, nullable: true) .Annotation("MySql:CharSet", "utf8mb4"), ConcurrencyStamp = table.Column <string>(type: "longtext", nullable: true) .Annotation("MySql:CharSet", "utf8mb4") }, constraints: table => { table.PrimaryKey("PK_AspNetRoles", x => x.Id); }) .Annotation("MySql:CharSet", "utf8mb4"); migrationBuilder.CreateTable( name: "AspNetUsers", columns: table => new { Id = table.Column <Guid>(type: "char(36)", nullable: false, collation: "ascii_general_ci"), UserName = table.Column <string>(type: "varchar(256)", maxLength: 256, nullable: true) .Annotation("MySql:CharSet", "utf8mb4"), NormalizedUserName = table.Column <string>(type: "varchar(256)", maxLength: 256, nullable: true) .Annotation("MySql:CharSet", "utf8mb4"), Email = table.Column <string>(type: "varchar(256)", maxLength: 256, nullable: true) .Annotation("MySql:CharSet", "utf8mb4"), NormalizedEmail = table.Column <string>(type: "varchar(256)", maxLength: 256, nullable: true) .Annotation("MySql:CharSet", "utf8mb4"), EmailConfirmed = table.Column <bool>(type: "tinyint(1)", nullable: false), PasswordHash = table.Column <string>(type: "longtext", nullable: true) .Annotation("MySql:CharSet", "utf8mb4"), SecurityStamp = table.Column <string>(type: "longtext", nullable: true) .Annotation("MySql:CharSet", "utf8mb4"), ConcurrencyStamp = table.Column <string>(type: "longtext", nullable: true) .Annotation("MySql:CharSet", "utf8mb4"), PhoneNumber = table.Column <string>(type: "longtext", nullable: true) .Annotation("MySql:CharSet", "utf8mb4"), PhoneNumberConfirmed = table.Column <bool>(type: "tinyint(1)", nullable: false), TwoFactorEnabled = table.Column <bool>(type: "tinyint(1)", nullable: false), LockoutEnd = table.Column <DateTimeOffset>(type: "datetime(6)", nullable: true), LockoutEnabled = table.Column <bool>(type: "tinyint(1)", nullable: false), AccessFailedCount = table.Column <int>(type: "int", nullable: false) }, constraints: table => { table.PrimaryKey("PK_AspNetUsers", x => x.Id); }) .Annotation("MySql:CharSet", "utf8mb4"); migrationBuilder.CreateTable( name: "OpenIddictApplications", columns: table => new { Id = table.Column <Guid>(type: "char(36)", nullable: false, collation: "ascii_general_ci"), ClientId = table.Column <string>(type: "varchar(100)", maxLength: 100, nullable: true) .Annotation("MySql:CharSet", "utf8mb4"), ClientSecret = table.Column <string>(type: "longtext", nullable: true) .Annotation("MySql:CharSet", "utf8mb4"), ConcurrencyToken = table.Column <string>(type: "varchar(50)", maxLength: 50, nullable: true) .Annotation("MySql:CharSet", "utf8mb4"), ConsentType = table.Column <string>(type: "varchar(50)", maxLength: 50, nullable: true) .Annotation("MySql:CharSet", "utf8mb4"), DisplayName = table.Column <string>(type: "longtext", nullable: true) .Annotation("MySql:CharSet", "utf8mb4"), DisplayNames = table.Column <string>(type: "longtext", nullable: true) .Annotation("MySql:CharSet", "utf8mb4"), Permissions = table.Column <string>(type: "longtext", nullable: true) .Annotation("MySql:CharSet", "utf8mb4"), PostLogoutRedirectUris = table.Column <string>(type: "longtext", nullable: true) .Annotation("MySql:CharSet", "utf8mb4"), Properties = table.Column <string>(type: "longtext", nullable: true) .Annotation("MySql:CharSet", "utf8mb4"), RedirectUris = table.Column <string>(type: "longtext", nullable: true) .Annotation("MySql:CharSet", "utf8mb4"), Requirements = table.Column <string>(type: "longtext", nullable: true) .Annotation("MySql:CharSet", "utf8mb4"), Type = table.Column <string>(type: "varchar(50)", maxLength: 50, nullable: true) .Annotation("MySql:CharSet", "utf8mb4") }, constraints: table => { table.PrimaryKey("PK_OpenIddictApplications", x => x.Id); }) .Annotation("MySql:CharSet", "utf8mb4"); migrationBuilder.CreateTable( name: "OpenIddictScopes", columns: table => new { Id = table.Column <Guid>(type: "char(36)", nullable: false, collation: "ascii_general_ci"), ConcurrencyToken = table.Column <string>(type: "varchar(50)", maxLength: 50, nullable: true) .Annotation("MySql:CharSet", "utf8mb4"), Description = table.Column <string>(type: "longtext", nullable: true) .Annotation("MySql:CharSet", "utf8mb4"), Descriptions = table.Column <string>(type: "longtext", nullable: true) .Annotation("MySql:CharSet", "utf8mb4"), DisplayName = table.Column <string>(type: "longtext", nullable: true) .Annotation("MySql:CharSet", "utf8mb4"), DisplayNames = table.Column <string>(type: "longtext", nullable: true) .Annotation("MySql:CharSet", "utf8mb4"), Name = table.Column <string>(type: "varchar(200)", maxLength: 200, nullable: true) .Annotation("MySql:CharSet", "utf8mb4"), Properties = table.Column <string>(type: "longtext", nullable: true) .Annotation("MySql:CharSet", "utf8mb4"), Resources = table.Column <string>(type: "longtext", nullable: true) .Annotation("MySql:CharSet", "utf8mb4") }, constraints: table => { table.PrimaryKey("PK_OpenIddictScopes", x => x.Id); }) .Annotation("MySql:CharSet", "utf8mb4"); migrationBuilder.CreateTable( name: "AspNetRoleClaims", columns: table => new { Id = table.Column <int>(type: "int", nullable: false) .Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn), RoleId = table.Column <Guid>(type: "char(36)", nullable: false, collation: "ascii_general_ci"), ClaimType = table.Column <string>(type: "longtext", nullable: true) .Annotation("MySql:CharSet", "utf8mb4"), ClaimValue = table.Column <string>(type: "longtext", nullable: true) .Annotation("MySql:CharSet", "utf8mb4") }, constraints: table => { table.PrimaryKey("PK_AspNetRoleClaims", x => x.Id); table.ForeignKey( name: "FK_AspNetRoleClaims_AspNetRoles_RoleId", column: x => x.RoleId, principalTable: "AspNetRoles", principalColumn: "Id", onDelete: ReferentialAction.Cascade); }) .Annotation("MySql:CharSet", "utf8mb4"); migrationBuilder.CreateTable( name: "AspNetUserClaims", columns: table => new { Id = table.Column <int>(type: "int", nullable: false) .Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn), UserId = table.Column <Guid>(type: "char(36)", nullable: false, collation: "ascii_general_ci"), ClaimType = table.Column <string>(type: "longtext", nullable: true) .Annotation("MySql:CharSet", "utf8mb4"), ClaimValue = table.Column <string>(type: "longtext", nullable: true) .Annotation("MySql:CharSet", "utf8mb4") }, constraints: table => { table.PrimaryKey("PK_AspNetUserClaims", x => x.Id); table.ForeignKey( name: "FK_AspNetUserClaims_AspNetUsers_UserId", column: x => x.UserId, principalTable: "AspNetUsers", principalColumn: "Id", onDelete: ReferentialAction.Cascade); }) .Annotation("MySql:CharSet", "utf8mb4"); migrationBuilder.CreateTable( name: "AspNetUserLogins", columns: table => new { LoginProvider = table.Column <string>(type: "varchar(255)", nullable: false) .Annotation("MySql:CharSet", "utf8mb4"), ProviderKey = table.Column <string>(type: "varchar(255)", nullable: false) .Annotation("MySql:CharSet", "utf8mb4"), ProviderDisplayName = table.Column <string>(type: "longtext", nullable: true) .Annotation("MySql:CharSet", "utf8mb4"), UserId = table.Column <Guid>(type: "char(36)", nullable: false, collation: "ascii_general_ci") }, constraints: table => { table.PrimaryKey("PK_AspNetUserLogins", x => new { x.LoginProvider, x.ProviderKey }); table.ForeignKey( name: "FK_AspNetUserLogins_AspNetUsers_UserId", column: x => x.UserId, principalTable: "AspNetUsers", principalColumn: "Id", onDelete: ReferentialAction.Cascade); }) .Annotation("MySql:CharSet", "utf8mb4"); migrationBuilder.CreateTable( name: "AspNetUserRoles", columns: table => new { UserId = table.Column <Guid>(type: "char(36)", nullable: false, collation: "ascii_general_ci"), RoleId = table.Column <Guid>(type: "char(36)", nullable: false, collation: "ascii_general_ci") }, constraints: table => { table.PrimaryKey("PK_AspNetUserRoles", x => new { x.UserId, x.RoleId }); table.ForeignKey( name: "FK_AspNetUserRoles_AspNetRoles_RoleId", column: x => x.RoleId, principalTable: "AspNetRoles", principalColumn: "Id", onDelete: ReferentialAction.Cascade); table.ForeignKey( name: "FK_AspNetUserRoles_AspNetUsers_UserId", column: x => x.UserId, principalTable: "AspNetUsers", principalColumn: "Id", onDelete: ReferentialAction.Cascade); }) .Annotation("MySql:CharSet", "utf8mb4"); migrationBuilder.CreateTable( name: "AspNetUserTokens", columns: table => new { UserId = table.Column <Guid>(type: "char(36)", nullable: false, collation: "ascii_general_ci"), LoginProvider = table.Column <string>(type: "varchar(255)", nullable: false) .Annotation("MySql:CharSet", "utf8mb4"), Name = table.Column <string>(type: "varchar(255)", nullable: false) .Annotation("MySql:CharSet", "utf8mb4"), Value = table.Column <string>(type: "longtext", nullable: true) .Annotation("MySql:CharSet", "utf8mb4") }, constraints: table => { table.PrimaryKey("PK_AspNetUserTokens", x => new { x.UserId, x.LoginProvider, x.Name }); table.ForeignKey( name: "FK_AspNetUserTokens_AspNetUsers_UserId", column: x => x.UserId, principalTable: "AspNetUsers", principalColumn: "Id", onDelete: ReferentialAction.Cascade); }) .Annotation("MySql:CharSet", "utf8mb4"); migrationBuilder.CreateTable( name: "OpenIddictAuthorizations", columns: table => new { Id = table.Column <Guid>(type: "char(36)", nullable: false, collation: "ascii_general_ci"), ApplicationId = table.Column <Guid>(type: "char(36)", nullable: true, collation: "ascii_general_ci"), ConcurrencyToken = table.Column <string>(type: "varchar(50)", maxLength: 50, nullable: true) .Annotation("MySql:CharSet", "utf8mb4"), CreationDate = table.Column <DateTime>(type: "datetime(6)", nullable: true), Properties = table.Column <string>(type: "longtext", nullable: true) .Annotation("MySql:CharSet", "utf8mb4"), Scopes = table.Column <string>(type: "longtext", nullable: true) .Annotation("MySql:CharSet", "utf8mb4"), Status = table.Column <string>(type: "varchar(50)", maxLength: 50, nullable: true) .Annotation("MySql:CharSet", "utf8mb4"), Subject = table.Column <string>(type: "varchar(400)", maxLength: 400, nullable: true) .Annotation("MySql:CharSet", "utf8mb4"), Type = table.Column <string>(type: "varchar(50)", maxLength: 50, nullable: true) .Annotation("MySql:CharSet", "utf8mb4") }, constraints: table => { table.PrimaryKey("PK_OpenIddictAuthorizations", x => x.Id); table.ForeignKey( name: "FK_OpenIddictAuthorizations_OpenIddictApplications_ApplicationId", column: x => x.ApplicationId, principalTable: "OpenIddictApplications", principalColumn: "Id"); }) .Annotation("MySql:CharSet", "utf8mb4"); migrationBuilder.CreateTable( name: "OpenIddictTokens", columns: table => new { Id = table.Column <Guid>(type: "char(36)", nullable: false, collation: "ascii_general_ci"), ApplicationId = table.Column <Guid>(type: "char(36)", nullable: true, collation: "ascii_general_ci"), AuthorizationId = table.Column <Guid>(type: "char(36)", nullable: true, collation: "ascii_general_ci"), ConcurrencyToken = table.Column <string>(type: "varchar(50)", maxLength: 50, nullable: true) .Annotation("MySql:CharSet", "utf8mb4"), CreationDate = table.Column <DateTime>(type: "datetime(6)", nullable: true), ExpirationDate = table.Column <DateTime>(type: "datetime(6)", nullable: true), Payload = table.Column <string>(type: "longtext", nullable: true) .Annotation("MySql:CharSet", "utf8mb4"), Properties = table.Column <string>(type: "longtext", nullable: true) .Annotation("MySql:CharSet", "utf8mb4"), RedemptionDate = table.Column <DateTime>(type: "datetime(6)", nullable: true), ReferenceId = table.Column <string>(type: "varchar(100)", maxLength: 100, nullable: true) .Annotation("MySql:CharSet", "utf8mb4"), Status = table.Column <string>(type: "varchar(50)", maxLength: 50, nullable: true) .Annotation("MySql:CharSet", "utf8mb4"), Subject = table.Column <string>(type: "varchar(400)", maxLength: 400, nullable: true) .Annotation("MySql:CharSet", "utf8mb4"), Type = table.Column <string>(type: "varchar(50)", maxLength: 50, nullable: true) .Annotation("MySql:CharSet", "utf8mb4") }, constraints: table => { table.PrimaryKey("PK_OpenIddictTokens", x => x.Id); table.ForeignKey( name: "FK_OpenIddictTokens_OpenIddictApplications_ApplicationId", column: x => x.ApplicationId, principalTable: "OpenIddictApplications", principalColumn: "Id"); table.ForeignKey( name: "FK_OpenIddictTokens_OpenIddictAuthorizations_AuthorizationId", column: x => x.AuthorizationId, principalTable: "OpenIddictAuthorizations", principalColumn: "Id"); }) .Annotation("MySql:CharSet", "utf8mb4"); migrationBuilder.CreateIndex( name: "IX_AspNetRoleClaims_RoleId", table: "AspNetRoleClaims", column: "RoleId"); migrationBuilder.CreateIndex( name: "RoleNameIndex", table: "AspNetRoles", column: "NormalizedName", unique: true); migrationBuilder.CreateIndex( name: "IX_AspNetUserClaims_UserId", table: "AspNetUserClaims", column: "UserId"); migrationBuilder.CreateIndex( name: "IX_AspNetUserLogins_UserId", table: "AspNetUserLogins", column: "UserId"); migrationBuilder.CreateIndex( name: "IX_AspNetUserRoles_RoleId", table: "AspNetUserRoles", column: "RoleId"); migrationBuilder.CreateIndex( name: "EmailIndex", table: "AspNetUsers", column: "NormalizedEmail"); migrationBuilder.CreateIndex( name: "UserNameIndex", table: "AspNetUsers", column: "NormalizedUserName", unique: true); migrationBuilder.CreateIndex( name: "IX_OpenIddictApplications_ClientId", table: "OpenIddictApplications", column: "ClientId", unique: true); migrationBuilder.CreateIndex( name: "IX_OpenIddictAuthorizations_ApplicationId_Status_Subject_Type", table: "OpenIddictAuthorizations", columns: new[] { "ApplicationId", "Status", "Subject", "Type" }); migrationBuilder.CreateIndex( name: "IX_OpenIddictScopes_Name", table: "OpenIddictScopes", column: "Name", unique: true); migrationBuilder.CreateIndex( name: "IX_OpenIddictTokens_ApplicationId_Status_Subject_Type", table: "OpenIddictTokens", columns: new[] { "ApplicationId", "Status", "Subject", "Type" }); migrationBuilder.CreateIndex( name: "IX_OpenIddictTokens_AuthorizationId", table: "OpenIddictTokens", column: "AuthorizationId"); migrationBuilder.CreateIndex( name: "IX_OpenIddictTokens_ReferenceId", table: "OpenIddictTokens", column: "ReferenceId", unique: true); }
protected override void Up(MigrationBuilder migrationBuilder) { migrationBuilder.AlterDatabase() .Annotation("SqlServer:MemoryOptimized", true); migrationBuilder.CreateTable( name: "Courses", columns: table => new { Id = table.Column <int>(type: "int", nullable: false) .Annotation("SqlServer:Identity", "1, 1"), Title = table.Column <string>(type: "nvarchar(50)", maxLength: 50, nullable: false), Level = table.Column <string>(type: "nvarchar(15)", maxLength: 15, nullable: false) }, constraints: table => { table.PrimaryKey("PK_Courses", x => x.Id) .Annotation("SqlServer:Clustered", false); }) .Annotation("SqlServer:MemoryOptimized", true); migrationBuilder.CreateTable( name: "Persons", columns: table => new { Id = table.Column <int>(type: "int", nullable: false) .Annotation("SqlServer:Identity", "1, 1"), FirstName = table.Column <string>(type: "nvarchar(50)", maxLength: 50, nullable: false), LastName = table.Column <string>(type: "nvarchar(50)", maxLength: 50, nullable: false), Role = table.Column <int>(type: "int", nullable: false), SubscriptionLevel = table.Column <int>(type: "int", nullable: true) }, constraints: table => { table.PrimaryKey("PK_Persons", x => x.Id) .Annotation("SqlServer:Clustered", false); }) .Annotation("SqlServer:MemoryOptimized", true); migrationBuilder.CreateTable( name: "CourseEnrollments", columns: table => new { CourseId = table.Column <int>(type: "int", nullable: false), StudentId = table.Column <int>(type: "int", nullable: false), DateEnrolled = table.Column <DateTime>(type: "datetime2", nullable: false) }, constraints: table => { table.PrimaryKey("PK_CourseEnrollments", x => new { x.CourseId, x.StudentId }) .Annotation("SqlServer:Clustered", false); table.ForeignKey( name: "FK_CourseEnrollments_Courses_CourseId", column: x => x.CourseId, principalTable: "Courses", principalColumn: "Id", onDelete: ReferentialAction.NoAction); table.ForeignKey( name: "FK_CourseEnrollments_Persons_StudentId", column: x => x.StudentId, principalTable: "Persons", principalColumn: "Id", onDelete: ReferentialAction.NoAction); }) .Annotation("SqlServer:MemoryOptimized", true); migrationBuilder.CreateIndex( name: "IX_CourseEnrollments_StudentId", table: "CourseEnrollments", column: "StudentId") .Annotation("SqlServer:Clustered", false); }
protected override void Up(MigrationBuilder migrationBuilder) { migrationBuilder.AlterDatabase() .Annotation("MySql:CharSet", "utf8mb4"); migrationBuilder.CreateTable( name: "Activation", columns: table => new { Uuid = table.Column <Guid>(type: "char(36)", nullable: false, collation: "ascii_general_ci"), UserUuid = table.Column <Guid>(type: "char(36)", nullable: false, collation: "ascii_general_ci"), Code = table.Column <string>(type: "longtext", nullable: true) .Annotation("MySql:CharSet", "utf8mb4") }, constraints: table => { table.PrimaryKey("PK_Activation", x => x.Uuid); }) .Annotation("MySql:CharSet", "utf8mb4"); migrationBuilder.CreateTable( name: "DisabledUser", columns: table => new { Uuid = table.Column <Guid>(type: "char(36)", nullable: false, collation: "ascii_general_ci"), UserUuid = table.Column <Guid>(type: "char(36)", nullable: false, collation: "ascii_general_ci"), Reason = table.Column <int>(type: "int", nullable: false) }, constraints: table => { table.PrimaryKey("PK_DisabledUser", x => x.Uuid); }) .Annotation("MySql:CharSet", "utf8mb4"); migrationBuilder.CreateTable( name: "PasswordReset", columns: table => new { Uuid = table.Column <Guid>(type: "char(36)", nullable: false, collation: "ascii_general_ci"), UserUuid = table.Column <Guid>(type: "char(36)", nullable: false, collation: "ascii_general_ci"), Code = table.Column <string>(type: "longtext", nullable: true) .Annotation("MySql:CharSet", "utf8mb4") }, constraints: table => { table.PrimaryKey("PK_PasswordReset", x => x.Uuid); }) .Annotation("MySql:CharSet", "utf8mb4"); migrationBuilder.CreateTable( name: "User", columns: table => new { Uuid = table.Column <Guid>(type: "char(36)", nullable: false, collation: "ascii_general_ci"), Username = table.Column <string>(type: "longtext", nullable: true) .Annotation("MySql:CharSet", "utf8mb4"), About = table.Column <string>(type: "longtext", nullable: true) .Annotation("MySql:CharSet", "utf8mb4"), Email = table.Column <string>(type: "longtext", nullable: true) .Annotation("MySql:CharSet", "utf8mb4"), Gender = table.Column <int>(type: "int", nullable: false), AccountRole = table.Column <int>(type: "int", nullable: false), BirthDate = table.Column <DateTime>(type: "datetime(6)", nullable: false), ReceiveEmail = table.Column <bool>(type: "tinyint(1)", nullable: false) }, constraints: table => { table.PrimaryKey("PK_User", x => x.Uuid); }) .Annotation("MySql:CharSet", "utf8mb4"); migrationBuilder.CreateTable( name: "Artist", columns: table => new { Uuid = table.Column <Guid>(type: "char(36)", nullable: false, collation: "ascii_general_ci"), UserUuid = table.Column <Guid>(type: "char(36)", nullable: false, collation: "ascii_general_ci"), Artist = table.Column <string>(type: "longtext", nullable: true) .Annotation("MySql:CharSet", "utf8mb4") }, constraints: table => { table.PrimaryKey("PK_Artist", x => x.Uuid); table.ForeignKey( name: "FK_Artist_User_UserUuid", column: x => x.UserUuid, principalTable: "User", principalColumn: "Uuid", onDelete: ReferentialAction.Cascade); }) .Annotation("MySql:CharSet", "utf8mb4"); migrationBuilder.CreateTable( name: "Hobby", columns: table => new { Uuid = table.Column <Guid>(type: "char(36)", nullable: false, collation: "ascii_general_ci"), UserUuid = table.Column <Guid>(type: "char(36)", nullable: false, collation: "ascii_general_ci"), Hobby = table.Column <string>(type: "longtext", nullable: true) .Annotation("MySql:CharSet", "utf8mb4") }, constraints: table => { table.PrimaryKey("PK_Hobby", x => x.Uuid); table.ForeignKey( name: "FK_Hobby_User_UserUuid", column: x => x.UserUuid, principalTable: "User", principalColumn: "Uuid", onDelete: ReferentialAction.Cascade); }) .Annotation("MySql:CharSet", "utf8mb4"); migrationBuilder.CreateIndex( name: "IX_Artist_UserUuid", table: "Artist", column: "UserUuid"); migrationBuilder.CreateIndex( name: "IX_Hobby_UserUuid", table: "Hobby", column: "UserUuid"); }
protected override void Up(MigrationBuilder migrationBuilder) { migrationBuilder.AlterDatabase() .Annotation("Npgsql:Enum:activity_level", "sedentary,lightly_active,moderately_active,very_active") .Annotation("Npgsql:Enum:deficit_goal", "lose_weight,maintain,gain_muscle") .Annotation("Npgsql:Enum:gender", "male,female") .Annotation("Npgsql:Enum:measurement_unit", "g,tbsp,tsp,cup,ml") .Annotation("Npgsql:PostgresExtension:citext", ",,"); migrationBuilder.CreateSequence( name: "EntityFrameworkHiLoSequence", incrementBy: 10); migrationBuilder.CreateTable( name: "ingredient", columns: table => new { id = table.Column <long>(nullable: false) .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.SequenceHiLo), name = table.Column <string>(type: "citext", maxLength: 256, nullable: false), measurement_unit = table.Column <MeasurementUnit>(nullable: false), serving_value = table.Column <float>(nullable: false), calories_per_serving = table.Column <float>(nullable: false), carbs_per_serving = table.Column <float>(nullable: false), fat_per_serving = table.Column <float>(nullable: false), protein_per_serving = table.Column <float>(nullable: false), created_on = table.Column <Instant>(nullable: false), updated_on = table.Column <Instant>(nullable: true) }, constraints: table => { table.PrimaryKey("pk_ingredient", x => x.id); }); migrationBuilder.CreateTable( name: "roles", columns: table => new { id = table.Column <string>(nullable: false), name = table.Column <string>(maxLength: 256, nullable: true), normalized_name = table.Column <string>(maxLength: 256, nullable: true), concurrency_stamp = table.Column <string>(nullable: true) }, constraints: table => { table.PrimaryKey("pk_roles", x => x.id); }); migrationBuilder.CreateTable( name: "user_tokens", columns: table => new { user_id = table.Column <string>(nullable: false), login_provider = table.Column <string>(nullable: false), name = table.Column <string>(nullable: false), value = table.Column <string>(nullable: true) }, constraints: table => { table.PrimaryKey("pk_user_tokens", x => new { x.user_id, x.login_provider, x.name }); }); migrationBuilder.CreateTable( name: "users", columns: table => new { id = table.Column <string>(nullable: false), user_name = table.Column <string>(maxLength: 256, nullable: false), normalized_user_name = table.Column <string>(maxLength: 256, nullable: false), email = table.Column <string>(maxLength: 256, nullable: false), normalized_email = table.Column <string>(maxLength: 256, nullable: false), email_confirmed = table.Column <bool>(nullable: false), password_hash = table.Column <string>(nullable: false), security_stamp = table.Column <string>(nullable: false), concurrency_stamp = table.Column <string>(nullable: true), phone_number = table.Column <string>(maxLength: 15, nullable: false), phone_number_confirmed = table.Column <bool>(nullable: false), two_factor_enabled = table.Column <bool>(nullable: false), lockout_end = table.Column <DateTimeOffset>(nullable: true), lockout_enabled = table.Column <bool>(nullable: false), access_failed_count = table.Column <int>(nullable: false), first_name = table.Column <string>(maxLength: 256, nullable: false), last_name = table.Column <string>(maxLength: 256, nullable: false), birth_date = table.Column <LocalDate>(nullable: false), gender = table.Column <Gender>(nullable: false), created_on = table.Column <Instant>(nullable: false), updated_on = table.Column <Instant>(nullable: true) }, constraints: table => { table.PrimaryKey("pk_users", x => x.id); }); migrationBuilder.CreateTable( name: "role_claims", columns: table => new { id = table.Column <int>(nullable: false) .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), role_id = table.Column <string>(nullable: false), claim_type = table.Column <string>(nullable: false), claim_value = table.Column <string>(nullable: true) }, constraints: table => { table.PrimaryKey("pk_role_claims", x => x.id); table.ForeignKey( name: "fk_role_claims_roles_identity_role_id", column: x => x.role_id, principalTable: "roles", principalColumn: "id", onDelete: ReferentialAction.Cascade); }); migrationBuilder.CreateTable( name: "notification", columns: table => new { id = table.Column <long>(nullable: false) .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.SequenceHiLo), user_id = table.Column <string>(nullable: false), message = table.Column <string>(nullable: false), created_on = table.Column <Instant>(nullable: false), read_on = table.Column <Instant>(nullable: true) }, constraints: table => { table.PrimaryKey("pk_notification", x => x.id); table.ForeignKey( name: "fk_notification_users_user_id", column: x => x.user_id, principalTable: "users", principalColumn: "id", onDelete: ReferentialAction.Cascade); }); migrationBuilder.CreateTable( name: "user_claims", columns: table => new { id = table.Column <int>(nullable: false) .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.SequenceHiLo), user_id = table.Column <string>(nullable: false), claim_type = table.Column <string>(nullable: false), claim_value = table.Column <string>(nullable: true) }, constraints: table => { table.PrimaryKey("pk_user_claims", x => x.id); table.ForeignKey( name: "fk_user_claims_users_user_id", column: x => x.user_id, principalTable: "users", principalColumn: "id", onDelete: ReferentialAction.Cascade); }); migrationBuilder.CreateTable( name: "user_intake_target", columns: table => new { id = table.Column <long>(nullable: false) .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.SequenceHiLo), user_id = table.Column <string>(nullable: false), height = table.Column <float>(nullable: false), fat_percentage = table.Column <float>(nullable: false), activity_level = table.Column <ActivityLevel>(nullable: false), goal = table.Column <DeficitGoal>(nullable: false), deficit_percentage = table.Column <float>(nullable: false), net_carbs_percentage = table.Column <float>(nullable: false), protein_taken = table.Column <float>(nullable: false), total_calories_intake = table.Column <float>(nullable: true), total_fat_intake = table.Column <float>(nullable: true), total_carbs_intake = table.Column <float>(nullable: true), total_protein_intake = table.Column <float>(nullable: true), created_on = table.Column <Instant>(nullable: false), updated_on = table.Column <Instant>(nullable: true) }, constraints: table => { table.PrimaryKey("pk_user_intake_target", x => x.id); table.ForeignKey( name: "fk_user_intake_target_users_user_id", column: x => x.user_id, principalTable: "users", principalColumn: "id", onDelete: ReferentialAction.Cascade); }); migrationBuilder.CreateTable( name: "user_logins", columns: table => new { login_provider = table.Column <string>(nullable: false), provider_key = table.Column <string>(nullable: false), provider_display_name = table.Column <string>(nullable: true), user_id = table.Column <string>(nullable: false) }, constraints: table => { table.PrimaryKey("pk_user_logins", x => new { x.login_provider, x.provider_key }); table.ForeignKey( name: "fk_user_logins_users_user_id", column: x => x.user_id, principalTable: "users", principalColumn: "id", onDelete: ReferentialAction.Cascade); }); migrationBuilder.CreateTable( name: "user_roles", columns: table => new { user_id = table.Column <string>(nullable: false), role_id = table.Column <string>(nullable: false) }, constraints: table => { table.PrimaryKey("pk_user_roles", x => new { x.user_id, x.role_id }); table.ForeignKey( name: "fk_user_roles_roles_identity_role_id", column: x => x.role_id, principalTable: "roles", principalColumn: "id", onDelete: ReferentialAction.Cascade); table.ForeignKey( name: "fk_user_roles_users_user_id", column: x => x.user_id, principalTable: "users", principalColumn: "id", onDelete: ReferentialAction.Cascade); }); migrationBuilder.CreateTable( name: "daily_log", columns: table => new { id = table.Column <long>(nullable: false) .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), target_id = table.Column <long>(nullable: false), user_intake_target_id = table.Column <long>(nullable: true), total_calories = table.Column <short>(nullable: false), total_carbs = table.Column <short>(nullable: false), total_fat = table.Column <short>(nullable: false), total_protein = table.Column <short>(nullable: false), created_on = table.Column <Instant>(nullable: false), updated_on = table.Column <Instant>(nullable: true) }, constraints: table => { table.PrimaryKey("pk_daily_log", x => x.id); table.ForeignKey( name: "fk_daily_log_user_intake_target_user_intake_target_id", column: x => x.user_intake_target_id, principalTable: "user_intake_target", principalColumn: "id", onDelete: ReferentialAction.Restrict); }); migrationBuilder.CreateTable( name: "intake", columns: table => new { id = table.Column <long>(nullable: false) .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.SequenceHiLo), target_id = table.Column <long>(nullable: false), ingredient_id = table.Column <long>(nullable: false), measurement_unit = table.Column <MeasurementUnit>(nullable: false), size_taken = table.Column <float>(nullable: false), calories = table.Column <float>(nullable: false), carbs = table.Column <float>(nullable: false), fat = table.Column <float>(nullable: false), protein = table.Column <float>(nullable: false), time = table.Column <Instant>(nullable: false), created_on = table.Column <Instant>(nullable: false), updated_on = table.Column <Instant>(nullable: true) }, constraints: table => { table.PrimaryKey("pk_intake", x => x.id); table.ForeignKey( name: "fk_intake_ingredient_ingredient_id", column: x => x.ingredient_id, principalTable: "ingredient", principalColumn: "id", onDelete: ReferentialAction.Cascade); table.ForeignKey( name: "fk_intake_user_intake_target_user_intake_target_id", column: x => x.target_id, principalTable: "user_intake_target", principalColumn: "id", onDelete: ReferentialAction.Cascade); }); migrationBuilder.CreateIndex( name: "ix_daily_log_user_intake_target_id", table: "daily_log", column: "user_intake_target_id"); migrationBuilder.CreateIndex( name: "ix_ingredient_name", table: "ingredient", column: "name", unique: true); migrationBuilder.CreateIndex( name: "ix_intake_ingredient_id", table: "intake", column: "ingredient_id"); migrationBuilder.CreateIndex( name: "ix_intake_target_id", table: "intake", column: "target_id"); migrationBuilder.CreateIndex( name: "ix_notification_user_id", table: "notification", column: "user_id"); migrationBuilder.CreateIndex( name: "ix_role_claims_role_id", table: "role_claims", column: "role_id"); migrationBuilder.CreateIndex( name: "ix_roles_normalized_name", table: "roles", column: "normalized_name", unique: true); migrationBuilder.CreateIndex( name: "ix_user_claims_user_id", table: "user_claims", column: "user_id"); migrationBuilder.CreateIndex( name: "ix_user_intake_target_user_id", table: "user_intake_target", column: "user_id"); migrationBuilder.CreateIndex( name: "ix_user_logins_user_id", table: "user_logins", column: "user_id"); migrationBuilder.CreateIndex( name: "ix_user_roles_role_id", table: "user_roles", column: "role_id"); migrationBuilder.CreateIndex( name: "ix_users_normalized_email", table: "users", column: "normalized_email"); migrationBuilder.CreateIndex( name: "ix_users_normalized_user_name", table: "users", column: "normalized_user_name", unique: true); }
protected override void Up(MigrationBuilder migrationBuilder) { migrationBuilder.AlterDatabase() .Annotation("Npgsql:Enum:connection_log_severity", "info,error,warning") .Annotation("Npgsql:PostgresExtension:uuid-ossp", ",,"); migrationBuilder.CreateTable( "Tenants", table => new { Id = table.Column <Guid>("uuid", nullable: false) }, constraints: table => { table.PrimaryKey("PK_Tenants", x => x.Id); }); migrationBuilder.CreateTable( "Nodes", table => new { Id = table.Column <Guid>("uuid", nullable: false), Enabled = table.Column <bool>("boolean", nullable: false), Name = table.Column <string>("character varying(255)", maxLength: 255, nullable: false), Host = table.Column <string>("character varying(255)", maxLength: 255, nullable: false), Port = table.Column <int>("integer", nullable: false), Username = table.Column <string>("character varying(255)", maxLength: 255, nullable: false), Password = table.Column <byte[]>("bytea", nullable: true), PrivateKey = table.Column <byte[]>("bytea", nullable: true), ReconciliationFailed = table.Column <bool>("boolean", nullable: true), Version = table.Column <Guid>("uuid", nullable: false), TenantId = table.Column <Guid>("uuid", nullable: true) }, constraints: table => { table.PrimaryKey("PK_Nodes", x => x.Id); table.ForeignKey( "FK_Nodes_Tenants_TenantId", x => x.TenantId, "Tenants", "Id", onDelete: ReferentialAction.Cascade); }); migrationBuilder.CreateTable( "ComposeVersions", table => new { Id = table.Column <Guid>("uuid", nullable: false), Content = table.Column <string>("text", nullable: false), Directory = table.Column <string>("text", nullable: false), ServiceName = table.Column <string>("character varying(255)", maxLength: 255, nullable: true), ServiceEnabled = table.Column <bool>("boolean", nullable: false), ComposeId = table.Column <Guid>("uuid", nullable: false), PendingDelete = table.Column <bool>("boolean", nullable: false) }, constraints: table => { table.PrimaryKey("PK_ComposeVersions", x => x.Id); }); migrationBuilder.CreateTable( "Composes", table => new { Id = table.Column <Guid>("uuid", nullable: false), Name = table.Column <string>("character varying(255)", maxLength: 255, nullable: false), CurrentId = table.Column <Guid>("uuid", nullable: false), TenantId = table.Column <Guid>("uuid", nullable: true) }, constraints: table => { table.PrimaryKey("PK_Composes", x => x.Id); table.ForeignKey( "FK_Composes_ComposeVersions_CurrentId", x => x.CurrentId, "ComposeVersions", "Id", onDelete: ReferentialAction.Restrict); table.ForeignKey( "FK_Composes_Tenants_TenantId", x => x.TenantId, "Tenants", "Id", onDelete: ReferentialAction.Cascade); }); migrationBuilder.CreateTable( "Deployments", table => new { Id = table.Column <Guid>("uuid", nullable: false), Enabled = table.Column <bool>("boolean", nullable: false), ComposeId = table.Column <Guid>("uuid", nullable: false), LastDeployedComposeVersionId = table.Column <Guid>("uuid", nullable: true), NodeId = table.Column <Guid>("uuid", nullable: false), LastCheck = table.Column <DateTime>("timestamp without time zone", nullable: true), LastDeployedNodeVersion = table.Column <Guid>("uuid", nullable: true), LastDeployedAsEnabled = table.Column <bool>("boolean", nullable: true), ReconciliationFailed = table.Column <bool>("boolean", nullable: true) }, constraints: table => { table.PrimaryKey("PK_Deployments", x => x.Id); table.ForeignKey( "FK_Deployments_Composes_ComposeId", x => x.ComposeId, "Composes", "Id", onDelete: ReferentialAction.Cascade); table.ForeignKey( "FK_Deployments_ComposeVersions_LastDeployedComposeVersionId", x => x.LastDeployedComposeVersionId, "ComposeVersions", "Id", onDelete: ReferentialAction.Restrict); table.ForeignKey( "FK_Deployments_Nodes_NodeId", x => x.NodeId, "Nodes", "Id", onDelete: ReferentialAction.Cascade); }); migrationBuilder.CreateTable( "ConnectionLogs", table => new { Id = table.Column <Guid>("uuid", nullable: false), Severity = table.Column <int>("integer", nullable: false), Message = table.Column <string>("text", nullable: false), Time = table.Column <DateTime>("timestamp without time zone", nullable: false), Error = table.Column <string>("text", nullable: true), Metadata = table.Column <Dictionary <string, object> >("jsonb", nullable: true), NodeId = table.Column <Guid>("uuid", nullable: true), DeploymentId = table.Column <Guid>("uuid", nullable: true), TenantId = table.Column <Guid>("uuid", nullable: true), ComposeId = table.Column <Guid>("uuid", nullable: true) }, constraints: table => { table.PrimaryKey("PK_ConnectionLogs", x => x.Id); table.ForeignKey( "FK_ConnectionLogs_Composes_ComposeId", x => x.ComposeId, "Composes", "Id", onDelete: ReferentialAction.SetNull); table.ForeignKey( "FK_ConnectionLogs_Deployments_DeploymentId", x => x.DeploymentId, "Deployments", "Id", onDelete: ReferentialAction.SetNull); table.ForeignKey( "FK_ConnectionLogs_Nodes_NodeId", x => x.NodeId, "Nodes", "Id", onDelete: ReferentialAction.SetNull); table.ForeignKey( "FK_ConnectionLogs_Tenants_TenantId", x => x.TenantId, "Tenants", "Id", onDelete: ReferentialAction.SetNull); }); migrationBuilder.CreateIndex( "IX_Composes_CurrentId", "Composes", "CurrentId", unique: true); migrationBuilder.CreateIndex( "IX_Composes_TenantId", "Composes", "TenantId"); migrationBuilder.CreateIndex( "IX_ComposeVersions_ComposeId", "ComposeVersions", "ComposeId"); migrationBuilder.CreateIndex( "IX_ConnectionLogs_ComposeId", "ConnectionLogs", "ComposeId"); migrationBuilder.CreateIndex( "IX_ConnectionLogs_DeploymentId", "ConnectionLogs", "DeploymentId"); migrationBuilder.CreateIndex( "IX_ConnectionLogs_NodeId", "ConnectionLogs", "NodeId"); migrationBuilder.CreateIndex( "IX_ConnectionLogs_TenantId", "ConnectionLogs", "TenantId"); migrationBuilder.CreateIndex( "IX_Deployments_ComposeId_NodeId", "Deployments", new[] { "ComposeId", "NodeId" }, unique: true); migrationBuilder.CreateIndex( "IX_Deployments_LastDeployedComposeVersionId", "Deployments", "LastDeployedComposeVersionId"); migrationBuilder.CreateIndex( "IX_Deployments_NodeId", "Deployments", "NodeId"); migrationBuilder.CreateIndex( "IX_Nodes_TenantId", "Nodes", "TenantId"); migrationBuilder.AddForeignKey( "FK_ComposeVersions_Composes_ComposeId", "ComposeVersions", "ComposeId", "Composes", principalColumn: "Id", onDelete: ReferentialAction.Cascade); migrationBuilder.Sql( "ALTER TABLE \"Composes\" ALTER CONSTRAINT \"FK_Composes_ComposeVersions_CurrentId\" DEFERRABLE INITIALLY DEFERRED;"); }
protected override void Up(MigrationBuilder migrationBuilder) { migrationBuilder.AlterDatabase() .Annotation("Npgsql:PostgresExtension:postgis", "'postgis', '', ''"); migrationBuilder.CreateTable( name: "Dayss", columns: table => new { IdDay = table.Column <int>(nullable: false) .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.SerialColumn), NameDay = table.Column <string>(nullable: true) }, constraints: table => { table.PrimaryKey("PK_Dayss", x => x.IdDay); }); migrationBuilder.CreateTable( name: "Mtcs", columns: table => new { Gid = table.Column <int>(nullable: false) .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.SerialColumn), Id = table.Column <long>(nullable: true), Groesse = table.Column <long>(nullable: true), Geom = table.Column <Geometry>(nullable: true), Area = table.Column <decimal>(nullable: true) }, constraints: table => { table.PrimaryKey("PK_Mtcs", x => x.Gid); }); migrationBuilder.CreateTable( name: "MtcActivitys", columns: table => new { IdAct = table.Column <int>(nullable: false) .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.SerialColumn), ZoneAct = table.Column <int>(nullable: false), CountAct = table.Column <long>(nullable: false), HoursAct = table.Column <int>(nullable: false), DaysAct = table.Column <int>(nullable: false), Density = table.Column <decimal>(nullable: true) }, constraints: table => { table.PrimaryKey("PK_MtcActivitys", x => x.IdAct); table.ForeignKey( name: "FK_MtcActivitys_Dayss_DaysAct", column: x => x.DaysAct, principalTable: "Dayss", principalColumn: "IdDay", onDelete: ReferentialAction.Cascade); table.ForeignKey( name: "FK_MtcActivitys_Mtcs_ZoneAct", column: x => x.ZoneAct, principalTable: "Mtcs", principalColumn: "Gid", onDelete: ReferentialAction.Cascade); }); migrationBuilder.CreateTable( name: "MtcHomezones", columns: table => new { IdHz = table.Column <int>(nullable: false) .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.SerialColumn), ZoneHz = table.Column <int>(nullable: false), HomeHz = table.Column <int>(nullable: false), DaysHz = table.Column <int>(nullable: false), SharedHz = table.Column <decimal>(nullable: false) }, constraints: table => { table.PrimaryKey("PK_MtcHomezones", x => x.IdHz); table.ForeignKey( name: "FK_MtcHomezones_Mtcs_HomeHz", column: x => x.HomeHz, principalTable: "Mtcs", principalColumn: "Gid", onDelete: ReferentialAction.Cascade); }); migrationBuilder.CreateIndex( name: "IX_MtcActivitys_DaysAct", table: "MtcActivitys", column: "DaysAct"); migrationBuilder.CreateIndex( name: "IX_MtcActivitys_ZoneAct", table: "MtcActivitys", column: "ZoneAct"); migrationBuilder.CreateIndex( name: "IX_MtcHomezones_HomeHz", table: "MtcHomezones", column: "HomeHz"); }
protected override void Up(MigrationBuilder migrationBuilder) { migrationBuilder.AlterDatabase() .Annotation("MySql:CharSet", "utf8mb4"); migrationBuilder.CreateTable( name: "edu_Departments", columns: table => new { Id = table.Column <int>(type: "int", nullable: false) .Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn), Code = table.Column <string>(type: "longtext", nullable: true) .Annotation("MySql:CharSet", "utf8mb4") }, constraints: table => { table.PrimaryKey("PK_edu_Departments", x => x.Id); }) .Annotation("MySql:CharSet", "utf8mb4"); migrationBuilder.CreateTable( name: "sys_Languages", columns: table => new { Id = table.Column <int>(type: "int", nullable: false) .Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn), Code = table.Column <string>(type: "longtext", nullable: true) .Annotation("MySql:CharSet", "utf8mb4") }, constraints: table => { table.PrimaryKey("PK_sys_Languages", x => x.Id); }) .Annotation("MySql:CharSet", "utf8mb4"); migrationBuilder.CreateTable( name: "edu_DepartmentLocalizations", columns: table => new { Id = table.Column <int>(type: "int", nullable: false) .Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn), Name = table.Column <string>(type: "longtext", nullable: true) .Annotation("MySql:CharSet", "utf8mb4"), DepartmentId = table.Column <int>(type: "int", nullable: false), LanguageId = table.Column <int>(type: "int", nullable: false) }, constraints: table => { table.PrimaryKey("PK_edu_DepartmentLocalizations", x => x.Id); table.ForeignKey( name: "FK_edu_DepartmentLocalizations_edu_Departments_DepartmentId", column: x => x.DepartmentId, principalTable: "edu_Departments", principalColumn: "Id", onDelete: ReferentialAction.Cascade); table.ForeignKey( name: "FK_edu_DepartmentLocalizations_sys_Languages_LanguageId", column: x => x.LanguageId, principalTable: "sys_Languages", principalColumn: "Id", onDelete: ReferentialAction.Cascade); }) .Annotation("MySql:CharSet", "utf8mb4"); migrationBuilder.CreateIndex( name: "IX_edu_DepartmentLocalizations_DepartmentId", table: "edu_DepartmentLocalizations", column: "DepartmentId"); migrationBuilder.CreateIndex( name: "IX_edu_DepartmentLocalizations_LanguageId", table: "edu_DepartmentLocalizations", column: "LanguageId"); }
protected override void Up(MigrationBuilder migrationBuilder) { migrationBuilder.AlterDatabase() .Annotation("MySql:CharSet", "utf8mb4"); migrationBuilder.CreateTable( name: "Programare", columns: table => new { ProgramareId = table.Column <int>(type: "int", nullable: false) .Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn), numeClient = table.Column <string>(type: "longtext", nullable: true) .Annotation("MySql:CharSet", "utf8mb4"), telefon = table.Column <string>(type: "varchar(10)", maxLength: 10, nullable: true) .Annotation("MySql:CharSet", "utf8mb4"), dataOra = table.Column <DateTime>(type: "datetime(6)", nullable: false), username = table.Column <string>(type: "longtext", nullable: true) .Annotation("MySql:CharSet", "utf8mb4") }, constraints: table => { table.PrimaryKey("PK_Programare", x => x.ProgramareId); }) .Annotation("MySql:CharSet", "utf8mb4"); migrationBuilder.CreateTable( name: "Serviciu", columns: table => new { ServiciuId = table.Column <int>(type: "int", nullable: false) .Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn), numeServiciu = table.Column <string>(type: "longtext", nullable: true) .Annotation("MySql:CharSet", "utf8mb4"), pret = table.Column <float>(type: "float", nullable: false) }, constraints: table => { table.PrimaryKey("PK_Serviciu", x => x.ServiciuId); }) .Annotation("MySql:CharSet", "utf8mb4"); migrationBuilder.CreateTable( name: "ProgramareServiciu", columns: table => new { ProgramareId = table.Column <int>(type: "int", nullable: false), ServiciuId = table.Column <int>(type: "int", nullable: false) }, constraints: table => { table.PrimaryKey("PK_ProgramareServiciu", x => new { x.ProgramareId, x.ServiciuId }); table.ForeignKey( name: "FK_ProgramareServiciu_Programare_ProgramareId", column: x => x.ProgramareId, principalTable: "Programare", principalColumn: "ProgramareId", onDelete: ReferentialAction.Cascade); table.ForeignKey( name: "FK_ProgramareServiciu_Serviciu_ServiciuId", column: x => x.ServiciuId, principalTable: "Serviciu", principalColumn: "ServiciuId", onDelete: ReferentialAction.Cascade); }) .Annotation("MySql:CharSet", "utf8mb4"); migrationBuilder.CreateIndex( name: "IX_ProgramareServiciu_ServiciuId", table: "ProgramareServiciu", column: "ServiciuId"); }
protected override void Up(MigrationBuilder migrationBuilder) { migrationBuilder.AlterDatabase() .Annotation("MySql:CharSet", "utf8mb4"); migrationBuilder.CreateTable( name: "Partners", columns: table => new { Id = table.Column <int>(type: "int", nullable: false) .Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn), CNPJ = table.Column <string>(type: "longtext", nullable: true) .Annotation("MySql:CharSet", "utf8mb4"), Name = table.Column <string>(type: "longtext", nullable: true) .Annotation("MySql:CharSet", "utf8mb4") }, constraints: table => { table.PrimaryKey("PK_Partners", x => x.Id); }) .Annotation("MySql:CharSet", "utf8mb4"); migrationBuilder.CreateTable( name: "TB_User", columns: table => new { Id = table.Column <int>(type: "int", nullable: false) .Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn), CPF = table.Column <string>(type: "longtext", nullable: true) .Annotation("MySql:CharSet", "utf8mb4"), Email = table.Column <string>(type: "longtext", nullable: true) .Annotation("MySql:CharSet", "utf8mb4"), Name = table.Column <string>(type: "longtext", nullable: true) .Annotation("MySql:CharSet", "utf8mb4"), Phone = table.Column <string>(type: "longtext", nullable: true) .Annotation("MySql:CharSet", "utf8mb4"), Password = table.Column <string>(type: "longtext", nullable: true) .Annotation("MySql:CharSet", "utf8mb4") }, constraints: table => { table.PrimaryKey("PK_TB_User", x => x.Id); }) .Annotation("MySql:CharSet", "utf8mb4"); migrationBuilder.CreateTable( name: "Products", columns: table => new { Id = table.Column <int>(type: "int", nullable: false) .Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn), SKU = table.Column <string>(type: "longtext", nullable: true) .Annotation("MySql:CharSet", "utf8mb4"), Name = table.Column <string>(type: "longtext", nullable: true) .Annotation("MySql:CharSet", "utf8mb4"), DotType = table.Column <int>(type: "int", nullable: false), DotPrice = table.Column <int>(type: "int", nullable: false), PartnerId = table.Column <int>(type: "int", nullable: true) }, constraints: table => { table.PrimaryKey("PK_Products", x => x.Id); table.ForeignKey( name: "FK_Products_Partners_PartnerId", column: x => x.PartnerId, principalTable: "Partners", principalColumn: "Id", onDelete: ReferentialAction.Restrict); }) .Annotation("MySql:CharSet", "utf8mb4"); migrationBuilder.CreateTable( name: "TB_UserAddress", columns: table => new { Id = table.Column <int>(type: "int", nullable: false) .Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn), Name = table.Column <string>(type: "longtext", nullable: true) .Annotation("MySql:CharSet", "utf8mb4"), Type = table.Column <int>(type: "int", nullable: false), Description = table.Column <string>(type: "longtext", nullable: true) .Annotation("MySql:CharSet", "utf8mb4"), City = table.Column <string>(type: "longtext", nullable: true) .Annotation("MySql:CharSet", "utf8mb4"), State = table.Column <string>(type: "longtext", nullable: true) .Annotation("MySql:CharSet", "utf8mb4"), Country = table.Column <string>(type: "longtext", nullable: true) .Annotation("MySql:CharSet", "utf8mb4"), ZipCode = table.Column <string>(type: "longtext", nullable: true) .Annotation("MySql:CharSet", "utf8mb4"), UserId = table.Column <int>(type: "int", nullable: true) }, constraints: table => { table.PrimaryKey("PK_TB_UserAddress", x => x.Id); table.ForeignKey( name: "FK_TB_UserAddress_TB_User_UserId", column: x => x.UserId, principalTable: "TB_User", principalColumn: "Id", onDelete: ReferentialAction.Restrict); }) .Annotation("MySql:CharSet", "utf8mb4"); migrationBuilder.CreateTable( name: "Orders", columns: table => new { Id = table.Column <int>(type: "int", nullable: false) .Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn), Occurrence = table.Column <DateTime>(type: "datetime(6)", nullable: false), UserId = table.Column <int>(type: "int", nullable: true), AddressId = table.Column <int>(type: "int", nullable: true) }, constraints: table => { table.PrimaryKey("PK_Orders", x => x.Id); table.ForeignKey( name: "FK_Orders_TB_User_UserId", column: x => x.UserId, principalTable: "TB_User", principalColumn: "Id", onDelete: ReferentialAction.Restrict); table.ForeignKey( name: "FK_Orders_TB_UserAddress_AddressId", column: x => x.AddressId, principalTable: "TB_UserAddress", principalColumn: "Id", onDelete: ReferentialAction.Restrict); }) .Annotation("MySql:CharSet", "utf8mb4"); migrationBuilder.CreateTable( name: "Movements", columns: table => new { Id = table.Column <int>(type: "int", nullable: false) .Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn), Occurrence = table.Column <DateTime>(type: "datetime(6)", nullable: false), Type = table.Column <int>(type: "int", nullable: false), Dots = table.Column <int>(type: "int", nullable: false), DueDate = table.Column <DateTime>(type: "datetime(6)", nullable: false), UserId = table.Column <int>(type: "int", nullable: true), ProductId = table.Column <int>(type: "int", nullable: true), OrderId = table.Column <int>(type: "int", nullable: true) }, constraints: table => { table.PrimaryKey("PK_Movements", x => x.Id); table.ForeignKey( name: "FK_Movements_Orders_OrderId", column: x => x.OrderId, principalTable: "Orders", principalColumn: "Id", onDelete: ReferentialAction.Restrict); table.ForeignKey( name: "FK_Movements_Products_ProductId", column: x => x.ProductId, principalTable: "Products", principalColumn: "Id", onDelete: ReferentialAction.Restrict); table.ForeignKey( name: "FK_Movements_TB_User_UserId", column: x => x.UserId, principalTable: "TB_User", principalColumn: "Id", onDelete: ReferentialAction.Restrict); }) .Annotation("MySql:CharSet", "utf8mb4"); migrationBuilder.CreateTable( name: "OrderProduct", columns: table => new { OrdersId = table.Column <int>(type: "int", nullable: false), ProductsId = table.Column <int>(type: "int", nullable: false) }, constraints: table => { table.PrimaryKey("PK_OrderProduct", x => new { x.OrdersId, x.ProductsId }); table.ForeignKey( name: "FK_OrderProduct_Orders_OrdersId", column: x => x.OrdersId, principalTable: "Orders", principalColumn: "Id", onDelete: ReferentialAction.Cascade); table.ForeignKey( name: "FK_OrderProduct_Products_ProductsId", column: x => x.ProductsId, principalTable: "Products", principalColumn: "Id", onDelete: ReferentialAction.Cascade); }) .Annotation("MySql:CharSet", "utf8mb4"); migrationBuilder.CreateIndex( name: "IX_Movements_OrderId", table: "Movements", column: "OrderId"); migrationBuilder.CreateIndex( name: "IX_Movements_ProductId", table: "Movements", column: "ProductId"); migrationBuilder.CreateIndex( name: "IX_Movements_UserId", table: "Movements", column: "UserId"); migrationBuilder.CreateIndex( name: "IX_OrderProduct_ProductsId", table: "OrderProduct", column: "ProductsId"); migrationBuilder.CreateIndex( name: "IX_Orders_AddressId", table: "Orders", column: "AddressId"); migrationBuilder.CreateIndex( name: "IX_Orders_UserId", table: "Orders", column: "UserId"); migrationBuilder.CreateIndex( name: "IX_Products_PartnerId", table: "Products", column: "PartnerId"); migrationBuilder.CreateIndex( name: "IX_TB_UserAddress_UserId", table: "TB_UserAddress", column: "UserId"); }
protected override void Up(MigrationBuilder migrationBuilder) { migrationBuilder.DropIndex( name: "IX_AbpSettings_TenantId_Name", table: "AbpSettings"); migrationBuilder.DropColumn( name: "LastLoginTime", table: "AbpUsers"); migrationBuilder.DropColumn( name: "LastLoginTime", table: "AbpUserAccounts"); migrationBuilder.AlterDatabase() .Annotation("Npgsql:PostgresExtension:postgis", ",,") .OldAnnotation("Npgsql:PostgresExtension:postgis", "'postgis', '', ''"); migrationBuilder.AlterColumn <string>( name: "LanguageName", table: "AbpLanguageTexts", maxLength: 128, nullable: false, oldClrType: typeof(string), oldMaxLength: 10); migrationBuilder.AlterColumn <string>( name: "Name", table: "AbpLanguages", maxLength: 128, nullable: false, oldClrType: typeof(string), oldMaxLength: 10); migrationBuilder.AddColumn <string>( name: "ReturnValue", table: "AbpAuditLogs", nullable: true); migrationBuilder.CreateTable( name: "AbpOrganizationUnitRoles", columns: table => new { Id = table.Column <long>(nullable: false) .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.SerialColumn), CreationTime = table.Column <DateTime>(nullable: false), CreatorUserId = table.Column <long>(nullable: true), TenantId = table.Column <int>(nullable: true), RoleId = table.Column <int>(nullable: false), OrganizationUnitId = table.Column <long>(nullable: false), IsDeleted = table.Column <bool>(nullable: false) }, constraints: table => { table.PrimaryKey("PK_AbpOrganizationUnitRoles", x => x.Id); }); migrationBuilder.CreateIndex( name: "IX_AbpSettings_TenantId_Name_UserId", table: "AbpSettings", columns: new[] { "TenantId", "Name", "UserId" }, unique: true); migrationBuilder.CreateIndex( name: "IX_AbpOrganizationUnitRoles_TenantId_OrganizationUnitId", table: "AbpOrganizationUnitRoles", columns: new[] { "TenantId", "OrganizationUnitId" }); migrationBuilder.CreateIndex( name: "IX_AbpOrganizationUnitRoles_TenantId_RoleId", table: "AbpOrganizationUnitRoles", columns: new[] { "TenantId", "RoleId" }); }
protected override void Up(MigrationBuilder migrationBuilder) { migrationBuilder.AlterDatabase() .Annotation("Npgsql:PostgresExtension:uuid-ossp", ",,"); migrationBuilder.CreateTable( name: "files", columns: table => new { id = table.Column <Guid>(nullable: false, defaultValueSql: "uuid_generate_v4()"), date_created = table.Column <DateTime>(nullable: false), date_modified = table.Column <DateTime>(nullable: true), created_by = table.Column <Guid>(nullable: false), modified_by = table.Column <Guid>(nullable: true), name = table.Column <string>(nullable: true), storage_path = table.Column <string>(nullable: true), length = table.Column <long>(nullable: false) }, constraints: table => { table.PrimaryKey("PK_files", x => x.id); }); migrationBuilder.CreateTable( name: "scenarios", columns: table => new { id = table.Column <Guid>(nullable: false, defaultValueSql: "uuid_generate_v4()"), date_created = table.Column <DateTime>(nullable: false), date_modified = table.Column <DateTime>(nullable: true), created_by = table.Column <Guid>(nullable: false), modified_by = table.Column <Guid>(nullable: true), name = table.Column <string>(nullable: true), description = table.Column <string>(nullable: true), duration_hours = table.Column <int>(nullable: true) }, constraints: table => { table.PrimaryKey("PK_scenarios", x => x.id); }); migrationBuilder.CreateTable( name: "users", columns: table => new { key = table.Column <int>(nullable: false) .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.SerialColumn), date_created = table.Column <DateTime>(nullable: false), date_modified = table.Column <DateTime>(nullable: true), created_by = table.Column <Guid>(nullable: false), modified_by = table.Column <Guid>(nullable: true), id = table.Column <Guid>(nullable: false), name = table.Column <string>(nullable: true) }, constraints: table => { table.PrimaryKey("PK_users", x => x.key); }); migrationBuilder.CreateTable( name: "sessions", columns: table => new { id = table.Column <Guid>(nullable: false, defaultValueSql: "uuid_generate_v4()"), date_created = table.Column <DateTime>(nullable: false), date_modified = table.Column <DateTime>(nullable: true), created_by = table.Column <Guid>(nullable: false), modified_by = table.Column <Guid>(nullable: true), name = table.Column <string>(nullable: true), description = table.Column <string>(nullable: true), start_date = table.Column <DateTime>(nullable: false), end_date = table.Column <DateTime>(nullable: false), status = table.Column <int>(nullable: false), on_demand = table.Column <bool>(nullable: false), scenario_id = table.Column <Guid>(nullable: true), exercise_id = table.Column <Guid>(nullable: true), exercise = table.Column <string>(nullable: true) }, constraints: table => { table.PrimaryKey("PK_sessions", x => x.id); table.ForeignKey( name: "FK_sessions_scenarios_scenario_id", column: x => x.scenario_id, principalTable: "scenarios", principalColumn: "id", onDelete: ReferentialAction.Restrict); }); migrationBuilder.CreateTable( name: "dispatch_tasks", columns: table => new { id = table.Column <Guid>(nullable: false, defaultValueSql: "uuid_generate_v4()"), date_created = table.Column <DateTime>(nullable: false), date_modified = table.Column <DateTime>(nullable: true), created_by = table.Column <Guid>(nullable: false), modified_by = table.Column <Guid>(nullable: true), name = table.Column <string>(nullable: true), description = table.Column <string>(nullable: true), scenario_id = table.Column <Guid>(nullable: true), session_id = table.Column <Guid>(nullable: true), user_id = table.Column <Guid>(nullable: true), action = table.Column <int>(nullable: false), vm_mask = table.Column <string>(nullable: true), api_url = table.Column <string>(nullable: true), input_string = table.Column <string>(nullable: true), expected_output = table.Column <string>(nullable: true), expiration_seconds = table.Column <int>(nullable: false), delay_seconds = table.Column <int>(nullable: false), interval_seconds = table.Column <int>(nullable: false), iterations = table.Column <int>(nullable: false), trigger_task_id = table.Column <Guid>(nullable: true), trigger_condition = table.Column <int>(nullable: false) }, constraints: table => { table.PrimaryKey("PK_dispatch_tasks", x => x.id); table.ForeignKey( name: "FK_dispatch_tasks_scenarios_scenario_id", column: x => x.scenario_id, principalTable: "scenarios", principalColumn: "id", onDelete: ReferentialAction.Restrict); table.ForeignKey( name: "FK_dispatch_tasks_sessions_session_id", column: x => x.session_id, principalTable: "sessions", principalColumn: "id", onDelete: ReferentialAction.Restrict); table.ForeignKey( name: "FK_dispatch_tasks_dispatch_tasks_trigger_task_id", column: x => x.trigger_task_id, principalTable: "dispatch_tasks", principalColumn: "id", onDelete: ReferentialAction.Restrict); }); migrationBuilder.CreateTable( name: "dispatch_task_results", columns: table => new { id = table.Column <Guid>(nullable: false, defaultValueSql: "uuid_generate_v4()"), date_created = table.Column <DateTime>(nullable: false), date_modified = table.Column <DateTime>(nullable: true), created_by = table.Column <Guid>(nullable: false), modified_by = table.Column <Guid>(nullable: true), dispatch_task_id = table.Column <Guid>(nullable: true), vm_id = table.Column <Guid>(nullable: true), vm_name = table.Column <string>(nullable: true), api_url = table.Column <string>(nullable: true), input_string = table.Column <string>(nullable: true), expiration_seconds = table.Column <int>(nullable: false), iterations = table.Column <int>(nullable: false), interval_seconds = table.Column <int>(nullable: false), status = table.Column <int>(nullable: false), expected_output = table.Column <string>(nullable: true), actual_output = table.Column <string>(nullable: true), sent_date = table.Column <DateTime>(nullable: false), status_date = table.Column <DateTime>(nullable: false) }, constraints: table => { table.PrimaryKey("PK_dispatch_task_results", x => x.id); table.ForeignKey( name: "FK_dispatch_task_results_dispatch_tasks_dispatch_task_id", column: x => x.dispatch_task_id, principalTable: "dispatch_tasks", principalColumn: "id", onDelete: ReferentialAction.Restrict); }); migrationBuilder.CreateIndex( name: "IX_dispatch_task_results_dispatch_task_id", table: "dispatch_task_results", column: "dispatch_task_id"); migrationBuilder.CreateIndex( name: "IX_dispatch_tasks_scenario_id", table: "dispatch_tasks", column: "scenario_id"); migrationBuilder.CreateIndex( name: "IX_dispatch_tasks_session_id", table: "dispatch_tasks", column: "session_id"); migrationBuilder.CreateIndex( name: "IX_dispatch_tasks_trigger_task_id", table: "dispatch_tasks", column: "trigger_task_id"); migrationBuilder.CreateIndex( name: "IX_sessions_scenario_id", table: "sessions", column: "scenario_id"); migrationBuilder.CreateIndex( name: "IX_users_id", table: "users", column: "id", unique: true); }
protected override void Up(MigrationBuilder migrationBuilder) { migrationBuilder.AlterDatabase() .Annotation("Npgsql:PostgresExtension:uuid-ossp", ",,"); migrationBuilder.CreateTable( name: "Accounts", columns: table => new { Id = table.Column <Guid>(nullable: false, defaultValueSql: "uuid_generate_v4()"), Username = table.Column <string>(nullable: true), PrimaryEmailEmailAddress = table.Column <string>(nullable: true) }, constraints: table => { table.PrimaryKey("PK_Accounts", x => x.Id); }); migrationBuilder.CreateTable( name: "AccountEmailAddresses", columns: table => new { EmailAddress = table.Column <string>(nullable: false), IsVerified = table.Column <bool>(nullable: false), AccountId = table.Column <Guid>(nullable: true) }, constraints: table => { table.PrimaryKey("PK_AccountEmailAddresses", x => x.EmailAddress); table.ForeignKey( name: "FK_AccountEmailAddresses_Accounts_AccountId", column: x => x.AccountId, principalTable: "Accounts", principalColumn: "Id", onDelete: ReferentialAction.Cascade); }); migrationBuilder.CreateTable( name: "AuthTokens", columns: table => new { TokenString = table.Column <string>(nullable: false), AccountId = table.Column <Guid>(nullable: true), LastUsed = table.Column <DateTime>(nullable: false) }, constraints: table => { table.PrimaryKey("PK_AuthTokens", x => x.TokenString); table.ForeignKey( name: "FK_AuthTokens_Accounts_AccountId", column: x => x.AccountId, principalTable: "Accounts", principalColumn: "Id", onDelete: ReferentialAction.Cascade); }); migrationBuilder.CreateTable( name: "Claims", columns: table => new { Name = table.Column <string>(nullable: false), Value = table.Column <string>(nullable: true), AccountId = table.Column <Guid>(nullable: true) }, constraints: table => { table.PrimaryKey("PK_Claims", x => x.Name); table.ForeignKey( name: "FK_Claims_Accounts_AccountId", column: x => x.AccountId, principalTable: "Accounts", principalColumn: "Id", onDelete: ReferentialAction.Cascade); }); migrationBuilder.CreateTable( name: "PasswordCredentials", columns: table => new { AccountId = table.Column <Guid>(nullable: false), HashedPassword = table.Column <string>(nullable: true), PasswordSalt = table.Column <string>(nullable: true), PasswordHashingAlgorithm = table.Column <int>(nullable: false) }, constraints: table => { table.PrimaryKey("PK_PasswordCredentials", x => x.AccountId); table.ForeignKey( name: "FK_PasswordCredentials_Accounts_AccountId", column: x => x.AccountId, principalTable: "Accounts", principalColumn: "Id", onDelete: ReferentialAction.Cascade); }); migrationBuilder.CreateTable( name: "EmailVerificationTokens", columns: table => new { VerificationToken = table.Column <string>(nullable: false), EmailAddress1 = table.Column <string>(nullable: true), IsActive = table.Column <bool>(nullable: false) }, constraints: table => { table.PrimaryKey("PK_EmailVerificationTokens", x => x.VerificationToken); table.ForeignKey( name: "FK_EmailVerificationTokens_AccountEmailAddresses_EmailAddress1", column: x => x.EmailAddress1, principalTable: "AccountEmailAddresses", principalColumn: "EmailAddress", onDelete: ReferentialAction.Cascade); }); migrationBuilder.CreateTable( name: "PasswordResetTokens", columns: table => new { ResetToken = table.Column <string>(nullable: false), IsActive = table.Column <bool>(nullable: false), PasswordCredentialAccountId = table.Column <Guid>(nullable: true) }, constraints: table => { table.PrimaryKey("PK_PasswordResetTokens", x => x.ResetToken); table.ForeignKey( name: "FK_PasswordResetTokens_PasswordCredentials_PasswordCredentialA~", column: x => x.PasswordCredentialAccountId, principalTable: "PasswordCredentials", principalColumn: "AccountId", onDelete: ReferentialAction.Cascade); }); migrationBuilder.CreateIndex( name: "IX_AccountEmailAddresses_AccountId", table: "AccountEmailAddresses", column: "AccountId"); migrationBuilder.CreateIndex( name: "IX_Accounts_PrimaryEmailEmailAddress", table: "Accounts", column: "PrimaryEmailEmailAddress"); migrationBuilder.CreateIndex( name: "IX_AuthTokens_AccountId", table: "AuthTokens", column: "AccountId"); migrationBuilder.CreateIndex( name: "IX_Claims_AccountId", table: "Claims", column: "AccountId"); migrationBuilder.CreateIndex( name: "IX_EmailVerificationTokens_EmailAddress1", table: "EmailVerificationTokens", column: "EmailAddress1"); migrationBuilder.CreateIndex( name: "IX_PasswordResetTokens_PasswordCredentialAccountId", table: "PasswordResetTokens", column: "PasswordCredentialAccountId"); migrationBuilder.AddForeignKey( name: "FK_Accounts_AccountEmailAddresses_PrimaryEmailEmailAddress", table: "Accounts", column: "PrimaryEmailEmailAddress", principalTable: "AccountEmailAddresses", principalColumn: "EmailAddress", onDelete: ReferentialAction.Restrict); }
protected override void Up(MigrationBuilder migrationBuilder) { migrationBuilder.AlterDatabase() .Annotation("Npgsql:PostgresExtension:unaccent", ",,"); migrationBuilder.CreateTable( name: "Files", columns: table => new { Id = table.Column <int>(type: "integer", nullable: false) .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), Data = table.Column <byte[]>(type: "bytea", nullable: false), ContentType = table.Column <string>(type: "text", nullable: false) }, constraints: table => { table.PrimaryKey("PK_Files", x => x.Id); }); migrationBuilder.CreateTable( name: "Flicks", columns: table => new { Id = table.Column <int>(type: "integer", nullable: false) .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), Created = table.Column <DateTimeOffset>(type: "timestamp with time zone", nullable: false), Kind = table.Column <byte>(type: "smallint", nullable: false), ImdbId = table.Column <string>(type: "character varying(12)", maxLength: 12, nullable: false), Title = table.Column <string>(type: "text", nullable: false), OriginalTitle = table.Column <string>(type: "text", nullable: true), FirstAired = table.Column <DateTimeOffset>(type: "timestamp with time zone", nullable: true), LastAired = table.Column <DateTimeOffset>(type: "timestamp with time zone", nullable: true), EpisodeCount = table.Column <int>(type: "integer", nullable: true), Runtime = table.Column <TimeSpan>(type: "interval", nullable: true), ExternalRating = table.Column <double>(type: "double precision", nullable: true), Synopsis = table.Column <string>(type: "text", nullable: true), Tags = table.Column <string[]>(type: "text[]", nullable: false), ExternalLinks = table.Column <string[]>(type: "text[]", nullable: false), CoverImageId = table.Column <int>(type: "integer", nullable: true) }, constraints: table => { table.PrimaryKey("PK_Flicks", x => x.Id); }); migrationBuilder.CreateTable( name: "Users", columns: table => new { Id = table.Column <int>(type: "integer", nullable: false) .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), Created = table.Column <DateTimeOffset>(type: "timestamp with time zone", nullable: false), Role = table.Column <byte>(type: "smallint", nullable: false), Username = table.Column <string>(type: "character varying(48)", maxLength: 48, nullable: false), UsernameNormalized = table.Column <string>(type: "text", nullable: false), Email = table.Column <string>(type: "character varying(256)", maxLength: 256, nullable: false), EmailNormalized = table.Column <string>(type: "text", nullable: false), IsEmailConfirmed = table.Column <bool>(type: "boolean", nullable: false), PasswordHash = table.Column <byte[]>(type: "bytea", nullable: false) }, constraints: table => { table.PrimaryKey("PK_Users", x => x.Id); }); migrationBuilder.CreateTable( name: "Profiles", columns: table => new { Id = table.Column <int>(type: "integer", nullable: false) .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), IsPublic = table.Column <bool>(type: "boolean", nullable: false), Location = table.Column <string>(type: "text", nullable: true), Bio = table.Column <string>(type: "text", nullable: true), ExternalLinks = table.Column <string[]>(type: "text[]", nullable: false), AvatarImageId = table.Column <int>(type: "integer", nullable: true), UserId = table.Column <int>(type: "integer", nullable: false) }, constraints: table => { table.PrimaryKey("PK_Profiles", x => x.Id); table.ForeignKey( name: "FK_Profiles_Users_UserId", column: x => x.UserId, principalTable: "Users", principalColumn: "Id", onDelete: ReferentialAction.Cascade); }); migrationBuilder.CreateTable( name: "ProfileFlickEntries", columns: table => new { Id = table.Column <int>(type: "integer", nullable: false) .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), Created = table.Column <DateTimeOffset>(type: "timestamp with time zone", nullable: false), Updated = table.Column <DateTimeOffset>(type: "timestamp with time zone", nullable: false), Status = table.Column <int>(type: "integer", nullable: false), EpisodeCount = table.Column <int>(type: "integer", nullable: true), Rating = table.Column <double>(type: "double precision", nullable: true), Review = table.Column <string>(type: "character varying(20000)", maxLength: 20000, nullable: true), ProfileId = table.Column <int>(type: "integer", nullable: false), FlickId = table.Column <int>(type: "integer", nullable: false) }, constraints: table => { table.PrimaryKey("PK_ProfileFlickEntries", x => x.Id); table.ForeignKey( name: "FK_ProfileFlickEntries_Flicks_FlickId", column: x => x.FlickId, principalTable: "Flicks", principalColumn: "Id", onDelete: ReferentialAction.Cascade); table.ForeignKey( name: "FK_ProfileFlickEntries_Profiles_ProfileId", column: x => x.ProfileId, principalTable: "Profiles", principalColumn: "Id", onDelete: ReferentialAction.Cascade); }); migrationBuilder.CreateIndex( name: "IX_Flicks_ImdbId", table: "Flicks", column: "ImdbId", unique: true); migrationBuilder.CreateIndex( name: "IX_ProfileFlickEntries_FlickId", table: "ProfileFlickEntries", column: "FlickId"); migrationBuilder.CreateIndex( name: "IX_ProfileFlickEntries_ProfileId", table: "ProfileFlickEntries", column: "ProfileId"); migrationBuilder.CreateIndex( name: "IX_Profiles_UserId", table: "Profiles", column: "UserId", unique: true); migrationBuilder.CreateIndex( name: "IX_Users_EmailNormalized", table: "Users", column: "EmailNormalized", unique: true); migrationBuilder.CreateIndex( name: "IX_Users_UsernameNormalized", table: "Users", column: "UsernameNormalized", unique: true); }
protected override void Up(MigrationBuilder migrationBuilder) { migrationBuilder.AlterDatabase() .Annotation("Npgsql:PostgresExtension:adminpack", ",,"); migrationBuilder.CreateSequence( name: "access_groups_id_seq", startValue: 100L); migrationBuilder.CreateSequence( name: "consumption_events_id_seq", startValue: 1000L); migrationBuilder.CreateSequence( name: "currency_types_id_seq", startValue: 100L); migrationBuilder.CreateSequence( name: "fabric_tests_id_seq", startValue: 1000L); migrationBuilder.CreateSequence( name: "inventory_categories_id_seq", startValue: 100L); migrationBuilder.CreateSequence( name: "items_id_seq", startValue: 1000L); migrationBuilder.CreateSequence( name: "storage_location_id_seq"); migrationBuilder.CreateSequence( name: "units_id_seq", startValue: 100L); migrationBuilder.CreateTable( name: "access_groups", columns: table => new { access_group_id = table.Column <int>(nullable: false, defaultValueSql: "nextval('access_groups_id_seq'::regclass)"), name = table.Column <string>(nullable: true), description = table.Column <string>(nullable: true) }, constraints: table => { table.PrimaryKey("pk_access_groups", x => x.access_group_id); }); migrationBuilder.CreateTable( name: "currency_types", columns: table => new { currency_type_id = table.Column <int>(nullable: false, defaultValueSql: "nextval('currency_types_id_seq'::regclass)"), name = table.Column <string>(nullable: false), abbreviation = table.Column <string>(nullable: false), symbol = table.Column <string>(nullable: true) }, constraints: table => { table.PrimaryKey("pk_currency_types", x => x.currency_type_id); }); migrationBuilder.CreateTable( name: "inventory_categories", columns: table => new { inventory_category_id = table.Column <int>(nullable: false, defaultValueSql: "nextval('inventory_categories_id_seq'::regclass)"), name = table.Column <string>(nullable: false), description = table.Column <string>(nullable: true), sort_order = table.Column <int>(nullable: false), active = table.Column <bool>(nullable: false) }, constraints: table => { table.PrimaryKey("pk_inventory_categories", x => x.inventory_category_id); }); migrationBuilder.CreateTable( name: "roles", columns: table => new { id = table.Column <string>(nullable: false), name = table.Column <string>(maxLength: 256, nullable: true), normalized_name = table.Column <string>(maxLength: 256, nullable: true), concurrency_stamp = table.Column <string>(nullable: true), description = table.Column <string>(nullable: true), display_name = table.Column <string>(nullable: true) }, constraints: table => { table.PrimaryKey("pk_roles", x => x.id); }); migrationBuilder.CreateTable( name: "storage_locations", columns: table => new { storage_location_id = table.Column <int>(nullable: false, defaultValueSql: "nextval('storage_location_id_seq'::regclass)"), name = table.Column <string>(nullable: false), description = table.Column <string>(nullable: true), sort_order = table.Column <int>(nullable: false), active = table.Column <bool>(nullable: false) }, constraints: table => { table.PrimaryKey("pk_storage_locations", x => x.storage_location_id); }); migrationBuilder.CreateTable( name: "units", columns: table => new { unit_id = table.Column <int>(nullable: false, defaultValueSql: "nextval('units_id_seq'::regclass)"), name = table.Column <string>(nullable: false), abbreviation = table.Column <string>(nullable: false), sort_order = table.Column <int>(nullable: false), active = table.Column <bool>(nullable: false) }, constraints: table => { table.PrimaryKey("pk_units", x => x.unit_id); }); migrationBuilder.CreateTable( name: "users", columns: table => new { id = table.Column <string>(nullable: false), user_name = table.Column <string>(maxLength: 256, nullable: true), normalized_user_name = table.Column <string>(maxLength: 256, nullable: true), email = table.Column <string>(maxLength: 256, nullable: true), normalized_email = table.Column <string>(maxLength: 256, nullable: true), email_confirmed = table.Column <bool>(nullable: false), password_hash = table.Column <string>(nullable: true), security_stamp = table.Column <string>(nullable: true), concurrency_stamp = table.Column <string>(nullable: true), phone_number = table.Column <string>(nullable: true), phone_number_confirmed = table.Column <bool>(nullable: false), two_factor_enabled = table.Column <bool>(nullable: false), lockout_end = table.Column <DateTimeOffset>(nullable: true), lockout_enabled = table.Column <bool>(nullable: false), access_failed_count = table.Column <int>(nullable: false), active = table.Column <bool>(nullable: false) }, constraints: table => { table.PrimaryKey("pk_users", x => x.id); }); migrationBuilder.CreateTable( name: "access_group_roles", columns: table => new { access_group_id = table.Column <int>(nullable: false), role_id = table.Column <string>(nullable: false) }, constraints: table => { table.PrimaryKey("pk_access_group_roles", x => new { x.access_group_id, x.role_id }); table.ForeignKey( name: "fk_access_group_roles_access_groups_access_group_id", column: x => x.access_group_id, principalTable: "access_groups", principalColumn: "access_group_id", onDelete: ReferentialAction.Cascade); table.ForeignKey( name: "fk_access_group_roles_roles_role_id", column: x => x.role_id, principalTable: "roles", principalColumn: "id", onDelete: ReferentialAction.Cascade); }); migrationBuilder.CreateTable( name: "role_claims", columns: table => new { id = table.Column <int>(nullable: false) .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), role_id = table.Column <string>(nullable: false), claim_type = table.Column <string>(nullable: true), claim_value = table.Column <string>(nullable: true) }, constraints: table => { table.PrimaryKey("pk_role_claims", x => x.id); table.ForeignKey( name: "fk_role_claims_roles_role_id", column: x => x.role_id, principalTable: "roles", principalColumn: "id", onDelete: ReferentialAction.Cascade); }); migrationBuilder.CreateTable( name: "inventory_items", columns: table => new { inventory_item_id = table.Column <string>(nullable: false, defaultValueSql: "'I' || nextval('items_id_seq'::regclass)"), date_added = table.Column <DateTime>(nullable: true), added_by = table.Column <string>(nullable: true), date_updated = table.Column <DateTime>(nullable: true), updated_by = table.Column <string>(nullable: true), description = table.Column <string>(nullable: false), inventory_category_id = table.Column <int>(nullable: false), storage_location_id = table.Column <int>(nullable: true), quantity_purchased = table.Column <decimal>(nullable: false), unit_id = table.Column <int>(nullable: false), fob_cost = table.Column <decimal>(nullable: false), shipping_cost = table.Column <decimal>(nullable: false), import_cost = table.Column <decimal>(nullable: false), vat_cost = table.Column <decimal>(nullable: false), customer_purchased_for = table.Column <string>(nullable: false), customer_reserved_for = table.Column <string>(nullable: false), supplier = table.Column <string>(nullable: true), quantity_to_purchase_now = table.Column <string>(nullable: true), target_price = table.Column <string>(nullable: true), shipping_company = table.Column <string>(nullable: true), bonded_warehouse = table.Column <bool>(nullable: false), date_confirmed = table.Column <DateTime>(nullable: true), date_shipped = table.Column <DateTime>(nullable: true), date_arrived = table.Column <DateTime>(nullable: true), comments = table.Column <string>(nullable: true) }, constraints: table => { table.PrimaryKey("pk_inventory_items", x => x.inventory_item_id); table.ForeignKey( name: "fk_inventory_items_inventory_categories_inventory_category_id", column: x => x.inventory_category_id, principalTable: "inventory_categories", principalColumn: "inventory_category_id", onDelete: ReferentialAction.Restrict); table.ForeignKey( name: "fk_inventory_items_storage_locations_storage_location_id", column: x => x.storage_location_id, principalTable: "storage_locations", principalColumn: "storage_location_id", onDelete: ReferentialAction.Restrict); table.ForeignKey( name: "fk_inventory_items_units_unit_id", column: x => x.unit_id, principalTable: "units", principalColumn: "unit_id", onDelete: ReferentialAction.Cascade); }); migrationBuilder.CreateTable( name: "user_access_groups", columns: table => new { user_id = table.Column <string>(nullable: false), access_group_id = table.Column <int>(nullable: false) }, constraints: table => { table.PrimaryKey("pk_user_access_groups", x => new { x.access_group_id, x.user_id }); table.ForeignKey( name: "fk_user_access_groups_access_groups_access_group_id", column: x => x.access_group_id, principalTable: "access_groups", principalColumn: "access_group_id", onDelete: ReferentialAction.Cascade); table.ForeignKey( name: "fk_user_access_groups_users_user_id", column: x => x.user_id, principalTable: "users", principalColumn: "id", onDelete: ReferentialAction.Cascade); }); migrationBuilder.CreateTable( name: "user_claims", columns: table => new { id = table.Column <int>(nullable: false) .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), user_id = table.Column <string>(nullable: false), claim_type = table.Column <string>(nullable: true), claim_value = table.Column <string>(nullable: true) }, constraints: table => { table.PrimaryKey("pk_user_claims", x => x.id); table.ForeignKey( name: "fk_user_claims_users_user_id", column: x => x.user_id, principalTable: "users", principalColumn: "id", onDelete: ReferentialAction.Cascade); }); migrationBuilder.CreateTable( name: "user_logins", columns: table => new { login_provider = table.Column <string>(nullable: false), provider_key = table.Column <string>(nullable: false), provider_display_name = table.Column <string>(nullable: true), user_id = table.Column <string>(nullable: false) }, constraints: table => { table.PrimaryKey("pk_user_logins", x => new { x.login_provider, x.provider_key }); table.ForeignKey( name: "fk_user_logins_users_user_id", column: x => x.user_id, principalTable: "users", principalColumn: "id", onDelete: ReferentialAction.Cascade); }); migrationBuilder.CreateTable( name: "user_roles", columns: table => new { user_id = table.Column <string>(nullable: false), role_id = table.Column <string>(nullable: false) }, constraints: table => { table.PrimaryKey("pk_user_roles", x => new { x.user_id, x.role_id }); table.ForeignKey( name: "fk_user_roles_roles_role_id", column: x => x.role_id, principalTable: "roles", principalColumn: "id", onDelete: ReferentialAction.Cascade); table.ForeignKey( name: "fk_user_roles_users_user_id", column: x => x.user_id, principalTable: "users", principalColumn: "id", onDelete: ReferentialAction.Cascade); }); migrationBuilder.CreateTable( name: "user_tokens", columns: table => new { user_id = table.Column <string>(nullable: false), login_provider = table.Column <string>(nullable: false), name = table.Column <string>(nullable: false), value = table.Column <string>(nullable: true) }, constraints: table => { table.PrimaryKey("pk_user_tokens", x => new { x.user_id, x.login_provider, x.name }); table.ForeignKey( name: "fk_user_tokens_users_user_id", column: x => x.user_id, principalTable: "users", principalColumn: "id", onDelete: ReferentialAction.Cascade); }); migrationBuilder.CreateTable( name: "consumption_events", columns: table => new { consumption_event_id = table.Column <string>(nullable: false, defaultValueSql: "'CE' || nextval('consumption_events_id_seq'::regclass)"), date_added = table.Column <DateTime>(nullable: true), added_by = table.Column <string>(nullable: true), date_updated = table.Column <DateTime>(nullable: true), updated_by = table.Column <string>(nullable: true), quantity_consumed = table.Column <decimal>(nullable: false), consumed_by = table.Column <string>(nullable: false), date_consumed = table.Column <DateTime>(nullable: false), order_number = table.Column <string>(nullable: true), pattern_number = table.Column <string>(nullable: true), comments = table.Column <string>(nullable: true), inventory_item_id = table.Column <string>(nullable: false) }, constraints: table => { table.PrimaryKey("pk_consumption_events", x => x.consumption_event_id); table.ForeignKey( name: "fk_consumption_events_inventory_items_inventory_item_id", column: x => x.inventory_item_id, principalTable: "inventory_items", principalColumn: "inventory_item_id", onDelete: ReferentialAction.Cascade); }); migrationBuilder.CreateTable( name: "fabric_tests", columns: table => new { fabric_test_id = table.Column <string>(nullable: false, defaultValueSql: "nextval('fabric_tests_id_seq'::regclass)"), name = table.Column <string>(nullable: true), result = table.Column <string>(nullable: true), inventory_item_id = table.Column <string>(nullable: true) }, constraints: table => { table.PrimaryKey("pk_fabric_tests", x => x.fabric_test_id); table.ForeignKey( name: "fk_fabric_tests_inventory_items_inventory_item_id", column: x => x.inventory_item_id, principalTable: "inventory_items", principalColumn: "inventory_item_id", onDelete: ReferentialAction.Cascade); }); migrationBuilder.InsertData( table: "access_groups", columns: new[] { "access_group_id", "description", "name" }, values: new object[] { 1, null, "Administrator" }); migrationBuilder.InsertData( table: "currency_types", columns: new[] { "currency_type_id", "abbreviation", "name", "symbol" }, values: new object[] { 1, "NRP", "Nepali Rupees", "रु" }); migrationBuilder.InsertData( table: "inventory_categories", columns: new[] { "inventory_category_id", "active", "description", "name", "sort_order" }, values: new object[, ] { { 1, true, "", "Elastic", 1 }, { 2, true, "", "Fastener", 2 }, { 3, true, "", "Knit", 3 }, { 4, true, "", "Labels and Tags", 4 }, { 5, true, "", "Leather", 5 }, { 6, true, "", "Other", 6 }, { 7, true, "", "Thread", 7 }, { 8, true, "", "Woven", 8 }, { 9, true, "", "Zipper", 9 } }); migrationBuilder.InsertData( table: "roles", columns: new[] { "id", "concurrency_stamp", "description", "display_name", "name", "normalized_name" }, values: new object[, ] { { "f6bb4564-6919-484b-897b-4a2c994721e5", null, null, "Report Read", "Report_Read", "REPORT_READ" }, { "d9fe7909-63eb-496f-a81c-bcff6f0456c5", null, null, "Administrator Access", "Admin_Access", "ADMIN_ACCESS" }, { "d6206540-4ba5-4dce-a608-37ba6523be27", null, null, "Consumption Event Delete", "ConsumptionEvent_Delete", "CONSUMPTIONEVENT_DELETE" }, { "a8a0c676-d58e-4be3-94db-ca7a5198692a", null, null, "Consumption Event Update", "ConsumptionEvent_Edit", "CONSUMPTIONEVENT_EDIT" }, { "a56ff8b3-479f-4d1c-aed3-b1b7ec5d6998", null, null, "Consumption Event Read", "ConsumptionEvent_Read", "CONSUMPTIONEVENT_READ" }, { "a08e13a5-00a8-4d7d-9aaf-c0d3a816e48b", null, null, "Item Read", "Item_Read", "ITEM_READ" }, { "6ce169eb-8cfc-49da-9306-15e41ef13562", null, null, "Item Delete", "Item_Delete", "ITEM_DELETE" }, { "9de4e55f-b26c-4b62-812a-cf52000b97bf", null, null, "Item Update", "Item_Edit", "ITEM_EDIT" }, { "faffc6d3-f72f-4b64-b208-3c7cfec71270", null, null, "Item Create", "Item_Create", "ITEM_CREATE" }, { "bcabe6d9-e245-40f8-ad4a-38f76ee73614", null, null, "Consumption Event Create", "ConsumptionEvent_Create", "CONSUMPTIONEVENT_CREATE" } }); migrationBuilder.InsertData( table: "units", columns: new[] { "unit_id", "abbreviation", "active", "name", "sort_order" }, values: new object[, ] { { 4, "set", true, "set", 4 }, { 1, "kg", true, "kilogram", 1 }, { 2, "m", true, "meter", 2 }, { 3, "piece", true, "piece", 3 } }); migrationBuilder.InsertData( table: "users", columns: new[] { "id", "access_failed_count", "active", "concurrency_stamp", "email", "email_confirmed", "lockout_enabled", "lockout_end", "normalized_email", "normalized_user_name", "password_hash", "phone_number", "phone_number_confirmed", "security_stamp", "two_factor_enabled", "user_name" }, values: new object[] { "20551684-b958-4581-af23-96c1528b0e29", 0, true, "2cebd9d0-694d-4ed3-8dc2-384f41557310", "*****@*****.**", false, false, null, "*****@*****.**", "BOB", "AQAAAAEAACcQAAAAEI4jEmRsUYzL6KnpR2/OjIPvkI9BWNmnnCZYah1GFvB2EOCWkgkk49YqCJBz38N8rg==", null, false, "3YILVFJYDKC4OK7QLLR4TO4KT6V4ZK5E", false, "Bob" }); migrationBuilder.InsertData( table: "access_group_roles", columns: new[] { "access_group_id", "role_id" }, values: new object[, ] { { 1, "faffc6d3-f72f-4b64-b208-3c7cfec71270" }, { 1, "a08e13a5-00a8-4d7d-9aaf-c0d3a816e48b" }, { 1, "9de4e55f-b26c-4b62-812a-cf52000b97bf" }, { 1, "6ce169eb-8cfc-49da-9306-15e41ef13562" }, { 1, "bcabe6d9-e245-40f8-ad4a-38f76ee73614" }, { 1, "a56ff8b3-479f-4d1c-aed3-b1b7ec5d6998" }, { 1, "a8a0c676-d58e-4be3-94db-ca7a5198692a" }, { 1, "d6206540-4ba5-4dce-a608-37ba6523be27" }, { 1, "d9fe7909-63eb-496f-a81c-bcff6f0456c5" }, { 1, "f6bb4564-6919-484b-897b-4a2c994721e5" } }); migrationBuilder.InsertData( table: "user_access_groups", columns: new[] { "access_group_id", "user_id" }, values: new object[] { 1, "20551684-b958-4581-af23-96c1528b0e29" }); migrationBuilder.InsertData( table: "user_roles", columns: new[] { "user_id", "role_id" }, values: new object[, ] { { "20551684-b958-4581-af23-96c1528b0e29", "faffc6d3-f72f-4b64-b208-3c7cfec71270" }, { "20551684-b958-4581-af23-96c1528b0e29", "a08e13a5-00a8-4d7d-9aaf-c0d3a816e48b" }, { "20551684-b958-4581-af23-96c1528b0e29", "9de4e55f-b26c-4b62-812a-cf52000b97bf" }, { "20551684-b958-4581-af23-96c1528b0e29", "6ce169eb-8cfc-49da-9306-15e41ef13562" }, { "20551684-b958-4581-af23-96c1528b0e29", "bcabe6d9-e245-40f8-ad4a-38f76ee73614" }, { "20551684-b958-4581-af23-96c1528b0e29", "a56ff8b3-479f-4d1c-aed3-b1b7ec5d6998" }, { "20551684-b958-4581-af23-96c1528b0e29", "a8a0c676-d58e-4be3-94db-ca7a5198692a" }, { "20551684-b958-4581-af23-96c1528b0e29", "d6206540-4ba5-4dce-a608-37ba6523be27" }, { "20551684-b958-4581-af23-96c1528b0e29", "d9fe7909-63eb-496f-a81c-bcff6f0456c5" }, { "20551684-b958-4581-af23-96c1528b0e29", "f6bb4564-6919-484b-897b-4a2c994721e5" } }); migrationBuilder.CreateIndex( name: "ix_access_group_roles_role_id", table: "access_group_roles", column: "role_id"); migrationBuilder.CreateIndex( name: "ix_consumption_events_consumed_by", table: "consumption_events", column: "consumed_by"); migrationBuilder.CreateIndex( name: "ix_consumption_events_date_added", table: "consumption_events", column: "date_added"); migrationBuilder.CreateIndex( name: "ix_consumption_events_inventory_item_id", table: "consumption_events", column: "inventory_item_id"); migrationBuilder.CreateIndex( name: "ix_consumption_events_order_number", table: "consumption_events", column: "order_number"); migrationBuilder.CreateIndex( name: "ix_currency_types_abbreviation", table: "currency_types", column: "abbreviation", unique: true); migrationBuilder.CreateIndex( name: "ix_currency_types_name", table: "currency_types", column: "name", unique: true); migrationBuilder.CreateIndex( name: "ix_fabric_tests_inventory_item_id", table: "fabric_tests", column: "inventory_item_id"); migrationBuilder.CreateIndex( name: "ix_inventory_categories_name", table: "inventory_categories", column: "name", unique: true); migrationBuilder.CreateIndex( name: "ix_inventory_categories_sort_order", table: "inventory_categories", column: "sort_order", unique: true); migrationBuilder.CreateIndex( name: "ix_inventory_items_inventory_category_id", table: "inventory_items", column: "inventory_category_id"); migrationBuilder.CreateIndex( name: "ix_inventory_items_storage_location_id", table: "inventory_items", column: "storage_location_id"); migrationBuilder.CreateIndex( name: "ix_inventory_items_unit_id", table: "inventory_items", column: "unit_id"); migrationBuilder.CreateIndex( name: "ix_role_claims_role_id", table: "role_claims", column: "role_id"); migrationBuilder.CreateIndex( name: "role_name_index", table: "roles", column: "normalized_name", unique: true); migrationBuilder.CreateIndex( name: "ix_units_abbreviation", table: "units", column: "abbreviation", unique: true); migrationBuilder.CreateIndex( name: "ix_units_name", table: "units", column: "name", unique: true); migrationBuilder.CreateIndex( name: "ix_units_sort_order", table: "units", column: "sort_order", unique: true); migrationBuilder.CreateIndex( name: "ix_user_access_groups_user_id", table: "user_access_groups", column: "user_id"); migrationBuilder.CreateIndex( name: "ix_user_claims_user_id", table: "user_claims", column: "user_id"); migrationBuilder.CreateIndex( name: "ix_user_logins_user_id", table: "user_logins", column: "user_id"); migrationBuilder.CreateIndex( name: "ix_user_roles_role_id", table: "user_roles", column: "role_id"); migrationBuilder.CreateIndex( name: "email_index", table: "users", column: "normalized_email"); migrationBuilder.CreateIndex( name: "user_name_index", table: "users", column: "normalized_user_name", unique: true); }
ed override void Up(MigrationBuilder migrationBuilder) { migrationBuilder.AlterDatabase() .Annotation("Npgsql:Enum:state", "qld,nsw,vic,tas,wa,sa,nt") .Annotation("Npgsql:PostgresExtension:uuid-ossp", ",,"); migrationBuilder.CreateTable( name: "__Files", columns: table => new { Id = table.Column <Guid>(nullable: false, defaultValueSql: "uuid_generate_v4()"), Created = table.Column <DateTime>(nullable: false, defaultValueSql: "CURRENT_TIMESTAMP"), Modified = table.Column <DateTime>(nullable: false, defaultValueSql: "CURRENT_TIMESTAMP"), Container = table.Column <string>(nullable: false), FileId = table.Column <string>(nullable: false), FileName = table.Column <string>(nullable: false), ContentType = table.Column <string>(nullable: true), Length = table.Column <long>(nullable: false) }, constraints: table => { table.PrimaryKey("PK___Files", x => x.Id); }); migrationBuilder.CreateTable( name: "AspNetRoles", columns: table => new { Id = table.Column <Guid>(nullable: false, defaultValueSql: "uuid_generate_v4()"), Name = table.Column <string>(maxLength: 256, nullable: true), NormalizedName = table.Column <string>(maxLength: 256, nullable: true), ConcurrencyStamp = table.Column <string>(nullable: true), HasBackendAccess = table.Column <bool>(nullable: true) }, constraints: table => { table.PrimaryKey("PK_AspNetRoles", x => x.Id); }); migrationBuilder.CreateTable( name: "AspNetUsers", columns: table => new { Id = table.Column <Guid>(nullable: false, defaultValueSql: "uuid_generate_v4()"), NormalizedUserName = table.Column <string>(maxLength: 256, nullable: true), NormalizedEmail = table.Column <string>(maxLength: 256, nullable: true), EmailConfirmed = table.Column <bool>(nullable: false), SecurityStamp = table.Column <string>(nullable: true), ConcurrencyStamp = table.Column <string>(nullable: true), PhoneNumber = table.Column <string>(nullable: true), PhoneNumberConfirmed = table.Column <bool>(nullable: false), TwoFactorEnabled = table.Column <bool>(nullable: false), LockoutEnd = table.Column <DateTimeOffset>(nullable: true), LockoutEnabled = table.Column <bool>(nullable: false), AccessFailedCount = table.Column <int>(nullable: false), Created = table.Column <DateTime>(nullable: false, defaultValueSql: "CURRENT_TIMESTAMP"), Modified = table.Column <DateTime>(nullable: false, defaultValueSql: "CURRENT_TIMESTAMP"), Owner = table.Column <Guid>(nullable: false), UserName = table.Column <string>(maxLength: 256, nullable: false), Email = table.Column <string>(maxLength: 256, nullable: true), Discriminator = table.Column <string>(nullable: false), PasswordHash = table.Column <string>(nullable: true) }, constraints: table => { table.PrimaryKey("PK_AspNetUsers", x => x.Id); }); migrationBuilder.CreateTable( name: "DataionKeys", columns: table => new { Id = table.Column <int>(nullable: false) .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), FriendlyName = table.Column <string>(nullable: true), Xml = table.Column <string>(nullable: true) }, constraints: table => { table.PrimaryKey("PK_DataionKeys", x => x.Id); }); migrationBuilder.CreateTable( name: "Farm", columns: table => new { Id = table.Column <Guid>(nullable: false, defaultValueSql: "uuid_generate_v4()"), Owner = table.Column <Guid>(nullable: false), Created = table.Column <DateTime>(nullable: false, defaultValueSql: "CURRENT_TIMESTAMP"), Modified = table.Column <DateTime>(nullable: false, defaultValueSql: "CURRENT_TIMESTAMP"), Name = table.Column <string>(nullable: true), State = table.Column <State>(nullable: false) }, constraints: table => { table.PrimaryKey("PK_Farm", x => x.Id); }); migrationBuilder.CreateTable( name: "NewsArticle", columns: table => new { Id = table.Column <Guid>(nullable: false, defaultValueSql: "uuid_generate_v4()"), Owner = table.Column <Guid>(nullable: false), Created = table.Column <DateTime>(nullable: false, defaultValueSql: "CURRENT_TIMESTAMP"), Modified = table.Column <DateTime>(nullable: false, defaultValueSql: "CURRENT_TIMESTAMP"), Title = table.Column <string>(nullable: true), Content = table.Column <string>(nullable: true), Qld = table.Column <bool>(nullable: true), Nsw = table.Column <bool>(nullable: true), Vic = table.Column <bool>(nullable: true), Tas = table.Column <bool>(nullable: true), Wa = table.Column <bool>(nullable: true), Sa = table.Column <bool>(nullable: true), Nt = table.Column <bool>(nullable: true) }, constraints: table => { table.PrimaryKey("PK_NewsArticle", x => x.Id); }); migrationBuilder.CreateTable( name: "OpenIddictApplications", columns: table => new { Id = table.Column <Guid>(nullable: false), ClientId = table.Column <string>(maxLength: 100, nullable: false), ClientSecret = table.Column <string>(nullable: true), ConcurrencyToken = table.Column <string>(maxLength: 50, nullable: true), ConsentType = table.Column <string>(nullable: true), DisplayName = table.Column <string>(nullable: true), Permissions = table.Column <string>(nullable: true), PostLogoutRedirectUris = table.Column <string>(nullable: true), Properties = table.Column <string>(nullable: true), RedirectUris = table.Column <string>(nullable: true), Type = table.Column <string>(maxLength: 25, nullable: false) }, constraints: table => { table.PrimaryKey("PK_OpenIddictApplications", x => x.Id); }); migrationBuilder.CreateTable( name: "OpenIddictScopes", columns: table => new { Id = table.Column <Guid>(nullable: false), ConcurrencyToken = table.Column <string>(maxLength: 50, nullable: true), Description = table.Column <string>(nullable: true), DisplayName = table.Column <string>(nullable: true), Name = table.Column <string>(maxLength: 200, nullable: false), Properties = table.Column <string>(nullable: true), Resources = table.Column <string>(nullable: true) }, constraints: table => { table.PrimaryKey("PK_OpenIddictScopes", x => x.Id); }); migrationBuilder.CreateTable( name: "AspNetRoleClaims", columns: table => new { Id = table.Column <int>(nullable: false) .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), RoleId = table.Column <Guid>(nullable: false), ClaimType = table.Column <string>(nullable: true), ClaimValue = table.Column <string>(nullable: true) }, constraints: table => { table.PrimaryKey("PK_AspNetRoleClaims", x => x.Id); table.ForeignKey( name: "FK_AspNetRoleClaims_AspNetRoles_RoleId", column: x => x.RoleId, principalTable: "AspNetRoles", principalColumn: "Id", onDelete: ReferentialAction.Cascade); }); migrationBuilder.CreateTable( name: "AspNetUserClaims", columns: table => new { Id = table.Column <int>(nullable: false) .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), UserId = table.Column <Guid>(nullable: false), ClaimType = table.Column <string>(nullable: true), ClaimValue = table.Column <string>(nullable: true) }, constraints: table => { table.PrimaryKey("PK_AspNetUserClaims", x => x.Id); table.ForeignKey( name: "FK_AspNetUserClaims_AspNetUsers_UserId", column: x => x.UserId, principalTable: "AspNetUsers", principalColumn: "Id", onDelete: ReferentialAction.Cascade); }); migrationBuilder.CreateTable( name: "AspNetUserLogins", columns: table => new { LoginProvider = table.Column <string>(nullable: false), ProviderKey = table.Column <string>(nullable: false), ProviderDisplayName = table.Column <string>(nullable: true), UserId = table.Column <Guid>(nullable: false) }, constraints: table => { table.PrimaryKey("PK_AspNetUserLogins", x => new { x.LoginProvider, x.ProviderKey }); table.ForeignKey( name: "FK_AspNetUserLogins_AspNetUsers_UserId", column: x => x.UserId, principalTable: "AspNetUsers", principalColumn: "Id", onDelete: ReferentialAction.Cascade); }); migrationBuilder.CreateTable( name: "AspNetUserRoles", columns: table => new { UserId = table.Column <Guid>(nullable: false), RoleId = table.Column <Guid>(nullable: false) }, constraints: table => { table.PrimaryKey("PK_AspNetUserRoles", x => new { x.UserId, x.RoleId }); table.ForeignKey( name: "FK_AspNetUserRoles_AspNetRoles_RoleId", column: x => x.RoleId, principalTable: "AspNetRoles", principalColumn: "Id", onDelete: ReferentialAction.Cascade); table.ForeignKey( name: "FK_AspNetUserRoles_AspNetUsers_UserId", column: x => x.UserId, principalTable: "AspNetUsers", principalColumn: "Id", onDelete: ReferentialAction.Cascade); }); migrationBuilder.CreateTable( name: "AspNetUserTokens", columns: table => new { UserId = table.Column <Guid>(nullable: false), LoginProvider = table.Column <string>(nullable: false), Name = table.Column <string>(nullable: false), Value = table.Column <string>(nullable: true) }, constraints: table => { table.PrimaryKey("PK_AspNetUserTokens", x => new { x.UserId, x.LoginProvider, x.Name }); table.ForeignKey( name: "FK_AspNetUserTokens_AspNetUsers_UserId", column: x => x.UserId, principalTable: "AspNetUsers", principalColumn: "Id", onDelete: ReferentialAction.Cascade); }); migrationBuilder.CreateTable( name: "FarmersFarms", columns: table => new { Id = table.Column <Guid>(nullable: false, defaultValueSql: "uuid_generate_v4()"), Created = table.Column <DateTime>(nullable: false, defaultValueSql: "CURRENT_TIMESTAMP"), Modified = table.Column <DateTime>(nullable: false, defaultValueSql: "CURRENT_TIMESTAMP"), Owner = table.Column <Guid>(nullable: false), FarmersId = table.Column <Guid>(nullable: false), FarmsId = table.Column <Guid>(nullable: false) }, constraints: table => { table.PrimaryKey("PK_FarmersFarms", x => x.Id); table.ForeignKey( name: "FK_FarmersFarms_AspNetUsers_FarmersId", column: x => x.FarmersId, principalTable: "AspNetUsers", principalColumn: "Id", onDelete: ReferentialAction.Cascade); table.ForeignKey( name: "FK_FarmersFarms_Farm_FarmsId", column: x => x.FarmsId, principalTable: "Farm", principalColumn: "Id", onDelete: ReferentialAction.Cascade); }); migrationBuilder.CreateTable( name: "MilkTest", columns: table => new { Id = table.Column <Guid>(nullable: false, defaultValueSql: "uuid_generate_v4()"), Owner = table.Column <Guid>(nullable: false), Created = table.Column <DateTime>(nullable: false, defaultValueSql: "CURRENT_TIMESTAMP"), Modified = table.Column <DateTime>(nullable: false, defaultValueSql: "CURRENT_TIMESTAMP"), Time = table.Column <DateTime>(nullable: true), Volume = table.Column <int>(nullable: true), Temperature = table.Column <double>(nullable: true), MilkFat = table.Column <double>(nullable: true), Protein = table.Column <double>(nullable: true), FarmId = table.Column <Guid>(nullable: true) }, constraints: table => { table.PrimaryKey("PK_MilkTest", x => x.Id); table.ForeignKey( name: "FK_MilkTest_Farm_FarmId", column: x => x.FarmId, principalTable: "Farm", principalColumn: "Id", onDelete: ReferentialAction.Restrict); }); migrationBuilder.CreateTable( name: "OpenIddictAuthorizations", columns: table => new { Id = table.Column <Guid>(nullable: false), ApplicationId = table.Column <Guid>(nullable: true), ConcurrencyToken = table.Column <string>(maxLength: 50, nullable: true), Properties = table.Column <string>(nullable: true), Scopes = table.Column <string>(nullable: true), Status = table.Column <string>(maxLength: 25, nullable: false), Subject = table.Column <string>(maxLength: 450, nullable: false), Type = table.Column <string>(maxLength: 25, nullable: false) }, constraints: table => { table.PrimaryKey("PK_OpenIddictAuthorizations", x => x.Id); table.ForeignKey( name: "FK_OpenIddictAuthorizations_OpenIddictApplications_Application~", column: x => x.ApplicationId, principalTable: "OpenIddictApplications", principalColumn: "Id", onDelete: ReferentialAction.Restrict); }); migrationBuilder.CreateTable( name: "OpenIddictTokens", columns: table => new { Id = table.Column <Guid>(nullable: false), ApplicationId = table.Column <Guid>(nullable: true), AuthorizationId = table.Column <Guid>(nullable: true), ConcurrencyToken = table.Column <string>(maxLength: 50, nullable: true), CreationDate = table.Column <DateTimeOffset>(nullable: true), ExpirationDate = table.Column <DateTimeOffset>(nullable: true), Payload = table.Column <string>(nullable: true), Properties = table.Column <string>(nullable: true), ReferenceId = table.Column <string>(maxLength: 100, nullable: true), Status = table.Column <string>(maxLength: 25, nullable: false), Subject = table.Column <string>(maxLength: 450, nullable: false), Type = table.Column <string>(maxLength: 25, nullable: false) }, constraints: table => { table.PrimaryKey("PK_OpenIddictTokens", x => x.Id); table.ForeignKey( name: "FK_OpenIddictTokens_OpenIddictApplications_ApplicationId", column: x => x.ApplicationId, principalTable: "OpenIddictApplications", principalColumn: "Id", onDelete: ReferentialAction.Restrict); table.ForeignKey( name: "FK_OpenIddictTokens_OpenIddictAuthorizations_AuthorizationId", column: x => x.AuthorizationId, principalTable: "OpenIddictAuthorizations", principalColumn: "Id", onDelete: ReferentialAction.Restrict); }); migrationBuilder.CreateIndex( name: "IX_AspNetRoleClaims_RoleId", table: "AspNetRoleClaims", column: "RoleId"); migrationBuilder.CreateIndex( name: "RoleNameIndex", table: "AspNetRoles", column: "NormalizedName", unique: true); migrationBuilder.CreateIndex( name: "IX_AspNetUserClaims_UserId", table: "AspNetUserClaims", column: "UserId"); migrationBuilder.CreateIndex( name: "IX_AspNetUserLogins_UserId", table: "AspNetUserLogins", column: "UserId"); migrationBuilder.CreateIndex( name: "IX_AspNetUserRoles_RoleId", table: "AspNetUserRoles", column: "RoleId"); migrationBuilder.CreateIndex( name: "IX_AspNetUsers_Discriminator", table: "AspNetUsers", column: "Discriminator"); migrationBuilder.CreateIndex( name: "EmailIndex", table: "AspNetUsers", column: "NormalizedEmail"); migrationBuilder.CreateIndex( name: "UserNameIndex", table: "AspNetUsers", column: "NormalizedUserName", unique: true); migrationBuilder.CreateIndex( name: "IX_FarmersFarms_FarmersId", table: "FarmersFarms", column: "FarmersId"); migrationBuilder.CreateIndex( name: "IX_FarmersFarms_FarmsId", table: "FarmersFarms", column: "FarmsId"); migrationBuilder.CreateIndex( name: "IX_MilkTest_FarmId", table: "MilkTest", column: "FarmId"); migrationBuilder.CreateIndex( name: "IX_OpenIddictApplications_ClientId", table: "OpenIddictApplications", column: "ClientId", unique: true); migrationBuilder.CreateIndex( name: "IX_OpenIddictAuthorizations_ApplicationId_Status_Subject_Type", table: "OpenIddictAuthorizations", columns: new[] { "ApplicationId", "Status", "Subject", "Type" }); migrationBuilder.CreateIndex( name: "IX_OpenIddictScopes_Name", table: "OpenIddictScopes", column: "Name", unique: true); migrationBuilder.CreateIndex( name: "IX_OpenIddictTokens_AuthorizationId", table: "OpenIddictTokens", column: "AuthorizationId"); migrationBuilder.CreateIndex( name: "IX_OpenIddictTokens_ReferenceId", table: "OpenIddictTokens", column: "ReferenceId", unique: true); migrationBuilder.CreateIndex( name: "IX_OpenIddictTokens_ApplicationId_Status_Subject_Type", table: "OpenIddictTokens", columns: new[] { "ApplicationId", "Status", "Subject", "Type" }); }
protected override void Up(MigrationBuilder migrationBuilder) { migrationBuilder.AlterDatabase() .Annotation("Npgsql:Enum:subscriptions", "email,vk"); }
protected override void Up(MigrationBuilder migrationBuilder) { migrationBuilder.AlterDatabase() .Annotation("Npgsql:PostgresExtension:pgcrypto", ",,") .Annotation("Npgsql:PostgresExtension:uuid-ossp", ",,"); }
protected override void Up(MigrationBuilder migrationBuilder) { migrationBuilder.DropForeignKey( name: "FK_Roleplays_Servers_ServerID", schema: "RoleplayModule", table: "Roleplays"); migrationBuilder.DropForeignKey( name: "FK_Roleplays_Users_OwnerID", schema: "RoleplayModule", table: "Roleplays"); migrationBuilder.DropForeignKey( name: "FK_ServerSettings_Servers_ServerID", schema: "RoleplayModule", table: "ServerSettings"); migrationBuilder.DropForeignKey( name: "FK_UserMessages_Users_AuthorID", schema: "RoleplayModule", table: "UserMessages"); migrationBuilder.AlterDatabase() .Annotation("Npgsql:PostgresExtension:fuzzystrmatch", ",,"); migrationBuilder.AlterColumn <long>( name: "AuthorID", schema: "RoleplayModule", table: "UserMessages", type: "bigint", nullable: false, defaultValue: 0L, oldClrType: typeof(long), oldType: "bigint", oldNullable: true); migrationBuilder.AlterColumn <long>( name: "ServerID", schema: "RoleplayModule", table: "ServerSettings", type: "bigint", nullable: false, defaultValue: 0L, oldClrType: typeof(long), oldType: "bigint", oldNullable: true); migrationBuilder.AlterColumn <long>( name: "ServerID", schema: "RoleplayModule", table: "Roleplays", type: "bigint", nullable: false, defaultValue: 0L, oldClrType: typeof(long), oldType: "bigint", oldNullable: true); migrationBuilder.AlterColumn <long>( name: "OwnerID", schema: "RoleplayModule", table: "Roleplays", type: "bigint", nullable: false, defaultValue: 0L, oldClrType: typeof(long), oldType: "bigint", oldNullable: true); migrationBuilder.AlterColumn <DateTimeOffset>( name: "LastUpdated", schema: "RoleplayModule", table: "Roleplays", type: "timestamp with time zone", nullable: true, oldClrType: typeof(DateTime), oldType: "timestamp without time zone", oldNullable: true); migrationBuilder.AddForeignKey( name: "FK_Roleplays_Servers_ServerID", schema: "RoleplayModule", table: "Roleplays", column: "ServerID", principalSchema: "Core", principalTable: "Servers", principalColumn: "ID", onDelete: ReferentialAction.Cascade); migrationBuilder.AddForeignKey( name: "FK_Roleplays_Users_OwnerID", schema: "RoleplayModule", table: "Roleplays", column: "OwnerID", principalSchema: "Core", principalTable: "Users", principalColumn: "ID", onDelete: ReferentialAction.Cascade); migrationBuilder.AddForeignKey( name: "FK_ServerSettings_Servers_ServerID", schema: "RoleplayModule", table: "ServerSettings", column: "ServerID", principalSchema: "Core", principalTable: "Servers", principalColumn: "ID", onDelete: ReferentialAction.Cascade); migrationBuilder.AddForeignKey( name: "FK_UserMessages_Users_AuthorID", schema: "RoleplayModule", table: "UserMessages", column: "AuthorID", principalSchema: "Core", principalTable: "Users", principalColumn: "ID", onDelete: ReferentialAction.Cascade); }
protected override void Up(MigrationBuilder migrationBuilder) { migrationBuilder.AlterDatabase() .Annotation("Npgsql:Enum:clan_role", "unknown,commander,executive_officer,recruitment_officer,commissioned_officer,officer,private") .Annotation("Npgsql:Enum:mod_action_type", "deletion,update") .Annotation("Npgsql:Enum:notification_type", "unknown,other,post_added,post_edited,post_deleted,post_mod_edited,post_mod_deleted,platform_ban") .OldAnnotation("Npgsql:Enum:mod_action_type", "deletion,update") .OldAnnotation("Npgsql:Enum:notification_type", "unknown,other,post_added,post_edited,post_deleted,post_mod_edited,post_mod_deleted,platform_ban"); migrationBuilder.CreateTable( name: "Clans", columns: table => new { Id = table.Column <long>(type: "bigint", nullable: false), Tag = table.Column <string>(type: "text", nullable: true), Name = table.Column <string>(type: "text", nullable: true), Description = table.Column <string>(type: "text", nullable: true), LeagueColor = table.Column <long>(type: "bigint", nullable: false), IsDisbanded = table.Column <bool>(type: "boolean", nullable: false), CreatedAt = table.Column <DateTime>(type: "timestamp with time zone", nullable: false, defaultValueSql: "NOW()"), UpdatedAt = table.Column <DateTime>(type: "timestamp with time zone", nullable: false), MembersUpdatedAt = table.Column <DateTime>(type: "timestamp with time zone", nullable: false) }, constraints: table => { table.PrimaryKey("PK_Clans", x => x.Id); }); migrationBuilder.CreateTable( name: "ClanMembers", columns: table => new { Id = table.Column <Guid>(type: "uuid", nullable: false), PlayerId = table.Column <long>(type: "bigint", nullable: false), ClanId = table.Column <long>(type: "bigint", nullable: false), JoinedAt = table.Column <DateOnly>(type: "date", nullable: false), LeftAt = table.Column <DateOnly>(type: "date", nullable: true), Role = table.Column <ClanRole>(type: "clan_role", nullable: false) }, constraints: table => { table.PrimaryKey("PK_ClanMembers", x => x.Id); table.ForeignKey( name: "FK_ClanMembers_Clans_ClanId", column: x => x.ClanId, principalTable: "Clans", principalColumn: "Id", onDelete: ReferentialAction.Cascade); table.ForeignKey( name: "FK_ClanMembers_Players_PlayerId", column: x => x.PlayerId, principalTable: "Players", principalColumn: "Id", onDelete: ReferentialAction.Cascade); }); migrationBuilder.CreateIndex( name: "IX_ClanMembers_ClanId", table: "ClanMembers", column: "ClanId"); migrationBuilder.CreateIndex( name: "IX_ClanMembers_PlayerId", table: "ClanMembers", column: "PlayerId", unique: true); }
protected override void Up(MigrationBuilder migrationBuilder) { migrationBuilder.AlterDatabase() .Annotation("Npgsql:PostgresExtension:uuid-ossp", "'uuid-ossp', '', ''"); migrationBuilder.CreateTable( name: "ApplicationTypes", columns: table => new { Id = table.Column <int>(nullable: false) .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.SerialColumn), Name = table.Column <string>(nullable: true), Description = table.Column <string>(nullable: true) }, constraints: table => { table.PrimaryKey("PK_ApplicationTypes", x => x.Id); }); migrationBuilder.CreateTable( name: "Emails", columns: table => new { Id = table.Column <int>(nullable: false) .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.SerialColumn), To = table.Column <string>(nullable: true), Cc = table.Column <string>(nullable: true), Bcc = table.Column <string>(nullable: true), Subject = table.Column <string>(nullable: true), ContentTemplate = table.Column <string>(nullable: true), ContentModelJson = table.Column <string>(nullable: true), Created = table.Column <DateTime>(nullable: false) }, constraints: table => { table.PrimaryKey("PK_Emails", x => x.Id); }); migrationBuilder.CreateTable( name: "OrganizationInviteRequests", columns: table => new { Id = table.Column <int>(nullable: false) .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.SerialColumn), Name = table.Column <string>(nullable: true), OrgAdminEmail = table.Column <string>(nullable: true), WebsiteUrl = table.Column <string>(nullable: true), DateCreated = table.Column <DateTime>(nullable: true), DateUpdated = table.Column <DateTime>(nullable: true) }, constraints: table => { table.PrimaryKey("PK_OrganizationInviteRequests", x => x.Id); }); migrationBuilder.CreateTable( name: "OrganizationInvites", columns: table => new { Id = table.Column <int>(nullable: false) .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.SerialColumn), Name = table.Column <string>(nullable: true), OwnerEmail = table.Column <string>(nullable: true), Token = table.Column <string>(nullable: true) }, constraints: table => { table.PrimaryKey("PK_OrganizationInvites", x => x.Id); }); migrationBuilder.CreateTable( name: "Roles", columns: table => new { Id = table.Column <int>(nullable: false) .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.SerialColumn), RoleName = table.Column <int>(nullable: false) }, constraints: table => { table.PrimaryKey("PK_Roles", x => x.Id); }); migrationBuilder.CreateTable( name: "StoreTypes", columns: table => new { Id = table.Column <int>(nullable: false) .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.SerialColumn), Name = table.Column <string>(nullable: true), Description = table.Column <string>(nullable: true) }, constraints: table => { table.PrimaryKey("PK_StoreTypes", x => x.Id); }); migrationBuilder.CreateTable( name: "SystemStatuses", columns: table => new { Id = table.Column <int>(nullable: false) .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.SerialColumn), BuildEngineUrl = table.Column <string>(nullable: true), BuildEngineApiAccessToken = table.Column <string>(nullable: true), SystemAvailable = table.Column <bool>(nullable: false), DateCreated = table.Column <DateTime>(nullable: true), DateUpdated = table.Column <DateTime>(nullable: true) }, constraints: table => { table.PrimaryKey("PK_SystemStatuses", x => x.Id); }); migrationBuilder.CreateTable( name: "Users", columns: table => new { Id = table.Column <int>(nullable: false) .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.SerialColumn), Name = table.Column <string>(nullable: true), GivenName = table.Column <string>(nullable: true), FamilyName = table.Column <string>(nullable: true), Email = table.Column <string>(nullable: true), Phone = table.Column <string>(nullable: true), Timezone = table.Column <string>(nullable: true), Locale = table.Column <string>(nullable: true), IsLocked = table.Column <bool>(nullable: false), ExternalId = table.Column <string>(nullable: true), ProfileVisibility = table.Column <int>(nullable: false, defaultValue: 1), EmailNotification = table.Column <bool>(nullable: true, defaultValue: true), PublishingKey = table.Column <string>(nullable: true), WorkflowUserId = table.Column <Guid>(nullable: true), DateCreated = table.Column <DateTime>(nullable: true), DateUpdated = table.Column <DateTime>(nullable: true) }, constraints: table => { table.PrimaryKey("PK_Users", x => x.Id); }); migrationBuilder.CreateTable( name: "StoreLanguages", columns: table => new { Id = table.Column <int>(nullable: false) .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.SerialColumn), Name = table.Column <string>(nullable: true), Description = table.Column <string>(nullable: true), StoreTypeId = table.Column <int>(nullable: false) }, constraints: table => { table.PrimaryKey("PK_StoreLanguages", x => x.Id); table.ForeignKey( name: "FK_StoreLanguages_StoreTypes_StoreTypeId", column: x => x.StoreTypeId, principalTable: "StoreTypes", principalColumn: "Id", onDelete: ReferentialAction.Cascade); }); migrationBuilder.CreateTable( name: "Stores", columns: table => new { Id = table.Column <int>(nullable: false) .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.SerialColumn), Name = table.Column <string>(nullable: true), Description = table.Column <string>(nullable: true), StoreTypeId = table.Column <int>(nullable: false) }, constraints: table => { table.PrimaryKey("PK_Stores", x => x.Id); table.ForeignKey( name: "FK_Stores_StoreTypes_StoreTypeId", column: x => x.StoreTypeId, principalTable: "StoreTypes", principalColumn: "Id", onDelete: ReferentialAction.Cascade); }); migrationBuilder.CreateTable( name: "WorkflowDefinitions", columns: table => new { Id = table.Column <int>(nullable: false) .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.SerialColumn), Name = table.Column <string>(nullable: true), Enabled = table.Column <bool>(nullable: false), Description = table.Column <string>(nullable: true), WorkflowScheme = table.Column <string>(nullable: true), WorkflowBusinessFlow = table.Column <string>(nullable: true), StoreTypeId = table.Column <int>(nullable: true) }, constraints: table => { table.PrimaryKey("PK_WorkflowDefinitions", x => x.Id); table.ForeignKey( name: "FK_WorkflowDefinitions_StoreTypes_StoreTypeId", column: x => x.StoreTypeId, principalTable: "StoreTypes", principalColumn: "Id", onDelete: ReferentialAction.Restrict); }); migrationBuilder.CreateTable( name: "Organizations", columns: table => new { Id = table.Column <int>(nullable: false) .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.SerialColumn), Name = table.Column <string>(nullable: true), WebsiteUrl = table.Column <string>(nullable: true), BuildEngineUrl = table.Column <string>(nullable: true), BuildEngineApiAccessToken = table.Column <string>(nullable: true), LogoUrl = table.Column <string>(nullable: true), UseSilBuildInfrastructure = table.Column <bool>(nullable: true, defaultValue: true), PublicByDefault = table.Column <bool>(nullable: true, defaultValue: true), OwnerId = table.Column <int>(nullable: false) }, constraints: table => { table.PrimaryKey("PK_Organizations", x => x.Id); table.ForeignKey( name: "FK_Organizations_Users_OwnerId", column: x => x.OwnerId, principalTable: "Users", principalColumn: "Id", onDelete: ReferentialAction.Cascade); }); migrationBuilder.CreateTable( name: "ProductDefinitions", columns: table => new { Id = table.Column <int>(nullable: false) .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.SerialColumn), Name = table.Column <string>(nullable: true), TypeId = table.Column <int>(nullable: false), Description = table.Column <string>(nullable: true), WorkflowId = table.Column <int>(nullable: false) }, constraints: table => { table.PrimaryKey("PK_ProductDefinitions", x => x.Id); table.ForeignKey( name: "FK_ProductDefinitions_ApplicationTypes_TypeId", column: x => x.TypeId, principalTable: "ApplicationTypes", principalColumn: "Id", onDelete: ReferentialAction.Cascade); table.ForeignKey( name: "FK_ProductDefinitions_WorkflowDefinitions_WorkflowId", column: x => x.WorkflowId, principalTable: "WorkflowDefinitions", principalColumn: "Id", onDelete: ReferentialAction.Cascade); }); migrationBuilder.CreateTable( name: "Groups", columns: table => new { Id = table.Column <int>(nullable: false) .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.SerialColumn), Name = table.Column <string>(nullable: true), Abbreviation = table.Column <string>(nullable: true), OwnerId = table.Column <int>(nullable: false) }, constraints: table => { table.PrimaryKey("PK_Groups", x => x.Id); table.ForeignKey( name: "FK_Groups_Organizations_OwnerId", column: x => x.OwnerId, principalTable: "Organizations", principalColumn: "Id", onDelete: ReferentialAction.Cascade); }); migrationBuilder.CreateTable( name: "OrganizationMemberships", columns: table => new { Id = table.Column <int>(nullable: false) .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.SerialColumn), UserId = table.Column <int>(nullable: false), OrganizationId = table.Column <int>(nullable: false) }, constraints: table => { table.PrimaryKey("PK_OrganizationMemberships", x => x.Id); table.ForeignKey( name: "FK_OrganizationMemberships_Organizations_OrganizationId", column: x => x.OrganizationId, principalTable: "Organizations", principalColumn: "Id", onDelete: ReferentialAction.Cascade); table.ForeignKey( name: "FK_OrganizationMemberships_Users_UserId", column: x => x.UserId, principalTable: "Users", principalColumn: "Id", onDelete: ReferentialAction.Cascade); }); migrationBuilder.CreateTable( name: "OrganizationStores", columns: table => new { Id = table.Column <int>(nullable: false) .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.SerialColumn), OrganizationId = table.Column <int>(nullable: false), StoreId = table.Column <int>(nullable: false) }, constraints: table => { table.PrimaryKey("PK_OrganizationStores", x => x.Id); table.ForeignKey( name: "FK_OrganizationStores_Organizations_OrganizationId", column: x => x.OrganizationId, principalTable: "Organizations", principalColumn: "Id", onDelete: ReferentialAction.Cascade); table.ForeignKey( name: "FK_OrganizationStores_Stores_StoreId", column: x => x.StoreId, principalTable: "Stores", principalColumn: "Id", onDelete: ReferentialAction.Cascade); }); migrationBuilder.CreateTable( name: "UserRoles", columns: table => new { Id = table.Column <int>(nullable: false) .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.SerialColumn), UserId = table.Column <int>(nullable: false), RoleId = table.Column <int>(nullable: false), OrganizationId = table.Column <int>(nullable: false) }, constraints: table => { table.PrimaryKey("PK_UserRoles", x => x.Id); table.ForeignKey( name: "FK_UserRoles_Organizations_OrganizationId", column: x => x.OrganizationId, principalTable: "Organizations", principalColumn: "Id", onDelete: ReferentialAction.Cascade); 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: "OrganizationProductDefinitions", columns: table => new { Id = table.Column <int>(nullable: false) .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.SerialColumn), OrganizationId = table.Column <int>(nullable: false), ProductDefinitionId = table.Column <int>(nullable: false) }, constraints: table => { table.PrimaryKey("PK_OrganizationProductDefinitions", x => x.Id); table.ForeignKey( name: "FK_OrganizationProductDefinitions_Organizations_OrganizationId", column: x => x.OrganizationId, principalTable: "Organizations", principalColumn: "Id", onDelete: ReferentialAction.Cascade); table.ForeignKey( name: "FK_OrganizationProductDefinitions_ProductDefinitions_ProductDe~", column: x => x.ProductDefinitionId, principalTable: "ProductDefinitions", principalColumn: "Id", onDelete: ReferentialAction.Cascade); }); migrationBuilder.CreateTable( name: "GroupMemberships", columns: table => new { Id = table.Column <int>(nullable: false) .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.SerialColumn), UserId = table.Column <int>(nullable: false), GroupId = table.Column <int>(nullable: false) }, constraints: table => { table.PrimaryKey("PK_GroupMemberships", x => x.Id); table.ForeignKey( name: "FK_GroupMemberships_Groups_GroupId", column: x => x.GroupId, principalTable: "Groups", principalColumn: "Id", onDelete: ReferentialAction.Cascade); table.ForeignKey( name: "FK_GroupMemberships_Users_UserId", column: x => x.UserId, principalTable: "Users", principalColumn: "Id", onDelete: ReferentialAction.Cascade); }); migrationBuilder.CreateTable( name: "Projects", columns: table => new { Id = table.Column <int>(nullable: false) .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.SerialColumn), Name = table.Column <string>(nullable: true), TypeId = table.Column <int>(nullable: false), Description = table.Column <string>(nullable: true), OwnerId = table.Column <int>(nullable: false), GroupId = table.Column <int>(nullable: false), OrganizationId = table.Column <int>(nullable: false), Language = table.Column <string>(nullable: true), IsPublic = table.Column <bool>(nullable: true, defaultValue: true), DateCreated = table.Column <DateTime>(nullable: true), DateUpdated = table.Column <DateTime>(nullable: true), DateArchived = table.Column <DateTime>(nullable: true), AllowDownloads = table.Column <bool>(nullable: true, defaultValue: true), AutomaticBuilds = table.Column <bool>(nullable: true, defaultValue: true), WorkflowProjectId = table.Column <int>(nullable: false, defaultValue: 0), WorkflowProjectUrl = table.Column <string>(nullable: true) }, constraints: table => { table.PrimaryKey("PK_Projects", x => x.Id); table.ForeignKey( name: "FK_Projects_Groups_GroupId", column: x => x.GroupId, principalTable: "Groups", principalColumn: "Id", onDelete: ReferentialAction.Cascade); table.ForeignKey( name: "FK_Projects_Organizations_OrganizationId", column: x => x.OrganizationId, principalTable: "Organizations", principalColumn: "Id", onDelete: ReferentialAction.Cascade); table.ForeignKey( name: "FK_Projects_Users_OwnerId", column: x => x.OwnerId, principalTable: "Users", principalColumn: "Id", onDelete: ReferentialAction.Cascade); table.ForeignKey( name: "FK_Projects_ApplicationTypes_TypeId", column: x => x.TypeId, principalTable: "ApplicationTypes", principalColumn: "Id", onDelete: ReferentialAction.Cascade); }); migrationBuilder.CreateTable( name: "Products", columns: table => new { Id = table.Column <Guid>(nullable: false, defaultValueSql: "uuid_generate_v4()"), ProjectId = table.Column <int>(nullable: false), ProductDefinitionId = table.Column <int>(nullable: false), StoreId = table.Column <int>(nullable: true), StoreLanguageId = table.Column <int>(nullable: true), DateCreated = table.Column <DateTime>(nullable: true), DateUpdated = table.Column <DateTime>(nullable: true), WorkflowJobId = table.Column <int>(nullable: false), WorkflowBuildId = table.Column <int>(nullable: false), DateBuilt = table.Column <DateTime>(nullable: true), WorkflowPublishId = table.Column <int>(nullable: false), DatePublished = table.Column <DateTime>(nullable: true) }, constraints: table => { table.PrimaryKey("PK_Products", x => x.Id); table.ForeignKey( name: "FK_Products_ProductDefinitions_ProductDefinitionId", column: x => x.ProductDefinitionId, principalTable: "ProductDefinitions", principalColumn: "Id", onDelete: ReferentialAction.Cascade); table.ForeignKey( name: "FK_Products_Projects_ProjectId", column: x => x.ProjectId, principalTable: "Projects", principalColumn: "Id", onDelete: ReferentialAction.Cascade); table.ForeignKey( name: "FK_Products_Stores_StoreId", column: x => x.StoreId, principalTable: "Stores", principalColumn: "Id", onDelete: ReferentialAction.Restrict); table.ForeignKey( name: "FK_Products_StoreLanguages_StoreLanguageId", column: x => x.StoreLanguageId, principalTable: "StoreLanguages", principalColumn: "Id", onDelete: ReferentialAction.Restrict); }); migrationBuilder.CreateTable( name: "Reviewers", columns: table => new { Id = table.Column <int>(nullable: false) .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.SerialColumn), Name = table.Column <string>(nullable: true), Email = table.Column <string>(nullable: true), ProjectId = table.Column <int>(nullable: false) }, constraints: table => { table.PrimaryKey("PK_Reviewers", x => x.Id); table.ForeignKey( name: "FK_Reviewers_Projects_ProjectId", column: x => x.ProjectId, principalTable: "Projects", principalColumn: "Id", onDelete: ReferentialAction.Cascade); }); migrationBuilder.CreateTable( name: "ProductArtifacts", columns: table => new { Id = table.Column <int>(nullable: false) .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.SerialColumn), ProductId = table.Column <Guid>(nullable: false), ArtifactType = table.Column <string>(nullable: true), Url = table.Column <string>(nullable: true), FileSize = table.Column <long>(nullable: true), ContentType = table.Column <string>(nullable: true), DateCreated = table.Column <DateTime>(nullable: true), DateUpdated = table.Column <DateTime>(nullable: true) }, constraints: table => { table.PrimaryKey("PK_ProductArtifacts", x => x.Id); table.ForeignKey( name: "FK_ProductArtifacts_Products_ProductId", column: x => x.ProductId, principalTable: "Products", principalColumn: "Id", onDelete: ReferentialAction.Cascade); }); migrationBuilder.CreateTable( name: "UserTasks", columns: table => new { Id = table.Column <int>(nullable: false) .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.SerialColumn), UserId = table.Column <int>(nullable: false), ProductId = table.Column <Guid>(nullable: false), ActivityName = table.Column <string>(nullable: true), Status = table.Column <string>(nullable: true), DateCreated = table.Column <DateTime>(nullable: true), DateUpdated = table.Column <DateTime>(nullable: true) }, constraints: table => { table.PrimaryKey("PK_UserTasks", x => x.Id); table.ForeignKey( name: "FK_UserTasks_Products_ProductId", column: x => x.ProductId, principalTable: "Products", principalColumn: "Id", onDelete: ReferentialAction.Cascade); table.ForeignKey( name: "FK_UserTasks_Users_UserId", column: x => x.UserId, principalTable: "Users", principalColumn: "Id", onDelete: ReferentialAction.Cascade); }); migrationBuilder.CreateIndex( name: "IX_GroupMemberships_GroupId", table: "GroupMemberships", column: "GroupId"); migrationBuilder.CreateIndex( name: "IX_GroupMemberships_UserId", table: "GroupMemberships", column: "UserId"); migrationBuilder.CreateIndex( name: "IX_Groups_OwnerId", table: "Groups", column: "OwnerId"); migrationBuilder.CreateIndex( name: "IX_OrganizationMemberships_OrganizationId", table: "OrganizationMemberships", column: "OrganizationId"); migrationBuilder.CreateIndex( name: "IX_OrganizationMemberships_UserId", table: "OrganizationMemberships", column: "UserId"); migrationBuilder.CreateIndex( name: "IX_OrganizationProductDefinitions_OrganizationId", table: "OrganizationProductDefinitions", column: "OrganizationId"); migrationBuilder.CreateIndex( name: "IX_OrganizationProductDefinitions_ProductDefinitionId", table: "OrganizationProductDefinitions", column: "ProductDefinitionId"); migrationBuilder.CreateIndex( name: "IX_Organizations_OwnerId", table: "Organizations", column: "OwnerId"); migrationBuilder.CreateIndex( name: "IX_OrganizationStores_OrganizationId", table: "OrganizationStores", column: "OrganizationId"); migrationBuilder.CreateIndex( name: "IX_OrganizationStores_StoreId", table: "OrganizationStores", column: "StoreId"); migrationBuilder.CreateIndex( name: "IX_ProductArtifacts_ProductId", table: "ProductArtifacts", column: "ProductId"); migrationBuilder.CreateIndex( name: "IX_ProductDefinitions_TypeId", table: "ProductDefinitions", column: "TypeId"); migrationBuilder.CreateIndex( name: "IX_ProductDefinitions_WorkflowId", table: "ProductDefinitions", column: "WorkflowId"); migrationBuilder.CreateIndex( name: "IX_Products_ProductDefinitionId", table: "Products", column: "ProductDefinitionId"); migrationBuilder.CreateIndex( name: "IX_Products_ProjectId", table: "Products", column: "ProjectId"); migrationBuilder.CreateIndex( name: "IX_Products_StoreId", table: "Products", column: "StoreId"); migrationBuilder.CreateIndex( name: "IX_Products_StoreLanguageId", table: "Products", column: "StoreLanguageId"); migrationBuilder.CreateIndex( name: "IX_Projects_GroupId", table: "Projects", column: "GroupId"); migrationBuilder.CreateIndex( name: "IX_Projects_OrganizationId", table: "Projects", column: "OrganizationId"); migrationBuilder.CreateIndex( name: "IX_Projects_OwnerId", table: "Projects", column: "OwnerId"); migrationBuilder.CreateIndex( name: "IX_Projects_TypeId", table: "Projects", column: "TypeId"); migrationBuilder.CreateIndex( name: "IX_Reviewers_ProjectId", table: "Reviewers", column: "ProjectId"); migrationBuilder.CreateIndex( name: "IX_StoreLanguages_StoreTypeId", table: "StoreLanguages", column: "StoreTypeId"); migrationBuilder.CreateIndex( name: "IX_Stores_StoreTypeId", table: "Stores", column: "StoreTypeId"); migrationBuilder.CreateIndex( name: "IX_UserRoles_OrganizationId", table: "UserRoles", column: "OrganizationId"); migrationBuilder.CreateIndex( name: "IX_UserRoles_RoleId", table: "UserRoles", column: "RoleId"); migrationBuilder.CreateIndex( name: "IX_UserRoles_UserId", table: "UserRoles", column: "UserId"); migrationBuilder.CreateIndex( name: "IX_Users_WorkflowUserId", table: "Users", column: "WorkflowUserId"); migrationBuilder.CreateIndex( name: "IX_UserTasks_ProductId", table: "UserTasks", column: "ProductId"); migrationBuilder.CreateIndex( name: "IX_UserTasks_UserId", table: "UserTasks", column: "UserId"); migrationBuilder.CreateIndex( name: "IX_WorkflowDefinitions_StoreTypeId", table: "WorkflowDefinitions", column: "StoreTypeId"); }
protected override void Up(MigrationBuilder migrationBuilder) { migrationBuilder.EnsureSchema( name: "ModuleHotel"); migrationBuilder.AlterDatabase() .Annotation("Npgsql:PostgresExtension:uuid-ossp", ",,"); migrationBuilder.CreateTable( name: "Companies", columns: table => new { Id = table.Column <int>(nullable: false) .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.SerialColumn), Name = table.Column <string>(nullable: true), Slug = table.Column <string>(nullable: true) }, constraints: table => { table.PrimaryKey("PK_Companies", x => x.Id); }); migrationBuilder.CreateTable( name: "Roles", columns: table => new { Id = table.Column <int>(nullable: false) .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.SerialColumn), Name = table.Column <string>(maxLength: 256, nullable: true), NormalizedName = table.Column <string>(maxLength: 256, nullable: true), ConcurrencyStamp = table.Column <string>(nullable: true) }, constraints: table => { table.PrimaryKey("PK_Roles", x => x.Id); }); migrationBuilder.CreateTable( name: "Users", columns: table => new { Id = table.Column <int>(nullable: false) .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.SerialColumn), UserName = table.Column <string>(maxLength: 256, nullable: true), NormalizedUserName = table.Column <string>(maxLength: 256, nullable: true), Email = table.Column <string>(maxLength: 256, nullable: true), NormalizedEmail = table.Column <string>(maxLength: 256, nullable: true), EmailConfirmed = table.Column <bool>(nullable: false), PasswordHash = table.Column <string>(nullable: true), SecurityStamp = table.Column <string>(nullable: true), ConcurrencyStamp = table.Column <string>(nullable: true), PhoneNumber = table.Column <string>(nullable: true), PhoneNumberConfirmed = table.Column <bool>(nullable: false), TwoFactorEnabled = table.Column <bool>(nullable: false), LockoutEnd = table.Column <DateTimeOffset>(nullable: true), LockoutEnabled = table.Column <bool>(nullable: false), AccessFailedCount = table.Column <int>(nullable: false) }, constraints: table => { table.PrimaryKey("PK_Users", x => x.Id); }); migrationBuilder.CreateTable( name: "Pages", columns: table => new { Id = table.Column <int>(nullable: false) .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.SerialColumn), BackgroundImage = table.Column <string>(nullable: true), CallToAction = table.Column <string>(nullable: true), CallToActionLink = table.Column <string>(nullable: true), CompanyId = table.Column <int>(nullable: false), Header = table.Column <string>(nullable: true), Name = table.Column <string>(nullable: true), Slug = table.Column <string>(nullable: true), Title = table.Column <string>(nullable: true) }, constraints: table => { table.PrimaryKey("PK_Pages", x => x.Id); table.ForeignKey( name: "FK_Pages_Companies_CompanyId", column: x => x.CompanyId, principalTable: "Companies", principalColumn: "Id", onDelete: ReferentialAction.Cascade); }); migrationBuilder.CreateTable( name: "StripeAccounts", columns: table => new { Id = table.Column <int>(nullable: false) .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.SerialColumn), AccessToken = table.Column <string>(maxLength: 64, nullable: true), CompanyId = table.Column <int>(nullable: false), LiveMode = table.Column <bool>(nullable: false), RefreshToken = table.Column <string>(maxLength: 64, nullable: true), Scope = table.Column <string>(maxLength: 32, nullable: true), StripePublishableKey = table.Column <string>(maxLength: 64, nullable: true), StripeUserId = table.Column <string>(maxLength: 64, nullable: true), TokenType = table.Column <string>(maxLength: 64, nullable: true) }, constraints: table => { table.PrimaryKey("PK_StripeAccounts", x => x.Id); table.ForeignKey( name: "FK_StripeAccounts_Companies_CompanyId", column: x => x.CompanyId, principalTable: "Companies", principalColumn: "Id", onDelete: ReferentialAction.Cascade); }); migrationBuilder.CreateTable( name: "StripeOAuthRequests", columns: table => new { Id = table.Column <Guid>(nullable: false), CompanyId = table.Column <int>(nullable: false) }, constraints: table => { table.PrimaryKey("PK_StripeOAuthRequests", x => x.Id); table.ForeignKey( name: "FK_StripeOAuthRequests_Companies_CompanyId", column: x => x.CompanyId, principalTable: "Companies", principalColumn: "Id", onDelete: ReferentialAction.Cascade); }); migrationBuilder.CreateTable( name: "AspNetRoleClaims", columns: table => new { Id = table.Column <int>(nullable: false) .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.SerialColumn), RoleId = table.Column <int>(nullable: false), ClaimType = table.Column <string>(nullable: true), ClaimValue = table.Column <string>(nullable: true) }, constraints: table => { table.PrimaryKey("PK_AspNetRoleClaims", x => x.Id); table.ForeignKey( name: "FK_AspNetRoleClaims_Roles_RoleId", column: x => x.RoleId, principalTable: "Roles", principalColumn: "Id", onDelete: ReferentialAction.Cascade); }); migrationBuilder.CreateTable( name: "AspNetUserClaims", columns: table => new { Id = table.Column <int>(nullable: false) .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.SerialColumn), UserId = table.Column <int>(nullable: false), ClaimType = table.Column <string>(nullable: true), ClaimValue = table.Column <string>(nullable: true) }, constraints: table => { table.PrimaryKey("PK_AspNetUserClaims", x => x.Id); table.ForeignKey( name: "FK_AspNetUserClaims_Users_UserId", column: x => x.UserId, principalTable: "Users", principalColumn: "Id", onDelete: ReferentialAction.Cascade); }); migrationBuilder.CreateTable( name: "AspNetUserLogins", columns: table => new { LoginProvider = table.Column <string>(nullable: false), ProviderKey = table.Column <string>(nullable: false), ProviderDisplayName = table.Column <string>(nullable: true), UserId = table.Column <int>(nullable: false) }, constraints: table => { table.PrimaryKey("PK_AspNetUserLogins", x => new { x.LoginProvider, x.ProviderKey }); table.ForeignKey( name: "FK_AspNetUserLogins_Users_UserId", column: x => x.UserId, principalTable: "Users", principalColumn: "Id", onDelete: ReferentialAction.Cascade); }); migrationBuilder.CreateTable( name: "AspNetUserRoles", columns: table => new { UserId = table.Column <int>(nullable: false), RoleId = table.Column <int>(nullable: false) }, constraints: table => { table.PrimaryKey("PK_AspNetUserRoles", x => new { x.UserId, x.RoleId }); table.ForeignKey( name: "FK_AspNetUserRoles_Roles_RoleId", column: x => x.RoleId, principalTable: "Roles", principalColumn: "Id", onDelete: ReferentialAction.Cascade); table.ForeignKey( name: "FK_AspNetUserRoles_Users_UserId", column: x => x.UserId, principalTable: "Users", principalColumn: "Id", onDelete: ReferentialAction.Cascade); }); migrationBuilder.CreateTable( name: "AspNetUserTokens", columns: table => new { UserId = table.Column <int>(nullable: false), LoginProvider = table.Column <string>(nullable: false), Name = table.Column <string>(nullable: false), Value = table.Column <string>(nullable: true) }, constraints: table => { table.PrimaryKey("PK_AspNetUserTokens", x => new { x.UserId, x.LoginProvider, x.Name }); table.ForeignKey( name: "FK_AspNetUserTokens_Users_UserId", column: x => x.UserId, principalTable: "Users", principalColumn: "Id", onDelete: ReferentialAction.Cascade); }); migrationBuilder.CreateTable( name: "Cards", columns: table => new { Id = table.Column <int>(nullable: false) .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.SerialColumn), BackgroundUrl = table.Column <string>(nullable: true), CallToAction = table.Column <string>(nullable: true), CallToActionUrl = table.Column <string>(nullable: true), PageId = table.Column <int>(nullable: false), PosterUrl = table.Column <string>(nullable: true), CardType = table.Column <int>(nullable: false), Order = table.Column <int>(nullable: false), Text = table.Column <string>(nullable: true) }, constraints: table => { table.PrimaryKey("PK_Cards", x => x.Id); table.ForeignKey( name: "FK_Cards_Pages_PageId", column: x => x.PageId, principalTable: "Pages", principalColumn: "Id", onDelete: ReferentialAction.Cascade); }); migrationBuilder.CreateTable( name: "Hotels", schema: "ModuleHotel", columns: table => new { Id = table.Column <int>(nullable: false) .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.SerialColumn), Capacity = table.Column <int>(nullable: false), GettingAround = table.Column <string>(nullable: true), PageId = table.Column <int>(nullable: false), Location = table.Column <string>(nullable: true) }, constraints: table => { table.PrimaryKey("PK_Hotels", x => x.Id); table.ForeignKey( name: "FK_Hotels_Pages_PageId", column: x => x.PageId, principalTable: "Pages", principalColumn: "Id", onDelete: ReferentialAction.Cascade); }); migrationBuilder.CreateTable( name: "Amenities", schema: "ModuleHotel", columns: table => new { Id = table.Column <int>(nullable: false) .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.SerialColumn), HotelId = table.Column <int>(nullable: false), Text = table.Column <string>(nullable: true) }, constraints: table => { table.PrimaryKey("PK_Amenities", x => x.Id); table.ForeignKey( name: "FK_Amenities_Hotels_HotelId", column: x => x.HotelId, principalSchema: "ModuleHotel", principalTable: "Hotels", principalColumn: "Id", onDelete: ReferentialAction.Cascade); }); migrationBuilder.CreateTable( name: "Beds", schema: "ModuleHotel", columns: table => new { Id = table.Column <int>(nullable: false) .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.SerialColumn), BedType = table.Column <int>(nullable: false), Count = table.Column <int>(nullable: false), HotelId = table.Column <int>(nullable: false) }, constraints: table => { table.PrimaryKey("PK_Beds", x => x.Id); table.ForeignKey( name: "FK_Beds_Hotels_HotelId", column: x => x.HotelId, principalSchema: "ModuleHotel", principalTable: "Hotels", principalColumn: "Id", onDelete: ReferentialAction.Cascade); }); migrationBuilder.CreateTable( name: "Rules", schema: "ModuleHotel", columns: table => new { Id = table.Column <int>(nullable: false) .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.SerialColumn), HotelId = table.Column <int>(nullable: false), Text = table.Column <string>(nullable: true) }, constraints: table => { table.PrimaryKey("PK_Rules", x => x.Id); table.ForeignKey( name: "FK_Rules_Hotels_HotelId", column: x => x.HotelId, principalSchema: "ModuleHotel", principalTable: "Hotels", principalColumn: "Id", onDelete: ReferentialAction.Cascade); }); migrationBuilder.CreateTable( name: "Spaces", schema: "ModuleHotel", columns: table => new { Id = table.Column <int>(nullable: false) .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.SerialColumn), HotelId = table.Column <int>(nullable: false), Name = table.Column <string>(nullable: true) }, constraints: table => { table.PrimaryKey("PK_Spaces", x => x.Id); table.ForeignKey( name: "FK_Spaces_Hotels_HotelId", column: x => x.HotelId, principalSchema: "ModuleHotel", principalTable: "Hotels", principalColumn: "Id", onDelete: ReferentialAction.Cascade); }); migrationBuilder.CreateIndex( name: "IX_AspNetRoleClaims_RoleId", table: "AspNetRoleClaims", column: "RoleId"); migrationBuilder.CreateIndex( name: "IX_AspNetUserClaims_UserId", table: "AspNetUserClaims", column: "UserId"); migrationBuilder.CreateIndex( name: "IX_AspNetUserLogins_UserId", table: "AspNetUserLogins", column: "UserId"); migrationBuilder.CreateIndex( name: "IX_AspNetUserRoles_RoleId", table: "AspNetUserRoles", column: "RoleId"); migrationBuilder.CreateIndex( name: "IX_Cards_PageId", table: "Cards", column: "PageId"); migrationBuilder.CreateIndex( name: "IX_Pages_CompanyId", table: "Pages", column: "CompanyId"); migrationBuilder.CreateIndex( name: "RoleNameIndex", table: "Roles", column: "NormalizedName", unique: true); migrationBuilder.CreateIndex( name: "IX_StripeAccounts_CompanyId", table: "StripeAccounts", column: "CompanyId"); migrationBuilder.CreateIndex( name: "IX_StripeOAuthRequests_CompanyId", table: "StripeOAuthRequests", column: "CompanyId"); migrationBuilder.CreateIndex( name: "EmailIndex", table: "Users", column: "NormalizedEmail"); migrationBuilder.CreateIndex( name: "UserNameIndex", table: "Users", column: "NormalizedUserName", unique: true); migrationBuilder.CreateIndex( name: "IX_Amenities_HotelId", schema: "ModuleHotel", table: "Amenities", column: "HotelId"); migrationBuilder.CreateIndex( name: "IX_Beds_HotelId", schema: "ModuleHotel", table: "Beds", column: "HotelId"); migrationBuilder.CreateIndex( name: "IX_Hotels_PageId", schema: "ModuleHotel", table: "Hotels", column: "PageId", unique: true); migrationBuilder.CreateIndex( name: "IX_Rules_HotelId", schema: "ModuleHotel", table: "Rules", column: "HotelId"); migrationBuilder.CreateIndex( name: "IX_Spaces_HotelId", schema: "ModuleHotel", table: "Spaces", column: "HotelId"); }
protected override void Up(MigrationBuilder migrationBuilder) { migrationBuilder.AlterDatabase() .Annotation("Npgsql:PostgresExtension:postgis", ",,"); migrationBuilder.CreateTable( name: "AspNetRoles", columns: table => new { Id = table.Column <string>(nullable: false), Name = table.Column <string>(maxLength: 256, nullable: true), NormalizedName = table.Column <string>(maxLength: 256, nullable: true), ConcurrencyStamp = table.Column <string>(nullable: true) }, constraints: table => { table.PrimaryKey("PK_AspNetRoles", x => x.Id); }); migrationBuilder.CreateTable( name: "AspNetUsers", columns: table => new { Id = table.Column <string>(nullable: false), UserName = table.Column <string>(maxLength: 256, nullable: true), NormalizedUserName = table.Column <string>(maxLength: 256, nullable: true), Email = table.Column <string>(maxLength: 256, nullable: true), NormalizedEmail = table.Column <string>(maxLength: 256, nullable: true), EmailConfirmed = table.Column <bool>(nullable: false), PasswordHash = table.Column <string>(nullable: true), SecurityStamp = table.Column <string>(nullable: true), ConcurrencyStamp = table.Column <string>(nullable: true), PhoneNumber = table.Column <string>(nullable: true), PhoneNumberConfirmed = table.Column <bool>(nullable: false), TwoFactorEnabled = table.Column <bool>(nullable: false), LockoutEnd = table.Column <DateTimeOffset>(nullable: true), LockoutEnabled = table.Column <bool>(nullable: false), AccessFailedCount = table.Column <int>(nullable: false) }, constraints: table => { table.PrimaryKey("PK_AspNetUsers", x => x.Id); }); migrationBuilder.CreateTable( name: "Points", columns: table => new { Id = table.Column <int>(nullable: false) .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), Lat = table.Column <double>(nullable: false), Lan = table.Column <double>(nullable: false), Description = table.Column <string>(nullable: true), Name = table.Column <string>(nullable: true), City = table.Column <string>(nullable: true), Geom = table.Column <Geometry>(nullable: true, computedColumnSql: "public.ST_SetSRID(ST_MakePoint(\"Lan\",\"Lat\"),4326)") }, constraints: table => { table.PrimaryKey("PK_Points", x => x.Id); }); migrationBuilder.CreateTable( name: "AspNetRoleClaims", columns: table => new { Id = table.Column <int>(nullable: false) .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), RoleId = table.Column <string>(nullable: false), ClaimType = table.Column <string>(nullable: true), ClaimValue = table.Column <string>(nullable: true) }, constraints: table => { table.PrimaryKey("PK_AspNetRoleClaims", x => x.Id); table.ForeignKey( name: "FK_AspNetRoleClaims_AspNetRoles_RoleId", column: x => x.RoleId, principalTable: "AspNetRoles", principalColumn: "Id", onDelete: ReferentialAction.Cascade); }); migrationBuilder.CreateTable( name: "AspNetUserClaims", columns: table => new { Id = table.Column <int>(nullable: false) .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), UserId = table.Column <string>(nullable: false), ClaimType = table.Column <string>(nullable: true), ClaimValue = table.Column <string>(nullable: true) }, constraints: table => { table.PrimaryKey("PK_AspNetUserClaims", x => x.Id); table.ForeignKey( name: "FK_AspNetUserClaims_AspNetUsers_UserId", column: x => x.UserId, principalTable: "AspNetUsers", principalColumn: "Id", onDelete: ReferentialAction.Cascade); }); migrationBuilder.CreateTable( name: "AspNetUserLogins", columns: table => new { LoginProvider = table.Column <string>(maxLength: 128, nullable: false), ProviderKey = table.Column <string>(maxLength: 128, nullable: false), ProviderDisplayName = table.Column <string>(nullable: true), UserId = table.Column <string>(nullable: false) }, constraints: table => { table.PrimaryKey("PK_AspNetUserLogins", x => new { x.LoginProvider, x.ProviderKey }); table.ForeignKey( name: "FK_AspNetUserLogins_AspNetUsers_UserId", column: x => x.UserId, principalTable: "AspNetUsers", principalColumn: "Id", onDelete: ReferentialAction.Cascade); }); migrationBuilder.CreateTable( name: "AspNetUserRoles", columns: table => new { UserId = table.Column <string>(nullable: false), RoleId = table.Column <string>(nullable: false) }, constraints: table => { table.PrimaryKey("PK_AspNetUserRoles", x => new { x.UserId, x.RoleId }); table.ForeignKey( name: "FK_AspNetUserRoles_AspNetRoles_RoleId", column: x => x.RoleId, principalTable: "AspNetRoles", principalColumn: "Id", onDelete: ReferentialAction.Cascade); table.ForeignKey( name: "FK_AspNetUserRoles_AspNetUsers_UserId", column: x => x.UserId, principalTable: "AspNetUsers", principalColumn: "Id", onDelete: ReferentialAction.Cascade); }); migrationBuilder.CreateTable( name: "AspNetUserTokens", columns: table => new { UserId = table.Column <string>(nullable: false), LoginProvider = table.Column <string>(maxLength: 128, nullable: false), Name = table.Column <string>(maxLength: 128, nullable: false), Value = table.Column <string>(nullable: true) }, constraints: table => { table.PrimaryKey("PK_AspNetUserTokens", x => new { x.UserId, x.LoginProvider, x.Name }); table.ForeignKey( name: "FK_AspNetUserTokens_AspNetUsers_UserId", column: x => x.UserId, principalTable: "AspNetUsers", principalColumn: "Id", onDelete: ReferentialAction.Cascade); }); migrationBuilder.CreateIndex( name: "IX_AspNetRoleClaims_RoleId", table: "AspNetRoleClaims", column: "RoleId"); migrationBuilder.CreateIndex( name: "RoleNameIndex", table: "AspNetRoles", column: "NormalizedName", unique: true); migrationBuilder.CreateIndex( name: "IX_AspNetUserClaims_UserId", table: "AspNetUserClaims", column: "UserId"); migrationBuilder.CreateIndex( name: "IX_AspNetUserLogins_UserId", table: "AspNetUserLogins", column: "UserId"); migrationBuilder.CreateIndex( name: "IX_AspNetUserRoles_RoleId", table: "AspNetUserRoles", column: "RoleId"); migrationBuilder.CreateIndex( name: "EmailIndex", table: "AspNetUsers", column: "NormalizedEmail"); migrationBuilder.CreateIndex( name: "UserNameIndex", table: "AspNetUsers", column: "NormalizedUserName", unique: true); }
protected override void Up(MigrationBuilder migrationBuilder) { migrationBuilder.AlterDatabase() .Annotation("Npgsql:Enum:shifts_description", "morning,afternoon,night,dawn"); migrationBuilder.AddColumn <int>( name: "Name", table: "Shifts", nullable: false, defaultValue: 0); migrationBuilder.CreateTable( name: "Psicos", columns: table => new { Id = table.Column <Guid>(nullable: false), CreateAt = table.Column <DateTime>(nullable: false), UpdateAt = table.Column <DateTime>(nullable: false), IdUser = table.Column <Guid>(nullable: false) }, constraints: table => { table.PrimaryKey("PK_Psicos", x => x.Id); table.ForeignKey( name: "FK_Psicos_Users_IdUser", column: x => x.IdUser, principalTable: "Users", principalColumn: "Id", onDelete: ReferentialAction.Cascade); }); migrationBuilder.CreateTable( name: "Volunteers", columns: table => new { Id = table.Column <Guid>(nullable: false), CreateAt = table.Column <DateTime>(nullable: false), UpdateAt = table.Column <DateTime>(nullable: false), Ra = table.Column <int>(nullable: false), Course = table.Column <string>(maxLength: 128, nullable: false), NeedPsico = table.Column <bool>(nullable: false), IdUser = table.Column <Guid>(nullable: false) }, constraints: table => { table.PrimaryKey("PK_Volunteers", x => x.Id); table.ForeignKey( name: "FK_Volunteers_Users_IdUser", column: x => x.IdUser, principalTable: "Users", principalColumn: "Id", onDelete: ReferentialAction.Cascade); }); migrationBuilder.CreateTable( name: "Attendances", columns: table => new { Id = table.Column <Guid>(nullable: false), CreateAt = table.Column <DateTime>(nullable: false), UpdateAt = table.Column <DateTime>(nullable: false), Begin = table.Column <DateTime>(nullable: false), End = table.Column <DateTime>(nullable: false), Latitude = table.Column <double>(nullable: false), Longitude = table.Column <double>(nullable: false), IdVolunteer = table.Column <Guid>(nullable: false), IdShift = table.Column <Guid>(nullable: false) }, constraints: table => { table.PrimaryKey("PK_Attendances", x => x.Id); table.ForeignKey( name: "FK_Attendances_Shifts_IdShift", column: x => x.IdShift, principalTable: "Shifts", principalColumn: "Id", onDelete: ReferentialAction.Cascade); table.ForeignKey( name: "FK_Attendances_Volunteers_IdVolunteer", column: x => x.IdVolunteer, principalTable: "Volunteers", principalColumn: "Id", onDelete: ReferentialAction.Cascade); }); migrationBuilder.CreateTable( name: "VolunteerShifts", columns: table => new { Id = table.Column <Guid>(nullable: false), CreateAt = table.Column <DateTime>(nullable: false), UpdateAt = table.Column <DateTime>(nullable: false), Idvolunteer = table.Column <Guid>(nullable: false), IdVolunteer = table.Column <Guid>(nullable: false), IdShift = table.Column <Guid>(nullable: false) }, constraints: table => { table.PrimaryKey("PK_VolunteerShifts", x => x.Id); table.ForeignKey( name: "FK_VolunteerShifts_Shifts_IdShift", column: x => x.IdShift, principalTable: "Shifts", principalColumn: "Id", onDelete: ReferentialAction.Cascade); table.ForeignKey( name: "FK_VolunteerShifts_Volunteers_IdVolunteer", column: x => x.IdVolunteer, principalTable: "Volunteers", principalColumn: "Id", onDelete: ReferentialAction.Cascade); }); migrationBuilder.CreateIndex( name: "IX_Attendances_IdShift", table: "Attendances", column: "IdShift"); migrationBuilder.CreateIndex( name: "IX_Attendances_IdVolunteer", table: "Attendances", column: "IdVolunteer"); migrationBuilder.CreateIndex( name: "IX_Psicos_IdUser", table: "Psicos", column: "IdUser"); migrationBuilder.CreateIndex( name: "IX_Volunteers_IdUser", table: "Volunteers", column: "IdUser"); migrationBuilder.CreateIndex( name: "IX_VolunteerShifts_IdShift", table: "VolunteerShifts", column: "IdShift"); migrationBuilder.CreateIndex( name: "IX_VolunteerShifts_IdVolunteer", table: "VolunteerShifts", column: "IdVolunteer"); }
protected override void Up(MigrationBuilder migrationBuilder) { migrationBuilder.AlterDatabase() .Annotation("Npgsql:Enum:mod_dependency_type", "dependency,optional_dependency,incompatible") .Annotation("Npgsql:Enum:org_member_role", "owner,admin,member"); migrationBuilder.CreateTable( name: "AspNetRoles", columns: table => new { Id = table.Column <string>(nullable: false), Name = table.Column <string>(maxLength: 256, nullable: true), NormalizedName = table.Column <string>(maxLength: 256, nullable: true), ConcurrencyStamp = table.Column <string>(nullable: true) }, constraints: table => { table.PrimaryKey("PK_AspNetRoles", x => x.Id); }); migrationBuilder.CreateTable( name: "Orgs", columns: table => new { Id = table.Column <int>(nullable: false) .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.SerialColumn), DisplayName = table.Column <string>(maxLength: 128, nullable: false), Slug = table.Column <string>(nullable: true), ShowUsers = table.Column <bool>(nullable: true, defaultValue: true), CreatedAt = table.Column <DateTime>(nullable: false) }, constraints: table => { table.PrimaryKey("PK_Orgs", x => x.Id); }); migrationBuilder.CreateTable( name: "StoredFiles", columns: table => new { Id = table.Column <Guid>(nullable: false), ObjectId = table.Column <long>(nullable: false), FileName = table.Column <string>(nullable: true), FileInfo = table.Column <string>(nullable: true) }, constraints: table => { table.PrimaryKey("PK_StoredFiles", x => x.Id); }); migrationBuilder.CreateTable( name: "VersionNumbers", columns: table => new { ID = table.Column <int>(nullable: false) .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.SerialColumn), Major = table.Column <int>(nullable: false), Minor = table.Column <int>(nullable: false), Patch = table.Column <int>(nullable: false) }, constraints: table => { table.PrimaryKey("PK_VersionNumbers", x => x.ID); table.UniqueConstraint("AK_VersionNumbers_Major_Minor_Patch", x => new { x.Major, x.Minor, x.Patch }); }); migrationBuilder.CreateTable( name: "AspNetRoleClaims", columns: table => new { Id = table.Column <int>(nullable: false) .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.SerialColumn), RoleId = table.Column <string>(nullable: false), ClaimType = table.Column <string>(nullable: true), ClaimValue = table.Column <string>(nullable: true) }, constraints: table => { table.PrimaryKey("PK_AspNetRoleClaims", x => x.Id); table.ForeignKey( name: "FK_AspNetRoleClaims_AspNetRoles_RoleId", column: x => x.RoleId, principalTable: "AspNetRoles", principalColumn: "Id", onDelete: ReferentialAction.Cascade); }); migrationBuilder.CreateTable( name: "AspNetUsers", columns: table => new { Id = table.Column <string>(nullable: false), UserName = table.Column <string>(maxLength: 256, nullable: true), NormalizedUserName = table.Column <string>(maxLength: 256, nullable: true), Email = table.Column <string>(maxLength: 256, nullable: true), NormalizedEmail = table.Column <string>(maxLength: 256, nullable: true), EmailConfirmed = table.Column <bool>(nullable: false), PasswordHash = table.Column <string>(nullable: true), SecurityStamp = table.Column <string>(nullable: true), ConcurrencyStamp = table.Column <string>(nullable: true), PhoneNumber = table.Column <string>(nullable: true), PhoneNumberConfirmed = table.Column <bool>(nullable: false), TwoFactorEnabled = table.Column <bool>(nullable: false), LockoutEnd = table.Column <DateTimeOffset>(nullable: true), LockoutEnabled = table.Column <bool>(nullable: false), AccessFailedCount = table.Column <int>(nullable: false), ShadowOrgId = table.Column <int>(nullable: false) }, constraints: table => { table.PrimaryKey("PK_AspNetUsers", x => x.Id); table.ForeignKey( name: "FK_AspNetUsers_Orgs_ShadowOrgId", column: x => x.ShadowOrgId, principalTable: "Orgs", principalColumn: "Id", onDelete: ReferentialAction.Cascade); }); migrationBuilder.CreateTable( name: "DisunityVersions", columns: table => new { Id = table.Column <int>(nullable: false) .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.SerialColumn), Url = table.Column <string>(nullable: true), VersionNumberId = table.Column <int>(nullable: false) }, constraints: table => { table.PrimaryKey("PK_DisunityVersions", x => x.Id); table.ForeignKey( name: "FK_DisunityVersions_VersionNumbers_VersionNumberId", column: x => x.VersionNumberId, principalTable: "VersionNumbers", principalColumn: "ID", onDelete: ReferentialAction.Cascade); }); migrationBuilder.CreateTable( name: "UnityVersions", columns: table => new { Id = table.Column <int>(nullable: false) .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.SerialColumn), VersionNumberId = table.Column <int>(nullable: false) }, constraints: table => { table.PrimaryKey("PK_UnityVersions", x => x.Id); table.ForeignKey( name: "FK_UnityVersions_VersionNumbers_VersionNumberId", column: x => x.VersionNumberId, principalTable: "VersionNumbers", principalColumn: "ID", onDelete: ReferentialAction.Cascade); }); migrationBuilder.CreateTable( name: "AspNetUserClaims", columns: table => new { Id = table.Column <int>(nullable: false) .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.SerialColumn), UserId = table.Column <string>(nullable: false), ClaimType = table.Column <string>(nullable: true), ClaimValue = table.Column <string>(nullable: true) }, constraints: table => { table.PrimaryKey("PK_AspNetUserClaims", x => x.Id); table.ForeignKey( name: "FK_AspNetUserClaims_AspNetUsers_UserId", column: x => x.UserId, principalTable: "AspNetUsers", principalColumn: "Id", onDelete: ReferentialAction.Cascade); }); migrationBuilder.CreateTable( name: "AspNetUserLogins", columns: table => new { LoginProvider = table.Column <string>(maxLength: 128, nullable: false), ProviderKey = table.Column <string>(maxLength: 128, nullable: false), ProviderDisplayName = table.Column <string>(nullable: true), UserId = table.Column <string>(nullable: false) }, constraints: table => { table.PrimaryKey("PK_AspNetUserLogins", x => new { x.LoginProvider, x.ProviderKey }); table.ForeignKey( name: "FK_AspNetUserLogins_AspNetUsers_UserId", column: x => x.UserId, principalTable: "AspNetUsers", principalColumn: "Id", onDelete: ReferentialAction.Cascade); }); migrationBuilder.CreateTable( name: "AspNetUserRoles", columns: table => new { UserId = table.Column <string>(nullable: false), RoleId = table.Column <string>(nullable: false) }, constraints: table => { table.PrimaryKey("PK_AspNetUserRoles", x => new { x.UserId, x.RoleId }); table.ForeignKey( name: "FK_AspNetUserRoles_AspNetRoles_RoleId", column: x => x.RoleId, principalTable: "AspNetRoles", principalColumn: "Id", onDelete: ReferentialAction.Cascade); table.ForeignKey( name: "FK_AspNetUserRoles_AspNetUsers_UserId", column: x => x.UserId, principalTable: "AspNetUsers", principalColumn: "Id", onDelete: ReferentialAction.Cascade); }); migrationBuilder.CreateTable( name: "AspNetUserTokens", columns: table => new { UserId = table.Column <string>(nullable: false), LoginProvider = table.Column <string>(maxLength: 128, nullable: false), Name = table.Column <string>(maxLength: 128, nullable: false), Value = table.Column <string>(nullable: true) }, constraints: table => { table.PrimaryKey("PK_AspNetUserTokens", x => new { x.UserId, x.LoginProvider, x.Name }); table.ForeignKey( name: "FK_AspNetUserTokens_AspNetUsers_UserId", column: x => x.UserId, principalTable: "AspNetUsers", principalColumn: "Id", onDelete: ReferentialAction.Cascade); }); migrationBuilder.CreateTable( name: "OrgMembers", columns: table => new { UserId = table.Column <string>(nullable: false), OrgId = table.Column <int>(nullable: false), Role = table.Column <OrgMemberRole>(nullable: false) }, constraints: table => { table.PrimaryKey("PK_OrgMembers", x => new { x.UserId, x.OrgId }); table.ForeignKey( name: "FK_OrgMembers_Orgs_OrgId", column: x => x.OrgId, principalTable: "Orgs", principalColumn: "Id", onDelete: ReferentialAction.Cascade); table.ForeignKey( name: "FK_OrgMembers_AspNetUsers_UserId", column: x => x.UserId, principalTable: "AspNetUsers", principalColumn: "Id", onDelete: ReferentialAction.Cascade); }); migrationBuilder.CreateTable( name: "DisunityVersionCompatibilities", columns: table => new { ID = table.Column <int>(nullable: false) .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.SerialColumn), VersionId = table.Column <int>(nullable: false), MinCompatibleVersionId = table.Column <int>(nullable: true), MaxCompatibleVersionId = table.Column <int>(nullable: true) }, constraints: table => { table.PrimaryKey("PK_DisunityVersionCompatibilities", x => x.ID); table.ForeignKey( name: "FK_DisunityVersionCompatibilities_UnityVersions_MaxCompatibleV~", column: x => x.MaxCompatibleVersionId, principalTable: "UnityVersions", principalColumn: "Id", onDelete: ReferentialAction.Restrict); table.ForeignKey( name: "FK_DisunityVersionCompatibilities_UnityVersions_MinCompatibleV~", column: x => x.MinCompatibleVersionId, principalTable: "UnityVersions", principalColumn: "Id", onDelete: ReferentialAction.Restrict); table.ForeignKey( name: "FK_DisunityVersionCompatibilities_DisunityVersions_VersionId", column: x => x.VersionId, principalTable: "DisunityVersions", principalColumn: "Id", onDelete: ReferentialAction.Cascade); }); migrationBuilder.CreateTable( name: "ModDisunityCompatibilities", columns: table => new { ID = table.Column <int>(nullable: false) .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.SerialColumn), VersionId = table.Column <int>(nullable: false), MinCompatibleVersionId = table.Column <int>(nullable: true), MaxCompatibleVersionId = table.Column <int>(nullable: true) }, constraints: table => { table.PrimaryKey("PK_ModDisunityCompatibilities", x => x.ID); table.ForeignKey( name: "FK_ModDisunityCompatibilities_DisunityVersions_MaxCompatibleVe~", column: x => x.MaxCompatibleVersionId, principalTable: "DisunityVersions", principalColumn: "Id", onDelete: ReferentialAction.Restrict); table.ForeignKey( name: "FK_ModDisunityCompatibilities_DisunityVersions_MinCompatibleVe~", column: x => x.MinCompatibleVersionId, principalTable: "DisunityVersions", principalColumn: "Id", onDelete: ReferentialAction.Restrict); }); migrationBuilder.CreateTable( name: "ModDependencies", columns: table => new { DependentId = table.Column <int>(nullable: false), DependencyId = table.Column <int>(nullable: false), DependencyType = table.Column <ModDependencyType>(nullable: false), MinVersionId = table.Column <int>(nullable: true), MaxVersionId = table.Column <int>(nullable: true) }, constraints: table => { table.PrimaryKey("PK_ModDependencies", x => new { x.DependentId, x.DependencyId }); }); migrationBuilder.CreateTable( name: "ModVersions", columns: table => new { Id = table.Column <int>(nullable: false) .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.SerialColumn), ModId = table.Column <int>(nullable: false), DisplayName = table.Column <string>(maxLength: 128, nullable: false), IsActive = table.Column <bool>(nullable: true, defaultValue: false), Downloads = table.Column <int>(nullable: true, defaultValue: 0), VersionNumberId = table.Column <int>(nullable: false), WebsiteUrl = table.Column <string>(maxLength: 1024, nullable: false), Description = table.Column <string>(maxLength: 256, nullable: false), Readme = table.Column <string>(nullable: false), FileId = table.Column <string>(maxLength: 1024, nullable: false), IconUrl = table.Column <string>(maxLength: 1024, nullable: false), CreatedAt = table.Column <DateTime>(nullable: false) }, constraints: table => { table.PrimaryKey("PK_ModVersions", x => x.Id); table.ForeignKey( name: "FK_ModVersions_VersionNumbers_VersionNumberId", column: x => x.VersionNumberId, principalTable: "VersionNumbers", principalColumn: "ID", onDelete: ReferentialAction.Cascade); }); migrationBuilder.CreateTable( name: "ModVersionDownloadEvents", columns: table => new { ModVersionId = table.Column <int>(nullable: false), SourceIp = table.Column <string>(nullable: false), LatestDownload = table.Column <DateTime>(nullable: false), TotalDownloads = table.Column <int>(nullable: true, defaultValue: 1), CountedDownloads = table.Column <int>(nullable: true, defaultValue: 1), CreatedAt = table.Column <DateTime>(nullable: false), UpdatedAt = table.Column <DateTime>(nullable: false) }, constraints: table => { table.PrimaryKey("PK_ModVersionDownloadEvents", x => new { x.SourceIp, x.ModVersionId }); table.ForeignKey( name: "FK_ModVersionDownloadEvents_ModVersions_ModVersionId", column: x => x.ModVersionId, principalTable: "ModVersions", principalColumn: "Id", onDelete: ReferentialAction.Cascade); }); migrationBuilder.CreateTable( name: "Mods", columns: table => new { Id = table.Column <int>(nullable: false) .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.SerialColumn), OwnerId = table.Column <int>(nullable: false), Slug = table.Column <string>(maxLength: 128, nullable: false), IsActive = table.Column <bool>(nullable: true, defaultValue: true), IsDeprecated = table.Column <bool>(nullable: true, defaultValue: false), IsPinned = table.Column <bool>(nullable: true, defaultValue: false), LatestId = table.Column <int>(nullable: true), CreatedAt = table.Column <DateTime>(nullable: false), TargetId = table.Column <int>(nullable: true) }, constraints: table => { table.PrimaryKey("PK_Mods", x => x.Id); table.UniqueConstraint("AK_Mods_OwnerId_Slug", x => new { x.OwnerId, x.Slug }); table.ForeignKey( name: "FK_Mods_ModVersions_LatestId", column: x => x.LatestId, principalTable: "ModVersions", principalColumn: "Id", onDelete: ReferentialAction.Restrict); table.ForeignKey( name: "FK_Mods_Orgs_OwnerId", column: x => x.OwnerId, principalTable: "Orgs", principalColumn: "Id", onDelete: ReferentialAction.Restrict); }); migrationBuilder.CreateTable( name: "ModTargetCompatibilities", columns: table => new { VersionId = table.Column <int>(nullable: false), TargetId = table.Column <int>(nullable: false), MinCompatibleVersionId = table.Column <int>(nullable: true), MaxCompatibleVersionId = table.Column <int>(nullable: true) }, constraints: table => { table.PrimaryKey("PK_ModTargetCompatibilities", x => new { x.VersionId, x.TargetId }); table.ForeignKey( name: "FK_ModTargetCompatibilities_ModVersions_VersionId", column: x => x.VersionId, principalTable: "ModVersions", principalColumn: "Id", onDelete: ReferentialAction.Cascade); }); migrationBuilder.CreateTable( name: "TargetVersions", columns: table => new { ID = table.Column <int>(nullable: false) .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.SerialColumn), TargetId = table.Column <int>(nullable: false), DisplayName = table.Column <string>(maxLength: 128, nullable: false), VersionNumber = table.Column <string>(maxLength: 16, nullable: false), WebsiteUrl = table.Column <string>(maxLength: 1024, nullable: false), Description = table.Column <string>(maxLength: 256, nullable: false), IconUrl = table.Column <string>(maxLength: 1024, nullable: false), Hash = table.Column <string>(maxLength: 128, nullable: true) }, constraints: table => { table.PrimaryKey("PK_TargetVersions", x => x.ID); table.UniqueConstraint("AK_TargetVersions_TargetId_VersionNumber", x => new { x.TargetId, x.VersionNumber }); }); migrationBuilder.CreateTable( name: "Targets", columns: table => new { Id = table.Column <int>(nullable: false) .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.SerialColumn), LatestId = table.Column <int>(nullable: true), Slug = table.Column <string>(maxLength: 128, nullable: false) }, constraints: table => { table.PrimaryKey("PK_Targets", x => x.Id); table.ForeignKey( name: "FK_Targets_TargetVersions_LatestId", column: x => x.LatestId, principalTable: "TargetVersions", principalColumn: "ID", onDelete: ReferentialAction.Restrict); }); migrationBuilder.CreateTable( name: "TargetVersionCompatibilities", columns: table => new { ID = table.Column <int>(nullable: false) .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.SerialColumn), VersionId = table.Column <int>(nullable: false), MinCompatibleVersionId = table.Column <int>(nullable: true), MaxCompatibleVersionId = table.Column <int>(nullable: true) }, constraints: table => { table.PrimaryKey("PK_TargetVersionCompatibilities", x => x.ID); table.ForeignKey( name: "FK_TargetVersionCompatibilities_UnityVersions_MaxCompatibleVer~", column: x => x.MaxCompatibleVersionId, principalTable: "UnityVersions", principalColumn: "Id", onDelete: ReferentialAction.Restrict); table.ForeignKey( name: "FK_TargetVersionCompatibilities_UnityVersions_MinCompatibleVer~", column: x => x.MinCompatibleVersionId, principalTable: "UnityVersions", principalColumn: "Id", onDelete: ReferentialAction.Restrict); table.ForeignKey( name: "FK_TargetVersionCompatibilities_TargetVersions_VersionId", column: x => x.VersionId, principalTable: "TargetVersions", principalColumn: "ID", onDelete: ReferentialAction.Cascade); }); migrationBuilder.CreateIndex( name: "IX_AspNetRoleClaims_RoleId", table: "AspNetRoleClaims", column: "RoleId"); migrationBuilder.CreateIndex( name: "RoleNameIndex", table: "AspNetRoles", column: "NormalizedName", unique: true); migrationBuilder.CreateIndex( name: "IX_AspNetUserClaims_UserId", table: "AspNetUserClaims", column: "UserId"); migrationBuilder.CreateIndex( name: "IX_AspNetUserLogins_UserId", table: "AspNetUserLogins", column: "UserId"); migrationBuilder.CreateIndex( name: "IX_AspNetUserRoles_RoleId", table: "AspNetUserRoles", column: "RoleId"); migrationBuilder.CreateIndex( name: "EmailIndex", table: "AspNetUsers", column: "NormalizedEmail"); migrationBuilder.CreateIndex( name: "UserNameIndex", table: "AspNetUsers", column: "NormalizedUserName", unique: true); migrationBuilder.CreateIndex( name: "IX_AspNetUsers_ShadowOrgId", table: "AspNetUsers", column: "ShadowOrgId"); migrationBuilder.CreateIndex( name: "IX_DisunityVersionCompatibilities_MaxCompatibleVersionId", table: "DisunityVersionCompatibilities", column: "MaxCompatibleVersionId"); migrationBuilder.CreateIndex( name: "IX_DisunityVersionCompatibilities_MinCompatibleVersionId", table: "DisunityVersionCompatibilities", column: "MinCompatibleVersionId"); migrationBuilder.CreateIndex( name: "IX_DisunityVersionCompatibilities_VersionId", table: "DisunityVersionCompatibilities", column: "VersionId", unique: true); migrationBuilder.CreateIndex( name: "IX_DisunityVersions_VersionNumberId", table: "DisunityVersions", column: "VersionNumberId", unique: true); migrationBuilder.CreateIndex( name: "IX_ModDependencies_DependencyId", table: "ModDependencies", column: "DependencyId"); migrationBuilder.CreateIndex( name: "IX_ModDependencies_MaxVersionId", table: "ModDependencies", column: "MaxVersionId"); migrationBuilder.CreateIndex( name: "IX_ModDependencies_MinVersionId", table: "ModDependencies", column: "MinVersionId"); migrationBuilder.CreateIndex( name: "IX_ModDisunityCompatibilities_MaxCompatibleVersionId", table: "ModDisunityCompatibilities", column: "MaxCompatibleVersionId"); migrationBuilder.CreateIndex( name: "IX_ModDisunityCompatibilities_MinCompatibleVersionId", table: "ModDisunityCompatibilities", column: "MinCompatibleVersionId"); migrationBuilder.CreateIndex( name: "IX_ModDisunityCompatibilities_VersionId", table: "ModDisunityCompatibilities", column: "VersionId", unique: true); migrationBuilder.CreateIndex( name: "IX_Mods_LatestId", table: "Mods", column: "LatestId"); migrationBuilder.CreateIndex( name: "IX_Mods_TargetId", table: "Mods", column: "TargetId"); migrationBuilder.CreateIndex( name: "IX_ModTargetCompatibilities_MaxCompatibleVersionId", table: "ModTargetCompatibilities", column: "MaxCompatibleVersionId"); migrationBuilder.CreateIndex( name: "IX_ModTargetCompatibilities_MinCompatibleVersionId", table: "ModTargetCompatibilities", column: "MinCompatibleVersionId"); migrationBuilder.CreateIndex( name: "IX_ModTargetCompatibilities_TargetId", table: "ModTargetCompatibilities", column: "TargetId"); migrationBuilder.CreateIndex( name: "IX_ModVersionDownloadEvents_ModVersionId", table: "ModVersionDownloadEvents", column: "ModVersionId"); migrationBuilder.CreateIndex( name: "IX_ModVersions_VersionNumberId", table: "ModVersions", column: "VersionNumberId"); migrationBuilder.CreateIndex( name: "IX_ModVersions_ModId_VersionNumberId", table: "ModVersions", columns: new[] { "ModId", "VersionNumberId" }, unique: true); migrationBuilder.CreateIndex( name: "IX_OrgMembers_OrgId_Role", table: "OrgMembers", columns: new[] { "OrgId", "Role" }, unique: true, filter: "\"Role\" = 'owner'"); migrationBuilder.CreateIndex( name: "IX_Orgs_Slug", table: "Orgs", column: "Slug", unique: true); migrationBuilder.CreateIndex( name: "IX_Targets_LatestId", table: "Targets", column: "LatestId", unique: true); migrationBuilder.CreateIndex( name: "IX_Targets_Slug", table: "Targets", column: "Slug", unique: true); migrationBuilder.CreateIndex( name: "IX_TargetVersionCompatibilities_MaxCompatibleVersionId", table: "TargetVersionCompatibilities", column: "MaxCompatibleVersionId"); migrationBuilder.CreateIndex( name: "IX_TargetVersionCompatibilities_MinCompatibleVersionId", table: "TargetVersionCompatibilities", column: "MinCompatibleVersionId"); migrationBuilder.CreateIndex( name: "IX_TargetVersionCompatibilities_VersionId", table: "TargetVersionCompatibilities", column: "VersionId", unique: true); migrationBuilder.CreateIndex( name: "IX_UnityVersions_VersionNumberId", table: "UnityVersions", column: "VersionNumberId", unique: true); migrationBuilder.AddForeignKey( name: "FK_ModDisunityCompatibilities_ModVersions_VersionId", table: "ModDisunityCompatibilities", column: "VersionId", principalTable: "ModVersions", principalColumn: "Id", onDelete: ReferentialAction.Cascade); migrationBuilder.AddForeignKey( name: "FK_ModDependencies_Mods_DependencyId", table: "ModDependencies", column: "DependencyId", principalTable: "Mods", principalColumn: "Id", onDelete: ReferentialAction.Cascade); migrationBuilder.AddForeignKey( name: "FK_ModDependencies_ModVersions_DependentId", table: "ModDependencies", column: "DependentId", principalTable: "ModVersions", principalColumn: "Id", onDelete: ReferentialAction.Cascade); migrationBuilder.AddForeignKey( name: "FK_ModDependencies_ModVersions_MaxVersionId", table: "ModDependencies", column: "MaxVersionId", principalTable: "ModVersions", principalColumn: "Id", onDelete: ReferentialAction.Restrict); migrationBuilder.AddForeignKey( name: "FK_ModDependencies_ModVersions_MinVersionId", table: "ModDependencies", column: "MinVersionId", principalTable: "ModVersions", principalColumn: "Id", onDelete: ReferentialAction.Restrict); migrationBuilder.AddForeignKey( name: "FK_ModVersions_Mods_ModId", table: "ModVersions", column: "ModId", principalTable: "Mods", principalColumn: "Id", onDelete: ReferentialAction.Cascade); migrationBuilder.AddForeignKey( name: "FK_Mods_Targets_TargetId", table: "Mods", column: "TargetId", principalTable: "Targets", principalColumn: "Id", onDelete: ReferentialAction.Restrict); migrationBuilder.AddForeignKey( name: "FK_ModTargetCompatibilities_Targets_TargetId", table: "ModTargetCompatibilities", column: "TargetId", principalTable: "Targets", principalColumn: "Id", onDelete: ReferentialAction.Cascade); migrationBuilder.AddForeignKey( name: "FK_ModTargetCompatibilities_TargetVersions_MaxCompatibleVersio~", table: "ModTargetCompatibilities", column: "MaxCompatibleVersionId", principalTable: "TargetVersions", principalColumn: "ID", onDelete: ReferentialAction.Restrict); migrationBuilder.AddForeignKey( name: "FK_ModTargetCompatibilities_TargetVersions_MinCompatibleVersio~", table: "ModTargetCompatibilities", column: "MinCompatibleVersionId", principalTable: "TargetVersions", principalColumn: "ID", onDelete: ReferentialAction.Restrict); migrationBuilder.AddForeignKey( name: "FK_TargetVersions_Targets_TargetId", table: "TargetVersions", column: "TargetId", principalTable: "Targets", principalColumn: "Id", onDelete: ReferentialAction.Cascade); }
protected override void Up(MigrationBuilder migrationBuilder) { migrationBuilder.AlterDatabase() .Annotation("Npgsql:PostgresExtension:postgis", "'postgis', '', ''"); migrationBuilder.CreateTable( name: "AspNetRoles", columns: table => new { Id = table.Column <string>(nullable: false), Name = table.Column <string>(maxLength: 256, nullable: true), NormalizedName = table.Column <string>(maxLength: 256, nullable: true), ConcurrencyStamp = table.Column <string>(nullable: true) }, constraints: table => { table.PrimaryKey("PK_AspNetRoles", x => x.Id); }); migrationBuilder.CreateTable( name: "AspNetUsers", columns: table => new { Id = table.Column <string>(nullable: false), UserName = table.Column <string>(maxLength: 256, nullable: true), NormalizedUserName = table.Column <string>(maxLength: 256, nullable: true), Email = table.Column <string>(maxLength: 256, nullable: true), NormalizedEmail = table.Column <string>(maxLength: 256, nullable: true), EmailConfirmed = table.Column <bool>(nullable: false), PasswordHash = table.Column <string>(nullable: true), SecurityStamp = table.Column <string>(nullable: true), ConcurrencyStamp = table.Column <string>(nullable: true), PhoneNumber = table.Column <string>(nullable: true), PhoneNumberConfirmed = table.Column <bool>(nullable: false), TwoFactorEnabled = table.Column <bool>(nullable: false), LockoutEnd = table.Column <DateTimeOffset>(nullable: true), LockoutEnabled = table.Column <bool>(nullable: false), AccessFailedCount = table.Column <int>(nullable: false), FirstName = table.Column <string>(nullable: true), LastName = table.Column <string>(nullable: true), PrivateKey = table.Column <string>(nullable: true) }, constraints: table => { table.PrimaryKey("PK_AspNetUsers", x => x.Id); }); migrationBuilder.CreateTable( name: "Contracts", columns: table => new { Id = table.Column <long>(nullable: false) .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.SerialColumn), TokenValue = table.Column <long>(nullable: false), FromLatitude = table.Column <double>(nullable: false), FromLongitude = table.Column <double>(nullable: false), ToLatitude = table.Column <double>(nullable: false), ToLongitude = table.Column <double>(nullable: false) }, constraints: table => { table.PrimaryKey("PK_Contracts", x => x.Id); }); migrationBuilder.CreateTable( name: "AspNetRoleClaims", columns: table => new { Id = table.Column <int>(nullable: false) .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.SerialColumn), RoleId = table.Column <string>(nullable: false), ClaimType = table.Column <string>(nullable: true), ClaimValue = table.Column <string>(nullable: true) }, constraints: table => { table.PrimaryKey("PK_AspNetRoleClaims", x => x.Id); table.ForeignKey( name: "FK_AspNetRoleClaims_AspNetRoles_RoleId", column: x => x.RoleId, principalTable: "AspNetRoles", principalColumn: "Id", onDelete: ReferentialAction.Cascade); }); migrationBuilder.CreateTable( name: "AdminResponces", columns: table => new { Id = table.Column <Guid>(nullable: false), Message = table.Column <string>(nullable: true), CreationTime = table.Column <DateTime>(nullable: false), AdminId = table.Column <Guid>(nullable: false), IdentityId = table.Column <string>(nullable: true), AppUserId = table.Column <string>(nullable: true) }, constraints: table => { table.PrimaryKey("PK_AdminResponces", x => x.Id); table.ForeignKey( name: "FK_AdminResponces_AspNetUsers_AppUserId", column: x => x.AppUserId, principalTable: "AspNetUsers", principalColumn: "Id", onDelete: ReferentialAction.Restrict); }); migrationBuilder.CreateTable( name: "Admins", columns: table => new { Id = table.Column <Guid>(nullable: false), IdentityId = table.Column <string>(nullable: true), IsApproved = table.Column <bool>(nullable: false) }, constraints: table => { table.PrimaryKey("PK_Admins", x => x.Id); table.ForeignKey( name: "FK_Admins_AspNetUsers_IdentityId", column: x => x.IdentityId, principalTable: "AspNetUsers", principalColumn: "Id", onDelete: ReferentialAction.Restrict); }); migrationBuilder.CreateTable( name: "AspNetUserClaims", columns: table => new { Id = table.Column <int>(nullable: false) .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.SerialColumn), UserId = table.Column <string>(nullable: false), ClaimType = table.Column <string>(nullable: true), ClaimValue = table.Column <string>(nullable: true) }, constraints: table => { table.PrimaryKey("PK_AspNetUserClaims", x => x.Id); table.ForeignKey( name: "FK_AspNetUserClaims_AspNetUsers_UserId", column: x => x.UserId, principalTable: "AspNetUsers", principalColumn: "Id", onDelete: ReferentialAction.Cascade); }); migrationBuilder.CreateTable( name: "AspNetUserLogins", columns: table => new { LoginProvider = table.Column <string>(nullable: false), ProviderKey = table.Column <string>(nullable: false), ProviderDisplayName = table.Column <string>(nullable: true), UserId = table.Column <string>(nullable: false) }, constraints: table => { table.PrimaryKey("PK_AspNetUserLogins", x => new { x.LoginProvider, x.ProviderKey }); table.ForeignKey( name: "FK_AspNetUserLogins_AspNetUsers_UserId", column: x => x.UserId, principalTable: "AspNetUsers", principalColumn: "Id", onDelete: ReferentialAction.Cascade); }); migrationBuilder.CreateTable( name: "AspNetUserRoles", columns: table => new { UserId = table.Column <string>(nullable: false), RoleId = table.Column <string>(nullable: false) }, constraints: table => { table.PrimaryKey("PK_AspNetUserRoles", x => new { x.UserId, x.RoleId }); table.ForeignKey( name: "FK_AspNetUserRoles_AspNetRoles_RoleId", column: x => x.RoleId, principalTable: "AspNetRoles", principalColumn: "Id", onDelete: ReferentialAction.Cascade); table.ForeignKey( name: "FK_AspNetUserRoles_AspNetUsers_UserId", column: x => x.UserId, principalTable: "AspNetUsers", principalColumn: "Id", onDelete: ReferentialAction.Cascade); }); migrationBuilder.CreateTable( name: "AspNetUserTokens", columns: table => new { UserId = table.Column <string>(nullable: false), LoginProvider = table.Column <string>(nullable: false), Name = table.Column <string>(nullable: false), Value = table.Column <string>(nullable: true) }, constraints: table => { table.PrimaryKey("PK_AspNetUserTokens", x => new { x.UserId, x.LoginProvider, x.Name }); table.ForeignKey( name: "FK_AspNetUserTokens_AspNetUsers_UserId", column: x => x.UserId, principalTable: "AspNetUsers", principalColumn: "Id", onDelete: ReferentialAction.Cascade); }); migrationBuilder.CreateTable( name: "Customers", columns: table => new { Id = table.Column <Guid>(nullable: false), ConnectionId = table.Column <string>(nullable: true), IdentityId = table.Column <string>(nullable: true) }, constraints: table => { table.PrimaryKey("PK_Customers", x => x.Id); table.ForeignKey( name: "FK_Customers_AspNetUsers_IdentityId", column: x => x.IdentityId, principalTable: "AspNetUsers", principalColumn: "Id", onDelete: ReferentialAction.Restrict); }); migrationBuilder.CreateTable( name: "Drivers", columns: table => new { Id = table.Column <Guid>(nullable: false), ConnectionId = table.Column <string>(nullable: true), IdentityId = table.Column <string>(nullable: true), City = table.Column <string>(nullable: true), Location = table.Column <Point>(nullable: true) }, constraints: table => { table.PrimaryKey("PK_Drivers", x => x.Id); table.ForeignKey( name: "FK_Drivers_AspNetUsers_IdentityId", column: x => x.IdentityId, principalTable: "AspNetUsers", principalColumn: "Id", onDelete: ReferentialAction.Restrict); }); migrationBuilder.CreateTable( name: "ProfilePictures", columns: table => new { Id = table.Column <string>(nullable: false), IdentityId = table.Column <string>(nullable: true) }, constraints: table => { table.PrimaryKey("PK_ProfilePictures", x => x.Id); table.ForeignKey( name: "FK_ProfilePictures_AspNetUsers_IdentityId", column: x => x.IdentityId, principalTable: "AspNetUsers", principalColumn: "Id", onDelete: ReferentialAction.Restrict); }); migrationBuilder.CreateTable( name: "RefreshTokens", columns: table => new { Token = table.Column <string>(nullable: false), IdentityId = table.Column <string>(nullable: true), Expiration = table.Column <long>(nullable: false), Ip = table.Column <string>(nullable: true), Useragent = table.Column <string>(nullable: true) }, constraints: table => { table.PrimaryKey("PK_RefreshTokens", x => x.Token); table.ForeignKey( name: "FK_RefreshTokens_AspNetUsers_IdentityId", column: x => x.IdentityId, principalTable: "AspNetUsers", principalColumn: "Id", onDelete: ReferentialAction.Restrict); }); migrationBuilder.CreateTable( name: "RefundRequests", columns: table => new { Id = table.Column <Guid>(nullable: false), Message = table.Column <string>(nullable: true), CreationTime = table.Column <DateTime>(nullable: false), Solved = table.Column <bool>(nullable: false), CustomerId = table.Column <Guid>(nullable: false), IdentityId = table.Column <string>(nullable: true), TripHistoryId = table.Column <Guid>(nullable: false), AdminResponseId = table.Column <Guid>(nullable: false) }, constraints: table => { table.PrimaryKey("PK_RefundRequests", x => x.Id); table.ForeignKey( name: "FK_RefundRequests_Customers_CustomerId", column: x => x.CustomerId, principalTable: "Customers", principalColumn: "Id", onDelete: ReferentialAction.Cascade); }); migrationBuilder.CreateTable( name: "DriverLicenses", columns: table => new { Id = table.Column <Guid>(nullable: false), LicensedFrom = table.Column <DateTime>(nullable: false), LicensedTo = table.Column <DateTime>(nullable: false), ImageId = table.Column <string>(nullable: true), UpdateTime = table.Column <DateTime>(nullable: false), DriverId = table.Column <Guid>(nullable: false), IsApproved = table.Column <bool>(nullable: false) }, constraints: table => { table.PrimaryKey("PK_DriverLicenses", x => x.Id); table.ForeignKey( name: "FK_DriverLicenses_Drivers_DriverId", column: x => x.DriverId, principalTable: "Drivers", principalColumn: "Id", onDelete: ReferentialAction.Cascade); }); migrationBuilder.CreateTable( name: "TripHistories", columns: table => new { ContractId = table.Column <long>(nullable: false), Id = table.Column <Guid>(nullable: false), CustomerId = table.Column <Guid>(nullable: false), DriverId = table.Column <Guid>(nullable: false), From = table.Column <Point>(nullable: true), To = table.Column <Point>(nullable: true), CreationTime = table.Column <DateTime>(nullable: false), DriverTakeTripTime = table.Column <DateTime>(nullable: false), StartTime = table.Column <DateTime>(nullable: false), FinishTime = table.Column <DateTime>(nullable: false), Price = table.Column <long>(nullable: false), Distance = table.Column <double>(nullable: false) }, constraints: table => { table.PrimaryKey("PK_TripHistories", x => x.Id); table.ForeignKey( name: "FK_TripHistories_Customers_CustomerId", column: x => x.CustomerId, principalTable: "Customers", principalColumn: "Id", onDelete: ReferentialAction.Cascade); table.ForeignKey( name: "FK_TripHistories_Drivers_DriverId", column: x => x.DriverId, principalTable: "Drivers", principalColumn: "Id", onDelete: ReferentialAction.Cascade); }); migrationBuilder.CreateTable( name: "Trips", columns: table => new { ContractId = table.Column <long>(nullable: false), Id = table.Column <Guid>(nullable: false), CustomerId = table.Column <Guid>(nullable: false), DriverId = table.Column <Guid>(nullable: true), From = table.Column <Point>(nullable: true), To = table.Column <Point>(nullable: true), LastLat = table.Column <double>(nullable: false), LastLon = table.Column <double>(nullable: false), Distance = table.Column <double>(nullable: false), Price = table.Column <long>(nullable: false), LastUpdateTime = table.Column <DateTime>(nullable: false), CreationTime = table.Column <DateTime>(nullable: false), DriverTakeTripTime = table.Column <DateTime>(nullable: false), StartTime = table.Column <DateTime>(nullable: false), FinishTime = table.Column <DateTime>(nullable: false) }, constraints: table => { table.PrimaryKey("PK_Trips", x => x.Id); table.ForeignKey( name: "FK_Trips_Customers_CustomerId", column: x => x.CustomerId, principalTable: "Customers", principalColumn: "Id", onDelete: ReferentialAction.Cascade); table.ForeignKey( name: "FK_Trips_Drivers_DriverId", column: x => x.DriverId, principalTable: "Drivers", principalColumn: "Id", onDelete: ReferentialAction.Restrict); }); migrationBuilder.CreateTable( name: "Vehicles", columns: table => new { Id = table.Column <Guid>(nullable: false), Number = table.Column <string>(nullable: true), Model = table.Column <string>(nullable: true), Brand = table.Column <string>(nullable: true), Color = table.Column <string>(nullable: true), DriverId = table.Column <Guid>(nullable: false) }, constraints: table => { table.PrimaryKey("PK_Vehicles", x => x.Id); table.ForeignKey( name: "FK_Vehicles_Drivers_DriverId", column: x => x.DriverId, principalTable: "Drivers", principalColumn: "Id", onDelete: ReferentialAction.Cascade); }); migrationBuilder.CreateTable( name: "TripHistoryRouteNodes", columns: table => new { Latitude = table.Column <double>(nullable: false), Longitude = table.Column <double>(nullable: false), UpdateTime = table.Column <DateTime>(nullable: false), Id = table.Column <Guid>(nullable: false), TripHistoryId = table.Column <Guid>(nullable: false) }, constraints: table => { table.PrimaryKey("PK_TripHistoryRouteNodes", x => x.Id); table.ForeignKey( name: "FK_TripHistoryRouteNodes_TripHistories_TripHistoryId", column: x => x.TripHistoryId, principalTable: "TripHistories", principalColumn: "Id", onDelete: ReferentialAction.Cascade); }); migrationBuilder.CreateTable( name: "TripRouteNodes", columns: table => new { Latitude = table.Column <double>(nullable: false), Longitude = table.Column <double>(nullable: false), UpdateTime = table.Column <DateTime>(nullable: false), Id = table.Column <Guid>(nullable: false), TripId = table.Column <Guid>(nullable: false) }, constraints: table => { table.PrimaryKey("PK_TripRouteNodes", x => x.Id); table.ForeignKey( name: "FK_TripRouteNodes_Trips_TripId", column: x => x.TripId, principalTable: "Trips", principalColumn: "Id", onDelete: ReferentialAction.Cascade); }); migrationBuilder.CreateTable( name: "Pictures", columns: table => new { Id = table.Column <string>(nullable: false), VehicleId = table.Column <Guid>(nullable: false) }, constraints: table => { table.PrimaryKey("PK_Pictures", x => x.Id); table.ForeignKey( name: "FK_Pictures_Vehicles_VehicleId", column: x => x.VehicleId, principalTable: "Vehicles", principalColumn: "Id", onDelete: ReferentialAction.Cascade); }); migrationBuilder.CreateIndex( name: "IX_AdminResponces_AppUserId", table: "AdminResponces", column: "AppUserId"); migrationBuilder.CreateIndex( name: "IX_Admins_IdentityId", table: "Admins", column: "IdentityId"); migrationBuilder.CreateIndex( name: "IX_AspNetRoleClaims_RoleId", table: "AspNetRoleClaims", column: "RoleId"); migrationBuilder.CreateIndex( name: "RoleNameIndex", table: "AspNetRoles", column: "NormalizedName", unique: true); migrationBuilder.CreateIndex( name: "IX_AspNetUserClaims_UserId", table: "AspNetUserClaims", column: "UserId"); migrationBuilder.CreateIndex( name: "IX_AspNetUserLogins_UserId", table: "AspNetUserLogins", column: "UserId"); migrationBuilder.CreateIndex( name: "IX_AspNetUserRoles_RoleId", table: "AspNetUserRoles", column: "RoleId"); migrationBuilder.CreateIndex( name: "EmailIndex", table: "AspNetUsers", column: "NormalizedEmail"); migrationBuilder.CreateIndex( name: "UserNameIndex", table: "AspNetUsers", column: "NormalizedUserName", unique: true); migrationBuilder.CreateIndex( name: "IX_Customers_IdentityId", table: "Customers", column: "IdentityId"); migrationBuilder.CreateIndex( name: "IX_DriverLicenses_DriverId", table: "DriverLicenses", column: "DriverId", unique: true); migrationBuilder.CreateIndex( name: "IX_Drivers_IdentityId", table: "Drivers", column: "IdentityId"); migrationBuilder.CreateIndex( name: "IX_Pictures_VehicleId", table: "Pictures", column: "VehicleId"); migrationBuilder.CreateIndex( name: "IX_ProfilePictures_IdentityId", table: "ProfilePictures", column: "IdentityId", unique: true); migrationBuilder.CreateIndex( name: "IX_RefreshTokens_IdentityId", table: "RefreshTokens", column: "IdentityId"); migrationBuilder.CreateIndex( name: "IX_RefundRequests_CustomerId", table: "RefundRequests", column: "CustomerId"); migrationBuilder.CreateIndex( name: "IX_TripHistories_CustomerId", table: "TripHistories", column: "CustomerId"); migrationBuilder.CreateIndex( name: "IX_TripHistories_DriverId", table: "TripHistories", column: "DriverId"); migrationBuilder.CreateIndex( name: "IX_TripHistoryRouteNodes_TripHistoryId", table: "TripHistoryRouteNodes", column: "TripHistoryId"); migrationBuilder.CreateIndex( name: "IX_TripRouteNodes_TripId", table: "TripRouteNodes", column: "TripId"); migrationBuilder.CreateIndex( name: "IX_Trips_CustomerId", table: "Trips", column: "CustomerId", unique: true); migrationBuilder.CreateIndex( name: "IX_Trips_DriverId", table: "Trips", column: "DriverId", unique: true); migrationBuilder.CreateIndex( name: "IX_Vehicles_DriverId", table: "Vehicles", column: "DriverId", unique: true); }