using System; using Microsoft.EntityFrameworkCore.Migrations; using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata; #nullable disable namespace BeautySalonDatabaseImplement.Migrations { /// public partial class InitialCreate : Migration { /// protected override void Up(MigrationBuilder migrationBuilder) { migrationBuilder.CreateTable( name: "Clients", columns: table => new { Id = table.Column(type: "integer", nullable: false) .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), ClientFIO = table.Column(type: "text", nullable: false), PhoneNumber = table.Column(type: "text", nullable: false) }, constraints: table => { table.PrimaryKey("PK_Clients", x => x.Id); }); migrationBuilder.CreateTable( name: "Masters", columns: table => new { Id = table.Column(type: "integer", nullable: false) .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), MasterFIO = table.Column(type: "text", nullable: false), Wage = table.Column(type: "double precision", nullable: false) }, constraints: table => { table.PrimaryKey("PK_Masters", x => x.Id); }); migrationBuilder.CreateTable( name: "Services", columns: table => new { Id = table.Column(type: "integer", nullable: false) .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), ServiceName = table.Column(type: "text", nullable: false), Cost = table.Column(type: "double precision", nullable: false), Time = table.Column(type: "double precision", nullable: false) }, constraints: table => { table.PrimaryKey("PK_Services", x => x.Id); }); migrationBuilder.CreateTable( name: "MasterServices", columns: table => new { Id = table.Column(type: "integer", nullable: false) .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), MasterId = table.Column(type: "integer", nullable: false), ServiceId = table.Column(type: "integer", nullable: false), Wage = table.Column(type: "double precision", nullable: false) }, constraints: table => { table.PrimaryKey("PK_MasterServices", x => x.Id); table.ForeignKey( name: "FK_MasterServices_Masters_MasterId", column: x => x.MasterId, principalTable: "Masters", principalColumn: "Id", onDelete: ReferentialAction.Cascade); table.ForeignKey( name: "FK_MasterServices_Services_ServiceId", column: x => x.ServiceId, principalTable: "Services", principalColumn: "Id", onDelete: ReferentialAction.Cascade); }); migrationBuilder.CreateTable( name: "Visits", columns: table => new { Id = table.Column(type: "integer", nullable: false) .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), DateOfVisit = table.Column(type: "timestamp with time zone", nullable: false), ClientId = table.Column(type: "integer", nullable: false), ServiceId = table.Column(type: "integer", nullable: false), ClientFIO = table.Column(type: "text", nullable: false), ServiceName = table.Column(type: "text", nullable: false), Sum = table.Column(type: "double precision", nullable: false), MasterId = table.Column(type: "integer", nullable: true) }, constraints: table => { table.PrimaryKey("PK_Visits", x => x.Id); table.ForeignKey( name: "FK_Visits_Clients_ClientId", column: x => x.ClientId, principalTable: "Clients", principalColumn: "Id", onDelete: ReferentialAction.Cascade); table.ForeignKey( name: "FK_Visits_Masters_MasterId", column: x => x.MasterId, principalTable: "Masters", principalColumn: "Id"); table.ForeignKey( name: "FK_Visits_Services_ServiceId", column: x => x.ServiceId, principalTable: "Services", principalColumn: "Id", onDelete: ReferentialAction.Cascade); }); migrationBuilder.CreateIndex( name: "IX_MasterServices_MasterId", table: "MasterServices", column: "MasterId"); migrationBuilder.CreateIndex( name: "IX_MasterServices_ServiceId", table: "MasterServices", column: "ServiceId"); migrationBuilder.CreateIndex( name: "IX_Visits_ClientId", table: "Visits", column: "ClientId"); migrationBuilder.CreateIndex( name: "IX_Visits_MasterId", table: "Visits", column: "MasterId"); migrationBuilder.CreateIndex( name: "IX_Visits_ServiceId", table: "Visits", column: "ServiceId"); } /// protected override void Down(MigrationBuilder migrationBuilder) { migrationBuilder.DropTable( name: "MasterServices"); migrationBuilder.DropTable( name: "Visits"); migrationBuilder.DropTable( name: "Clients"); migrationBuilder.DropTable( name: "Masters"); migrationBuilder.DropTable( name: "Services"); } } }