using System; using Microsoft.EntityFrameworkCore.Metadata; using Microsoft.EntityFrameworkCore.Migrations; namespace RMuseum.Migrations { public partial class Initial : Migration { protected override void Up(MigrationBuilder migrationBuilder) { migrationBuilder.CreateTable( name: "AspNetRoles", columns: table => new { Id = table.Column(nullable: false), Name = table.Column(maxLength: 256, nullable: true), NormalizedName = table.Column(maxLength: 256, nullable: true), ConcurrencyStamp = table.Column(nullable: true), Description = table.Column(nullable: true) }, constraints: table => { table.PrimaryKey("PK_AspNetRoles", x => x.Id); }); migrationBuilder.CreateTable( name: "Tags", columns: table => new { Id = table.Column(nullable: false), Order = table.Column(nullable: false), TagType = table.Column(nullable: false), FriendlyUrl = table.Column(nullable: true), Status = table.Column(nullable: false), Name = table.Column(nullable: true), NameInEnglish = table.Column(nullable: true), PluralName = table.Column(nullable: true), PluralNameInEnglish = table.Column(nullable: true), GlobalValue = table.Column(nullable: false) }, constraints: table => { table.PrimaryKey("PK_Tags", x => x.Id); }); migrationBuilder.CreateTable( name: "VerifyQueueItems", columns: table => new { Id = table.Column(nullable: false), QueueType = table.Column(nullable: false), Email = table.Column(nullable: true), PhoneNumber = table.Column(nullable: true), DateTime = table.Column(nullable: false), Secret = table.Column(nullable: true), ClientIPAddress = table.Column(nullable: true), ClientAppName = table.Column(nullable: true), Language = table.Column(nullable: true) }, constraints: table => { table.PrimaryKey("PK_VerifyQueueItems", x => x.Id); }); migrationBuilder.CreateTable( name: "AspNetRoleClaims", columns: table => new { Id = table.Column(nullable: false) .Annotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn), RoleId = table.Column(nullable: false), ClaimType = table.Column(nullable: true), ClaimValue = table.Column(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: "Permissions", columns: table => new { Id = table.Column(nullable: false), SecurableItemShortName = table.Column(nullable: true), OperationShortName = table.Column(nullable: true), RAppRoleId = table.Column(nullable: true) }, constraints: table => { table.PrimaryKey("PK_Permissions", x => x.Id); table.ForeignKey( name: "FK_Permissions_AspNetRoles_RAppRoleId", column: x => x.RAppRoleId, principalTable: "AspNetRoles", principalColumn: "Id", onDelete: ReferentialAction.Restrict); }); migrationBuilder.CreateTable( name: "ImportJobs", columns: table => new { Id = table.Column(nullable: false), JobType = table.Column(nullable: false), ResourceNumber = table.Column(nullable: true), FriendlyUrl = table.Column(nullable: true), SrcUrl = table.Column(nullable: true), QueueTime = table.Column(nullable: false), StartTime = table.Column(nullable: false), EndTime = table.Column(nullable: false), Status = table.Column(nullable: false), ProgressPercent = table.Column(nullable: false), Exception = table.Column(nullable: true), ArtifactId = table.Column(nullable: true), SrcContent = table.Column(nullable: true) }, constraints: table => { table.PrimaryKey("PK_ImportJobs", x => x.Id); }); migrationBuilder.CreateTable( name: "Items", columns: table => new { Id = table.Column(nullable: false), RArtifactMasterRecordId = table.Column(nullable: false), Order = table.Column(nullable: false), FriendlyUrl = table.Column(nullable: true), Name = table.Column(nullable: true), NameInEnglish = table.Column(nullable: true), Description = table.Column(nullable: true), DescriptionInEnglish = table.Column(nullable: true), CoverImageIndex = table.Column(nullable: false), LastModified = table.Column(nullable: false) }, constraints: table => { table.PrimaryKey("PK_Items", x => x.Id); }); migrationBuilder.CreateTable( name: "GeneralImages", columns: table => new { Id = table.Column(nullable: false), OriginalFileName = table.Column(nullable: true), ContentType = table.Column(nullable: true), FileSizeInBytes = table.Column(nullable: false), ImageWidth = table.Column(nullable: false), ImageHeight = table.Column(nullable: false), FolderName = table.Column(nullable: true), StoredFileName = table.Column(nullable: true), DataTime = table.Column(nullable: false), LastModified = table.Column(nullable: false), Discriminator = table.Column(nullable: false), Title = table.Column(nullable: true), TitleInEnglish = table.Column(nullable: true), Description = table.Column(nullable: true), DescriptionInEnglish = table.Column(nullable: true), Status = table.Column(nullable: true), Order = table.Column(nullable: true), NormalSizeImageStoredFileName = table.Column(nullable: true), ThumbnailImageStoredFileName = table.Column(nullable: true), NormalSizeImageWidth = table.Column(nullable: true), NormalSizeImageHeight = table.Column(nullable: true), ThumbnailImageWidth = table.Column(nullable: true), ThumbnailImageHeight = table.Column(nullable: true), SrcUrl = table.Column(nullable: true), LastModifiedMeta = table.Column(nullable: true), RArtifactItemRecordId = table.Column(nullable: true) }, constraints: table => { table.PrimaryKey("PK_GeneralImages", x => x.Id); table.ForeignKey( name: "FK_GeneralImages_Items_RArtifactItemRecordId", column: x => x.RArtifactItemRecordId, principalTable: "Items", principalColumn: "Id", onDelete: ReferentialAction.Restrict); }); migrationBuilder.CreateTable( name: "Artifacts", columns: table => new { Id = table.Column(nullable: false), FriendlyUrl = table.Column(nullable: true), Status = table.Column(nullable: false), Name = table.Column(nullable: true), NameInEnglish = table.Column(nullable: true), Description = table.Column(nullable: true), DescriptionInEnglish = table.Column(nullable: true), DateTime = table.Column(nullable: false), LastModified = table.Column(nullable: false), CoverItemIndex = table.Column(nullable: false), CoverImageId = table.Column(nullable: false), ItemCount = table.Column(nullable: false) }, constraints: table => { table.PrimaryKey("PK_Artifacts", x => x.Id); table.ForeignKey( name: "FK_Artifacts_GeneralImages_CoverImageId", column: x => x.CoverImageId, principalTable: "GeneralImages", principalColumn: "Id", onDelete: ReferentialAction.Cascade); }); migrationBuilder.CreateTable( name: "AspNetUsers", columns: table => new { Id = table.Column(nullable: false), UserName = table.Column(maxLength: 256, nullable: true), NormalizedUserName = table.Column(maxLength: 256, nullable: true), Email = table.Column(maxLength: 256, nullable: true), NormalizedEmail = table.Column(maxLength: 256, nullable: true), EmailConfirmed = table.Column(nullable: false), PasswordHash = table.Column(nullable: true), SecurityStamp = table.Column(nullable: true), ConcurrencyStamp = table.Column(nullable: true), PhoneNumber = table.Column(nullable: true), PhoneNumberConfirmed = table.Column(nullable: false), TwoFactorEnabled = table.Column(nullable: false), LockoutEnd = table.Column(nullable: true), LockoutEnabled = table.Column(nullable: false), AccessFailedCount = table.Column(nullable: false), FirstName = table.Column(nullable: true), SureName = table.Column(nullable: true), CreateDate = table.Column(nullable: false), Status = table.Column(nullable: false), RImageId = table.Column(nullable: true) }, constraints: table => { table.PrimaryKey("PK_AspNetUsers", x => x.Id); table.ForeignKey( name: "FK_AspNetUsers_GeneralImages_RImageId", column: x => x.RImageId, principalTable: "GeneralImages", principalColumn: "Id", onDelete: ReferentialAction.Restrict); }); migrationBuilder.CreateTable( name: "CaptchaImages", columns: table => new { Id = table.Column(nullable: false), RImageId = table.Column(nullable: false), Value = table.Column(nullable: true), DateTime = table.Column(nullable: false) }, constraints: table => { table.PrimaryKey("PK_CaptchaImages", x => x.Id); table.ForeignKey( name: "FK_CaptchaImages_GeneralImages_RImageId", column: x => x.RImageId, principalTable: "GeneralImages", principalColumn: "Id", onDelete: ReferentialAction.Cascade); }); migrationBuilder.CreateTable( name: "TagValues", columns: table => new { Id = table.Column(nullable: false), RTagId = table.Column(nullable: false), Order = table.Column(nullable: false), FriendlyUrl = table.Column(nullable: true), Status = table.Column(nullable: false), Value = table.Column(nullable: true), ValueInEnglish = table.Column(nullable: true), ValueSupplement = table.Column(nullable: true), RArtifactItemRecordId = table.Column(nullable: true), RArtifactMasterRecordId = table.Column(nullable: true) }, constraints: table => { table.PrimaryKey("PK_TagValues", x => x.Id); table.ForeignKey( name: "FK_TagValues_Items_RArtifactItemRecordId", column: x => x.RArtifactItemRecordId, principalTable: "Items", principalColumn: "Id", onDelete: ReferentialAction.Restrict); table.ForeignKey( name: "FK_TagValues_Artifacts_RArtifactMasterRecordId", column: x => x.RArtifactMasterRecordId, principalTable: "Artifacts", principalColumn: "Id", onDelete: ReferentialAction.Restrict); table.ForeignKey( name: "FK_TagValues_Tags_RTagId", column: x => x.RTagId, principalTable: "Tags", principalColumn: "Id", onDelete: ReferentialAction.Cascade); }); migrationBuilder.CreateTable( name: "AspNetUserClaims", columns: table => new { Id = table.Column(nullable: false) .Annotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn), UserId = table.Column(nullable: false), ClaimType = table.Column(nullable: true), ClaimValue = table.Column(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(nullable: false), ProviderKey = table.Column(nullable: false), ProviderDisplayName = table.Column(nullable: true), UserId = table.Column(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(nullable: false), RoleId = table.Column(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(nullable: false), LoginProvider = table.Column(nullable: false), Name = table.Column(nullable: false), Value = table.Column(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: "Sessions", columns: table => new { Id = table.Column(nullable: false), RAppUserId = table.Column(nullable: false), ClientIPAddress = table.Column(nullable: true), ClientAppName = table.Column(nullable: true), Language = table.Column(nullable: true), LoginTime = table.Column(nullable: false), LastRenewal = table.Column(nullable: false), ValidUntil = table.Column(nullable: false), Token = table.Column(nullable: true) }, constraints: table => { table.PrimaryKey("PK_Sessions", x => x.Id); table.ForeignKey( name: "FK_Sessions_AspNetUsers_RAppUserId", column: x => x.RAppUserId, principalTable: "AspNetUsers", principalColumn: "Id", onDelete: ReferentialAction.Cascade); }); migrationBuilder.CreateIndex( name: "IX_Artifacts_CoverImageId", table: "Artifacts", column: "CoverImageId"); migrationBuilder.CreateIndex( name: "IX_Artifacts_FriendlyUrl", table: "Artifacts", column: "FriendlyUrl", unique: true, filter: "[FriendlyUrl] IS NOT NULL"); migrationBuilder.CreateIndex( name: "IX_AspNetRoleClaims_RoleId", table: "AspNetRoleClaims", column: "RoleId"); migrationBuilder.CreateIndex( name: "RoleNameIndex", table: "AspNetRoles", column: "NormalizedName", unique: true, filter: "[NormalizedName] IS NOT NULL"); 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, filter: "[NormalizedUserName] IS NOT NULL"); migrationBuilder.CreateIndex( name: "IX_AspNetUsers_RImageId", table: "AspNetUsers", column: "RImageId"); migrationBuilder.CreateIndex( name: "IX_CaptchaImages_RImageId", table: "CaptchaImages", column: "RImageId"); migrationBuilder.CreateIndex( name: "IX_GeneralImages_RArtifactItemRecordId", table: "GeneralImages", column: "RArtifactItemRecordId"); migrationBuilder.CreateIndex( name: "IX_ImportJobs_ArtifactId", table: "ImportJobs", column: "ArtifactId"); migrationBuilder.CreateIndex( name: "IX_Items_RArtifactMasterRecordId_FriendlyUrl", table: "Items", columns: new[] { "RArtifactMasterRecordId", "FriendlyUrl" }, unique: true, filter: "[FriendlyUrl] IS NOT NULL"); migrationBuilder.CreateIndex( name: "IX_Items_RArtifactMasterRecordId_Order", table: "Items", columns: new[] { "RArtifactMasterRecordId", "Order" }, unique: true); migrationBuilder.CreateIndex( name: "IX_Permissions_RAppRoleId", table: "Permissions", column: "RAppRoleId"); migrationBuilder.CreateIndex( name: "IX_Sessions_RAppUserId", table: "Sessions", column: "RAppUserId"); migrationBuilder.CreateIndex( name: "IX_Tags_FriendlyUrl", table: "Tags", column: "FriendlyUrl"); migrationBuilder.CreateIndex( name: "IX_TagValues_FriendlyUrl", table: "TagValues", column: "FriendlyUrl"); migrationBuilder.CreateIndex( name: "IX_TagValues_RArtifactItemRecordId", table: "TagValues", column: "RArtifactItemRecordId"); migrationBuilder.CreateIndex( name: "IX_TagValues_RArtifactMasterRecordId", table: "TagValues", column: "RArtifactMasterRecordId"); migrationBuilder.CreateIndex( name: "IX_TagValues_RTagId", table: "TagValues", column: "RTagId"); migrationBuilder.CreateIndex( name: "IX_VerifyQueueItems_Secret", table: "VerifyQueueItems", column: "Secret", unique: true, filter: "[Secret] IS NOT NULL"); migrationBuilder.AddForeignKey( name: "FK_ImportJobs_Artifacts_ArtifactId", table: "ImportJobs", column: "ArtifactId", principalTable: "Artifacts", principalColumn: "Id", onDelete: ReferentialAction.Restrict); migrationBuilder.AddForeignKey( name: "FK_Items_Artifacts_RArtifactMasterRecordId", table: "Items", column: "RArtifactMasterRecordId", principalTable: "Artifacts", principalColumn: "Id", onDelete: ReferentialAction.Cascade); } protected override void Down(MigrationBuilder migrationBuilder) { migrationBuilder.DropForeignKey( name: "FK_Artifacts_GeneralImages_CoverImageId", table: "Artifacts"); migrationBuilder.DropTable( name: "AspNetRoleClaims"); migrationBuilder.DropTable( name: "AspNetUserClaims"); migrationBuilder.DropTable( name: "AspNetUserLogins"); migrationBuilder.DropTable( name: "AspNetUserRoles"); migrationBuilder.DropTable( name: "AspNetUserTokens"); migrationBuilder.DropTable( name: "CaptchaImages"); migrationBuilder.DropTable( name: "ImportJobs"); migrationBuilder.DropTable( name: "Permissions"); migrationBuilder.DropTable( name: "Sessions"); migrationBuilder.DropTable( name: "TagValues"); migrationBuilder.DropTable( name: "VerifyQueueItems"); migrationBuilder.DropTable( name: "AspNetRoles"); migrationBuilder.DropTable( name: "AspNetUsers"); migrationBuilder.DropTable( name: "Tags"); migrationBuilder.DropTable( name: "GeneralImages"); migrationBuilder.DropTable( name: "Items"); migrationBuilder.DropTable( name: "Artifacts"); } } }