using Microsoft.EntityFrameworkCore.Migrations; using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata; #nullable disable namespace FichaBackend.Migrations { /// public partial class @new : Migration { /// protected override void Up(MigrationBuilder migrationBuilder) { migrationBuilder.AddColumn( name: "GuideId", table: "Cities", type: "bigint", nullable: true); migrationBuilder.CreateTable( name: "Guides", columns: table => new { Id = table.Column(type: "bigint", nullable: false) .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), FullName = table.Column(type: "text", nullable: false), PhoneNumber = table.Column(type: "text", nullable: false), ContactUrl = table.Column(type: "text", nullable: true), Rating = table.Column(type: "real", nullable: false) }, constraints: table => { table.PrimaryKey("PK_Guides", x => x.Id); }); migrationBuilder.CreateTable( name: "Museums", columns: table => new { Id = table.Column(type: "bigint", nullable: false) .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), CityId = table.Column(type: "bigint", nullable: false), Name = table.Column(type: "text", nullable: false), Longtitude = table.Column(type: "double precision", nullable: false), Latitude = table.Column(type: "double precision", nullable: false), Price = table.Column(type: "real", nullable: true) }, constraints: table => { table.PrimaryKey("PK_Museums", x => x.Id); table.ForeignKey( name: "FK_Museums_Cities_CityId", column: x => x.CityId, principalTable: "Cities", principalColumn: "Id", onDelete: ReferentialAction.Cascade); }); migrationBuilder.CreateIndex( name: "IX_Cities_GuideId", table: "Cities", column: "GuideId"); migrationBuilder.CreateIndex( name: "IX_Museums_CityId", table: "Museums", column: "CityId"); migrationBuilder.AddForeignKey( name: "FK_Cities_Guides_GuideId", table: "Cities", column: "GuideId", principalTable: "Guides", principalColumn: "Id"); } /// protected override void Down(MigrationBuilder migrationBuilder) { migrationBuilder.DropForeignKey( name: "FK_Cities_Guides_GuideId", table: "Cities"); migrationBuilder.DropTable( name: "Guides"); migrationBuilder.DropTable( name: "Museums"); migrationBuilder.DropIndex( name: "IX_Cities_GuideId", table: "Cities"); migrationBuilder.DropColumn( name: "GuideId", table: "Cities"); } } }