using System; using Microsoft.EntityFrameworkCore.Migrations; using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata; #nullable disable namespace data.Migrations { /// public partial class InitialCreate : Migration { /// protected override void Up(MigrationBuilder migrationBuilder) { migrationBuilder.CreateTable( name: "groups", columns: table => new { Id = table.Column(type: "integer", nullable: false) .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), Name = table.Column(type: "text", nullable: false) }, constraints: table => { table.PrimaryKey("PK_groups", x => x.Id); }); migrationBuilder.CreateTable( name: "users", columns: table => new { Guid = table.Column(type: "uuid", nullable: false), Name = table.Column(type: "text", nullable: false), GroupId = table.Column(type: "integer", nullable: false) }, constraints: table => { table.PrimaryKey("PK_users", x => x.Guid); table.ForeignKey( name: "FK_users_groups_GroupId", column: x => x.GroupId, principalTable: "groups", principalColumn: "Id", onDelete: ReferentialAction.Cascade); }); migrationBuilder.CreateIndex( name: "IX_users_GroupId", table: "users", column: "GroupId"); } /// protected override void Down(MigrationBuilder migrationBuilder) { migrationBuilder.DropTable( name: "users"); migrationBuilder.DropTable( name: "groups"); } } }