using System; using Microsoft.EntityFrameworkCore.Migrations; using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata; #nullable disable namespace ROLAC.API.Migrations { /// public partial class AddMemberAndFamilyUnit : Migration { /// protected override void Up(MigrationBuilder migrationBuilder) { migrationBuilder.CreateTable( name: "FamilyUnits", columns: table => new { Id = table.Column(type: "integer", nullable: false) .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), FamilyName_en = table.Column(type: "character varying(200)", maxLength: 200, nullable: true), FamilyName_zh = table.Column(type: "character varying(200)", maxLength: 200, nullable: true), Notes = table.Column(type: "text", nullable: true), CreatedAt = table.Column(type: "timestamp with time zone", nullable: false), CreatedBy = table.Column(type: "text", nullable: false), UpdatedAt = table.Column(type: "timestamp with time zone", nullable: false), UpdatedBy = table.Column(type: "text", nullable: false) }, constraints: table => { table.PrimaryKey("PK_FamilyUnits", x => x.Id); }); migrationBuilder.CreateTable( name: "Members", columns: table => new { Id = table.Column(type: "integer", nullable: false) .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), FirstName_en = table.Column(type: "character varying(100)", maxLength: 100, nullable: false), LastName_en = table.Column(type: "character varying(100)", maxLength: 100, nullable: false), NickName = table.Column(type: "character varying(100)", maxLength: 100, nullable: true), FirstName_zh = table.Column(type: "character varying(100)", maxLength: 100, nullable: true), LastName_zh = table.Column(type: "character varying(100)", maxLength: 100, nullable: true), Gender = table.Column(type: "character varying(10)", maxLength: 10, nullable: true), DateOfBirth = table.Column(type: "date", nullable: true), BaptismDate = table.Column(type: "date", nullable: true), BaptismChurch = table.Column(type: "character varying(200)", maxLength: 200, nullable: true), Email = table.Column(type: "character varying(200)", maxLength: 200, nullable: true), PhoneCell = table.Column(type: "character varying(30)", maxLength: 30, nullable: true), PhoneHome = table.Column(type: "character varying(30)", maxLength: 30, nullable: true), Address = table.Column(type: "character varying(500)", maxLength: 500, nullable: true), City = table.Column(type: "character varying(100)", maxLength: 100, nullable: true), State = table.Column(type: "character varying(50)", maxLength: 50, nullable: true), ZipCode = table.Column(type: "character varying(20)", maxLength: 20, nullable: true), Country = table.Column(type: "character varying(100)", maxLength: 100, nullable: false, defaultValue: "USA"), PhotoBlobPath = table.Column(type: "character varying(500)", maxLength: 500, nullable: true), Status = table.Column(type: "character varying(20)", maxLength: 20, nullable: false, defaultValue: "Member"), LanguagePreference = table.Column(type: "character varying(10)", maxLength: 10, nullable: false, defaultValue: "en"), JoinDate = table.Column(type: "date", nullable: true), Notes = table.Column(type: "text", nullable: true), FamilyUnitId = table.Column(type: "integer", nullable: true), CreatedAt = table.Column(type: "timestamp with time zone", nullable: false), CreatedBy = table.Column(type: "character varying(450)", maxLength: 450, nullable: false), UpdatedAt = table.Column(type: "timestamp with time zone", nullable: false), UpdatedBy = table.Column(type: "character varying(450)", maxLength: 450, nullable: false), IsDeleted = table.Column(type: "boolean", nullable: false), DeletedAt = table.Column(type: "timestamp with time zone", nullable: true), DeletedBy = table.Column(type: "character varying(450)", maxLength: 450, nullable: true) }, constraints: table => { table.PrimaryKey("PK_Members", x => x.Id); table.ForeignKey( name: "FK_Members_FamilyUnits_FamilyUnitId", column: x => x.FamilyUnitId, principalTable: "FamilyUnits", principalColumn: "Id", onDelete: ReferentialAction.SetNull); }); migrationBuilder.CreateIndex( name: "IX_AspNetUsers_MemberId", table: "AspNetUsers", column: "MemberId", unique: true, filter: "\"MemberId\" IS NOT NULL"); migrationBuilder.CreateIndex( name: "IX_Members_Email", table: "Members", column: "Email", filter: "\"Email\" IS NOT NULL"); migrationBuilder.CreateIndex( name: "IX_Members_FamilyUnitId", table: "Members", column: "FamilyUnitId"); migrationBuilder.CreateIndex( name: "IX_Members_Status", table: "Members", column: "Status", filter: "\"IsDeleted\" = false"); } /// protected override void Down(MigrationBuilder migrationBuilder) { migrationBuilder.DropTable( name: "Members"); migrationBuilder.DropTable( name: "FamilyUnits"); migrationBuilder.DropIndex( name: "IX_AspNetUsers_MemberId", table: "AspNetUsers"); } } }