using System; using Microsoft.EntityFrameworkCore.Migrations; #nullable disable namespace TeleWave.Infrastructure.Migrations { /// public partial class AddGroups : Migration { /// protected override void Up(MigrationBuilder migrationBuilder) { migrationBuilder.CreateTable( name: "Groups", columns: table => new { Id = table.Column(type: "uuid", nullable: false), Name = table.Column(type: "character varying(256)", maxLength: 256, nullable: false), Description = table.Column(type: "character varying(2048)", maxLength: 2048, nullable: true), FilterJson = table.Column(type: "jsonb", nullable: true), ItemCount = table.Column(type: "integer", nullable: false), UnitCount = table.Column(type: "integer", nullable: false), TotalDuration = table.Column(type: "interval", nullable: false), StatsComputedAt = table.Column(type: "timestamp with time zone", nullable: true), CreatedAt = table.Column(type: "timestamp with time zone", nullable: false) }, constraints: table => { table.PrimaryKey("PK_Groups", x => x.Id); }); migrationBuilder.CreateTable( name: "GroupItems", columns: table => new { Id = table.Column(type: "uuid", nullable: false), GroupId = table.Column(type: "uuid", nullable: false), ElementKind = table.Column(type: "integer", nullable: false), ElementId = table.Column(type: "uuid", nullable: false), Weight = table.Column(type: "integer", nullable: false), Position = table.Column(type: "integer", nullable: false) }, constraints: table => { table.PrimaryKey("PK_GroupItems", x => x.Id); table.ForeignKey( name: "FK_GroupItems_Groups_GroupId", column: x => x.GroupId, principalTable: "Groups", principalColumn: "Id", onDelete: ReferentialAction.Cascade); }); migrationBuilder.CreateIndex( name: "IX_GroupItems_ElementKind_ElementId", table: "GroupItems", columns: new[] { "ElementKind", "ElementId" }); migrationBuilder.CreateIndex( name: "IX_GroupItems_GroupId_ElementKind_ElementId", table: "GroupItems", columns: new[] { "GroupId", "ElementKind", "ElementId" }, unique: true); migrationBuilder.CreateIndex( name: "IX_GroupItems_GroupId_Position", table: "GroupItems", columns: new[] { "GroupId", "Position" }); } /// protected override void Down(MigrationBuilder migrationBuilder) { migrationBuilder.DropTable( name: "GroupItems"); migrationBuilder.DropTable( name: "Groups"); } } }