From 7904ba43910141af9e41f892a10e2d57141d2a68 Mon Sep 17 00:00:00 2001 From: cuqmbr Date: Tue, 29 Mar 2022 20:20:49 +0300 Subject: [PATCH] style: update migration, context and db to match the models --- TicketOffice/Data/TicketOfficeContext.cs | 8 +- .../20220329095305_InitialCreate.Designer.cs | 162 ++++++++++++++++++ .../20220329095305_InitialCreate.cs | 123 +++++++++++++ .../TicketOfficeContextModelSnapshot.cs | 160 +++++++++++++++++ .../wwwroot/db/TicketOffice-SQLite.db | Bin 0 -> 45056 bytes .../wwwroot/db/TicketOffice-SQLite.db-shm | Bin 0 -> 32768 bytes .../wwwroot/db/TicketOffice-SQLite.db-wal | Bin 0 -> 49472 bytes 7 files changed, 449 insertions(+), 4 deletions(-) create mode 100644 TicketOffice/Migrations/20220329095305_InitialCreate.Designer.cs create mode 100644 TicketOffice/Migrations/20220329095305_InitialCreate.cs create mode 100644 TicketOffice/Migrations/TicketOfficeContextModelSnapshot.cs create mode 100644 TicketOffice/wwwroot/db/TicketOffice-SQLite.db create mode 100644 TicketOffice/wwwroot/db/TicketOffice-SQLite.db-shm create mode 100644 TicketOffice/wwwroot/db/TicketOffice-SQLite.db-wal diff --git a/TicketOffice/Data/TicketOfficeContext.cs b/TicketOffice/Data/TicketOfficeContext.cs index fec9b27..670b41e 100644 --- a/TicketOffice/Data/TicketOfficeContext.cs +++ b/TicketOffice/Data/TicketOfficeContext.cs @@ -10,17 +10,17 @@ namespace TicketOffice.Data { public class TicketOfficeContext : DbContext { - public TicketOfficeContext (DbContextOptions options) + public TicketOfficeContext(DbContextOptions options) : base(options) { } public DbSet User { get; set; } - public DbSet Route { get; set; } + public DbSet Route { get; set; } - public DbSet City { get; set; } + public DbSet City { get; set; } - public DbSet Ticket { get; set; } + public DbSet Ticket { get; set; } } } diff --git a/TicketOffice/Migrations/20220329095305_InitialCreate.Designer.cs b/TicketOffice/Migrations/20220329095305_InitialCreate.Designer.cs new file mode 100644 index 0000000..3edc673 --- /dev/null +++ b/TicketOffice/Migrations/20220329095305_InitialCreate.Designer.cs @@ -0,0 +1,162 @@ +// +using System; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Migrations; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; +using TicketOffice.Data; + +#nullable disable + +namespace TicketOffice.Migrations +{ + [DbContext(typeof(TicketOfficeContext))] + [Migration("20220329095305_InitialCreate")] + partial class InitialCreate + { + protected override void BuildTargetModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder.HasAnnotation("ProductVersion", "6.0.3"); + + modelBuilder.Entity("TicketOffice.Models.City", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("ArrivalTime") + .HasColumnType("TEXT"); + + b.Property("DepartureTime") + .HasColumnType("TEXT"); + + b.Property("Name") + .IsRequired() + .HasColumnType("TEXT"); + + b.Property("RouteId") + .HasColumnType("INTEGER"); + + b.HasKey("Id"); + + b.HasIndex("RouteId"); + + b.ToTable("City"); + }); + + modelBuilder.Entity("TicketOffice.Models.Route", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("Capacity") + .HasColumnType("INTEGER"); + + b.Property("Number") + .IsRequired() + .HasColumnType("TEXT"); + + b.HasKey("Id"); + + b.ToTable("Route"); + }); + + modelBuilder.Entity("TicketOffice.Models.Ticket", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("RouteId") + .HasColumnType("INTEGER"); + + b.Property("UserId") + .HasColumnType("INTEGER"); + + b.HasKey("Id"); + + b.HasIndex("RouteId"); + + b.HasIndex("UserId"); + + b.ToTable("Ticket"); + }); + + modelBuilder.Entity("TicketOffice.Models.User", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("Email") + .IsRequired() + .HasColumnType("TEXT"); + + b.Property("FirstName") + .HasColumnType("TEXT"); + + b.Property("IsManager") + .HasColumnType("INTEGER"); + + b.Property("LastName") + .HasColumnType("TEXT"); + + b.Property("Password") + .IsRequired() + .HasColumnType("TEXT"); + + b.Property("Patronymic") + .HasColumnType("TEXT"); + + b.HasKey("Id"); + + b.ToTable("User"); + }); + + modelBuilder.Entity("TicketOffice.Models.City", b => + { + b.HasOne("TicketOffice.Models.Route", "Route") + .WithMany("Cities") + .HasForeignKey("RouteId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Route"); + }); + + modelBuilder.Entity("TicketOffice.Models.Ticket", b => + { + b.HasOne("TicketOffice.Models.Route", "Route") + .WithMany("Tickets") + .HasForeignKey("RouteId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("TicketOffice.Models.User", "User") + .WithMany("Tickets") + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Route"); + + b.Navigation("User"); + }); + + modelBuilder.Entity("TicketOffice.Models.Route", b => + { + b.Navigation("Cities"); + + b.Navigation("Tickets"); + }); + + modelBuilder.Entity("TicketOffice.Models.User", b => + { + b.Navigation("Tickets"); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/TicketOffice/Migrations/20220329095305_InitialCreate.cs b/TicketOffice/Migrations/20220329095305_InitialCreate.cs new file mode 100644 index 0000000..cdbd5a8 --- /dev/null +++ b/TicketOffice/Migrations/20220329095305_InitialCreate.cs @@ -0,0 +1,123 @@ +using System; +using Microsoft.EntityFrameworkCore.Migrations; + +#nullable disable + +namespace TicketOffice.Migrations +{ + public partial class InitialCreate : Migration + { + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.CreateTable( + name: "Route", + columns: table => new + { + Id = table.Column(type: "INTEGER", nullable: false) + .Annotation("Sqlite:Autoincrement", true), + Number = table.Column(type: "TEXT", nullable: false), + Capacity = table.Column(type: "INTEGER", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_Route", x => x.Id); + }); + + migrationBuilder.CreateTable( + name: "User", + columns: table => new + { + Id = table.Column(type: "INTEGER", nullable: false) + .Annotation("Sqlite:Autoincrement", true), + FirstName = table.Column(type: "TEXT", nullable: true), + LastName = table.Column(type: "TEXT", nullable: true), + Patronymic = table.Column(type: "TEXT", nullable: true), + Email = table.Column(type: "TEXT", nullable: false), + Password = table.Column(type: "TEXT", nullable: false), + IsManager = table.Column(type: "INTEGER", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_User", x => x.Id); + }); + + migrationBuilder.CreateTable( + name: "City", + columns: table => new + { + Id = table.Column(type: "INTEGER", nullable: false) + .Annotation("Sqlite:Autoincrement", true), + Name = table.Column(type: "TEXT", nullable: false), + ArrivalTime = table.Column(type: "TEXT", nullable: true), + DepartureTime = table.Column(type: "TEXT", nullable: true), + RouteId = table.Column(type: "INTEGER", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_City", x => x.Id); + table.ForeignKey( + name: "FK_City_Route_RouteId", + column: x => x.RouteId, + principalTable: "Route", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + }); + + migrationBuilder.CreateTable( + name: "Ticket", + columns: table => new + { + Id = table.Column(type: "INTEGER", nullable: false) + .Annotation("Sqlite:Autoincrement", true), + UserId = table.Column(type: "INTEGER", nullable: false), + RouteId = table.Column(type: "INTEGER", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_Ticket", x => x.Id); + table.ForeignKey( + name: "FK_Ticket_Route_RouteId", + column: x => x.RouteId, + principalTable: "Route", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + table.ForeignKey( + name: "FK_Ticket_User_UserId", + column: x => x.UserId, + principalTable: "User", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + }); + + migrationBuilder.CreateIndex( + name: "IX_City_RouteId", + table: "City", + column: "RouteId"); + + migrationBuilder.CreateIndex( + name: "IX_Ticket_RouteId", + table: "Ticket", + column: "RouteId"); + + migrationBuilder.CreateIndex( + name: "IX_Ticket_UserId", + table: "Ticket", + column: "UserId"); + } + + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropTable( + name: "City"); + + migrationBuilder.DropTable( + name: "Ticket"); + + migrationBuilder.DropTable( + name: "Route"); + + migrationBuilder.DropTable( + name: "User"); + } + } +} diff --git a/TicketOffice/Migrations/TicketOfficeContextModelSnapshot.cs b/TicketOffice/Migrations/TicketOfficeContextModelSnapshot.cs new file mode 100644 index 0000000..f622297 --- /dev/null +++ b/TicketOffice/Migrations/TicketOfficeContextModelSnapshot.cs @@ -0,0 +1,160 @@ +// +using System; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; +using TicketOffice.Data; + +#nullable disable + +namespace TicketOffice.Migrations +{ + [DbContext(typeof(TicketOfficeContext))] + partial class TicketOfficeContextModelSnapshot : ModelSnapshot + { + protected override void BuildModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder.HasAnnotation("ProductVersion", "6.0.3"); + + modelBuilder.Entity("TicketOffice.Models.City", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("ArrivalTime") + .HasColumnType("TEXT"); + + b.Property("DepartureTime") + .HasColumnType("TEXT"); + + b.Property("Name") + .IsRequired() + .HasColumnType("TEXT"); + + b.Property("RouteId") + .HasColumnType("INTEGER"); + + b.HasKey("Id"); + + b.HasIndex("RouteId"); + + b.ToTable("City"); + }); + + modelBuilder.Entity("TicketOffice.Models.Route", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("Capacity") + .HasColumnType("INTEGER"); + + b.Property("Number") + .IsRequired() + .HasColumnType("TEXT"); + + b.HasKey("Id"); + + b.ToTable("Route"); + }); + + modelBuilder.Entity("TicketOffice.Models.Ticket", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("RouteId") + .HasColumnType("INTEGER"); + + b.Property("UserId") + .HasColumnType("INTEGER"); + + b.HasKey("Id"); + + b.HasIndex("RouteId"); + + b.HasIndex("UserId"); + + b.ToTable("Ticket"); + }); + + modelBuilder.Entity("TicketOffice.Models.User", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("Email") + .IsRequired() + .HasColumnType("TEXT"); + + b.Property("FirstName") + .HasColumnType("TEXT"); + + b.Property("IsManager") + .HasColumnType("INTEGER"); + + b.Property("LastName") + .HasColumnType("TEXT"); + + b.Property("Password") + .IsRequired() + .HasColumnType("TEXT"); + + b.Property("Patronymic") + .HasColumnType("TEXT"); + + b.HasKey("Id"); + + b.ToTable("User"); + }); + + modelBuilder.Entity("TicketOffice.Models.City", b => + { + b.HasOne("TicketOffice.Models.Route", "Route") + .WithMany("Cities") + .HasForeignKey("RouteId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Route"); + }); + + modelBuilder.Entity("TicketOffice.Models.Ticket", b => + { + b.HasOne("TicketOffice.Models.Route", "Route") + .WithMany("Tickets") + .HasForeignKey("RouteId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("TicketOffice.Models.User", "User") + .WithMany("Tickets") + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Route"); + + b.Navigation("User"); + }); + + modelBuilder.Entity("TicketOffice.Models.Route", b => + { + b.Navigation("Cities"); + + b.Navigation("Tickets"); + }); + + modelBuilder.Entity("TicketOffice.Models.User", b => + { + b.Navigation("Tickets"); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/TicketOffice/wwwroot/db/TicketOffice-SQLite.db b/TicketOffice/wwwroot/db/TicketOffice-SQLite.db new file mode 100644 index 0000000000000000000000000000000000000000..15f5bc7854a7662fbe32b1c2e2559d73dd58b3f0 GIT binary patch literal 45056 zcmeI*Pi)&%90zbeJ9Xof)*w+ul@OQ+q@`O^H=+LmhlSMbqNQnaJYMo35d}T(!4!S4nXXay-wSR}_xpcsdWzxjBXDN~pO(f0CB2C~Vi(00nDY?R&wx+~7E5($hf)ewq#*{NLziBM~f+R-A zN65{N$i-^SHJYI#y+Q}II%7AB<11k?dUlx9n!&TCyIl_UvUTZD;MN*`SXRP1ydU)T z!~OlykrA>hxccRa;Sb4QhJ$#e%(Ho|Wwa56PO;o(jOvuM1+AzQmP$%tHJ?|qONEtE zF+T((zbN7(kyPz)w1q5uU2jP zGVPYhoU^D~`W1E-cD{-u@#PS`(wrsho{)2+LT~HJj&Y-ASQ|#iW?!3I$IderJ(JGS zmhoFtLVq+GB|8_rnBKYIEkbSW_g{j?hxei!eTga5wl1^5cC*Op*YyqW!g!eC)+*_b zPEV7aoY(PkS({%puh_b4RxRg(>9|#UyK5oeKCrHJ=oP>p=zd6cRc-5H=OwjAoR$+W zcr`BD)y>+5`$BMqivJocCrDq)o56Rd2i8^(f_uuEhdAc7W6s>!69O3tdYlPPtwoU=^V)GJxr z&|PCHp(auhIxZsr$kA_15P$##AOHafKmY;|fB*y_009V`P=Ut;O}gJN0odpNy!;C% z|3Md+AOHafKmY;|fB*y_009U<00Iy=;Q|sL;)aQ;s>u%2vu*qNy5 zqZf4Ns2zu`t*ZRfeIgf6rAYm~#_jqiwB|ipbFa1LRQf4av$beCt$K|YLL!%8jo)wFsejtI zLl5^={WCh#5RKi&+x5>|TTP}XI|EInC%ix@fd%5EV+B%Y{Xl8n>$=pl>$IZR&z4Tm zq9i-wGlUVPr27!5Gk)h{8KmY;|fB*y_ P009U<00Iy={R000oiO@s literal 0 HcmV?d00001 diff --git a/TicketOffice/wwwroot/db/TicketOffice-SQLite.db-shm b/TicketOffice/wwwroot/db/TicketOffice-SQLite.db-shm new file mode 100644 index 0000000000000000000000000000000000000000..ef32cacbae3b0726e40aaf5b3bf136edcbe1111e GIT binary patch literal 32768 zcmeI*v26lD5Czb~;KPR`@S^V z)oHcbc?HakH`6Nf7}cw)*OyqIqjo?0)#v;Ad-1lMPbSUp`fFQ%{LKdAE6>MOZSvm3 zMY_-DWf;3A>M3dzm2VhC)!mx!%l+wGY=r;;0t5&UAV7cs0RjXF5FkK+009C72oNAZ zfB*pk1PBlyK!5-N0t5&UAV7cs0RjXF5FkK+009C72oNAZfB*pk1PBlyK!5-N0t5&U zAV7e?-3Zj}q^-Mou7?u1p+HWW69Q!l4BH8dW%jP?(gk|$Y|+vc^k1exzs$CEO&|mw zs+>bD1WFXhdFn!-Oo9A^fDj-+fB*pk1PBlyK!5-N0t5&UAV7cs0RjXF5FkK+0D=E0 Fa0FB&Bi{f3 literal 0 HcmV?d00001 diff --git a/TicketOffice/wwwroot/db/TicketOffice-SQLite.db-wal b/TicketOffice/wwwroot/db/TicketOffice-SQLite.db-wal new file mode 100644 index 0000000000000000000000000000000000000000..8da031b3a466627f4c61bbe5b6031a81ad1cebad GIT binary patch literal 49472 zcmeI*PiP!f9Ki9Jo!QAw67vKpDg_Bji`lxH*_mv1GcjltZBMN!twlVPg#;T~Hn^Lh z(SxUdWglgC&6CQ(ydtAiV>kAwll|yXe?6v+k;vKvFdxX?m85r{R5?|-?z-$ z-N$>s`R!+JKiJ^R!U4FLoYKmY**5I_I{1Q0*~fg320wk$2+zX`{(zbpA1e4x zw0MnaX{*)Z17R&V9M>&Uspt){SQP=v5{PSb+Mr)uca-Iu4cVp?U$qWZJ$q^?o=09 z)dhYNzla~icjCNQR6{fb5I_I{1Q0*~0R#|0009ILXdi*3q3a1N>XT7#nue_#s!JG# zt!e@(^=q1Sf%NxJtbe2P{77@ZK>PesGDQFZ1Q0*~0R#|0009ILKmdVj5Qw%0H0uJ} z4sLq4`1Quk&HVz`5RWAYAb&^t_BM5a z_PKy$iU0x#Ab+^C9zH&cp10Yn=AMO zj_)|;aF?a^d7d8Z4|fHJzUlnem~5@2DYjO{b-;R*MgWwcv1Alczfw z9Fd0%5zdCYgJbbkc|U)7pg}(u1sbqbAer%%1agKNfsEnQzvM1wMv2C zkYw&lBRR!Jdhz8&-;0*Z%W2D__1wYDmtMWF^Tpir>VFC?@u?<$6+ej!;wy1ZexV_N p00IagfB*srAb