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: "BlockedNewsUrls", columns: table => new { Id = table.Column(type: "uuid", nullable: false), Url = table.Column(type: "character varying(2048)", maxLength: 2048, nullable: false), Reason = table.Column(type: "character varying(256)", maxLength: 256, nullable: false), BlockedAtUtc = table.Column(type: "timestamp with time zone", nullable: false) }, constraints: table => { table.PrimaryKey("PK_BlockedNewsUrls", x => x.Id); }); migrationBuilder.CreateTable( name: "DynamicSettings", columns: table => new { Id = table.Column(type: "uuid", nullable: false), Key = table.Column(type: "character varying(150)", maxLength: 150, nullable: false), ValueJson = table.Column(type: "text", nullable: false), ServiceIdentifier = table.Column(type: "character varying(100)", maxLength: 100, nullable: false), LastUpdatedUtc = table.Column(type: "timestamp with time zone", nullable: false) }, constraints: table => { table.PrimaryKey("PK_DynamicSettings", 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), TitleHash = table.Column(type: "character varying(64)", maxLength: 64, nullable: true), SimHash = table.Column(type: "bigint", nullable: true) }, constraints: table => { table.PrimaryKey("PK_NewsArticles", 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_BlockedNewsUrls_Url", table: "BlockedNewsUrls", column: "Url", unique: true); migrationBuilder.CreateIndex( name: "IX_DynamicSettings_Key", table: "DynamicSettings", column: "Key", unique: true); 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_SimHash", table: "NewsArticles", column: "SimHash"); migrationBuilder.CreateIndex( name: "IX_NewsArticles_SourceUrl", table: "NewsArticles", column: "SourceUrl", unique: true); migrationBuilder.CreateIndex( name: "IX_NewsArticles_Status", table: "NewsArticles", column: "Status"); migrationBuilder.CreateIndex( name: "IX_NewsArticles_TitleHash", table: "NewsArticles", column: "TitleHash"); } /// protected override void Down(MigrationBuilder migrationBuilder) { migrationBuilder.DropTable( name: "ArticleSources"); migrationBuilder.DropTable( name: "BlockedNewsUrls"); migrationBuilder.DropTable( name: "DynamicSettings"); migrationBuilder.DropTable( name: "MatchedAssets"); migrationBuilder.DropTable( name: "NewsArticles"); } } }