Ignore:
Timestamp:
11/05/20 06:57:35 (3 years ago)
Author:
DimitarSlezenkovski <dslezenkovski@…>
Branches:
master
Children:
afc9a9a
Parents:
1f4846d
Message:

Add SystemService, Auth, fix a lil bugs :)

File:
1 moved

Legend:

Unmodified
Added
Removed
  • FarmatikoData/Migrations/20201104230858_InitialMigration.cs

    r1f4846d rd23bf72  
    55namespace FarmatikoData.Migrations
    66{
    7     public partial class Initialmigration : Migration
     7    public partial class InitialMigration : Migration
    88    {
    99        protected override void Up(MigrationBuilder migrationBuilder)
     
    1515                    Id = table.Column<int>(nullable: false)
    1616                        .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
    17                     CreatedOn = table.Column<DateTime>(nullable: false, defaultValueSql: "now()"),
     17                    CreatedOn = table.Column<DateTime>(nullable: false),
    1818                    DeletedOn = table.Column<DateTime>(nullable: true),
    1919                    Name = table.Column<string>(nullable: false),
     
    2424                    Phone = table.Column<string>(nullable: true)
    2525                },
    26                 constraints: table => 
     26                constraints: table =>
    2727                {
    2828                    table.PrimaryKey("PK_HealthFacilities", x => x.Id);
     
    3030
    3131            migrationBuilder.CreateTable(
     32                name: "Medicines",
     33                columns: table => new
     34                {
     35                    Id = table.Column<int>(nullable: false)
     36                        .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
     37                    CreatedOn = table.Column<DateTime>(nullable: false),
     38                    DeletedOn = table.Column<DateTime>(nullable: true),
     39                    Name = table.Column<string>(nullable: false),
     40                    Strength = table.Column<string>(nullable: false),
     41                    Form = table.Column<string>(nullable: true),
     42                    WayOfIssuing = table.Column<string>(nullable: false),
     43                    Manufacturer = table.Column<string>(nullable: false),
     44                    Price = table.Column<float>(nullable: false),
     45                    Packaging = table.Column<string>(nullable: true)
     46                },
     47                constraints: table =>
     48                {
     49                    table.PrimaryKey("PK_Medicines", x => x.Id);
     50                });
     51
     52            migrationBuilder.CreateTable(
    3253                name: "Pandemics",
    3354                columns: table => new
     
    3556                    Id = table.Column<int>(nullable: false)
    3657                        .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
    37                     CreatedOn = table.Column<DateTime>(nullable: false, defaultValueSql: "now()"),
    38                     DeletedOn = table.Column<DateTime>(nullable: true),
    39                     Name = table.Column<string>(nullable: true),
     58                    CreatedOn = table.Column<DateTime>(nullable: false),
     59                    DeletedOn = table.Column<DateTime>(nullable: true),
     60                    Name = table.Column<string>(nullable: false),
    4061                    TotalMK = table.Column<int>(nullable: false),
    4162                    ActiveMK = table.Column<int>(nullable: false),
    4263                    DeathsMK = table.Column<int>(nullable: false),
    4364                    NewMK = table.Column<int>(nullable: false),
    44                     TotalGlobal = table.Column<int>(nullable: false),
    45                     DeathsGlobal = table.Column<int>(nullable: false),
    46                     ActiveGlobal = table.Column<int>(nullable: false)
     65                    TotalGlobal = table.Column<long>(nullable: false),
     66                    DeathsGlobal = table.Column<long>(nullable: false),
     67                    ActiveGlobal = table.Column<long>(nullable: false)
    4768                },
    4869                constraints: table =>
     
    5273
    5374            migrationBuilder.CreateTable(
     75                name: "PharmacyHeads",
     76                columns: table => new
     77                {
     78                    Id = table.Column<int>(nullable: false)
     79                        .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
     80                    CreatedOn = table.Column<DateTime>(nullable: false),
     81                    DeletedOn = table.Column<DateTime>(nullable: true),
     82                    Email = table.Column<string>(nullable: false),
     83                    Name = table.Column<string>(nullable: false),
     84                    Password = table.Column<string>(nullable: false)
     85                },
     86                constraints: table =>
     87                {
     88                    table.PrimaryKey("PK_PharmacyHeads", x => x.Id);
     89                });
     90
     91            migrationBuilder.CreateTable(
     92                name: "Users",
     93                columns: table => new
     94                {
     95                    Id = table.Column<int>(nullable: false)
     96                        .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
     97                    CreatedOn = table.Column<DateTime>(nullable: false),
     98                    DeletedOn = table.Column<DateTime>(nullable: true),
     99                    Name = table.Column<string>(nullable: true),
     100                    Email = table.Column<string>(nullable: true),
     101                    Password = table.Column<string>(nullable: true),
     102                    UserRole = table.Column<int>(nullable: false)
     103                },
     104                constraints: table =>
     105                {
     106                    table.PrimaryKey("PK_Users", x => x.Id);
     107                });
     108
     109            migrationBuilder.CreateTable(
    54110                name: "HealthcareWorkers",
    55111                columns: table => new
     
    57113                    Id = table.Column<int>(nullable: false)
    58114                        .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
    59                     CreatedOn = table.Column<DateTime>(nullable: false, defaultValueSql: "now()"),
     115                    CreatedOn = table.Column<DateTime>(nullable: false),
    60116                    DeletedOn = table.Column<DateTime>(nullable: true),
    61117                    Name = table.Column<string>(nullable: false),
     
    76132
    77133            migrationBuilder.CreateTable(
    78                 name: "Medicines",
    79                 columns: table => new
    80                 {
    81                     Id = table.Column<int>(nullable: false)
    82                         .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
    83                     CreatedOn = table.Column<DateTime>(nullable: false, defaultValueSql: "now()"),
    84                     DeletedOn = table.Column<DateTime>(nullable: true),
    85                     Name = table.Column<string>(nullable: true),
    86                     Strength = table.Column<string>(nullable: true),
    87                     Form = table.Column<string>(nullable: true),
    88                     WayOfIssuing = table.Column<string>(nullable: true),
    89                     Manufacturer = table.Column<string>(nullable: true),
    90                     Price = table.Column<float>(nullable: false),
    91                     Packaging = table.Column<string>(nullable: true),
    92                     MedicineListId = table.Column<int>(nullable: true)
    93                 },
    94                 constraints: table =>
    95                 {
    96                     table.PrimaryKey("PK_Medicines", x => x.Id);
    97                 });
    98 
    99             migrationBuilder.CreateTable(
    100                 name: "PharmacyHeads",
    101                 columns: table => new
    102                 {
    103                     Id = table.Column<int>(nullable: false)
    104                         .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
    105                     CreatedOn = table.Column<DateTime>(nullable: false, defaultValueSql: "now()"),
    106                     DeletedOn = table.Column<DateTime>(nullable: true),
    107                     PharmacyMedicinesId = table.Column<int>(nullable: true),
    108                     PharmacyId = table.Column<int>(nullable: true),
    109                     Email = table.Column<string>(nullable: true),
    110                     Name = table.Column<string>(nullable: true),
    111                     Password = table.Column<string>(nullable: true)
    112                 },
    113                 constraints: table =>
    114                 {
    115                     table.PrimaryKey("PK_PharmacyHeads", x => x.Id);
    116                 });
    117 
    118             migrationBuilder.CreateTable(
    119134                name: "MedicineLists",
    120135                columns: table => new
     
    122137                    Id = table.Column<int>(nullable: false)
    123138                        .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
    124                     CreatedOn = table.Column<DateTime>(nullable: false, defaultValueSql: "now()"),
    125                     DeletedOn = table.Column<DateTime>(nullable: true),
    126                     MedicinesId = table.Column<int>(nullable: true),
     139                    CreatedOn = table.Column<DateTime>(nullable: false),
     140                    DeletedOn = table.Column<DateTime>(nullable: true),
     141                    MedicineId = table.Column<int>(nullable: false),
    127142                    HasMedicine = table.Column<bool>(nullable: false),
    128143                    PharmacyHeadId = table.Column<int>(nullable: true)
     
    132147                    table.PrimaryKey("PK_MedicineLists", x => x.Id);
    133148                    table.ForeignKey(
    134                         name: "FK_MedicineLists_Medicines_MedicinesId",
    135                         column: x => x.MedicinesId,
     149                        name: "FK_MedicineLists_Medicines_MedicineId",
     150                        column: x => x.MedicineId,
    136151                        principalTable: "Medicines",
    137152                        principalColumn: "Id",
    138                         onDelete: ReferentialAction.Restrict);
     153                        onDelete: ReferentialAction.Cascade);
    139154                    table.ForeignKey(
    140155                        name: "FK_MedicineLists_PharmacyHeads_PharmacyHeadId",
     
    151166                    Id = table.Column<int>(nullable: false)
    152167                        .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
    153                     CreatedOn = table.Column<DateTime>(nullable: false, defaultValueSql: "now()"),
    154                     DeletedOn = table.Column<DateTime>(nullable: true),
    155                     Name = table.Column<string>(nullable: true),
    156                     Location = table.Column<string>(nullable: true),
    157                     Address = table.Column<string>(nullable: true),
     168                    CreatedOn = table.Column<DateTime>(nullable: false),
     169                    DeletedOn = table.Column<DateTime>(nullable: true),
     170                    Name = table.Column<string>(nullable: false),
     171                    Location = table.Column<string>(nullable: false),
     172                    Address = table.Column<string>(nullable: false),
    158173                    WorkAllTime = table.Column<bool>(nullable: false),
    159174                    PharmacyHeadId = table.Column<int>(nullable: true)
     
    170185                });
    171186
     187            migrationBuilder.CreateTable(
     188                name: "PHRequests",
     189                columns: table => new
     190                {
     191                    Id = table.Column<int>(nullable: false)
     192                        .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
     193                    CreatedOn = table.Column<DateTime>(nullable: false),
     194                    DeletedOn = table.Column<DateTime>(nullable: true),
     195                    HeadId = table.Column<int>(nullable: false),
     196                    PharmacyId = table.Column<int>(nullable: false)
     197                },
     198                constraints: table =>
     199                {
     200                    table.PrimaryKey("PK_PHRequests", x => x.Id);
     201                    table.ForeignKey(
     202                        name: "FK_PHRequests_PharmacyHeads_HeadId",
     203                        column: x => x.HeadId,
     204                        principalTable: "PharmacyHeads",
     205                        principalColumn: "Id",
     206                        onDelete: ReferentialAction.Cascade);
     207                    table.ForeignKey(
     208                        name: "FK_PHRequests_Pharmacies_PharmacyId",
     209                        column: x => x.PharmacyId,
     210                        principalTable: "Pharmacies",
     211                        principalColumn: "Id",
     212                        onDelete: ReferentialAction.Cascade);
     213                });
     214
    172215            migrationBuilder.CreateIndex(
    173216                name: "IX_HealthcareWorkers_FacilityId",
     
    176219
    177220            migrationBuilder.CreateIndex(
    178                 name: "IX_MedicineLists_MedicinesId",
     221                name: "IX_MedicineLists_MedicineId",
    179222                table: "MedicineLists",
    180                 column: "MedicinesId");
     223                column: "MedicineId");
    181224
    182225            migrationBuilder.CreateIndex(
     
    186229
    187230            migrationBuilder.CreateIndex(
    188                 name: "IX_Medicines_MedicineListId",
    189                 table: "Medicines",
    190                 column: "MedicineListId");
    191 
    192             migrationBuilder.CreateIndex(
    193231                name: "IX_Pharmacies_PharmacyHeadId",
    194232                table: "Pharmacies",
     
    196234
    197235            migrationBuilder.CreateIndex(
    198                 name: "IX_PharmacyHeads_PharmacyId",
    199                 table: "PharmacyHeads",
     236                name: "IX_PHRequests_HeadId",
     237                table: "PHRequests",
     238                column: "HeadId");
     239
     240            migrationBuilder.CreateIndex(
     241                name: "IX_PHRequests_PharmacyId",
     242                table: "PHRequests",
    200243                column: "PharmacyId");
    201 
    202             migrationBuilder.CreateIndex(
    203                 name: "IX_PharmacyHeads_PharmacyMedicinesId",
    204                 table: "PharmacyHeads",
    205                 column: "PharmacyMedicinesId");
    206 
    207             migrationBuilder.AddForeignKey(
    208                 name: "FK_Medicines_MedicineLists_MedicineListId",
    209                 table: "Medicines",
    210                 column: "MedicineListId",
    211                 principalTable: "MedicineLists",
    212                 principalColumn: "Id",
    213                 onDelete: ReferentialAction.Restrict);
    214 
    215             migrationBuilder.AddForeignKey(
    216                 name: "FK_PharmacyHeads_MedicineLists_PharmacyMedicinesId",
    217                 table: "PharmacyHeads",
    218                 column: "PharmacyMedicinesId",
    219                 principalTable: "MedicineLists",
    220                 principalColumn: "Id",
    221                 onDelete: ReferentialAction.Restrict);
    222 
    223             migrationBuilder.AddForeignKey(
    224                 name: "FK_PharmacyHeads_Pharmacies_PharmacyId",
    225                 table: "PharmacyHeads",
    226                 column: "PharmacyId",
    227                 principalTable: "Pharmacies",
    228                 principalColumn: "Id",
    229                 onDelete: ReferentialAction.Restrict);
    230244        }
    231245
    232246        protected override void Down(MigrationBuilder migrationBuilder)
    233247        {
    234             migrationBuilder.DropForeignKey(
    235                 name: "FK_MedicineLists_Medicines_MedicinesId",
    236                 table: "MedicineLists");
    237 
    238             migrationBuilder.DropForeignKey(
    239                 name: "FK_MedicineLists_PharmacyHeads_PharmacyHeadId",
    240                 table: "MedicineLists");
    241 
    242             migrationBuilder.DropForeignKey(
    243                 name: "FK_Pharmacies_PharmacyHeads_PharmacyHeadId",
    244                 table: "Pharmacies");
    245 
    246248            migrationBuilder.DropTable(
    247249                name: "HealthcareWorkers");
    248250
    249251            migrationBuilder.DropTable(
     252                name: "MedicineLists");
     253
     254            migrationBuilder.DropTable(
    250255                name: "Pandemics");
    251256
    252257            migrationBuilder.DropTable(
     258                name: "PHRequests");
     259
     260            migrationBuilder.DropTable(
     261                name: "Users");
     262
     263            migrationBuilder.DropTable(
    253264                name: "HealthFacilities");
    254265
     
    257268
    258269            migrationBuilder.DropTable(
     270                name: "Pharmacies");
     271
     272            migrationBuilder.DropTable(
    259273                name: "PharmacyHeads");
    260 
    261             migrationBuilder.DropTable(
    262                 name: "Pharmacies");
    263 
    264             migrationBuilder.DropTable(
    265                 name: "MedicineLists");
    266274        }
    267275    }
Note: See TracChangeset for help on using the changeset viewer.