2fb86a435e
ASP.NET Core 10 Razor Pages + PostgreSQL/EF Core. RTL Persian, Jalali dates, self-hosted Vazirmatn, teal/coral brand. Features: - Shift listings: browse/filter (city, district, role, type, pay), weekly Jalali calendar, detail + interest handoff, near-me distance sort - Hiring (استخدام) listings with employment type + salary range - Pattern-engine recommendations + anonymous interest tracking (visitor cookie) - Heuristic Persian listing-parser + admin queue (raw channel post → shift/job) - Phone-OTP cookie auth + visitor-history linking + profile Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
276 lines
13 KiB
C#
276 lines
13 KiB
C#
using System;
|
|
using Microsoft.EntityFrameworkCore.Migrations;
|
|
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
|
|
|
|
#nullable disable
|
|
|
|
namespace JobsMedical.Web.Migrations
|
|
{
|
|
/// <inheritdoc />
|
|
public partial class InitialCreate : Migration
|
|
{
|
|
/// <inheritdoc />
|
|
protected override void Up(MigrationBuilder migrationBuilder)
|
|
{
|
|
migrationBuilder.CreateTable(
|
|
name: "Cities",
|
|
columns: table => new
|
|
{
|
|
Id = table.Column<int>(type: "integer", nullable: false)
|
|
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
|
|
Name = table.Column<string>(type: "character varying(100)", maxLength: 100, nullable: false),
|
|
Province = table.Column<string>(type: "character varying(100)", maxLength: 100, nullable: false),
|
|
IsActive = table.Column<bool>(type: "boolean", nullable: false)
|
|
},
|
|
constraints: table =>
|
|
{
|
|
table.PrimaryKey("PK_Cities", x => x.Id);
|
|
});
|
|
|
|
migrationBuilder.CreateTable(
|
|
name: "Users",
|
|
columns: table => new
|
|
{
|
|
Id = table.Column<int>(type: "integer", nullable: false)
|
|
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
|
|
Phone = table.Column<string>(type: "character varying(20)", maxLength: 20, nullable: false),
|
|
FullName = table.Column<string>(type: "character varying(150)", maxLength: 150, nullable: true),
|
|
Role = table.Column<int>(type: "integer", nullable: false),
|
|
IsPhoneVerified = table.Column<bool>(type: "boolean", nullable: false),
|
|
CreatedAt = table.Column<DateTime>(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<int>(type: "integer", nullable: false)
|
|
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
|
|
UserId = table.Column<int>(type: "integer", nullable: false),
|
|
LicenseNo = table.Column<string>(type: "character varying(20)", maxLength: 20, nullable: true),
|
|
Specialty = table.Column<string>(type: "character varying(100)", maxLength: 100, nullable: false),
|
|
CityId = table.Column<int>(type: "integer", nullable: true),
|
|
YearsExperience = table.Column<int>(type: "integer", nullable: false),
|
|
Bio = table.Column<string>(type: "character varying(1000)", maxLength: 1000, nullable: true),
|
|
IsVerified = table.Column<bool>(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<int>(type: "integer", nullable: false)
|
|
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
|
|
Name = table.Column<string>(type: "character varying(200)", maxLength: 200, nullable: false),
|
|
Type = table.Column<int>(type: "integer", nullable: false),
|
|
CityId = table.Column<int>(type: "integer", nullable: false),
|
|
Address = table.Column<string>(type: "character varying(500)", maxLength: 500, nullable: true),
|
|
Lat = table.Column<double>(type: "double precision", nullable: true),
|
|
Lng = table.Column<double>(type: "double precision", nullable: true),
|
|
Phone = table.Column<string>(type: "character varying(20)", maxLength: 20, nullable: true),
|
|
BaleId = table.Column<string>(type: "character varying(50)", maxLength: 50, nullable: true),
|
|
IsVerified = table.Column<bool>(type: "boolean", nullable: false),
|
|
OwnerUserId = table.Column<int>(type: "integer", nullable: true),
|
|
CreatedAt = table.Column<DateTime>(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<int>(type: "integer", nullable: false)
|
|
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
|
|
FacilityId = table.Column<int>(type: "integer", nullable: false),
|
|
Date = table.Column<DateOnly>(type: "date", nullable: false),
|
|
StartTime = table.Column<TimeOnly>(type: "time without time zone", nullable: false),
|
|
EndTime = table.Column<TimeOnly>(type: "time without time zone", nullable: false),
|
|
SpecialtyRequired = table.Column<string>(type: "character varying(100)", maxLength: 100, nullable: false),
|
|
ShiftType = table.Column<int>(type: "integer", nullable: false),
|
|
PayAmount = table.Column<long>(type: "bigint", nullable: true),
|
|
PayType = table.Column<int>(type: "integer", nullable: false),
|
|
Description = table.Column<string>(type: "character varying(1500)", maxLength: 1500, nullable: true),
|
|
Status = table.Column<int>(type: "integer", nullable: false),
|
|
Source = table.Column<int>(type: "integer", nullable: false),
|
|
SourceUrl = table.Column<string>(type: "character varying(500)", maxLength: 500, nullable: true),
|
|
CreatedAt = table.Column<DateTime>(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<int>(type: "integer", nullable: false)
|
|
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
|
|
ShiftId = table.Column<int>(type: "integer", nullable: false),
|
|
DoctorId = table.Column<int>(type: "integer", nullable: false),
|
|
Status = table.Column<int>(type: "integer", nullable: false),
|
|
Message = table.Column<string>(type: "character varying(500)", maxLength: 500, nullable: true),
|
|
CreatedAt = table.Column<DateTime>(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<int>(type: "integer", nullable: false)
|
|
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
|
|
SourceChannel = table.Column<string>(type: "character varying(200)", maxLength: 200, nullable: false),
|
|
RawText = table.Column<string>(type: "text", nullable: false),
|
|
ParsedJson = table.Column<string>(type: "text", nullable: true),
|
|
Status = table.Column<int>(type: "integer", nullable: false),
|
|
LinkedShiftId = table.Column<int>(type: "integer", nullable: true),
|
|
SourceUrl = table.Column<string>(type: "character varying(500)", maxLength: 500, nullable: true),
|
|
FetchedAt = table.Column<DateTime>(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);
|
|
}
|
|
|
|
/// <inheritdoc />
|
|
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");
|
|
}
|
|
}
|
|
}
|