using System; using Microsoft.EntityFrameworkCore.Metadata; using Microsoft.EntityFrameworkCore.Migrations; namespace Repositories.Migrations { public partial class v1 : Migration { protected override void Up(MigrationBuilder migrationBuilder) { migrationBuilder.CreateTable( name: "LookupCategories", columns: table => new { Id = table.Column(nullable: false) .Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn), CategoryName = table.Column(nullable: true), IsActive = table.Column(nullable: false) }, constraints: table => { table.PrimaryKey("PK_LookupCategories", x => x.Id); }); migrationBuilder.CreateTable( name: "LookupValues", columns: table => new { Id = table.Column(nullable: false) .Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn), Value = table.Column(nullable: true), IsActive = table.Column(nullable: false), LookupCategoryId = table.Column(nullable: true) }, constraints: table => { table.PrimaryKey("PK_LookupValues", x => x.Id); table.ForeignKey( name: "FK_LookupValues_LookupCategories_LookupCategoryId", column: x => x.LookupCategoryId, principalTable: "LookupCategories", principalColumn: "Id", onDelete: ReferentialAction.Restrict); }); migrationBuilder.CreateTable( name: "Person", columns: table => new { Id = table.Column(nullable: false) .Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn), LastName = table.Column(nullable: true), FirstName = table.Column(nullable: true), Birthday = table.Column(nullable: true), IsActive = table.Column(nullable: false), CreatedAt = table.Column(nullable: false), ChangedAt = table.Column(nullable: false), GenderId = table.Column(nullable: true) }, constraints: table => { table.PrimaryKey("PK_Person", x => x.Id); table.ForeignKey( name: "FK_Person_LookupValues_GenderId", column: x => x.GenderId, principalTable: "LookupValues", principalColumn: "Id", onDelete: ReferentialAction.Restrict); }); migrationBuilder.CreateTable( name: "Address", columns: table => new { Id = table.Column(nullable: false) .Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn), StreetName = table.Column(nullable: true), StreetNumber = table.Column(nullable: false), Zip = table.Column(nullable: true), City = table.Column(nullable: true), CreatedAt = table.Column(nullable: false), ChangedAt = table.Column(nullable: false), AddressTypeId = table.Column(nullable: true), PersonId = table.Column(nullable: true) }, constraints: table => { table.PrimaryKey("PK_Address", x => x.Id); table.ForeignKey( name: "FK_Address_LookupValues_AddressTypeId", column: x => x.AddressTypeId, principalTable: "LookupValues", principalColumn: "Id", onDelete: ReferentialAction.Restrict); table.ForeignKey( name: "FK_Address_Person_PersonId", column: x => x.PersonId, principalTable: "Person", principalColumn: "Id", onDelete: ReferentialAction.Restrict); }); migrationBuilder.CreateTable( name: "Communication", columns: table => new { Id = table.Column(nullable: false) .Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn), CommunicationValue = table.Column(nullable: true), CommunicationTypeId = table.Column(nullable: true), CreatedAt = table.Column(nullable: false), ChangedAt = table.Column(nullable: false), PersonId = table.Column(nullable: true) }, constraints: table => { table.PrimaryKey("PK_Communication", x => x.Id); table.ForeignKey( name: "FK_Communication_LookupValues_CommunicationTypeId", column: x => x.CommunicationTypeId, principalTable: "LookupValues", principalColumn: "Id", onDelete: ReferentialAction.Restrict); table.ForeignKey( name: "FK_Communication_Person_PersonId", column: x => x.PersonId, principalTable: "Person", principalColumn: "Id", onDelete: ReferentialAction.Restrict); }); migrationBuilder.CreateIndex( name: "IX_Address_AddressTypeId", table: "Address", column: "AddressTypeId"); migrationBuilder.CreateIndex( name: "IX_Address_PersonId", table: "Address", column: "PersonId"); migrationBuilder.CreateIndex( name: "IX_Communication_CommunicationTypeId", table: "Communication", column: "CommunicationTypeId"); migrationBuilder.CreateIndex( name: "IX_Communication_PersonId", table: "Communication", column: "PersonId"); migrationBuilder.CreateIndex( name: "IX_LookupValues_LookupCategoryId", table: "LookupValues", column: "LookupCategoryId"); migrationBuilder.CreateIndex( name: "IX_Person_GenderId", table: "Person", column: "GenderId"); } protected override void Down(MigrationBuilder migrationBuilder) { migrationBuilder.DropTable( name: "Address"); migrationBuilder.DropTable( name: "Communication"); migrationBuilder.DropTable( name: "Person"); migrationBuilder.DropTable( name: "LookupValues"); migrationBuilder.DropTable( name: "LookupCategories"); } } }