using System; using Microsoft.EntityFrameworkCore.Migrations; using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata; #nullable disable namespace JobsMedical.Web.Migrations { /// public partial class InitialCreate : Migration { /// protected override void Up(MigrationBuilder migrationBuilder) { migrationBuilder.CreateTable( name: "Cities", columns: table => new { Id = table.Column(type: "integer", nullable: false) .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), Name = table.Column(type: "character varying(100)", maxLength: 100, nullable: false), Province = table.Column(type: "character varying(100)", maxLength: 100, nullable: false), IsActive = table.Column(type: "boolean", nullable: false) }, constraints: table => { table.PrimaryKey("PK_Cities", x => x.Id); }); migrationBuilder.CreateTable( name: "Users", columns: table => new { Id = table.Column(type: "integer", nullable: false) .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), Phone = table.Column(type: "character varying(20)", maxLength: 20, nullable: false), FullName = table.Column(type: "character varying(150)", maxLength: 150, nullable: true), Role = table.Column(type: "integer", nullable: false), IsPhoneVerified = table.Column(type: "boolean", nullable: false), CreatedAt = table.Column(type: "timestamp with time zone", nullable: false) }, constraints: table => { table.PrimaryKey("PK_Users", x => x.Id); }); migrationBuilder.CreateTable( name: "DoctorProfiles", columns: table => new { Id = table.Column(type: "integer", nullable: false) .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), UserId = table.Column(type: "integer", nullable: false), LicenseNo = table.Column(type: "character varying(20)", maxLength: 20, nullable: true), Specialty = table.Column(type: "character varying(100)", maxLength: 100, nullable: false), CityId = table.Column(type: "integer", nullable: true), YearsExperience = table.Column(type: "integer", nullable: false), Bio = table.Column(type: "character varying(1000)", maxLength: 1000, nullable: true), IsVerified = table.Column(type: "boolean", nullable: false) }, constraints: table => { table.PrimaryKey("PK_DoctorProfiles", x => x.Id); table.ForeignKey( name: "FK_DoctorProfiles_Cities_CityId", column: x => x.CityId, principalTable: "Cities", principalColumn: "Id"); table.ForeignKey( name: "FK_DoctorProfiles_Users_UserId", column: x => x.UserId, principalTable: "Users", principalColumn: "Id", onDelete: ReferentialAction.Cascade); }); migrationBuilder.CreateTable( name: "Facilities", columns: table => new { Id = table.Column(type: "integer", nullable: false) .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), Name = table.Column(type: "character varying(200)", maxLength: 200, nullable: false), Type = table.Column(type: "integer", nullable: false), CityId = table.Column(type: "integer", nullable: false), Address = table.Column(type: "character varying(500)", maxLength: 500, nullable: true), Lat = table.Column(type: "double precision", nullable: true), Lng = table.Column(type: "double precision", nullable: true), Phone = table.Column(type: "character varying(20)", maxLength: 20, nullable: true), BaleId = table.Column(type: "character varying(50)", maxLength: 50, nullable: true), IsVerified = table.Column(type: "boolean", nullable: false), OwnerUserId = table.Column(type: "integer", nullable: true), CreatedAt = table.Column(type: "timestamp with time zone", nullable: false) }, constraints: table => { table.PrimaryKey("PK_Facilities", x => x.Id); table.ForeignKey( name: "FK_Facilities_Cities_CityId", column: x => x.CityId, principalTable: "Cities", principalColumn: "Id", onDelete: ReferentialAction.Cascade); table.ForeignKey( name: "FK_Facilities_Users_OwnerUserId", column: x => x.OwnerUserId, principalTable: "Users", principalColumn: "Id", onDelete: ReferentialAction.SetNull); }); migrationBuilder.CreateTable( name: "Shifts", columns: table => new { Id = table.Column(type: "integer", nullable: false) .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), FacilityId = table.Column(type: "integer", nullable: false), Date = table.Column(type: "date", nullable: false), StartTime = table.Column(type: "time without time zone", nullable: false), EndTime = table.Column(type: "time without time zone", nullable: false), SpecialtyRequired = table.Column(type: "character varying(100)", maxLength: 100, nullable: false), ShiftType = table.Column(type: "integer", nullable: false), PayAmount = table.Column(type: "bigint", nullable: true), PayType = table.Column(type: "integer", nullable: false), Description = table.Column(type: "character varying(1500)", maxLength: 1500, nullable: true), Status = table.Column(type: "integer", nullable: false), Source = table.Column(type: "integer", nullable: false), SourceUrl = table.Column(type: "character varying(500)", maxLength: 500, nullable: true), CreatedAt = table.Column(type: "timestamp with time zone", nullable: false) }, constraints: table => { table.PrimaryKey("PK_Shifts", x => x.Id); table.ForeignKey( name: "FK_Shifts_Facilities_FacilityId", column: x => x.FacilityId, principalTable: "Facilities", principalColumn: "Id", onDelete: ReferentialAction.Cascade); }); migrationBuilder.CreateTable( name: "Applications", columns: table => new { Id = table.Column(type: "integer", nullable: false) .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), ShiftId = table.Column(type: "integer", nullable: false), DoctorId = table.Column(type: "integer", nullable: false), Status = table.Column(type: "integer", nullable: false), Message = table.Column(type: "character varying(500)", maxLength: 500, nullable: true), CreatedAt = table.Column(type: "timestamp with time zone", nullable: false) }, constraints: table => { table.PrimaryKey("PK_Applications", x => x.Id); table.ForeignKey( name: "FK_Applications_Shifts_ShiftId", column: x => x.ShiftId, principalTable: "Shifts", principalColumn: "Id", onDelete: ReferentialAction.Cascade); table.ForeignKey( name: "FK_Applications_Users_DoctorId", column: x => x.DoctorId, principalTable: "Users", principalColumn: "Id", onDelete: ReferentialAction.Cascade); }); migrationBuilder.CreateTable( name: "RawListings", columns: table => new { Id = table.Column(type: "integer", nullable: false) .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), SourceChannel = table.Column(type: "character varying(200)", maxLength: 200, nullable: false), RawText = table.Column(type: "text", nullable: false), ParsedJson = table.Column(type: "text", nullable: true), Status = table.Column(type: "integer", nullable: false), LinkedShiftId = table.Column(type: "integer", nullable: true), SourceUrl = table.Column(type: "character varying(500)", maxLength: 500, nullable: true), FetchedAt = table.Column(type: "timestamp with time zone", nullable: false) }, constraints: table => { table.PrimaryKey("PK_RawListings", x => x.Id); table.ForeignKey( name: "FK_RawListings_Shifts_LinkedShiftId", column: x => x.LinkedShiftId, principalTable: "Shifts", principalColumn: "Id"); }); migrationBuilder.CreateIndex( name: "IX_Applications_DoctorId", table: "Applications", column: "DoctorId"); migrationBuilder.CreateIndex( name: "IX_Applications_ShiftId_DoctorId", table: "Applications", columns: new[] { "ShiftId", "DoctorId" }, unique: true); migrationBuilder.CreateIndex( name: "IX_DoctorProfiles_CityId", table: "DoctorProfiles", column: "CityId"); migrationBuilder.CreateIndex( name: "IX_DoctorProfiles_UserId", table: "DoctorProfiles", column: "UserId", unique: true); migrationBuilder.CreateIndex( name: "IX_Facilities_CityId", table: "Facilities", column: "CityId"); migrationBuilder.CreateIndex( name: "IX_Facilities_OwnerUserId", table: "Facilities", column: "OwnerUserId"); migrationBuilder.CreateIndex( name: "IX_RawListings_LinkedShiftId", table: "RawListings", column: "LinkedShiftId"); migrationBuilder.CreateIndex( name: "IX_Shifts_Date_Status", table: "Shifts", columns: new[] { "Date", "Status" }); migrationBuilder.CreateIndex( name: "IX_Shifts_FacilityId", table: "Shifts", column: "FacilityId"); migrationBuilder.CreateIndex( name: "IX_Users_Phone", table: "Users", column: "Phone", unique: true); } /// protected override void Down(MigrationBuilder migrationBuilder) { migrationBuilder.DropTable( name: "Applications"); migrationBuilder.DropTable( name: "DoctorProfiles"); migrationBuilder.DropTable( name: "RawListings"); migrationBuilder.DropTable( name: "Shifts"); migrationBuilder.DropTable( name: "Facilities"); migrationBuilder.DropTable( name: "Cities"); migrationBuilder.DropTable( name: "Users"); } } }