using Microsoft.EntityFrameworkCore.Migrations; using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata; #nullable disable namespace Yavsc.Migrations { /// public partial class pending : Migration { /// protected override void Up(MigrationBuilder migrationBuilder) { migrationBuilder.CreateTable( name: "RegexAlertPatterns", columns: table => new { Id = table.Column(type: "integer", nullable: false) .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), Pattern = table.Column(type: "character varying(500)", maxLength: 500, nullable: false), Description = table.Column(type: "character varying(200)", maxLength: 200, nullable: true), Severity = table.Column(type: "integer", nullable: false), IsActive = table.Column(type: "boolean", nullable: false) }, constraints: table => { table.PrimaryKey("PK_RegexAlertPatterns", x => x.Id); }); migrationBuilder.CreateTable( name: "TrustTokens", columns: table => new { Id = table.Column(type: "uuid", nullable: false), TokenHash = table.Column(type: "character varying(128)", maxLength: 128, nullable: false), TokenSource = table.Column(type: "character varying(32)", maxLength: 32, nullable: false), CreatedAt = table.Column(type: "timestamp with time zone", nullable: false), TrustScore = table.Column(type: "integer", nullable: true) }, constraints: table => { table.PrimaryKey("PK_TrustTokens", x => x.Id); }); migrationBuilder.CreateTable( name: "TrustDeclarations", columns: table => new { Id = table.Column(type: "bigint", nullable: false) .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), TrustTokenId = table.Column(type: "uuid", nullable: false), DeclarantTokenId = table.Column(type: "uuid", nullable: false), Content = table.Column(type: "character varying(2000)", maxLength: 2000, nullable: true), Sentiment = table.Column(type: "integer", nullable: false), SubmittedAt = table.Column(type: "timestamp with time zone", nullable: false), Status = table.Column(type: "integer", nullable: false), ScoreDelta = table.Column(type: "integer", nullable: true) }, constraints: table => { table.PrimaryKey("PK_TrustDeclarations", x => x.Id); table.ForeignKey( name: "FK_TrustDeclarations_TrustTokens_TrustTokenId", column: x => x.TrustTokenId, principalTable: "TrustTokens", principalColumn: "Id", onDelete: ReferentialAction.Restrict); }); migrationBuilder.CreateTable( name: "DeclarationFlag", columns: table => new { Id = table.Column(type: "bigint", nullable: false) .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), DeclarationId = table.Column(type: "bigint", nullable: false), PatternId = table.Column(type: "integer", nullable: false), MatchExcerpt = table.Column(type: "character varying(100)", maxLength: 100, nullable: true) }, constraints: table => { table.PrimaryKey("PK_DeclarationFlag", x => x.Id); table.ForeignKey( name: "FK_DeclarationFlag_RegexAlertPatterns_PatternId", column: x => x.PatternId, principalTable: "RegexAlertPatterns", principalColumn: "Id", onDelete: ReferentialAction.Restrict); table.ForeignKey( name: "FK_DeclarationFlag_TrustDeclarations_DeclarationId", column: x => x.DeclarationId, principalTable: "TrustDeclarations", principalColumn: "Id", onDelete: ReferentialAction.Cascade); }); migrationBuilder.CreateTable( name: "ModerationLogs", columns: table => new { Id = table.Column(type: "bigint", nullable: false) .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), DeclarationId = table.Column(type: "bigint", nullable: false), ModeratorId = table.Column(type: "text", nullable: true), Action = table.Column(type: "integer", nullable: false), ScoreDelta = table.Column(type: "integer", nullable: false), Timestamp = table.Column(type: "timestamp with time zone", nullable: false) }, constraints: table => { table.PrimaryKey("PK_ModerationLogs", x => x.Id); table.CheckConstraint("CK_ModerationLog_Immutable", "1=1"); table.ForeignKey( name: "FK_ModerationLogs_TrustDeclarations_DeclarationId", column: x => x.DeclarationId, principalTable: "TrustDeclarations", principalColumn: "Id", onDelete: ReferentialAction.Restrict); }); migrationBuilder.CreateIndex( name: "IX_DeclarationFlag_DeclarationId", table: "DeclarationFlag", column: "DeclarationId"); migrationBuilder.CreateIndex( name: "IX_DeclarationFlag_PatternId", table: "DeclarationFlag", column: "PatternId"); migrationBuilder.CreateIndex( name: "IX_ModerationLogs_DeclarationId", table: "ModerationLogs", column: "DeclarationId"); migrationBuilder.CreateIndex( name: "IX_ModerationLogs_ModeratorId", table: "ModerationLogs", column: "ModeratorId"); migrationBuilder.CreateIndex( name: "IX_ModerationLogs_Timestamp", table: "ModerationLogs", column: "Timestamp"); migrationBuilder.CreateIndex( name: "IX_RegexAlertPatterns_IsActive", table: "RegexAlertPatterns", column: "IsActive"); migrationBuilder.CreateIndex( name: "IX_TrustDeclarations_Status", table: "TrustDeclarations", column: "Status"); migrationBuilder.CreateIndex( name: "IX_TrustDeclarations_SubmittedAt", table: "TrustDeclarations", column: "SubmittedAt"); migrationBuilder.CreateIndex( name: "IX_TrustDeclarations_TrustTokenId", table: "TrustDeclarations", column: "TrustTokenId"); migrationBuilder.CreateIndex( name: "IX_TrustTokens_TokenHash", table: "TrustTokens", column: "TokenHash", unique: true); } /// protected override void Down(MigrationBuilder migrationBuilder) { migrationBuilder.DropTable( name: "DeclarationFlag"); migrationBuilder.DropTable( name: "ModerationLogs"); migrationBuilder.DropTable( name: "RegexAlertPatterns"); migrationBuilder.DropTable( name: "TrustDeclarations"); migrationBuilder.DropTable( name: "TrustTokens"); } } }