using System; using Microsoft.EntityFrameworkCore.Migrations; #nullable disable namespace EARSystem.Infrastructure.Migrations { /// public partial class InitialCreate : Migration { /// protected override void Up(MigrationBuilder migrationBuilder) { migrationBuilder.CreateTable( name: "AspNetRoles", columns: table => new { Id = table.Column(type: "nvarchar(450)", nullable: false), Name = table.Column(type: "nvarchar(256)", maxLength: 256, nullable: true), NormalizedName = table.Column(type: "nvarchar(256)", maxLength: 256, nullable: true), ConcurrencyStamp = table.Column(type: "nvarchar(max)", nullable: true) }, constraints: table => { table.PrimaryKey("PK_AspNetRoles", x => x.Id); }); migrationBuilder.CreateTable( name: "AspNetUsers", columns: table => new { Id = table.Column(type: "nvarchar(450)", nullable: false), DisplayName = table.Column(type: "nvarchar(40)", maxLength: 40, nullable: false), IsDemo = table.Column(type: "bit", nullable: false), UserName = table.Column(type: "nvarchar(256)", maxLength: 256, nullable: true), NormalizedUserName = table.Column(type: "nvarchar(256)", maxLength: 256, nullable: true), Email = table.Column(type: "nvarchar(256)", maxLength: 256, nullable: true), NormalizedEmail = table.Column(type: "nvarchar(256)", maxLength: 256, nullable: true), EmailConfirmed = table.Column(type: "bit", nullable: false), PasswordHash = table.Column(type: "nvarchar(max)", nullable: true), SecurityStamp = table.Column(type: "nvarchar(max)", nullable: true), ConcurrencyStamp = table.Column(type: "nvarchar(max)", nullable: true), PhoneNumber = table.Column(type: "nvarchar(max)", nullable: true), PhoneNumberConfirmed = table.Column(type: "bit", nullable: false), TwoFactorEnabled = table.Column(type: "bit", nullable: false), LockoutEnd = table.Column(type: "datetimeoffset", nullable: true), LockoutEnabled = table.Column(type: "bit", nullable: false), AccessFailedCount = table.Column(type: "int", nullable: false) }, constraints: table => { table.PrimaryKey("PK_AspNetUsers", x => x.Id); }); migrationBuilder.CreateTable( name: "Places", columns: table => new { Id = table.Column(type: "uniqueidentifier", nullable: false), Name = table.Column(type: "nvarchar(100)", maxLength: 100, nullable: false), Address = table.Column(type: "nvarchar(300)", maxLength: 300, nullable: false), Description = table.Column(type: "nvarchar(1000)", maxLength: 1000, nullable: false), Category = table.Column(type: "int", nullable: false), Source = table.Column(type: "int", nullable: false), Longitude = table.Column(type: "float", nullable: false), Latitude = table.Column(type: "float", nullable: false), Price = table.Column(type: "decimal(10,2)", precision: 10, scale: 2, nullable: true), Rating = table.Column(type: "float", nullable: true), OpenHour = table.Column(type: "int", nullable: true), CloseHour = table.Column(type: "int", nullable: true), AuthorizedExternalId = table.Column(type: "nvarchar(100)", maxLength: 100, nullable: true) }, constraints: table => { table.PrimaryKey("PK_Places", x => x.Id); }); migrationBuilder.CreateTable( name: "Rules", columns: table => new { Id = table.Column(type: "int", nullable: false) .Annotation("SqlServer:Identity", "1, 1"), Version = table.Column(type: "nvarchar(50)", maxLength: 50, nullable: false), WeightsJson = table.Column(type: "nvarchar(max)", nullable: false), ConcurrencyStamp = table.Column(type: "uniqueidentifier", nullable: false) }, constraints: table => { table.PrimaryKey("PK_Rules", x => x.Id); }); migrationBuilder.CreateTable( name: "AspNetRoleClaims", columns: table => new { Id = table.Column(type: "int", nullable: false) .Annotation("SqlServer:Identity", "1, 1"), RoleId = table.Column(type: "nvarchar(450)", nullable: false), ClaimType = table.Column(type: "nvarchar(max)", nullable: true), ClaimValue = table.Column(type: "nvarchar(max)", 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(type: "int", nullable: false) .Annotation("SqlServer:Identity", "1, 1"), UserId = table.Column(type: "nvarchar(450)", nullable: false), ClaimType = table.Column(type: "nvarchar(max)", nullable: true), ClaimValue = table.Column(type: "nvarchar(max)", 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(type: "nvarchar(450)", nullable: false), ProviderKey = table.Column(type: "nvarchar(450)", nullable: false), ProviderDisplayName = table.Column(type: "nvarchar(max)", nullable: true), UserId = table.Column(type: "nvarchar(450)", 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(type: "nvarchar(450)", nullable: false), RoleId = table.Column(type: "nvarchar(450)", 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(type: "nvarchar(450)", nullable: false), LoginProvider = table.Column(type: "nvarchar(450)", nullable: false), Name = table.Column(type: "nvarchar(450)", nullable: false), Value = table.Column(type: "nvarchar(max)", 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: "Moods", columns: table => new { Id = table.Column(type: "uniqueidentifier", nullable: false), UserId = table.Column(type: "nvarchar(450)", nullable: false), Mood = table.Column(type: "int", nullable: false), Energy = table.Column(type: "int", nullable: false), Stress = table.Column(type: "int", nullable: false), TagsJson = table.Column(type: "nvarchar(1000)", maxLength: 1000, nullable: false), Thoughts = table.Column(type: "nvarchar(max)", maxLength: 5000, nullable: false), RecordedAt = table.Column(type: "bigint", nullable: false), CreatedAt = table.Column(type: "bigint", nullable: false), Version = table.Column(type: "uniqueidentifier", nullable: false), ExperienceId = table.Column(type: "uniqueidentifier", nullable: true) }, constraints: table => { table.PrimaryKey("PK_Moods", x => x.Id); table.ForeignKey( name: "FK_Moods_AspNetUsers_UserId", column: x => x.UserId, principalTable: "AspNetUsers", principalColumn: "Id", onDelete: ReferentialAction.Cascade); }); migrationBuilder.CreateTable( name: "Preferences", columns: table => new { UserId = table.Column(type: "nvarchar(450)", nullable: false), FavoriteCategoriesJson = table.Column(type: "nvarchar(max)", nullable: false), BlockedCategoriesJson = table.Column(type: "nvarchar(max)", nullable: false), BlockedPlacesJson = table.Column(type: "nvarchar(max)", nullable: false), Budget = table.Column(type: "decimal(10,2)", precision: 10, scale: 2, nullable: true), RadiusMeters = table.Column(type: "int", nullable: false) }, constraints: table => { table.PrimaryKey("PK_Preferences", x => x.UserId); table.ForeignKey( name: "FK_Preferences_AspNetUsers_UserId", column: x => x.UserId, principalTable: "AspNetUsers", principalColumn: "Id", onDelete: ReferentialAction.Cascade); }); migrationBuilder.CreateTable( name: "Recommendations", columns: table => new { Id = table.Column(type: "uniqueidentifier", nullable: false), UserId = table.Column(type: "nvarchar(450)", nullable: false), Goal = table.Column(type: "int", nullable: false), Mode = table.Column(type: "int", nullable: false), AlgorithmVersion = table.Column(type: "nvarchar(50)", maxLength: 50, nullable: false), ResultsJson = table.Column(type: "nvarchar(max)", nullable: false), CreatedAt = table.Column(type: "bigint", nullable: false), DurationMs = table.Column(type: "float", nullable: false) }, constraints: table => { table.PrimaryKey("PK_Recommendations", x => x.Id); table.ForeignKey( name: "FK_Recommendations_AspNetUsers_UserId", column: x => x.UserId, principalTable: "AspNetUsers", principalColumn: "Id", onDelete: ReferentialAction.Cascade); }); migrationBuilder.CreateTable( name: "Atmospheres", columns: table => new { PlaceId = table.Column(type: "uniqueidentifier", nullable: false), Quiet = table.Column(type: "float", nullable: false), Comfort = table.Column(type: "float", nullable: false), Nature = table.Column(type: "float", nullable: false), Liveliness = table.Column(type: "float", nullable: false), Social = table.Column(type: "float", nullable: false), Focus = table.Column(type: "float", nullable: false), BaselineCount = table.Column(type: "int", nullable: false), Evidence = table.Column(type: "nvarchar(500)", maxLength: 500, nullable: false) }, constraints: table => { table.PrimaryKey("PK_Atmospheres", x => x.PlaceId); table.ForeignKey( name: "FK_Atmospheres_Places_PlaceId", column: x => x.PlaceId, principalTable: "Places", principalColumn: "Id", onDelete: ReferentialAction.Cascade); }); migrationBuilder.CreateTable( name: "Experiences", columns: table => new { Id = table.Column(type: "uniqueidentifier", nullable: false), UserId = table.Column(type: "nvarchar(450)", nullable: false), PlaceId = table.Column(type: "uniqueidentifier", nullable: false), VisitedAt = table.Column(type: "bigint", nullable: false), VisitDay = table.Column(type: "int", nullable: false), Satisfaction = table.Column(type: "int", nullable: false), MoodBefore = table.Column(type: "int", nullable: true), MoodAfter = table.Column(type: "int", nullable: true), Quiet = table.Column(type: "int", nullable: false), Comfort = table.Column(type: "int", nullable: false), Nature = table.Column(type: "int", nullable: false), Liveliness = table.Column(type: "int", nullable: false), Social = table.Column(type: "int", nullable: false), Focus = table.Column(type: "int", nullable: false), Thoughts = table.Column(type: "nvarchar(max)", maxLength: 5000, nullable: false), Contribute = table.Column(type: "bit", nullable: false), CreatedAt = table.Column(type: "bigint", nullable: false), Version = table.Column(type: "uniqueidentifier", nullable: false) }, constraints: table => { table.PrimaryKey("PK_Experiences", x => x.Id); table.ForeignKey( name: "FK_Experiences_AspNetUsers_UserId", column: x => x.UserId, principalTable: "AspNetUsers", principalColumn: "Id", onDelete: ReferentialAction.Cascade); table.ForeignKey( name: "FK_Experiences_Places_PlaceId", column: x => x.PlaceId, principalTable: "Places", principalColumn: "Id", onDelete: ReferentialAction.Restrict); }); migrationBuilder.CreateTable( name: "Favorites", columns: table => new { UserId = table.Column(type: "nvarchar(450)", nullable: false), PlaceId = table.Column(type: "uniqueidentifier", nullable: false), CreatedAt = table.Column(type: "bigint", nullable: false) }, constraints: table => { table.PrimaryKey("PK_Favorites", x => new { x.UserId, x.PlaceId }); table.ForeignKey( name: "FK_Favorites_AspNetUsers_UserId", column: x => x.UserId, principalTable: "AspNetUsers", principalColumn: "Id", onDelete: ReferentialAction.Cascade); table.ForeignKey( name: "FK_Favorites_Places_PlaceId", column: x => x.PlaceId, principalTable: "Places", 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, 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_Experiences_PlaceId_Contribute", table: "Experiences", columns: new[] { "PlaceId", "Contribute" }); migrationBuilder.CreateIndex( name: "IX_Experiences_UserId_PlaceId_VisitDay", table: "Experiences", columns: new[] { "UserId", "PlaceId", "VisitDay" }, unique: true); migrationBuilder.CreateIndex( name: "IX_Experiences_UserId_VisitedAt", table: "Experiences", columns: new[] { "UserId", "VisitedAt" }); migrationBuilder.CreateIndex( name: "IX_Favorites_PlaceId", table: "Favorites", column: "PlaceId"); migrationBuilder.CreateIndex( name: "IX_Moods_UserId_RecordedAt", table: "Moods", columns: new[] { "UserId", "RecordedAt" }); migrationBuilder.CreateIndex( name: "IX_Places_Source_Category", table: "Places", columns: new[] { "Source", "Category" }); migrationBuilder.CreateIndex( name: "IX_Recommendations_UserId_CreatedAt", table: "Recommendations", columns: new[] { "UserId", "CreatedAt" }); } /// protected override void Down(MigrationBuilder migrationBuilder) { migrationBuilder.DropTable( name: "AspNetRoleClaims"); migrationBuilder.DropTable( name: "AspNetUserClaims"); migrationBuilder.DropTable( name: "AspNetUserLogins"); migrationBuilder.DropTable( name: "AspNetUserRoles"); migrationBuilder.DropTable( name: "AspNetUserTokens"); migrationBuilder.DropTable( name: "Atmospheres"); migrationBuilder.DropTable( name: "Experiences"); migrationBuilder.DropTable( name: "Favorites"); migrationBuilder.DropTable( name: "Moods"); migrationBuilder.DropTable( name: "Preferences"); migrationBuilder.DropTable( name: "Recommendations"); migrationBuilder.DropTable( name: "Rules"); migrationBuilder.DropTable( name: "AspNetRoles"); migrationBuilder.DropTable( name: "Places"); migrationBuilder.DropTable( name: "AspNetUsers"); } } }