129 lines
5.2 KiB
C#
129 lines
5.2 KiB
C#
using System;
|
|
using Microsoft.EntityFrameworkCore.Migrations;
|
|
|
|
#nullable disable
|
|
|
|
namespace FinlyticNews.Migrations
|
|
{
|
|
/// <inheritdoc />
|
|
public partial class Init : Migration
|
|
{
|
|
/// <inheritdoc />
|
|
protected override void Up(MigrationBuilder migrationBuilder)
|
|
{
|
|
migrationBuilder.CreateTable(
|
|
name: "ArticleSources",
|
|
columns: table => new
|
|
{
|
|
Id = table.Column<Guid>(type: "uuid", nullable: false),
|
|
Source = table.Column<string>(type: "text", nullable: false),
|
|
Name = table.Column<string>(type: "text", nullable: false),
|
|
Type = table.Column<string>(type: "text", nullable: false)
|
|
},
|
|
constraints: table =>
|
|
{
|
|
table.PrimaryKey("PK_ArticleSources", x => x.Id);
|
|
});
|
|
|
|
migrationBuilder.CreateTable(
|
|
name: "NewsArticles",
|
|
columns: table => new
|
|
{
|
|
Id = table.Column<Guid>(type: "uuid", nullable: false),
|
|
Title = table.Column<string>(type: "text", nullable: false),
|
|
Author = table.Column<string>(type: "text", nullable: true),
|
|
Summary = table.Column<string>(type: "text", nullable: true),
|
|
ContentRaw = table.Column<string>(type: "text", nullable: false),
|
|
Language = table.Column<string>(type: "text", nullable: true),
|
|
SourceUrl = table.Column<string>(type: "text", nullable: false),
|
|
ScrapedAt = table.Column<DateTime>(type: "timestamp with time zone", nullable: false),
|
|
PublishedAt = table.Column<DateTime>(type: "timestamp with time zone", nullable: false),
|
|
Status = table.Column<string>(type: "text", nullable: false)
|
|
},
|
|
constraints: table =>
|
|
{
|
|
table.PrimaryKey("PK_NewsArticles", x => x.Id);
|
|
});
|
|
|
|
migrationBuilder.CreateTable(
|
|
name: "Settings",
|
|
columns: table => new
|
|
{
|
|
Id = table.Column<Guid>(type: "uuid", nullable: false),
|
|
PollingFrequencyMinutes = table.Column<int>(type: "integer", nullable: false),
|
|
ArticleRetentionDays = table.Column<int>(type: "integer", nullable: false),
|
|
DefaultPageSize = table.Column<int>(type: "integer", nullable: false),
|
|
ScrapingIntervalMinutes = table.Column<int>(type: "integer", nullable: false),
|
|
N8nWebhookUrl = table.Column<string>(type: "text", nullable: false),
|
|
UpdatedAt = table.Column<DateTime>(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<Guid>(type: "uuid", nullable: false),
|
|
NewsArticleId = table.Column<Guid>(type: "uuid", nullable: false),
|
|
Isin = table.Column<string>(type: "text", nullable: false),
|
|
Name = table.Column<string>(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");
|
|
}
|
|
|
|
/// <inheritdoc />
|
|
protected override void Down(MigrationBuilder migrationBuilder)
|
|
{
|
|
migrationBuilder.DropTable(
|
|
name: "ArticleSources");
|
|
|
|
migrationBuilder.DropTable(
|
|
name: "MatchedAssets");
|
|
|
|
migrationBuilder.DropTable(
|
|
name: "Settings");
|
|
|
|
migrationBuilder.DropTable(
|
|
name: "NewsArticles");
|
|
}
|
|
}
|
|
}
|