390 lines
24 KiB
C#

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<string>(type: "TEXT", maxLength: 128, nullable: false),
Type = table.Column<int>(type: "INTEGER", nullable: false),
Title = table.Column<string>(type: "TEXT", maxLength: 50, nullable: true),
FirstName = table.Column<string>(type: "TEXT", maxLength: 150, nullable: false),
LastName = table.Column<string>(type: "TEXT", maxLength: 150, nullable: false),
Sex = table.Column<int>(type: "INTEGER", nullable: false),
BirthDate = table.Column<long>(type: "INTEGER", nullable: true),
Photo = table.Column<string>(type: "TEXT", maxLength: 500, nullable: true),
Contact_Email = table.Column<string>(type: "TEXT", maxLength: 255, nullable: true),
Contact_Phone = table.Column<string>(type: "TEXT", maxLength: 100, nullable: true),
Contact_Mobile = table.Column<string>(type: "TEXT", maxLength: 100, nullable: true),
Address_AddressLine1 = table.Column<string>(type: "TEXT", maxLength: 100, nullable: true),
Address_AddressLine2 = table.Column<string>(type: "TEXT", maxLength: 100, nullable: true),
Address_City = table.Column<string>(type: "TEXT", maxLength: 100, nullable: true),
Address_Zip = table.Column<string>(type: "TEXT", maxLength: 20, nullable: true),
Address_State = table.Column<string>(type: "TEXT", maxLength: 100, nullable: true),
Address_CountryCode = table.Column<string>(type: "TEXT", maxLength: 2, nullable: true),
Lat = table.Column<double>(type: "REAL", nullable: false),
Lng = table.Column<double>(type: "REAL", nullable: false),
SocialMedia_Twitter = table.Column<string>(type: "TEXT", maxLength: 255, nullable: true),
SocialMedia_Facebook = table.Column<string>(type: "TEXT", maxLength: 255, nullable: true),
SocialMedia_LinkedIn = table.Column<string>(type: "TEXT", maxLength: 255, nullable: true),
SocialMedia_Xing = table.Column<string>(type: "TEXT", maxLength: 255, nullable: true),
SocialMedia_Instagram = table.Column<string>(type: "TEXT", maxLength: 255, nullable: true),
SocialMedia_Pinterest = table.Column<string>(type: "TEXT", maxLength: 255, nullable: true),
SocialMedia_Blog = table.Column<string>(type: "TEXT", maxLength: 255, nullable: true),
SocialMedia_YouTube = table.Column<string>(type: "TEXT", maxLength: 255, nullable: true),
SocialMedia_Vimeo = table.Column<string>(type: "TEXT", maxLength: 255, nullable: true),
SocialMedia_SnapChat = table.Column<string>(type: "TEXT", maxLength: 255, nullable: true),
SocialMedia_TikTok = table.Column<string>(type: "TEXT", maxLength: 255, nullable: true),
SocialMedia_Reddit = table.Column<string>(type: "TEXT", maxLength: 255, nullable: true),
SocialMedia_Show = table.Column<bool>(type: "INTEGER", nullable: true),
RatingStatistics_TotalRatings = table.Column<int>(type: "INTEGER", nullable: true),
RatingStatistics_TotalPoints = table.Column<decimal>(type: "TEXT", nullable: true),
RatingStatistics_AverageRating = table.Column<decimal>(type: "TEXT", nullable: true),
RatingStatisticsWalker_TotalRatings = table.Column<int>(type: "INTEGER", nullable: true),
RatingStatisticsWalker_TotalPoints = table.Column<decimal>(type: "TEXT", nullable: true),
RatingStatisticsWalker_AverageRating = table.Column<decimal>(type: "TEXT", nullable: true),
Locked = table.Column<bool>(type: "INTEGER", nullable: false),
LockedUntil = table.Column<long>(type: "INTEGER", nullable: true),
Created = table.Column<long>(type: "INTEGER", nullable: false),
Version = table.Column<byte[]>(type: "BLOB", rowVersion: true, nullable: true),
UpdatedAt = table.Column<long>(type: "INTEGER", nullable: false),
Deleted = table.Column<bool>(type: "INTEGER", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_AppUsers", x => x.Id);
});
migrationBuilder.CreateTable(
name: "Conversations",
columns: table => new
{
Id = table.Column<string>(type: "TEXT", maxLength: 128, nullable: false),
Recipient = table.Column<string>(type: "TEXT", maxLength: 128, nullable: false),
ReceipientType = table.Column<int>(type: "INTEGER", nullable: false),
RecipientName = table.Column<string>(type: "TEXT", maxLength: 300, nullable: true),
RecipientShort = table.Column<string>(type: "TEXT", maxLength: 2, nullable: true),
RecipientPhoto = table.Column<string>(type: "TEXT", nullable: true),
LastMessageId = table.Column<string>(type: "TEXT", maxLength: 128, nullable: true),
LastMessagePreview = table.Column<string>(type: "TEXT", nullable: true),
HasUnreadMessages = table.Column<bool>(type: "INTEGER", nullable: false),
Created = table.Column<long>(type: "INTEGER", nullable: false),
Version = table.Column<byte[]>(type: "BLOB", rowVersion: true, nullable: true),
UpdatedAt = table.Column<long>(type: "INTEGER", nullable: false),
Deleted = table.Column<bool>(type: "INTEGER", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_Conversations", x => x.Id);
});
migrationBuilder.CreateTable(
name: "DogRaces",
columns: table => new
{
Id = table.Column<string>(type: "TEXT", maxLength: 128, nullable: false),
Name = table.Column<string>(type: "TEXT", maxLength: 100, nullable: false),
Description = table.Column<string>(type: "TEXT", maxLength: 5000, nullable: true),
Age = table.Column<string>(type: "TEXT", maxLength: 1000, nullable: true),
SizeAndWeight = table.Column<string>(type: "TEXT", maxLength: 1000, nullable: true),
Personality = table.Column<string>(type: "TEXT", maxLength: 2000, nullable: true),
Coexistence = table.Column<string>(type: "TEXT", maxLength: 1000, nullable: true),
Care = table.Column<string>(type: "TEXT", maxLength: 1000, nullable: true),
Decision = table.Column<string>(type: "TEXT", maxLength: 2000, nullable: true),
Photo = table.Column<string>(type: "TEXT", maxLength: 500, nullable: true),
Created = table.Column<long>(type: "INTEGER", nullable: false),
Version = table.Column<byte[]>(type: "BLOB", rowVersion: true, nullable: true),
UpdatedAt = table.Column<long>(type: "INTEGER", nullable: false),
Deleted = table.Column<bool>(type: "INTEGER", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_DogRaces", x => x.Id);
});
migrationBuilder.CreateTable(
name: "DogWalkerProfiles",
columns: table => new
{
Id = table.Column<string>(type: "TEXT", maxLength: 128, nullable: false),
Radius = table.Column<double>(type: "REAL", nullable: false),
About = table.Column<string>(type: "TEXT", maxLength: 300, nullable: true),
AllowedRequests = table.Column<int>(type: "INTEGER", nullable: false),
PuppyAllowed = table.Column<bool>(type: "INTEGER", nullable: false),
DifficultAllowed = table.Column<bool>(type: "INTEGER", nullable: false),
AggressionLevel = table.Column<int>(type: "INTEGER", nullable: false),
AcceptedSize = table.Column<int>(type: "INTEGER", nullable: false),
PriceWalk = table.Column<decimal>(type: "TEXT", nullable: false),
PriceDay = table.Column<decimal>(type: "TEXT", nullable: false),
PriceSitting = table.Column<decimal>(type: "TEXT", nullable: false),
Version = table.Column<byte[]>(type: "BLOB", rowVersion: true, nullable: true),
UpdatedAt = table.Column<long>(type: "INTEGER", nullable: false),
Deleted = table.Column<bool>(type: "INTEGER", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_DogWalkerProfiles", x => x.Id);
});
migrationBuilder.CreateTable(
name: "NewsCategories",
columns: table => new
{
Id = table.Column<string>(type: "TEXT", maxLength: 128, nullable: false),
Language = table.Column<string>(type: "TEXT", maxLength: 2, nullable: false),
Name = table.Column<string>(type: "TEXT", maxLength: 100, nullable: false),
Description = table.Column<string>(type: "TEXT", nullable: true),
Image = table.Column<string>(type: "TEXT", maxLength: 500, nullable: true),
ImageLanguage = table.Column<string>(type: "TEXT", maxLength: 500, nullable: true),
OnlineStatus = table.Column<int>(type: "INTEGER", nullable: false),
Created = table.Column<long>(type: "INTEGER", nullable: false),
Version = table.Column<byte[]>(type: "BLOB", rowVersion: true, nullable: true),
UpdatedAt = table.Column<long>(type: "INTEGER", nullable: false),
Deleted = table.Column<bool>(type: "INTEGER", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_NewsCategories", x => x.Id);
});
migrationBuilder.CreateTable(
name: "PublicWalkRequests",
columns: table => new
{
Id = table.Column<string>(type: "TEXT", maxLength: 128, nullable: false),
DogOwnerId = table.Column<string>(type: "TEXT", maxLength: 128, nullable: true),
PickupAddress_AddressLine1 = table.Column<string>(type: "TEXT", maxLength: 100, nullable: true),
PickupAddress_AddressLine2 = table.Column<string>(type: "TEXT", maxLength: 100, nullable: true),
PickupAddress_City = table.Column<string>(type: "TEXT", maxLength: 100, nullable: true),
PickupAddress_Zip = table.Column<string>(type: "TEXT", maxLength: 20, nullable: true),
PickupAddress_State = table.Column<string>(type: "TEXT", maxLength: 100, nullable: true),
PickupAddress_CountryCode = table.Column<string>(type: "TEXT", maxLength: 2, nullable: true),
Lat = table.Column<double>(type: "REAL", nullable: false),
Lng = table.Column<double>(type: "REAL", nullable: false),
RequestType = table.Column<int>(type: "INTEGER", nullable: false),
StartDate = table.Column<long>(type: "INTEGER", nullable: false),
EndDate = table.Column<long>(type: "INTEGER", nullable: false),
DogId = table.Column<string>(type: "TEXT", maxLength: 128, nullable: true),
Exclusive = table.Column<bool>(type: "INTEGER", nullable: false),
Price = table.Column<decimal>(type: "TEXT", nullable: false),
Info = table.Column<string>(type: "TEXT", maxLength: 500, nullable: true),
ExpirationDate = table.Column<long>(type: "INTEGER", nullable: false),
DogWalkerId = table.Column<string>(type: "TEXT", maxLength: 128, nullable: true),
PublicWalkResponseId = table.Column<string>(type: "TEXT", nullable: true),
ResponseCount = table.Column<int>(type: "INTEGER", nullable: false),
Status = table.Column<int>(type: "INTEGER", nullable: false),
PlacedDate = table.Column<long>(type: "INTEGER", nullable: true),
Created = table.Column<long>(type: "INTEGER", nullable: false),
Version = table.Column<byte[]>(type: "BLOB", rowVersion: true, nullable: true),
UpdatedAt = table.Column<long>(type: "INTEGER", nullable: false),
Deleted = table.Column<bool>(type: "INTEGER", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_PublicWalkRequests", x => x.Id);
});
migrationBuilder.CreateTable(
name: "SyncInfosPull",
columns: table => new
{
Id = table.Column<int>(type: "INTEGER", nullable: false)
.Annotation("Sqlite:Autoincrement", true),
Table = table.Column<string>(type: "TEXT", maxLength: 100, nullable: false),
LastUpdate = table.Column<long>(type: "INTEGER", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_SyncInfosPull", x => x.Id);
});
migrationBuilder.CreateTable(
name: "SyncInfosPush",
columns: table => new
{
Id = table.Column<Guid>(type: "TEXT", nullable: false),
Table = table.Column<string>(type: "TEXT", maxLength: 100, nullable: false),
Key = table.Column<string>(type: "TEXT", maxLength: 100, nullable: false),
Operation = table.Column<int>(type: "INTEGER", nullable: false),
DateTime = table.Column<long>(type: "INTEGER", nullable: false),
Value = table.Column<string>(type: "TEXT", nullable: true)
},
constraints: table =>
{
table.PrimaryKey("PK_SyncInfosPush", x => x.Id);
});
migrationBuilder.CreateTable(
name: "Users",
columns: table => new
{
Id = table.Column<string>(type: "TEXT", maxLength: 128, nullable: false),
UserName = table.Column<string>(type: "TEXT", maxLength: 256, nullable: false),
FirstName = table.Column<string>(type: "TEXT", maxLength: 150, nullable: false),
LastName = table.Column<string>(type: "TEXT", maxLength: 150, nullable: false),
Roles = table.Column<string>(type: "TEXT", maxLength: 255, nullable: true),
Photo = table.Column<string>(type: "TEXT", maxLength: 500, nullable: true),
RegistrationDate = table.Column<long>(type: "INTEGER", nullable: true),
LastLoginDate = table.Column<long>(type: "INTEGER", nullable: true),
AppUserId = table.Column<string>(type: "TEXT", maxLength: 128, nullable: true),
AccessTokenExpires = table.Column<long>(type: "INTEGER", nullable: false),
RefreshTokenExpires = table.Column<long>(type: "INTEGER", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_Users", x => x.Id);
});
migrationBuilder.CreateTable(
name: "Messages",
columns: table => new
{
Id = table.Column<string>(type: "TEXT", maxLength: 128, nullable: false),
ConversationId = table.Column<string>(type: "TEXT", maxLength: 128, nullable: false),
Content = table.Column<string>(type: "TEXT", maxLength: 500, nullable: true),
Direction = table.Column<int>(type: "INTEGER", nullable: false),
Read = table.Column<bool>(type: "INTEGER", nullable: false),
Version = table.Column<byte[]>(type: "BLOB", rowVersion: true, nullable: true),
UpdatedAt = table.Column<long>(type: "INTEGER", nullable: false),
Deleted = table.Column<bool>(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<string>(type: "TEXT", maxLength: 128, nullable: false),
DogRaceId = table.Column<string>(type: "TEXT", maxLength: 128, nullable: true),
AppUserId = table.Column<string>(type: "TEXT", maxLength: 128, nullable: false),
Number = table.Column<string>(type: "TEXT", maxLength: 100, nullable: false),
Name = table.Column<string>(type: "TEXT", maxLength: 100, nullable: false),
Description = table.Column<string>(type: "TEXT", maxLength: 5000, nullable: true),
Photo = table.Column<string>(type: "TEXT", maxLength: 500, nullable: true),
BirthDate = table.Column<long>(type: "INTEGER", nullable: true),
Sex = table.Column<int>(type: "INTEGER", nullable: false),
Size = table.Column<int>(type: "INTEGER", nullable: false),
PullsTheLeash = table.Column<bool>(type: "INTEGER", nullable: false),
WalksTheLeash = table.Column<bool>(type: "INTEGER", nullable: false),
BasicCommands = table.Column<bool>(type: "INTEGER", nullable: false),
Hunter = table.Column<bool>(type: "INTEGER", nullable: false),
Eating = table.Column<bool>(type: "INTEGER", nullable: false),
Jumper = table.Column<bool>(type: "INTEGER", nullable: false),
LikesAdults = table.Column<bool>(type: "INTEGER", nullable: false),
LikesChildren = table.Column<bool>(type: "INTEGER", nullable: false),
LikesConspecifics = table.Column<bool>(type: "INTEGER", nullable: false),
IsTrustful = table.Column<bool>(type: "INTEGER", nullable: false),
IsAggressiv = table.Column<bool>(type: "INTEGER", nullable: false),
IsLoneGunner = table.Column<bool>(type: "INTEGER", nullable: false),
AggressionLevel = table.Column<int>(type: "INTEGER", nullable: false),
RushesOutside = table.Column<bool>(type: "INTEGER", nullable: false),
IsCalm = table.Column<bool>(type: "INTEGER", nullable: false),
IsPeeing = table.Column<bool>(type: "INTEGER", nullable: false),
IsShy = table.Column<bool>(type: "INTEGER", nullable: false),
IsGuard = table.Column<bool>(type: "INTEGER", nullable: false),
Intolerances = table.Column<string>(type: "TEXT", maxLength: 5000, nullable: true),
Chiped = table.Column<bool>(type: "INTEGER", nullable: false),
Sterilized = table.Column<bool>(type: "INTEGER", nullable: false),
MedicalInfo = table.Column<string>(type: "TEXT", maxLength: 5000, nullable: true),
HouseTrained = table.Column<bool>(type: "INTEGER", nullable: false),
FeedingTimes = table.Column<int>(type: "INTEGER", nullable: false),
FeedingIndividual = table.Column<string>(type: "TEXT", maxLength: 500, nullable: true),
RatingStatistics_TotalRatings = table.Column<int>(type: "INTEGER", nullable: true),
RatingStatistics_TotalPoints = table.Column<decimal>(type: "TEXT", nullable: true),
RatingStatistics_AverageRating = table.Column<decimal>(type: "TEXT", nullable: true),
Created = table.Column<long>(type: "INTEGER", nullable: false),
Version = table.Column<byte[]>(type: "BLOB", rowVersion: true, nullable: true),
UpdatedAt = table.Column<long>(type: "INTEGER", nullable: false),
Deleted = table.Column<bool>(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};");
}
}
}