using System; using Microsoft.EntityFrameworkCore.Migrations; #nullable disable namespace gehGassiApp.Data.Migrations { public partial class Initial : Migration { protected override void Up(MigrationBuilder migrationBuilder) { migrationBuilder.CreateTable( name: "AppUsers", columns: table => new { Id = table.Column(type: "TEXT", maxLength: 128, nullable: false), Type = table.Column(type: "INTEGER", nullable: false), Title = table.Column(type: "TEXT", maxLength: 50, nullable: true), FirstName = table.Column(type: "TEXT", maxLength: 150, nullable: false), LastName = table.Column(type: "TEXT", maxLength: 150, nullable: false), Sex = table.Column(type: "INTEGER", nullable: false), BirthDate = table.Column(type: "INTEGER", nullable: true), Photo = table.Column(type: "TEXT", maxLength: 500, nullable: true), Contact_Email = table.Column(type: "TEXT", maxLength: 255, nullable: true), Contact_Phone = table.Column(type: "TEXT", maxLength: 100, nullable: true), Contact_Mobile = table.Column(type: "TEXT", maxLength: 100, nullable: true), Address_AddressLine1 = table.Column(type: "TEXT", maxLength: 100, nullable: true), Address_AddressLine2 = table.Column(type: "TEXT", maxLength: 100, nullable: true), Address_City = table.Column(type: "TEXT", maxLength: 100, nullable: true), Address_Zip = table.Column(type: "TEXT", maxLength: 20, nullable: true), Address_State = table.Column(type: "TEXT", maxLength: 100, nullable: true), Address_CountryCode = table.Column(type: "TEXT", maxLength: 2, nullable: true), Lat = table.Column(type: "REAL", nullable: false), Lng = table.Column(type: "REAL", nullable: false), SocialMedia_Twitter = table.Column(type: "TEXT", maxLength: 255, nullable: true), SocialMedia_Facebook = table.Column(type: "TEXT", maxLength: 255, nullable: true), SocialMedia_LinkedIn = table.Column(type: "TEXT", maxLength: 255, nullable: true), SocialMedia_Xing = table.Column(type: "TEXT", maxLength: 255, nullable: true), SocialMedia_Instagram = table.Column(type: "TEXT", maxLength: 255, nullable: true), SocialMedia_Pinterest = table.Column(type: "TEXT", maxLength: 255, nullable: true), SocialMedia_Blog = table.Column(type: "TEXT", maxLength: 255, nullable: true), SocialMedia_YouTube = table.Column(type: "TEXT", maxLength: 255, nullable: true), SocialMedia_Vimeo = table.Column(type: "TEXT", maxLength: 255, nullable: true), SocialMedia_SnapChat = table.Column(type: "TEXT", maxLength: 255, nullable: true), SocialMedia_TikTok = table.Column(type: "TEXT", maxLength: 255, nullable: true), SocialMedia_Reddit = table.Column(type: "TEXT", maxLength: 255, nullable: true), SocialMedia_Show = table.Column(type: "INTEGER", nullable: true), RatingStatistics_TotalRatings = table.Column(type: "INTEGER", nullable: true), RatingStatistics_TotalPoints = table.Column(type: "TEXT", nullable: true), RatingStatistics_AverageRating = table.Column(type: "TEXT", nullable: true), RatingStatisticsWalker_TotalRatings = table.Column(type: "INTEGER", nullable: true), RatingStatisticsWalker_TotalPoints = table.Column(type: "TEXT", nullable: true), RatingStatisticsWalker_AverageRating = table.Column(type: "TEXT", nullable: true), Locked = table.Column(type: "INTEGER", nullable: false), LockedUntil = table.Column(type: "INTEGER", nullable: true), Created = table.Column(type: "INTEGER", nullable: false), Version = table.Column(type: "BLOB", rowVersion: true, nullable: true), UpdatedAt = table.Column(type: "INTEGER", nullable: false), Deleted = table.Column(type: "INTEGER", nullable: false) }, constraints: table => { table.PrimaryKey("PK_AppUsers", x => x.Id); }); migrationBuilder.CreateTable( name: "Conversations", columns: table => new { Id = table.Column(type: "TEXT", maxLength: 128, nullable: false), Recipient = table.Column(type: "TEXT", maxLength: 128, nullable: false), ReceipientType = table.Column(type: "INTEGER", nullable: false), RecipientName = table.Column(type: "TEXT", maxLength: 300, nullable: true), RecipientShort = table.Column(type: "TEXT", maxLength: 2, nullable: true), RecipientPhoto = table.Column(type: "TEXT", nullable: true), LastMessageId = table.Column(type: "TEXT", maxLength: 128, nullable: true), LastMessagePreview = table.Column(type: "TEXT", nullable: true), HasUnreadMessages = table.Column(type: "INTEGER", nullable: false), Created = table.Column(type: "INTEGER", nullable: false), Version = table.Column(type: "BLOB", rowVersion: true, nullable: true), UpdatedAt = table.Column(type: "INTEGER", nullable: false), Deleted = table.Column(type: "INTEGER", nullable: false) }, constraints: table => { table.PrimaryKey("PK_Conversations", x => x.Id); }); migrationBuilder.CreateTable( name: "DogRaces", columns: table => new { Id = table.Column(type: "TEXT", maxLength: 128, nullable: false), Name = table.Column(type: "TEXT", maxLength: 100, nullable: false), Description = table.Column(type: "TEXT", maxLength: 5000, nullable: true), Age = table.Column(type: "TEXT", maxLength: 1000, nullable: true), SizeAndWeight = table.Column(type: "TEXT", maxLength: 1000, nullable: true), Personality = table.Column(type: "TEXT", maxLength: 2000, nullable: true), Coexistence = table.Column(type: "TEXT", maxLength: 1000, nullable: true), Care = table.Column(type: "TEXT", maxLength: 1000, nullable: true), Decision = table.Column(type: "TEXT", maxLength: 2000, nullable: true), Photo = table.Column(type: "TEXT", maxLength: 500, nullable: true), Created = table.Column(type: "INTEGER", nullable: false), Version = table.Column(type: "BLOB", rowVersion: true, nullable: true), UpdatedAt = table.Column(type: "INTEGER", nullable: false), Deleted = table.Column(type: "INTEGER", nullable: false) }, constraints: table => { table.PrimaryKey("PK_DogRaces", x => x.Id); }); migrationBuilder.CreateTable( name: "DogWalkerProfiles", columns: table => new { Id = table.Column(type: "TEXT", maxLength: 128, nullable: false), Radius = table.Column(type: "REAL", nullable: false), About = table.Column(type: "TEXT", maxLength: 300, nullable: true), AllowedRequests = table.Column(type: "INTEGER", nullable: false), PuppyAllowed = table.Column(type: "INTEGER", nullable: false), DifficultAllowed = table.Column(type: "INTEGER", nullable: false), AggressionLevel = table.Column(type: "INTEGER", nullable: false), AcceptedSize = table.Column(type: "INTEGER", nullable: false), PriceWalk = table.Column(type: "TEXT", nullable: false), PriceDay = table.Column(type: "TEXT", nullable: false), PriceSitting = table.Column(type: "TEXT", nullable: false), Version = table.Column(type: "BLOB", rowVersion: true, nullable: true), UpdatedAt = table.Column(type: "INTEGER", nullable: false), Deleted = table.Column(type: "INTEGER", nullable: false) }, constraints: table => { table.PrimaryKey("PK_DogWalkerProfiles", x => x.Id); }); migrationBuilder.CreateTable( name: "NewsCategories", columns: table => new { Id = table.Column(type: "TEXT", maxLength: 128, nullable: false), Language = table.Column(type: "TEXT", maxLength: 2, nullable: false), Name = table.Column(type: "TEXT", maxLength: 100, nullable: false), Description = table.Column(type: "TEXT", nullable: true), Image = table.Column(type: "TEXT", maxLength: 500, nullable: true), ImageLanguage = table.Column(type: "TEXT", maxLength: 500, nullable: true), OnlineStatus = table.Column(type: "INTEGER", nullable: false), Created = table.Column(type: "INTEGER", nullable: false), Version = table.Column(type: "BLOB", rowVersion: true, nullable: true), UpdatedAt = table.Column(type: "INTEGER", nullable: false), Deleted = table.Column(type: "INTEGER", nullable: false) }, constraints: table => { table.PrimaryKey("PK_NewsCategories", x => x.Id); }); migrationBuilder.CreateTable( name: "PublicWalkRequests", columns: table => new { Id = table.Column(type: "TEXT", maxLength: 128, nullable: false), DogOwnerId = table.Column(type: "TEXT", maxLength: 128, nullable: true), PickupAddress_AddressLine1 = table.Column(type: "TEXT", maxLength: 100, nullable: true), PickupAddress_AddressLine2 = table.Column(type: "TEXT", maxLength: 100, nullable: true), PickupAddress_City = table.Column(type: "TEXT", maxLength: 100, nullable: true), PickupAddress_Zip = table.Column(type: "TEXT", maxLength: 20, nullable: true), PickupAddress_State = table.Column(type: "TEXT", maxLength: 100, nullable: true), PickupAddress_CountryCode = table.Column(type: "TEXT", maxLength: 2, nullable: true), Lat = table.Column(type: "REAL", nullable: false), Lng = table.Column(type: "REAL", nullable: false), RequestType = table.Column(type: "INTEGER", nullable: false), StartDate = table.Column(type: "INTEGER", nullable: false), EndDate = table.Column(type: "INTEGER", nullable: false), DogId = table.Column(type: "TEXT", maxLength: 128, nullable: true), Exclusive = table.Column(type: "INTEGER", nullable: false), Price = table.Column(type: "TEXT", nullable: false), Info = table.Column(type: "TEXT", maxLength: 500, nullable: true), ExpirationDate = table.Column(type: "INTEGER", nullable: false), DogWalkerId = table.Column(type: "TEXT", maxLength: 128, nullable: true), PublicWalkResponseId = table.Column(type: "TEXT", nullable: true), ResponseCount = table.Column(type: "INTEGER", nullable: false), Status = table.Column(type: "INTEGER", nullable: false), PlacedDate = table.Column(type: "INTEGER", nullable: true), Created = table.Column(type: "INTEGER", nullable: false), Version = table.Column(type: "BLOB", rowVersion: true, nullable: true), UpdatedAt = table.Column(type: "INTEGER", nullable: false), Deleted = table.Column(type: "INTEGER", nullable: false) }, constraints: table => { table.PrimaryKey("PK_PublicWalkRequests", x => x.Id); }); migrationBuilder.CreateTable( name: "SyncInfosPull", columns: table => new { Id = table.Column(type: "INTEGER", nullable: false) .Annotation("Sqlite:Autoincrement", true), Table = table.Column(type: "TEXT", maxLength: 100, nullable: false), LastUpdate = table.Column(type: "INTEGER", nullable: false) }, constraints: table => { table.PrimaryKey("PK_SyncInfosPull", x => x.Id); }); migrationBuilder.CreateTable( name: "SyncInfosPush", columns: table => new { Id = table.Column(type: "TEXT", nullable: false), Table = table.Column(type: "TEXT", maxLength: 100, nullable: false), Key = table.Column(type: "TEXT", maxLength: 100, nullable: false), Operation = table.Column(type: "INTEGER", nullable: false), DateTime = table.Column(type: "INTEGER", nullable: false), Value = table.Column(type: "TEXT", nullable: true) }, constraints: table => { table.PrimaryKey("PK_SyncInfosPush", x => x.Id); }); migrationBuilder.CreateTable( name: "Users", columns: table => new { Id = table.Column(type: "TEXT", maxLength: 128, nullable: false), UserName = table.Column(type: "TEXT", maxLength: 256, nullable: false), FirstName = table.Column(type: "TEXT", maxLength: 150, nullable: false), LastName = table.Column(type: "TEXT", maxLength: 150, nullable: false), Roles = table.Column(type: "TEXT", maxLength: 255, nullable: true), Photo = table.Column(type: "TEXT", maxLength: 500, nullable: true), RegistrationDate = table.Column(type: "INTEGER", nullable: true), LastLoginDate = table.Column(type: "INTEGER", nullable: true), AppUserId = table.Column(type: "TEXT", maxLength: 128, nullable: true), AccessTokenExpires = table.Column(type: "INTEGER", nullable: false), RefreshTokenExpires = table.Column(type: "INTEGER", nullable: false) }, constraints: table => { table.PrimaryKey("PK_Users", x => x.Id); }); migrationBuilder.CreateTable( name: "Messages", columns: table => new { Id = table.Column(type: "TEXT", maxLength: 128, nullable: false), ConversationId = table.Column(type: "TEXT", maxLength: 128, nullable: false), Content = table.Column(type: "TEXT", maxLength: 500, nullable: true), Direction = table.Column(type: "INTEGER", nullable: false), Read = table.Column(type: "INTEGER", nullable: false), Version = table.Column(type: "BLOB", rowVersion: true, nullable: true), UpdatedAt = table.Column(type: "INTEGER", nullable: false), Deleted = table.Column(type: "INTEGER", nullable: false) }, constraints: table => { table.PrimaryKey("PK_Messages", x => x.Id); table.ForeignKey( name: "FK_Messages_Conversations_ConversationId", column: x => x.ConversationId, principalTable: "Conversations", principalColumn: "Id", onDelete: ReferentialAction.Cascade); }); migrationBuilder.CreateTable( name: "Dogs", columns: table => new { Id = table.Column(type: "TEXT", maxLength: 128, nullable: false), DogRaceId = table.Column(type: "TEXT", maxLength: 128, nullable: true), AppUserId = table.Column(type: "TEXT", maxLength: 128, nullable: false), Number = table.Column(type: "TEXT", maxLength: 100, nullable: false), Name = table.Column(type: "TEXT", maxLength: 100, nullable: false), Description = table.Column(type: "TEXT", maxLength: 5000, nullable: true), Photo = table.Column(type: "TEXT", maxLength: 500, nullable: true), BirthDate = table.Column(type: "INTEGER", nullable: true), Sex = table.Column(type: "INTEGER", nullable: false), Size = table.Column(type: "INTEGER", nullable: false), PullsTheLeash = table.Column(type: "INTEGER", nullable: false), WalksTheLeash = table.Column(type: "INTEGER", nullable: false), BasicCommands = table.Column(type: "INTEGER", nullable: false), Hunter = table.Column(type: "INTEGER", nullable: false), Eating = table.Column(type: "INTEGER", nullable: false), Jumper = table.Column(type: "INTEGER", nullable: false), LikesAdults = table.Column(type: "INTEGER", nullable: false), LikesChildren = table.Column(type: "INTEGER", nullable: false), LikesConspecifics = table.Column(type: "INTEGER", nullable: false), IsTrustful = table.Column(type: "INTEGER", nullable: false), IsAggressiv = table.Column(type: "INTEGER", nullable: false), IsLoneGunner = table.Column(type: "INTEGER", nullable: false), AggressionLevel = table.Column(type: "INTEGER", nullable: false), RushesOutside = table.Column(type: "INTEGER", nullable: false), IsCalm = table.Column(type: "INTEGER", nullable: false), IsPeeing = table.Column(type: "INTEGER", nullable: false), IsShy = table.Column(type: "INTEGER", nullable: false), IsGuard = table.Column(type: "INTEGER", nullable: false), Intolerances = table.Column(type: "TEXT", maxLength: 5000, nullable: true), Chiped = table.Column(type: "INTEGER", nullable: false), Sterilized = table.Column(type: "INTEGER", nullable: false), MedicalInfo = table.Column(type: "TEXT", maxLength: 5000, nullable: true), HouseTrained = table.Column(type: "INTEGER", nullable: false), FeedingTimes = table.Column(type: "INTEGER", nullable: false), FeedingIndividual = table.Column(type: "TEXT", maxLength: 500, nullable: true), RatingStatistics_TotalRatings = table.Column(type: "INTEGER", nullable: true), RatingStatistics_TotalPoints = table.Column(type: "TEXT", nullable: true), RatingStatistics_AverageRating = table.Column(type: "TEXT", nullable: true), Created = table.Column(type: "INTEGER", nullable: false), Version = table.Column(type: "BLOB", rowVersion: true, nullable: true), UpdatedAt = table.Column(type: "INTEGER", nullable: false), Deleted = table.Column(type: "INTEGER", nullable: false) }, constraints: table => { table.PrimaryKey("PK_Dogs", x => x.Id); table.ForeignKey( name: "FK_Dogs_DogRaces_DogRaceId", column: x => x.DogRaceId, principalTable: "DogRaces", principalColumn: "Id"); }); migrationBuilder.CreateIndex( name: "IX_Dogs_DogRaceId", table: "Dogs", column: "DogRaceId"); migrationBuilder.CreateIndex( name: "IX_Messages_ConversationId", table: "Messages", column: "ConversationId"); var viewName = "vw_PublicWalkRequestWithNames"; var sql = @"SELECT PublicWalkRequests.*, D.Name as DogName, D.Photo as DogPhoto FROM PublicWalkRequests LEFT JOIN Dogs D ON PublicWalkRequests.DogId = D.Id"; migrationBuilder.Sql($"DROP VIEW IF EXISTS {viewName};"); migrationBuilder.Sql($"CREATE VIEW {viewName} AS {sql}"); System.Diagnostics.Debug.WriteLine($"Migration Initial done"); } protected override void Down(MigrationBuilder migrationBuilder) { migrationBuilder.DropTable( name: "AppUsers"); migrationBuilder.DropTable( name: "Dogs"); migrationBuilder.DropTable( name: "DogWalkerProfiles"); migrationBuilder.DropTable( name: "Messages"); migrationBuilder.DropTable( name: "NewsCategories"); migrationBuilder.DropTable( name: "PublicWalkRequests"); migrationBuilder.DropTable( name: "SyncInfosPull"); migrationBuilder.DropTable( name: "SyncInfosPush"); migrationBuilder.DropTable( name: "Users"); migrationBuilder.DropTable( name: "DogRaces"); migrationBuilder.DropTable( name: "Conversations"); var viewName = "vw_PublicWalkRequestWithNames"; migrationBuilder.Sql($"DROP VIEW IF EXISTS {viewName};"); } } }