using System;
using Microsoft.EntityFrameworkCore.Migrations;
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
#nullable disable
namespace TransmissionRssManager.Migrations
{
///
public partial class InitialCreate : Migration
{
///
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.CreateTable(
name: "RssFeeds",
columns: table => new
{
Id = table.Column(type: "integer", nullable: false)
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
Name = table.Column(type: "text", nullable: false),
Url = table.Column(type: "text", nullable: false),
Enabled = table.Column(type: "boolean", nullable: false),
LastCheckedAt = table.Column(type: "timestamp with time zone", nullable: false),
LastError = table.Column(type: "text", nullable: true),
RefreshInterval = table.Column(type: "integer", nullable: false),
CreatedAt = table.Column(type: "timestamp with time zone", nullable: false),
UpdatedAt = table.Column(type: "timestamp with time zone", nullable: true)
},
constraints: table =>
{
table.PrimaryKey("PK_RssFeeds", x => x.Id);
});
migrationBuilder.CreateTable(
name: "UserPreferences",
columns: table => new
{
Id = table.Column(type: "integer", nullable: false)
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
Key = table.Column(type: "text", nullable: false),
Value = table.Column(type: "text", nullable: true),
Description = table.Column(type: "text", nullable: true),
Category = table.Column(type: "text", nullable: true),
DataType = table.Column(type: "text", nullable: true),
CreatedAt = table.Column(type: "timestamp with time zone", nullable: false),
UpdatedAt = table.Column(type: "timestamp with time zone", nullable: true)
},
constraints: table =>
{
table.PrimaryKey("PK_UserPreferences", x => x.Id);
});
migrationBuilder.CreateTable(
name: "RssFeedRules",
columns: table => new
{
Id = table.Column(type: "integer", nullable: false)
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
Name = table.Column(type: "text", nullable: false),
RssFeedId = table.Column(type: "integer", nullable: false),
IncludePattern = table.Column(type: "text", nullable: true),
ExcludePattern = table.Column(type: "text", nullable: true),
UseRegex = table.Column(type: "boolean", nullable: false),
Enabled = table.Column(type: "boolean", nullable: false),
SaveToCustomPath = table.Column(type: "boolean", nullable: false),
CustomSavePath = table.Column(type: "text", nullable: true),
EnablePostProcessing = table.Column(type: "boolean", nullable: false),
Priority = table.Column(type: "integer", nullable: false),
CreatedAt = table.Column(type: "timestamp with time zone", nullable: false),
UpdatedAt = table.Column(type: "timestamp with time zone", nullable: true)
},
constraints: table =>
{
table.PrimaryKey("PK_RssFeedRules", x => x.Id);
table.ForeignKey(
name: "FK_RssFeedRules_RssFeeds_RssFeedId",
column: x => x.RssFeedId,
principalTable: "RssFeeds",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateTable(
name: "RssFeedItems",
columns: table => new
{
Id = table.Column(type: "integer", nullable: false)
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
Title = table.Column(type: "text", nullable: false),
Link = table.Column(type: "text", nullable: false),
Description = table.Column(type: "text", nullable: true),
PublishDate = table.Column(type: "timestamp with time zone", nullable: false),
RssFeedId = table.Column(type: "integer", nullable: false),
IsDownloaded = table.Column(type: "boolean", nullable: false),
DiscoveredAt = table.Column(type: "timestamp with time zone", nullable: false),
DownloadedAt = table.Column(type: "timestamp with time zone", nullable: true),
TorrentId = table.Column(type: "integer", nullable: true),
MatchedRuleId = table.Column(type: "integer", nullable: true),
DownloadError = table.Column(type: "text", nullable: true)
},
constraints: table =>
{
table.PrimaryKey("PK_RssFeedItems", x => x.Id);
table.ForeignKey(
name: "FK_RssFeedItems_RssFeedRules_MatchedRuleId",
column: x => x.MatchedRuleId,
principalTable: "RssFeedRules",
principalColumn: "Id",
onDelete: ReferentialAction.SetNull);
table.ForeignKey(
name: "FK_RssFeedItems_RssFeeds_RssFeedId",
column: x => x.RssFeedId,
principalTable: "RssFeeds",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateTable(
name: "Torrents",
columns: table => new
{
Id = table.Column(type: "integer", nullable: false)
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
Name = table.Column(type: "text", nullable: false),
Hash = table.Column(type: "text", nullable: false),
TransmissionId = table.Column(type: "integer", nullable: true),
Status = table.Column(type: "text", nullable: false),
TotalSize = table.Column(type: "bigint", nullable: false),
PercentDone = table.Column(type: "double precision", nullable: false),
UploadRatio = table.Column(type: "double precision", nullable: false),
RssFeedItemId = table.Column(type: "integer", nullable: true),
AddedOn = table.Column(type: "timestamp with time zone", nullable: false),
CompletedOn = table.Column(type: "timestamp with time zone", nullable: true),
PostProcessed = table.Column(type: "boolean", nullable: false),
PostProcessedOn = table.Column(type: "timestamp with time zone", nullable: true),
DownloadDirectory = table.Column(type: "text", nullable: true),
ErrorMessage = table.Column(type: "text", nullable: true)
},
constraints: table =>
{
table.PrimaryKey("PK_Torrents", x => x.Id);
table.ForeignKey(
name: "FK_Torrents_RssFeedItems_RssFeedItemId",
column: x => x.RssFeedItemId,
principalTable: "RssFeedItems",
principalColumn: "Id",
onDelete: ReferentialAction.SetNull);
});
migrationBuilder.CreateIndex(
name: "IX_RssFeedItems_MatchedRuleId",
table: "RssFeedItems",
column: "MatchedRuleId");
migrationBuilder.CreateIndex(
name: "IX_RssFeedItems_RssFeedId_Link",
table: "RssFeedItems",
columns: new[] { "RssFeedId", "Link" },
unique: true);
migrationBuilder.CreateIndex(
name: "IX_RssFeedRules_RssFeedId",
table: "RssFeedRules",
column: "RssFeedId");
migrationBuilder.CreateIndex(
name: "IX_Torrents_Hash",
table: "Torrents",
column: "Hash",
unique: true);
migrationBuilder.CreateIndex(
name: "IX_Torrents_RssFeedItemId",
table: "Torrents",
column: "RssFeedItemId",
unique: true);
migrationBuilder.CreateIndex(
name: "IX_UserPreferences_Key",
table: "UserPreferences",
column: "Key",
unique: true);
}
///
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropTable(
name: "Torrents");
migrationBuilder.DropTable(
name: "UserPreferences");
migrationBuilder.DropTable(
name: "RssFeedItems");
migrationBuilder.DropTable(
name: "RssFeedRules");
migrationBuilder.DropTable(
name: "RssFeeds");
}
}
}