using System; using Microsoft.EntityFrameworkCore.Migrations; #nullable disable namespace FinlyticNews.Migrations { /// public partial class Init : Migration { /// protected override void Up(MigrationBuilder migrationBuilder) { migrationBuilder.CreateTable( name: "ArticleSources", columns: table => new { Id = table.Column(type: "uuid", nullable: false), Source = table.Column(type: "text", nullable: false), Name = table.Column(type: "text", nullable: false), Type = table.Column(type: "text", nullable: false) }, constraints: table => { table.PrimaryKey("PK_ArticleSources", x => x.Id); }); migrationBuilder.CreateTable( name: "NewsArticles", columns: table => new { Id = table.Column(type: "uuid", nullable: false), Title = table.Column(type: "text", nullable: false), Author = table.Column(type: "text", nullable: true), Summary = table.Column(type: "text", nullable: true), ContentRaw = table.Column(type: "text", nullable: false), Language = table.Column(type: "text", nullable: true), SourceUrl = table.Column(type: "text", nullable: false), ScrapedAt = table.Column(type: "timestamp with time zone", nullable: false), PublishedAt = table.Column(type: "timestamp with time zone", nullable: false), Status = table.Column(type: "text", nullable: false) }, constraints: table => { table.PrimaryKey("PK_NewsArticles", x => x.Id); }); migrationBuilder.CreateTable( name: "Settings", columns: table => new { Id = table.Column(type: "uuid", nullable: false), PollingFrequencyMinutes = table.Column(type: "integer", nullable: false), ArticleRetentionDays = table.Column(type: "integer", nullable: false), DefaultPageSize = table.Column(type: "integer", nullable: false), ScrapingIntervalMinutes = table.Column(type: "integer", nullable: false), N8nWebhookUrl = table.Column(type: "text", nullable: false), UpdatedAt = table.Column(type: "timestamp with time zone", nullable: false) }, constraints: table => { table.PrimaryKey("PK_Settings", x => x.Id); }); migrationBuilder.CreateTable( name: "MatchedAssets", columns: table => new { Id = table.Column(type: "uuid", nullable: false), NewsArticleId = table.Column(type: "uuid", nullable: false), Isin = table.Column(type: "text", nullable: false), Name = table.Column(type: "text", nullable: false) }, constraints: table => { table.PrimaryKey("PK_MatchedAssets", x => x.Id); table.ForeignKey( name: "FK_MatchedAssets_NewsArticles_NewsArticleId", column: x => x.NewsArticleId, principalTable: "NewsArticles", principalColumn: "Id", onDelete: ReferentialAction.Cascade); }); migrationBuilder.CreateIndex( name: "IX_MatchedAssets_Isin", table: "MatchedAssets", column: "Isin"); migrationBuilder.CreateIndex( name: "IX_MatchedAssets_NewsArticleId", table: "MatchedAssets", column: "NewsArticleId"); migrationBuilder.CreateIndex( name: "IX_NewsArticles_PublishedAt_ScrapedAt", table: "NewsArticles", columns: new[] { "PublishedAt", "ScrapedAt" }); migrationBuilder.CreateIndex( name: "IX_NewsArticles_SourceUrl", table: "NewsArticles", column: "SourceUrl", unique: true); migrationBuilder.CreateIndex( name: "IX_NewsArticles_Status", table: "NewsArticles", column: "Status"); } /// protected override void Down(MigrationBuilder migrationBuilder) { migrationBuilder.DropTable( name: "ArticleSources"); migrationBuilder.DropTable( name: "MatchedAssets"); migrationBuilder.DropTable( name: "Settings"); migrationBuilder.DropTable( name: "NewsArticles"); } } }