Refactor code formatting and improve readability: standardize line breaks and indentation across various endpoint files, enhancing code clarity and maintainability. Update package version formatting in Directory.Packages.props for consistency.

This commit is contained in:
Leonid Pershin
2026-07-25 19:55:01 +03:00
parent 1f6fa6f1ae
commit f57b7503ed
122 changed files with 1856 additions and 892 deletions
@@ -59,15 +59,20 @@ public sealed class SchedulingBackgroundService(
var db = scope.ServiceProvider.GetRequiredService<IAppDbContext>();
var generator = scope.ServiceProvider.GetRequiredService<ScheduleGenerator>();
var channelIds = await db.Channels
.Where(c => c.IsEnabled)
var channelIds = await db
.Channels.Where(c => c.IsEnabled)
.Select(c => c.Id)
.ToListAsync(cancellationToken);
var now = DateTimeOffset.UtcNow;
foreach (var channelId in channelIds)
{
var added = await generator.GenerateAsync(channelId, now, regenerate: false, cancellationToken);
var added = await generator.GenerateAsync(
channelId,
now,
regenerate: false,
cancellationToken
);
if (added > 0)
logger.LogInformation(
"Канал {ChannelId}: добавлено {Count} записей расписания",
@@ -115,8 +115,12 @@ public static class DependencyInjection
/// <summary>Планировщик расписания: генератор, источник случайности и фоновый сервис горизонта.</summary>
private static void AddBroadcast(IServiceCollection services, IConfiguration configuration)
{
services.Configure<SchedulerOptions>(configuration.GetSection(SchedulerOptions.SectionName));
services.Configure<StreamingOptions>(configuration.GetSection(StreamingOptions.SectionName));
services.Configure<SchedulerOptions>(
configuration.GetSection(SchedulerOptions.SectionName)
);
services.Configure<StreamingOptions>(
configuration.GetSection(StreamingOptions.SectionName)
);
services.Configure<BumperOptions>(configuration.GetSection(BumperOptions.SectionName));
services.AddSingleton<IRandomSource, SystemRandomSource>();
@@ -74,7 +74,13 @@ internal sealed class IdentityService(
var role = await GetPrimaryRoleAsync(user);
var roleEntity = await roleManager.FindByNameAsync(role);
return new CurrentUserProfile(user.Id, user.UserName!, roleEntity?.Id ?? Guid.Empty, role, user.IsBlocked);
return new CurrentUserProfile(
user.Id,
user.UserName!,
roleEntity?.Id ?? Guid.Empty,
role,
user.IsBlocked
);
}
public async Task<Result> ChangePasswordAsync(
@@ -201,7 +207,12 @@ internal sealed class IdentityService(
from userRole in userRoles.DefaultIfEmpty()
join role in dbContext.Roles on userRole.RoleId equals role.Id into roles
from role in roles.DefaultIfEmpty()
select new { user, RoleId = (Guid?)userRole.RoleId, RoleName = role != null ? role.Name : null };
select new
{
user,
RoleId = (Guid?)userRole.RoleId,
RoleName = role != null ? role.Name : null,
};
if (!string.IsNullOrWhiteSpace(search))
query = query.Where(x => x.user.UserName!.Contains(search));
@@ -230,7 +241,10 @@ internal sealed class IdentityService(
return new PagedList<UserSummaryDto>(items, total, page, pageSize);
}
public async Task<UserSummaryDto?> GetUserAsync(Guid userId, CancellationToken cancellationToken)
public async Task<UserSummaryDto?> GetUserAsync(
Guid userId,
CancellationToken cancellationToken
)
{
var user = await userManager.FindByIdAsync(userId.ToString());
if (user is null)
@@ -6,10 +6,15 @@ using TeleWave.Application.Common.Models;
namespace TeleWave.Infrastructure.Identity;
internal sealed class RoleService(RoleManager<AppRole> roleManager, UserManager<AppUser> userManager)
: IRoleService
internal sealed class RoleService(
RoleManager<AppRole> roleManager,
UserManager<AppUser> userManager
) : IRoleService
{
public async Task<Result<RoleDto>> CreateRoleAsync(string name, CancellationToken cancellationToken)
public async Task<Result<RoleDto>> CreateRoleAsync(
string name,
CancellationToken cancellationToken
)
{
if (await roleManager.RoleExistsAsync(name))
return Result.Failure<RoleDto>(RoleErrors.DuplicateName);
@@ -42,10 +47,7 @@ internal sealed class RoleService(RoleManager<AppRole> roleManager, UserManager<
if (role.IsSystem)
return Result.Failure<RoleDto>(RoleErrors.CannotModifySystemRole);
if (
await roleManager.FindByNameAsync(name) is { } existing
&& existing.Id != roleId
)
if (await roleManager.FindByNameAsync(name) is { } existing && existing.Id != roleId)
return Result.Failure<RoleDto>(RoleErrors.DuplicateName);
role.Name = name;
@@ -60,11 +60,15 @@ public sealed class FfmpegBumperRenderer(
var playlist = Path.Combine(assetDir, "index.m3u8");
if (!File.Exists(playlist))
throw new InvalidOperationException("ffmpeg не создал плейлист заставки index.m3u8.");
throw new InvalidOperationException(
"ffmpeg не создал плейлист заставки index.m3u8."
);
var segmentCount = Directory.GetFiles(assetDir, "seg*.ts").Length;
if (segmentCount == 0)
throw new InvalidOperationException("ffmpeg не создал ни одного сегмента заставки.");
throw new InvalidOperationException(
"ffmpeg не создал ни одного сегмента заставки."
);
return new BumperRenderResult(
TimeSpan.FromSeconds(target),
@@ -168,17 +172,33 @@ public sealed class FfmpegBumperRenderer(
var line2Size = FitSize(spec.FreeLine2, titleSize, textWidth);
var line1Y = (int)(h * 0.40);
var line2Y = line1Y + (int)(line2Size * 1.2);
vchain.Append(',').Append(DrawTitle(font, nowFile, spec.AccentColor, line1Size, line1Y, 0.2));
vchain.Append(',').Append(DrawTitle(font, nextFile, spec.TextColor, line2Size, line2Y, 0.5));
vchain
.Append(',')
.Append(DrawTitle(font, nowFile, spec.AccentColor, line1Size, line1Y, 0.2));
vchain
.Append(',')
.Append(DrawTitle(font, nextFile, spec.TextColor, line2Size, line2Y, 0.5));
}
else
{
var nowSize = FitSize(spec.NowTitle, titleSize, textWidth);
var nextSize = FitSize(spec.NextTitle, titleSize, textWidth);
vchain.Append(',').Append(DrawLabel(font, spec.NowLabel, spec.AccentColor, labelSize, nowLabelY, 0.2));
vchain.Append(',').Append(DrawTitle(font, nowFile, spec.TextColor, nowSize, nowTitleY, 0.3));
vchain.Append(',').Append(DrawLabel(font, spec.NextLabel, spec.AccentColor, labelSize, nextLabelY, 1.0));
vchain.Append(',').Append(DrawTitle(font, nextFile, spec.TextColor, nextSize, nextTitleY, 1.1));
vchain
.Append(',')
.Append(
DrawLabel(font, spec.NowLabel, spec.AccentColor, labelSize, nowLabelY, 0.2)
);
vchain
.Append(',')
.Append(DrawTitle(font, nowFile, spec.TextColor, nowSize, nowTitleY, 0.3));
vchain
.Append(',')
.Append(
DrawLabel(font, spec.NextLabel, spec.AccentColor, labelSize, nextLabelY, 1.0)
);
vchain
.Append(',')
.Append(DrawTitle(font, nextFile, spec.TextColor, nextSize, nextTitleY, 1.1));
}
vchain.Append("[v]");
@@ -186,28 +206,47 @@ public sealed class FfmpegBumperRenderer(
var args = new List<string> { "-hide_banner", "-nostdin", "-y" };
args.AddRange(inputs);
args.AddRange(
[
"-filter_complex", filterComplex,
"-map", "[v]",
"-map", "[a]",
"-threads", _media.TranscodeThreads.ToString(CultureInfo.InvariantCulture),
"-c:v", "libx264",
"-preset", "veryfast",
"-crf", "21",
"-pix_fmt", "yuv420p",
"-force_key_frames", $"expr:gte(t,n_forced*{seg.ToString(CultureInfo.InvariantCulture)})",
"-sc_threshold", "0",
"-c:a", "aac",
"-b:a", "128k",
"-ac", "2",
"-ar", "48000",
"-t", Fmt(target),
"-f", "hls",
"-hls_time", seg.ToString(CultureInfo.InvariantCulture),
"-hls_playlist_type", "vod",
"-hls_list_size", "0",
"-hls_segment_filename", Path.Combine(assetDir, "seg%05d.ts"),
args.AddRange([
"-filter_complex",
filterComplex,
"-map",
"[v]",
"-map",
"[a]",
"-threads",
_media.TranscodeThreads.ToString(CultureInfo.InvariantCulture),
"-c:v",
"libx264",
"-preset",
"veryfast",
"-crf",
"21",
"-pix_fmt",
"yuv420p",
"-force_key_frames",
$"expr:gte(t,n_forced*{seg.ToString(CultureInfo.InvariantCulture)})",
"-sc_threshold",
"0",
"-c:a",
"aac",
"-b:a",
"128k",
"-ac",
"2",
"-ar",
"48000",
"-t",
Fmt(target),
"-f",
"hls",
"-hls_time",
seg.ToString(CultureInfo.InvariantCulture),
"-hls_playlist_type",
"vod",
"-hls_list_size",
"0",
"-hls_segment_filename",
Path.Combine(assetDir, "seg%05d.ts"),
Path.Combine(assetDir, "index.m3u8"),
]);
return args;
@@ -261,8 +300,7 @@ public sealed class FfmpegBumperRenderer(
/// <summary>Экранирование пути для значения опции фильтра (Windows-разделители → прямые слэши,
/// двоеточие экранируется). На Linux (контейнере) — фактически no-op.</summary>
private static string EscapePath(string path) =>
path.Replace('\\', '/').Replace(":", "\\:");
private static string EscapePath(string path) => path.Replace('\\', '/').Replace(":", "\\:");
/// <summary>Экранирование литерального текста подписи внутри значения опции drawtext.</summary>
private static string EscapeText(string text) =>
@@ -146,21 +146,19 @@ public sealed class FfmpegMediaProcessor(
args.Add(Fmt(target));
}
args.AddRange(
[
"-f",
"hls",
"-hls_time",
segmentSeconds.ToString(CultureInfo.InvariantCulture),
"-hls_playlist_type",
"vod",
"-hls_list_size",
"0",
"-hls_segment_filename",
Path.Combine(assetDir, "seg%05d.ts"),
Path.Combine(assetDir, "index.m3u8"),
]
);
args.AddRange([
"-f",
"hls",
"-hls_time",
segmentSeconds.ToString(CultureInfo.InvariantCulture),
"-hls_playlist_type",
"vod",
"-hls_list_size",
"0",
"-hls_segment_filename",
Path.Combine(assetDir, "seg%05d.ts"),
Path.Combine(assetDir, "index.m3u8"),
]);
return args;
}
@@ -169,15 +167,7 @@ public sealed class FfmpegMediaProcessor(
{
var result = await ProcessRunner.RunAsync(
_media.FfprobePath,
[
"-v",
"quiet",
"-print_format",
"json",
"-show_format",
"-show_streams",
path,
],
["-v", "quiet", "-print_format", "json", "-show_format", "-show_streams", path],
lowPriority: false,
cancellationToken
);
@@ -58,9 +58,10 @@ public sealed class FileSystemMediaStorage(MediaPathResolver paths) : IMediaStor
CancellationToken cancellationToken
)
{
var sourcePath = source == MediaSource.Inbox
? paths.InboxPath(sourceToken)
: paths.UploadPath(sourceToken);
var sourcePath =
source == MediaSource.Inbox
? paths.InboxPath(sourceToken)
: paths.UploadPath(sourceToken);
if (!File.Exists(sourcePath))
throw new FileNotFoundException("Исходный файл не найден в хранилище.", sourcePath);
@@ -5,7 +5,10 @@ namespace TeleWave.Infrastructure.Media;
/// <summary>Скачивает изображение по URL через HTTP-клиент «metadata» и определяет расширение.</summary>
public sealed class ImageDownloader(IHttpClientFactory httpFactory) : IImageDownloader
{
public async Task<DownloadedImage?> DownloadAsync(string url, CancellationToken cancellationToken)
public async Task<DownloadedImage?> DownloadAsync(
string url,
CancellationToken cancellationToken
)
{
try
{
@@ -18,7 +21,8 @@ public sealed class ImageDownloader(IHttpClientFactory httpFactory) : IImageDown
var bytes = await response.Content.ReadAsByteArrayAsync(cancellationToken);
return bytes.Length == 0 ? null : new DownloadedImage(bytes, ext);
}
catch (Exception ex) when (ex is HttpRequestException or TaskCanceledException or IOException)
catch (Exception ex)
when (ex is HttpRequestException or TaskCanceledException or IOException)
{
return null;
}
@@ -29,7 +29,9 @@ public sealed class InboxScannerBackgroundService(
protected override async Task ExecuteAsync(CancellationToken stoppingToken)
{
paths.EnsureDirectories();
using var timer = new PeriodicTimer(TimeSpan.FromSeconds(Math.Max(1, _media.InboxScanSeconds)));
using var timer = new PeriodicTimer(
TimeSpan.FromSeconds(Math.Max(1, _media.InboxScanSeconds))
);
while (await timer.WaitForNextTickAsync(stoppingToken))
{
@@ -53,7 +55,8 @@ public sealed class InboxScannerBackgroundService(
if (!Directory.Exists(paths.InboxDir))
return;
var files = Directory.EnumerateFiles(paths.InboxDir)
var files = Directory
.EnumerateFiles(paths.InboxDir)
.Where(f => MediaFormats.IsAllowed(f))
.ToList();
@@ -108,11 +111,19 @@ public sealed class InboxScannerBackgroundService(
if (result.IsSuccess)
{
queue.Enqueue(result.Value);
logger.LogInformation("Из inbox зарегистрирован ассет {AssetId} ({File})", result.Value, fileName);
logger.LogInformation(
"Из inbox зарегистрирован ассет {AssetId} ({File})",
result.Value,
fileName
);
}
else
{
logger.LogWarning("Не удалось зарегистрировать {File} из inbox: {Error}", fileName, result.Error.Code);
logger.LogWarning(
"Не удалось зарегистрировать {File} из inbox: {Error}",
fileName,
result.Error.Code
);
}
}
}
@@ -72,10 +72,7 @@ public sealed class MediaProcessingBackgroundService(
CancellationToken.None
);
inFlight[task] = 0;
_ = task.ContinueWith(
t => inFlight.TryRemove(t, out _),
TaskScheduler.Default
);
_ = task.ContinueWith(t => inFlight.TryRemove(t, out _), TaskScheduler.Default);
}
// Работы нет — ждём сигнала о новой либо периодического опроса.
@@ -118,8 +115,8 @@ public sealed class MediaProcessingBackgroundService(
await using var scope = scopeFactory.CreateAsyncScope();
var db = scope.ServiceProvider.GetRequiredService<IAppDbContext>();
var interrupted = await db.MediaAssets
.Where(x => x.Status == MediaAssetStatus.Processing)
var interrupted = await db
.MediaAssets.Where(x => x.Status == MediaAssetStatus.Processing)
.ToListAsync(cancellationToken);
if (interrupted.Count == 0)
return;
@@ -134,13 +131,15 @@ public sealed class MediaProcessingBackgroundService(
/// либо null если работы нет. Вызывается только диспетчером последовательно, поэтому два транскода
/// не возьмут один ассет.
/// </summary>
private async Task<(Guid Id, string Extension)?> ClaimNextAsync(CancellationToken cancellationToken)
private async Task<(Guid Id, string Extension)?> ClaimNextAsync(
CancellationToken cancellationToken
)
{
await using var scope = scopeFactory.CreateAsyncScope();
var db = scope.ServiceProvider.GetRequiredService<IAppDbContext>();
var asset = await db.MediaAssets
.Where(x => x.Status == MediaAssetStatus.Pending)
var asset = await db
.MediaAssets.Where(x => x.Status == MediaAssetStatus.Pending)
.OrderBy(x => x.CreatedAt)
.FirstOrDefaultAsync(cancellationToken);
if (asset is null)
@@ -152,7 +151,11 @@ public sealed class MediaProcessingBackgroundService(
}
/// <summary>Обрабатывает уже захваченный (Processing) ассет: транскод → Ready/Failed.</summary>
private async Task ProcessClaimedAsync(Guid assetId, string extension, CancellationToken cancellationToken)
private async Task ProcessClaimedAsync(
Guid assetId,
string extension,
CancellationToken cancellationToken
)
{
try
{
@@ -189,7 +192,10 @@ public sealed class MediaProcessingBackgroundService(
await using var scope = scopeFactory.CreateAsyncScope();
var db = scope.ServiceProvider.GetRequiredService<IAppDbContext>();
var asset = await db.MediaAssets.FirstOrDefaultAsync(x => x.Id == assetId, cancellationToken);
var asset = await db.MediaAssets.FirstOrDefaultAsync(
x => x.Id == assetId,
cancellationToken
);
if (asset is null)
return;
@@ -211,7 +217,10 @@ public sealed class MediaProcessingBackgroundService(
await using var scope = scopeFactory.CreateAsyncScope();
var db = scope.ServiceProvider.GetRequiredService<IAppDbContext>();
var asset = await db.MediaAssets.FirstOrDefaultAsync(x => x.Id == assetId, cancellationToken);
var asset = await db.MediaAssets.FirstOrDefaultAsync(
x => x.Id == assetId,
cancellationToken
);
if (asset is null)
return;
@@ -51,7 +51,8 @@ internal static class ProcessRunner
{
process.PriorityClass = ProcessPriorityClass.BelowNormal;
}
catch (Exception ex) when (ex is InvalidOperationException or PlatformNotSupportedException)
catch (Exception ex)
when (ex is InvalidOperationException or PlatformNotSupportedException)
{
// Процесс мог завершиться мгновенно или платформа не поддерживает — не критично.
}
@@ -7,8 +7,10 @@ using TeleWave.Application.Metadata;
namespace TeleWave.Infrastructure.Metadata;
/// <summary>Провайдер метаданных OMDb (omdbapi.com, данные IMDb). Требует API-ключ.</summary>
public sealed class OmdbMetadataProvider(IHttpClientFactory httpFactory, IOptions<MetadataOptions> options)
: IMetadataProvider
public sealed class OmdbMetadataProvider(
IHttpClientFactory httpFactory,
IOptions<MetadataOptions> options
) : IMetadataProvider
{
private readonly OmdbOptions _omdb = options.Value.Omdb;
@@ -19,7 +21,8 @@ public sealed class OmdbMetadataProvider(IHttpClientFactory httpFactory, IOption
CancellationToken cancellationToken
)
{
var url = $"{_omdb.BaseUrl}/?apikey={_omdb.ApiKey}&type=series&s={Uri.EscapeDataString(query)}";
var url =
$"{_omdb.BaseUrl}/?apikey={_omdb.ApiKey}&type=series&s={Uri.EscapeDataString(query)}";
using var doc = await GetJsonAsync(url, cancellationToken);
if (!doc.RootElement.TryGetProperty("Search", out var search))
return [];
@@ -43,7 +46,10 @@ public sealed class OmdbMetadataProvider(IHttpClientFactory httpFactory, IOption
return list;
}
public async Task<ShowMetadata?> GetShowAsync(string externalId, CancellationToken cancellationToken)
public async Task<ShowMetadata?> GetShowAsync(
string externalId,
CancellationToken cancellationToken
)
{
var url = $"{_omdb.BaseUrl}/?apikey={_omdb.ApiKey}&i={Uri.EscapeDataString(externalId)}";
using var doc = await TryGetJsonAsync(url, cancellationToken);
@@ -92,23 +98,30 @@ public sealed class OmdbMetadataProvider(IHttpClientFactory httpFactory, IOption
}
/// <summary>Как GetJsonAsync, но глотает ошибки в null (для get/episode — деградируем мягко).</summary>
private async Task<JsonDocument?> TryGetJsonAsync(string url, CancellationToken cancellationToken)
private async Task<JsonDocument?> TryGetJsonAsync(
string url,
CancellationToken cancellationToken
)
{
try
{
return await GetJsonAsync(url, cancellationToken);
}
catch (Exception ex) when (ex is HttpRequestException or JsonException or TaskCanceledException)
catch (Exception ex)
when (ex is HttpRequestException or JsonException or TaskCanceledException)
{
return null;
}
}
private static bool IsResponseTrue(JsonElement root) =>
GetString(root, "Response") is { } r && r.Equals("True", StringComparison.OrdinalIgnoreCase);
GetString(root, "Response") is { } r
&& r.Equals("True", StringComparison.OrdinalIgnoreCase);
private static string? GetString(JsonElement el, string name) =>
el.TryGetProperty(name, out var v) && v.ValueKind == JsonValueKind.String ? v.GetString() : null;
el.TryGetProperty(name, out var v) && v.ValueKind == JsonValueKind.String
? v.GetString()
: null;
/// <summary>OMDb отдаёт «N/A» вместо отсутствующих значений — приводим к null.</summary>
private static string? Clean(string? value) =>
@@ -7,8 +7,10 @@ using TeleWave.Application.Metadata;
namespace TeleWave.Infrastructure.Metadata;
/// <summary>Провайдер метаданных TMDb (themoviedb.org). Требует API-ключ (v3).</summary>
public sealed class TmdbMetadataProvider(IHttpClientFactory httpFactory, IOptions<MetadataOptions> options)
: IMetadataProvider
public sealed class TmdbMetadataProvider(
IHttpClientFactory httpFactory,
IOptions<MetadataOptions> options
) : IMetadataProvider
{
private readonly MetadataOptions _options = options.Value;
@@ -47,9 +49,13 @@ public sealed class TmdbMetadataProvider(IHttpClientFactory httpFactory, IOption
return list;
}
public async Task<ShowMetadata?> GetShowAsync(string externalId, CancellationToken cancellationToken)
public async Task<ShowMetadata?> GetShowAsync(
string externalId,
CancellationToken cancellationToken
)
{
var url = $"{Tmdb.BaseUrl}/tv/{externalId}?api_key={Tmdb.ApiKey}&language={_options.Language}";
var url =
$"{Tmdb.BaseUrl}/tv/{externalId}?api_key={Tmdb.ApiKey}&language={_options.Language}";
using var doc = await TryGetJsonAsync(url, cancellationToken);
if (doc is null)
return null;
@@ -102,23 +108,31 @@ public sealed class TmdbMetadataProvider(IHttpClientFactory httpFactory, IOption
}
/// <summary>Как GetJsonAsync, но глотает ошибки в null (для get/episode — деградируем мягко).</summary>
private async Task<JsonDocument?> TryGetJsonAsync(string url, CancellationToken cancellationToken)
private async Task<JsonDocument?> TryGetJsonAsync(
string url,
CancellationToken cancellationToken
)
{
try
{
return await GetJsonAsync(url, cancellationToken);
}
catch (Exception ex) when (ex is HttpRequestException or JsonException or TaskCanceledException)
catch (Exception ex)
when (ex is HttpRequestException or JsonException or TaskCanceledException)
{
return null;
}
}
private static string? GetString(JsonElement el, string name) =>
el.TryGetProperty(name, out var v) && v.ValueKind == JsonValueKind.String ? v.GetString() : null;
el.TryGetProperty(name, out var v) && v.ValueKind == JsonValueKind.String
? v.GetString()
: null;
private static int? GetInt(JsonElement el, string name) =>
el.TryGetProperty(name, out var v) && v.ValueKind == JsonValueKind.Number ? v.GetInt32() : null;
el.TryGetProperty(name, out var v) && v.ValueKind == JsonValueKind.Number
? v.GetInt32()
: null;
private static int? YearFrom(string? date) =>
date is { Length: >= 4 } && int.TryParse(date.AsSpan(0, 4), out var y) ? y : null;
@@ -18,14 +18,23 @@ namespace TeleWave.Infrastructure.Migrations
{
Id = table.Column<Guid>(type: "uuid", nullable: false),
IsSystem = table.Column<bool>(type: "boolean", nullable: false),
Name = table.Column<string>(type: "character varying(256)", maxLength: 256, nullable: true),
NormalizedName = table.Column<string>(type: "character varying(256)", maxLength: 256, nullable: true),
ConcurrencyStamp = table.Column<string>(type: "text", nullable: true)
Name = table.Column<string>(
type: "character varying(256)",
maxLength: 256,
nullable: true
),
NormalizedName = table.Column<string>(
type: "character varying(256)",
maxLength: 256,
nullable: true
),
ConcurrencyStamp = table.Column<string>(type: "text", nullable: true),
},
constraints: table =>
{
table.PrimaryKey("PK_AspNetRoles", x => x.Id);
});
}
);
migrationBuilder.CreateTable(
name: "AspNetUsers",
@@ -33,11 +42,30 @@ namespace TeleWave.Infrastructure.Migrations
{
Id = table.Column<Guid>(type: "uuid", nullable: false),
IsBlocked = table.Column<bool>(type: "boolean", nullable: false),
CreatedAt = table.Column<DateTimeOffset>(type: "timestamp with time zone", nullable: false),
UserName = table.Column<string>(type: "character varying(256)", maxLength: 256, nullable: true),
NormalizedUserName = table.Column<string>(type: "character varying(256)", maxLength: 256, nullable: true),
Email = table.Column<string>(type: "character varying(256)", maxLength: 256, nullable: true),
NormalizedEmail = table.Column<string>(type: "character varying(256)", maxLength: 256, nullable: true),
CreatedAt = table.Column<DateTimeOffset>(
type: "timestamp with time zone",
nullable: false
),
UserName = table.Column<string>(
type: "character varying(256)",
maxLength: 256,
nullable: true
),
NormalizedUserName = table.Column<string>(
type: "character varying(256)",
maxLength: 256,
nullable: true
),
Email = table.Column<string>(
type: "character varying(256)",
maxLength: 256,
nullable: true
),
NormalizedEmail = table.Column<string>(
type: "character varying(256)",
maxLength: 256,
nullable: true
),
EmailConfirmed = table.Column<bool>(type: "boolean", nullable: false),
PasswordHash = table.Column<string>(type: "text", nullable: true),
SecurityStamp = table.Column<string>(type: "text", nullable: true),
@@ -45,14 +73,18 @@ namespace TeleWave.Infrastructure.Migrations
PhoneNumber = table.Column<string>(type: "text", nullable: true),
PhoneNumberConfirmed = table.Column<bool>(type: "boolean", nullable: false),
TwoFactorEnabled = table.Column<bool>(type: "boolean", nullable: false),
LockoutEnd = table.Column<DateTimeOffset>(type: "timestamp with time zone", nullable: true),
LockoutEnd = table.Column<DateTimeOffset>(
type: "timestamp with time zone",
nullable: true
),
LockoutEnabled = table.Column<bool>(type: "boolean", nullable: false),
AccessFailedCount = table.Column<int>(type: "integer", nullable: false)
AccessFailedCount = table.Column<int>(type: "integer", nullable: false),
},
constraints: table =>
{
table.PrimaryKey("PK_AspNetUsers", x => x.Id);
});
}
);
migrationBuilder.CreateTable(
name: "RefreshTokens",
@@ -61,25 +93,39 @@ namespace TeleWave.Infrastructure.Migrations
Id = table.Column<Guid>(type: "uuid", nullable: false),
UserId = table.Column<Guid>(type: "uuid", nullable: false),
TokenHash = table.Column<string>(type: "text", nullable: false),
ExpiresAt = table.Column<DateTimeOffset>(type: "timestamp with time zone", nullable: false),
CreatedAt = table.Column<DateTimeOffset>(type: "timestamp with time zone", nullable: false),
RevokedAt = table.Column<DateTimeOffset>(type: "timestamp with time zone", nullable: true),
ReplacedByTokenHash = table.Column<string>(type: "text", nullable: true)
ExpiresAt = table.Column<DateTimeOffset>(
type: "timestamp with time zone",
nullable: false
),
CreatedAt = table.Column<DateTimeOffset>(
type: "timestamp with time zone",
nullable: false
),
RevokedAt = table.Column<DateTimeOffset>(
type: "timestamp with time zone",
nullable: true
),
ReplacedByTokenHash = table.Column<string>(type: "text", nullable: true),
},
constraints: table =>
{
table.PrimaryKey("PK_RefreshTokens", x => x.Id);
});
}
);
migrationBuilder.CreateTable(
name: "AspNetRoleClaims",
columns: table => new
{
Id = table.Column<int>(type: "integer", nullable: false)
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
Id = table
.Column<int>(type: "integer", nullable: false)
.Annotation(
"Npgsql:ValueGenerationStrategy",
NpgsqlValueGenerationStrategy.IdentityByDefaultColumn
),
RoleId = table.Column<Guid>(type: "uuid", nullable: false),
ClaimType = table.Column<string>(type: "text", nullable: true),
ClaimValue = table.Column<string>(type: "text", nullable: true)
ClaimValue = table.Column<string>(type: "text", nullable: true),
},
constraints: table =>
{
@@ -89,18 +135,24 @@ namespace TeleWave.Infrastructure.Migrations
column: x => x.RoleId,
principalTable: "AspNetRoles",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
});
onDelete: ReferentialAction.Cascade
);
}
);
migrationBuilder.CreateTable(
name: "AspNetUserClaims",
columns: table => new
{
Id = table.Column<int>(type: "integer", nullable: false)
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
Id = table
.Column<int>(type: "integer", nullable: false)
.Annotation(
"Npgsql:ValueGenerationStrategy",
NpgsqlValueGenerationStrategy.IdentityByDefaultColumn
),
UserId = table.Column<Guid>(type: "uuid", nullable: false),
ClaimType = table.Column<string>(type: "text", nullable: true),
ClaimValue = table.Column<string>(type: "text", nullable: true)
ClaimValue = table.Column<string>(type: "text", nullable: true),
},
constraints: table =>
{
@@ -110,8 +162,10 @@ namespace TeleWave.Infrastructure.Migrations
column: x => x.UserId,
principalTable: "AspNetUsers",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
});
onDelete: ReferentialAction.Cascade
);
}
);
migrationBuilder.CreateTable(
name: "AspNetUserLogins",
@@ -120,25 +174,30 @@ namespace TeleWave.Infrastructure.Migrations
LoginProvider = table.Column<string>(type: "text", nullable: false),
ProviderKey = table.Column<string>(type: "text", nullable: false),
ProviderDisplayName = table.Column<string>(type: "text", nullable: true),
UserId = table.Column<Guid>(type: "uuid", nullable: false)
UserId = table.Column<Guid>(type: "uuid", nullable: false),
},
constraints: table =>
{
table.PrimaryKey("PK_AspNetUserLogins", x => new { x.LoginProvider, x.ProviderKey });
table.PrimaryKey(
"PK_AspNetUserLogins",
x => new { x.LoginProvider, x.ProviderKey }
);
table.ForeignKey(
name: "FK_AspNetUserLogins_AspNetUsers_UserId",
column: x => x.UserId,
principalTable: "AspNetUsers",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
});
onDelete: ReferentialAction.Cascade
);
}
);
migrationBuilder.CreateTable(
name: "AspNetUserRoles",
columns: table => new
{
UserId = table.Column<Guid>(type: "uuid", nullable: false),
RoleId = table.Column<Guid>(type: "uuid", nullable: false)
RoleId = table.Column<Guid>(type: "uuid", nullable: false),
},
constraints: table =>
{
@@ -148,14 +207,17 @@ namespace TeleWave.Infrastructure.Migrations
column: x => x.RoleId,
principalTable: "AspNetRoles",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
onDelete: ReferentialAction.Cascade
);
table.ForeignKey(
name: "FK_AspNetUserRoles_AspNetUsers_UserId",
column: x => x.UserId,
principalTable: "AspNetUsers",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
});
onDelete: ReferentialAction.Cascade
);
}
);
migrationBuilder.CreateTable(
name: "AspNetUserTokens",
@@ -164,94 +226,105 @@ namespace TeleWave.Infrastructure.Migrations
UserId = table.Column<Guid>(type: "uuid", nullable: false),
LoginProvider = table.Column<string>(type: "text", nullable: false),
Name = table.Column<string>(type: "text", nullable: false),
Value = table.Column<string>(type: "text", nullable: true)
Value = table.Column<string>(type: "text", nullable: true),
},
constraints: table =>
{
table.PrimaryKey("PK_AspNetUserTokens", x => new { x.UserId, x.LoginProvider, x.Name });
table.PrimaryKey(
"PK_AspNetUserTokens",
x => new
{
x.UserId,
x.LoginProvider,
x.Name,
}
);
table.ForeignKey(
name: "FK_AspNetUserTokens_AspNetUsers_UserId",
column: x => x.UserId,
principalTable: "AspNetUsers",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
});
onDelete: ReferentialAction.Cascade
);
}
);
migrationBuilder.CreateIndex(
name: "IX_AspNetRoleClaims_RoleId",
table: "AspNetRoleClaims",
column: "RoleId");
column: "RoleId"
);
migrationBuilder.CreateIndex(
name: "RoleNameIndex",
table: "AspNetRoles",
column: "NormalizedName",
unique: true);
unique: true
);
migrationBuilder.CreateIndex(
name: "IX_AspNetUserClaims_UserId",
table: "AspNetUserClaims",
column: "UserId");
column: "UserId"
);
migrationBuilder.CreateIndex(
name: "IX_AspNetUserLogins_UserId",
table: "AspNetUserLogins",
column: "UserId");
column: "UserId"
);
migrationBuilder.CreateIndex(
name: "IX_AspNetUserRoles_RoleId",
table: "AspNetUserRoles",
column: "RoleId");
column: "RoleId"
);
migrationBuilder.CreateIndex(
name: "EmailIndex",
table: "AspNetUsers",
column: "NormalizedEmail");
column: "NormalizedEmail"
);
migrationBuilder.CreateIndex(
name: "UserNameIndex",
table: "AspNetUsers",
column: "NormalizedUserName",
unique: true);
unique: true
);
migrationBuilder.CreateIndex(
name: "IX_RefreshTokens_TokenHash",
table: "RefreshTokens",
column: "TokenHash",
unique: true);
unique: true
);
migrationBuilder.CreateIndex(
name: "IX_RefreshTokens_UserId",
table: "RefreshTokens",
column: "UserId");
column: "UserId"
);
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropTable(
name: "AspNetRoleClaims");
migrationBuilder.DropTable(name: "AspNetRoleClaims");
migrationBuilder.DropTable(
name: "AspNetUserClaims");
migrationBuilder.DropTable(name: "AspNetUserClaims");
migrationBuilder.DropTable(
name: "AspNetUserLogins");
migrationBuilder.DropTable(name: "AspNetUserLogins");
migrationBuilder.DropTable(
name: "AspNetUserRoles");
migrationBuilder.DropTable(name: "AspNetUserRoles");
migrationBuilder.DropTable(
name: "AspNetUserTokens");
migrationBuilder.DropTable(name: "AspNetUserTokens");
migrationBuilder.DropTable(
name: "RefreshTokens");
migrationBuilder.DropTable(name: "RefreshTokens");
migrationBuilder.DropTable(
name: "AspNetRoles");
migrationBuilder.DropTable(name: "AspNetRoles");
migrationBuilder.DropTable(
name: "AspNetUsers");
migrationBuilder.DropTable(name: "AspNetUsers");
}
}
}
@@ -16,8 +16,16 @@ namespace TeleWave.Infrastructure.Migrations
columns: table => new
{
Id = table.Column<Guid>(type: "uuid", nullable: false),
OriginalFileName = table.Column<string>(type: "character varying(512)", maxLength: 512, nullable: false),
OriginalExtension = table.Column<string>(type: "character varying(16)", maxLength: 16, nullable: false),
OriginalFileName = table.Column<string>(
type: "character varying(512)",
maxLength: 512,
nullable: false
),
OriginalExtension = table.Column<string>(
type: "character varying(16)",
maxLength: 16,
nullable: false
),
Source = table.Column<int>(type: "integer", nullable: false),
Status = table.Column<int>(type: "integer", nullable: false),
Duration = table.Column<TimeSpan>(type: "interval", nullable: true),
@@ -25,34 +33,58 @@ namespace TeleWave.Infrastructure.Migrations
SegmentCount = table.Column<int>(type: "integer", nullable: true),
Width = table.Column<int>(type: "integer", nullable: true),
Height = table.Column<int>(type: "integer", nullable: true),
VideoCodec = table.Column<string>(type: "character varying(32)", maxLength: 32, nullable: true),
AudioCodec = table.Column<string>(type: "character varying(32)", maxLength: 32, nullable: true),
RelativePath = table.Column<string>(type: "character varying(256)", maxLength: 256, nullable: true),
ErrorMessage = table.Column<string>(type: "character varying(2048)", maxLength: 2048, nullable: true),
CreatedAt = table.Column<DateTimeOffset>(type: "timestamp with time zone", nullable: false),
UpdatedAt = table.Column<DateTimeOffset>(type: "timestamp with time zone", nullable: false)
VideoCodec = table.Column<string>(
type: "character varying(32)",
maxLength: 32,
nullable: true
),
AudioCodec = table.Column<string>(
type: "character varying(32)",
maxLength: 32,
nullable: true
),
RelativePath = table.Column<string>(
type: "character varying(256)",
maxLength: 256,
nullable: true
),
ErrorMessage = table.Column<string>(
type: "character varying(2048)",
maxLength: 2048,
nullable: true
),
CreatedAt = table.Column<DateTimeOffset>(
type: "timestamp with time zone",
nullable: false
),
UpdatedAt = table.Column<DateTimeOffset>(
type: "timestamp with time zone",
nullable: false
),
},
constraints: table =>
{
table.PrimaryKey("PK_MediaAssets", x => x.Id);
});
}
);
migrationBuilder.CreateIndex(
name: "IX_MediaAssets_CreatedAt",
table: "MediaAssets",
column: "CreatedAt");
column: "CreatedAt"
);
migrationBuilder.CreateIndex(
name: "IX_MediaAssets_Status",
table: "MediaAssets",
column: "Status");
column: "Status"
);
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropTable(
name: "MediaAssets");
migrationBuilder.DropTable(name: "MediaAssets");
}
}
}
@@ -16,20 +16,35 @@ namespace TeleWave.Infrastructure.Migrations
columns: table => new
{
Id = table.Column<Guid>(type: "uuid", nullable: false),
Name = table.Column<string>(type: "character varying(256)", maxLength: 256, nullable: false),
Slug = table.Column<string>(type: "character varying(128)", maxLength: 128, nullable: false),
Name = table.Column<string>(
type: "character varying(256)",
maxLength: 256,
nullable: false
),
Slug = table.Column<string>(
type: "character varying(128)",
maxLength: 128,
nullable: false
),
IsEnabled = table.Column<bool>(type: "boolean", nullable: false),
EpochUtc = table.Column<DateTimeOffset>(type: "timestamp with time zone", nullable: false),
EpochUtc = table.Column<DateTimeOffset>(
type: "timestamp with time zone",
nullable: false
),
AdInsertion = table.Column<int>(type: "integer", nullable: false),
AdsPerBreak = table.Column<int>(type: "integer", nullable: false),
FillerAssetId = table.Column<Guid>(type: "uuid", nullable: true),
NextAdIndex = table.Column<int>(type: "integer", nullable: false),
CreatedAt = table.Column<DateTimeOffset>(type: "timestamp with time zone", nullable: false)
CreatedAt = table.Column<DateTimeOffset>(
type: "timestamp with time zone",
nullable: false
),
},
constraints: table =>
{
table.PrimaryKey("PK_Channels", x => x.Id);
});
}
);
migrationBuilder.CreateTable(
name: "ScheduleEntries",
@@ -39,30 +54,49 @@ namespace TeleWave.Infrastructure.Migrations
ChannelId = table.Column<Guid>(type: "uuid", nullable: false),
MediaAssetId = table.Column<Guid>(type: "uuid", nullable: false),
Kind = table.Column<int>(type: "integer", nullable: false),
StartsAtUtc = table.Column<DateTimeOffset>(type: "timestamp with time zone", nullable: false),
EndsAtUtc = table.Column<DateTimeOffset>(type: "timestamp with time zone", nullable: false),
StartsAtUtc = table.Column<DateTimeOffset>(
type: "timestamp with time zone",
nullable: false
),
EndsAtUtc = table.Column<DateTimeOffset>(
type: "timestamp with time zone",
nullable: false
),
ShowId = table.Column<Guid>(type: "uuid", nullable: true),
EpisodeIndex = table.Column<int>(type: "integer", nullable: true)
EpisodeIndex = table.Column<int>(type: "integer", nullable: true),
},
constraints: table =>
{
table.PrimaryKey("PK_ScheduleEntries", x => x.Id);
});
}
);
migrationBuilder.CreateTable(
name: "Shows",
columns: table => new
{
Id = table.Column<Guid>(type: "uuid", nullable: false),
Name = table.Column<string>(type: "character varying(256)", maxLength: 256, nullable: false),
Description = table.Column<string>(type: "character varying(2048)", maxLength: 2048, nullable: true),
Name = table.Column<string>(
type: "character varying(256)",
maxLength: 256,
nullable: false
),
Description = table.Column<string>(
type: "character varying(2048)",
maxLength: 2048,
nullable: true
),
Kind = table.Column<int>(type: "integer", nullable: false),
CreatedAt = table.Column<DateTimeOffset>(type: "timestamp with time zone", nullable: false)
CreatedAt = table.Column<DateTimeOffset>(
type: "timestamp with time zone",
nullable: false
),
},
constraints: table =>
{
table.PrimaryKey("PK_Shows", x => x.Id);
});
}
);
migrationBuilder.CreateTable(
name: "ChannelAd",
@@ -71,7 +105,7 @@ namespace TeleWave.Infrastructure.Migrations
Id = table.Column<Guid>(type: "uuid", nullable: false),
ChannelId = table.Column<Guid>(type: "uuid", nullable: false),
MediaAssetId = table.Column<Guid>(type: "uuid", nullable: false),
Position = table.Column<int>(type: "integer", nullable: false)
Position = table.Column<int>(type: "integer", nullable: false),
},
constraints: table =>
{
@@ -81,8 +115,10 @@ namespace TeleWave.Infrastructure.Migrations
column: x => x.ChannelId,
principalTable: "Channels",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
});
onDelete: ReferentialAction.Cascade
);
}
);
migrationBuilder.CreateTable(
name: "ChannelShow",
@@ -95,7 +131,7 @@ namespace TeleWave.Infrastructure.Migrations
BlockMode = table.Column<int>(type: "integer", nullable: false),
BlockValue = table.Column<int>(type: "integer", nullable: false),
IsEnabled = table.Column<bool>(type: "boolean", nullable: false),
NextEpisodeIndex = table.Column<int>(type: "integer", nullable: false)
NextEpisodeIndex = table.Column<int>(type: "integer", nullable: false),
},
constraints: table =>
{
@@ -105,8 +141,10 @@ namespace TeleWave.Infrastructure.Migrations
column: x => x.ChannelId,
principalTable: "Channels",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
});
onDelete: ReferentialAction.Cascade
);
}
);
migrationBuilder.CreateTable(
name: "ProgrammingOverride",
@@ -115,8 +153,14 @@ namespace TeleWave.Infrastructure.Migrations
Id = table.Column<Guid>(type: "uuid", nullable: false),
ChannelId = table.Column<Guid>(type: "uuid", nullable: false),
Mode = table.Column<int>(type: "integer", nullable: false),
StartsAtUtc = table.Column<DateTimeOffset>(type: "timestamp with time zone", nullable: false),
EndsAtUtc = table.Column<DateTimeOffset>(type: "timestamp with time zone", nullable: false)
StartsAtUtc = table.Column<DateTimeOffset>(
type: "timestamp with time zone",
nullable: false
),
EndsAtUtc = table.Column<DateTimeOffset>(
type: "timestamp with time zone",
nullable: false
),
},
constraints: table =>
{
@@ -126,8 +170,10 @@ namespace TeleWave.Infrastructure.Migrations
column: x => x.ChannelId,
principalTable: "Channels",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
});
onDelete: ReferentialAction.Cascade
);
}
);
migrationBuilder.CreateTable(
name: "ShowEpisode",
@@ -137,7 +183,10 @@ namespace TeleWave.Infrastructure.Migrations
ShowId = table.Column<Guid>(type: "uuid", nullable: false),
MediaAssetId = table.Column<Guid>(type: "uuid", nullable: false),
Position = table.Column<int>(type: "integer", nullable: false),
CreatedAt = table.Column<DateTimeOffset>(type: "timestamp with time zone", nullable: false)
CreatedAt = table.Column<DateTimeOffset>(
type: "timestamp with time zone",
nullable: false
),
},
constraints: table =>
{
@@ -147,8 +196,10 @@ namespace TeleWave.Infrastructure.Migrations
column: x => x.ShowId,
principalTable: "Shows",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
});
onDelete: ReferentialAction.Cascade
);
}
);
migrationBuilder.CreateTable(
name: "OverrideShow",
@@ -157,7 +208,7 @@ namespace TeleWave.Infrastructure.Migrations
Id = table.Column<Guid>(type: "uuid", nullable: false),
ProgrammingOverrideId = table.Column<Guid>(type: "uuid", nullable: false),
ShowId = table.Column<Guid>(type: "uuid", nullable: false),
Weight = table.Column<int>(type: "integer", nullable: false)
Weight = table.Column<int>(type: "integer", nullable: false),
},
constraints: table =>
{
@@ -167,87 +218,91 @@ namespace TeleWave.Infrastructure.Migrations
column: x => x.ProgrammingOverrideId,
principalTable: "ProgrammingOverride",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
});
onDelete: ReferentialAction.Cascade
);
}
);
migrationBuilder.CreateIndex(
name: "IX_ChannelAd_ChannelId_Position",
table: "ChannelAd",
columns: new[] { "ChannelId", "Position" });
columns: new[] { "ChannelId", "Position" }
);
migrationBuilder.CreateIndex(
name: "IX_Channels_Slug",
table: "Channels",
column: "Slug",
unique: true);
unique: true
);
migrationBuilder.CreateIndex(
name: "IX_ChannelShow_ChannelId_ShowId",
table: "ChannelShow",
columns: new[] { "ChannelId", "ShowId" });
columns: new[] { "ChannelId", "ShowId" }
);
migrationBuilder.CreateIndex(
name: "IX_OverrideShow_ProgrammingOverrideId",
table: "OverrideShow",
column: "ProgrammingOverrideId");
column: "ProgrammingOverrideId"
);
migrationBuilder.CreateIndex(
name: "IX_ProgrammingOverride_ChannelId_StartsAtUtc_EndsAtUtc",
table: "ProgrammingOverride",
columns: new[] { "ChannelId", "StartsAtUtc", "EndsAtUtc" });
columns: new[] { "ChannelId", "StartsAtUtc", "EndsAtUtc" }
);
migrationBuilder.CreateIndex(
name: "IX_ScheduleEntries_ChannelId_EndsAtUtc",
table: "ScheduleEntries",
columns: new[] { "ChannelId", "EndsAtUtc" });
columns: new[] { "ChannelId", "EndsAtUtc" }
);
migrationBuilder.CreateIndex(
name: "IX_ScheduleEntries_ChannelId_ShowId",
table: "ScheduleEntries",
columns: new[] { "ChannelId", "ShowId" });
columns: new[] { "ChannelId", "ShowId" }
);
migrationBuilder.CreateIndex(
name: "IX_ScheduleEntries_ChannelId_StartsAtUtc",
table: "ScheduleEntries",
columns: new[] { "ChannelId", "StartsAtUtc" });
columns: new[] { "ChannelId", "StartsAtUtc" }
);
migrationBuilder.CreateIndex(
name: "IX_ShowEpisode_MediaAssetId",
table: "ShowEpisode",
column: "MediaAssetId");
column: "MediaAssetId"
);
migrationBuilder.CreateIndex(
name: "IX_ShowEpisode_ShowId_Position",
table: "ShowEpisode",
columns: new[] { "ShowId", "Position" });
columns: new[] { "ShowId", "Position" }
);
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropTable(
name: "ChannelAd");
migrationBuilder.DropTable(name: "ChannelAd");
migrationBuilder.DropTable(
name: "ChannelShow");
migrationBuilder.DropTable(name: "ChannelShow");
migrationBuilder.DropTable(
name: "OverrideShow");
migrationBuilder.DropTable(name: "OverrideShow");
migrationBuilder.DropTable(
name: "ScheduleEntries");
migrationBuilder.DropTable(name: "ScheduleEntries");
migrationBuilder.DropTable(
name: "ShowEpisode");
migrationBuilder.DropTable(name: "ShowEpisode");
migrationBuilder.DropTable(
name: "ProgrammingOverride");
migrationBuilder.DropTable(name: "ProgrammingOverride");
migrationBuilder.DropTable(
name: "Shows");
migrationBuilder.DropTable(name: "Shows");
migrationBuilder.DropTable(
name: "Channels");
migrationBuilder.DropTable(name: "Channels");
}
}
}
@@ -16,7 +16,8 @@ namespace TeleWave.Infrastructure.Migrations
table: "Channels",
type: "boolean",
nullable: false,
defaultValue: false);
defaultValue: false
);
migrationBuilder.CreateTable(
name: "BumperAssets",
@@ -25,30 +26,36 @@ namespace TeleWave.Infrastructure.Migrations
Id = table.Column<Guid>(type: "uuid", nullable: false),
FromShowId = table.Column<Guid>(type: "uuid", nullable: false),
ToShowId = table.Column<Guid>(type: "uuid", nullable: false),
Signature = table.Column<string>(type: "character varying(128)", maxLength: 128, nullable: false),
Signature = table.Column<string>(
type: "character varying(128)",
maxLength: 128,
nullable: false
),
MediaAssetId = table.Column<Guid>(type: "uuid", nullable: false),
CreatedAt = table.Column<DateTimeOffset>(type: "timestamp with time zone", nullable: false)
CreatedAt = table.Column<DateTimeOffset>(
type: "timestamp with time zone",
nullable: false
),
},
constraints: table =>
{
table.PrimaryKey("PK_BumperAssets", x => x.Id);
});
}
);
migrationBuilder.CreateIndex(
name: "IX_BumperAssets_FromShowId_ToShowId_Signature",
table: "BumperAssets",
columns: new[] { "FromShowId", "ToShowId", "Signature" });
columns: new[] { "FromShowId", "ToShowId", "Signature" }
);
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropTable(
name: "BumperAssets");
migrationBuilder.DropTable(name: "BumperAssets");
migrationBuilder.DropColumn(
name: "BumpersEnabled",
table: "Channels");
migrationBuilder.DropColumn(name: "BumpersEnabled", table: "Channels");
}
}
}
@@ -15,114 +15,104 @@ namespace TeleWave.Infrastructure.Migrations
table: "Channels",
type: "text",
nullable: false,
defaultValue: "0x38bdf8");
defaultValue: "0x38bdf8"
);
migrationBuilder.AddColumn<string>(
name: "BumperBackgroundColor",
table: "Channels",
type: "text",
nullable: false,
defaultValue: "0x0b1020");
defaultValue: "0x0b1020"
);
migrationBuilder.AddColumn<string>(
name: "BumperBackgroundColor2",
table: "Channels",
type: "text",
nullable: false,
defaultValue: "0x1e293b");
defaultValue: "0x1e293b"
);
migrationBuilder.AddColumn<int>(
name: "BumperDurationSeconds",
table: "Channels",
type: "integer",
nullable: false,
defaultValue: 8);
defaultValue: 8
);
migrationBuilder.AddColumn<int>(
name: "BumperFont",
table: "Channels",
type: "integer",
nullable: false,
defaultValue: 0);
defaultValue: 0
);
migrationBuilder.AddColumn<int>(
name: "BumperMinIntervalMinutes",
table: "Channels",
type: "integer",
nullable: false,
defaultValue: 0);
defaultValue: 0
);
migrationBuilder.AddColumn<string>(
name: "BumperNextLabel",
table: "Channels",
type: "text",
nullable: false,
defaultValue: "ДАЛЕЕ");
defaultValue: "ДАЛЕЕ"
);
migrationBuilder.AddColumn<string>(
name: "BumperNowLabel",
table: "Channels",
type: "text",
nullable: false,
defaultValue: "СЕЙЧАС");
defaultValue: "СЕЙЧАС"
);
migrationBuilder.AddColumn<bool>(
name: "BumperOnlyBetweenDifferentShows",
table: "Channels",
type: "boolean",
nullable: false,
defaultValue: true);
defaultValue: true
);
migrationBuilder.AddColumn<string>(
name: "BumperTextColor",
table: "Channels",
type: "text",
nullable: false,
defaultValue: "white");
defaultValue: "white"
);
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropColumn(
name: "BumperAccentColor",
table: "Channels");
migrationBuilder.DropColumn(name: "BumperAccentColor", table: "Channels");
migrationBuilder.DropColumn(
name: "BumperBackgroundColor",
table: "Channels");
migrationBuilder.DropColumn(name: "BumperBackgroundColor", table: "Channels");
migrationBuilder.DropColumn(
name: "BumperBackgroundColor2",
table: "Channels");
migrationBuilder.DropColumn(name: "BumperBackgroundColor2", table: "Channels");
migrationBuilder.DropColumn(
name: "BumperDurationSeconds",
table: "Channels");
migrationBuilder.DropColumn(name: "BumperDurationSeconds", table: "Channels");
migrationBuilder.DropColumn(
name: "BumperFont",
table: "Channels");
migrationBuilder.DropColumn(name: "BumperFont", table: "Channels");
migrationBuilder.DropColumn(
name: "BumperMinIntervalMinutes",
table: "Channels");
migrationBuilder.DropColumn(name: "BumperMinIntervalMinutes", table: "Channels");
migrationBuilder.DropColumn(
name: "BumperNextLabel",
table: "Channels");
migrationBuilder.DropColumn(name: "BumperNextLabel", table: "Channels");
migrationBuilder.DropColumn(
name: "BumperNowLabel",
table: "Channels");
migrationBuilder.DropColumn(name: "BumperNowLabel", table: "Channels");
migrationBuilder.DropColumn(
name: "BumperOnlyBetweenDifferentShows",
table: "Channels");
migrationBuilder.DropColumn(name: "BumperOnlyBetweenDifferentShows", table: "Channels");
migrationBuilder.DropColumn(
name: "BumperTextColor",
table: "Channels");
migrationBuilder.DropColumn(name: "BumperTextColor", table: "Channels");
}
}
}
@@ -15,34 +15,39 @@ namespace TeleWave.Infrastructure.Migrations
name: "BumperBackgroundExtension",
table: "Channels",
type: "text",
nullable: true);
nullable: true
);
migrationBuilder.AddColumn<int>(
name: "BumperMode",
table: "Channels",
type: "integer",
nullable: false,
defaultValue: 0);
defaultValue: 0
);
migrationBuilder.AddColumn<string>(
name: "BumperMusicExtension",
table: "Channels",
type: "text",
nullable: true);
nullable: true
);
migrationBuilder.AddColumn<int>(
name: "BumperRevision",
table: "Channels",
type: "integer",
nullable: false,
defaultValue: 0);
defaultValue: 0
);
migrationBuilder.AddColumn<int>(
name: "NextJingleIndex",
table: "Channels",
type: "integer",
nullable: false,
defaultValue: 0);
defaultValue: 0
);
migrationBuilder.CreateTable(
name: "ChannelJingle",
@@ -51,7 +56,7 @@ namespace TeleWave.Infrastructure.Migrations
Id = table.Column<Guid>(type: "uuid", nullable: false),
ChannelId = table.Column<Guid>(type: "uuid", nullable: false),
MediaAssetId = table.Column<Guid>(type: "uuid", nullable: false),
Position = table.Column<int>(type: "integer", nullable: false)
Position = table.Column<int>(type: "integer", nullable: false),
},
constraints: table =>
{
@@ -61,40 +66,32 @@ namespace TeleWave.Infrastructure.Migrations
column: x => x.ChannelId,
principalTable: "Channels",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
});
onDelete: ReferentialAction.Cascade
);
}
);
migrationBuilder.CreateIndex(
name: "IX_ChannelJingle_ChannelId_Position",
table: "ChannelJingle",
columns: new[] { "ChannelId", "Position" });
columns: new[] { "ChannelId", "Position" }
);
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropTable(
name: "ChannelJingle");
migrationBuilder.DropTable(name: "ChannelJingle");
migrationBuilder.DropColumn(
name: "BumperBackgroundExtension",
table: "Channels");
migrationBuilder.DropColumn(name: "BumperBackgroundExtension", table: "Channels");
migrationBuilder.DropColumn(
name: "BumperMode",
table: "Channels");
migrationBuilder.DropColumn(name: "BumperMode", table: "Channels");
migrationBuilder.DropColumn(
name: "BumperMusicExtension",
table: "Channels");
migrationBuilder.DropColumn(name: "BumperMusicExtension", table: "Channels");
migrationBuilder.DropColumn(
name: "BumperRevision",
table: "Channels");
migrationBuilder.DropColumn(name: "BumperRevision", table: "Channels");
migrationBuilder.DropColumn(
name: "NextJingleIndex",
table: "Channels");
migrationBuilder.DropColumn(name: "NextJingleIndex", table: "Channels");
}
}
}
@@ -14,20 +14,28 @@ namespace TeleWave.Infrastructure.Migrations
name: "AppSettings",
columns: table => new
{
Key = table.Column<string>(type: "character varying(128)", maxLength: 128, nullable: false),
Value = table.Column<string>(type: "character varying(1024)", maxLength: 1024, nullable: false)
Key = table.Column<string>(
type: "character varying(128)",
maxLength: 128,
nullable: false
),
Value = table.Column<string>(
type: "character varying(1024)",
maxLength: 1024,
nullable: false
),
},
constraints: table =>
{
table.PrimaryKey("PK_AppSettings", x => x.Key);
});
}
);
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropTable(
name: "AppSettings");
migrationBuilder.DropTable(name: "AppSettings");
}
}
}
@@ -15,47 +15,43 @@ namespace TeleWave.Infrastructure.Migrations
table: "Shows",
type: "character varying(64)",
maxLength: 64,
nullable: true);
nullable: true
);
migrationBuilder.AddColumn<string>(
name: "MetadataProvider",
table: "Shows",
type: "character varying(16)",
maxLength: 16,
nullable: true);
nullable: true
);
migrationBuilder.AddColumn<string>(
name: "PosterPath",
table: "Shows",
type: "character varying(256)",
maxLength: 256,
nullable: true);
nullable: true
);
migrationBuilder.AddColumn<int>(
name: "Year",
table: "Shows",
type: "integer",
nullable: true);
nullable: true
);
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropColumn(
name: "MetadataExternalId",
table: "Shows");
migrationBuilder.DropColumn(name: "MetadataExternalId", table: "Shows");
migrationBuilder.DropColumn(
name: "MetadataProvider",
table: "Shows");
migrationBuilder.DropColumn(name: "MetadataProvider", table: "Shows");
migrationBuilder.DropColumn(
name: "PosterPath",
table: "Shows");
migrationBuilder.DropColumn(name: "PosterPath", table: "Shows");
migrationBuilder.DropColumn(
name: "Year",
table: "Shows");
migrationBuilder.DropColumn(name: "Year", table: "Shows");
}
}
}
@@ -15,68 +15,62 @@ namespace TeleWave.Infrastructure.Migrations
name: "AirDate",
table: "ShowEpisode",
type: "date",
nullable: true);
nullable: true
);
migrationBuilder.AddColumn<int>(
name: "Episode",
table: "ShowEpisode",
type: "integer",
nullable: true);
nullable: true
);
migrationBuilder.AddColumn<string>(
name: "Overview",
table: "ShowEpisode",
type: "character varying(4096)",
maxLength: 4096,
nullable: true);
nullable: true
);
migrationBuilder.AddColumn<int>(
name: "Season",
table: "ShowEpisode",
type: "integer",
nullable: true);
nullable: true
);
migrationBuilder.AddColumn<string>(
name: "StillPath",
table: "ShowEpisode",
type: "character varying(256)",
maxLength: 256,
nullable: true);
nullable: true
);
migrationBuilder.AddColumn<string>(
name: "Title",
table: "ShowEpisode",
type: "character varying(512)",
maxLength: 512,
nullable: true);
nullable: true
);
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropColumn(
name: "AirDate",
table: "ShowEpisode");
migrationBuilder.DropColumn(name: "AirDate", table: "ShowEpisode");
migrationBuilder.DropColumn(
name: "Episode",
table: "ShowEpisode");
migrationBuilder.DropColumn(name: "Episode", table: "ShowEpisode");
migrationBuilder.DropColumn(
name: "Overview",
table: "ShowEpisode");
migrationBuilder.DropColumn(name: "Overview", table: "ShowEpisode");
migrationBuilder.DropColumn(
name: "Season",
table: "ShowEpisode");
migrationBuilder.DropColumn(name: "Season", table: "ShowEpisode");
migrationBuilder.DropColumn(
name: "StillPath",
table: "ShowEpisode");
migrationBuilder.DropColumn(name: "StillPath", table: "ShowEpisode");
migrationBuilder.DropColumn(
name: "Title",
table: "ShowEpisode");
migrationBuilder.DropColumn(name: "Title", table: "ShowEpisode");
}
}
}
@@ -11,58 +11,41 @@ namespace TeleWave.Infrastructure.Migrations
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropTable(
name: "ChannelJingle");
migrationBuilder.DropTable(name: "ChannelJingle");
migrationBuilder.DropColumn(
name: "BumperAccentColor",
table: "Channels");
migrationBuilder.DropColumn(name: "BumperAccentColor", table: "Channels");
migrationBuilder.DropColumn(
name: "BumperBackgroundColor",
table: "Channels");
migrationBuilder.DropColumn(name: "BumperBackgroundColor", table: "Channels");
migrationBuilder.DropColumn(
name: "BumperBackgroundColor2",
table: "Channels");
migrationBuilder.DropColumn(name: "BumperBackgroundColor2", table: "Channels");
migrationBuilder.DropColumn(
name: "BumperBackgroundExtension",
table: "Channels");
migrationBuilder.DropColumn(name: "BumperBackgroundExtension", table: "Channels");
migrationBuilder.DropColumn(
name: "BumperDurationSeconds",
table: "Channels");
migrationBuilder.DropColumn(name: "BumperDurationSeconds", table: "Channels");
migrationBuilder.DropColumn(
name: "BumperMode",
table: "Channels");
migrationBuilder.DropColumn(name: "BumperMode", table: "Channels");
migrationBuilder.DropColumn(
name: "BumperMusicExtension",
table: "Channels");
migrationBuilder.DropColumn(name: "BumperMusicExtension", table: "Channels");
migrationBuilder.DropColumn(
name: "BumperTextColor",
table: "Channels");
migrationBuilder.DropColumn(name: "BumperTextColor", table: "Channels");
migrationBuilder.RenameColumn(
name: "NextJingleIndex",
table: "Channels",
newName: "NextBumperIndex");
newName: "NextBumperIndex"
);
// Ревизия файлов уехала на блоки заставок — старый счётчик не переносим, стратегия по
// умолчанию Rotation (0).
migrationBuilder.DropColumn(
name: "BumperRevision",
table: "Channels");
migrationBuilder.DropColumn(name: "BumperRevision", table: "Channels");
migrationBuilder.AddColumn<int>(
name: "BumperSelection",
table: "Channels",
type: "integer",
nullable: false,
defaultValue: 0);
defaultValue: 0
);
migrationBuilder.CreateTable(
name: "BumperTemplate",
@@ -71,16 +54,50 @@ namespace TeleWave.Infrastructure.Migrations
Id = table.Column<Guid>(type: "uuid", nullable: false),
ChannelId = table.Column<Guid>(type: "uuid", nullable: false),
Position = table.Column<int>(type: "integer", nullable: false),
Name = table.Column<string>(type: "character varying(64)", maxLength: 64, nullable: false),
BackgroundColor = table.Column<string>(type: "character varying(32)", maxLength: 32, nullable: false),
BackgroundColor2 = table.Column<string>(type: "character varying(32)", maxLength: 32, nullable: false),
AccentColor = table.Column<string>(type: "character varying(32)", maxLength: 32, nullable: false),
TextColor = table.Column<string>(type: "character varying(32)", maxLength: 32, nullable: false),
BackgroundImageExtension = table.Column<string>(type: "character varying(16)", maxLength: 16, nullable: true),
AudioExtension = table.Column<string>(type: "character varying(16)", maxLength: 16, nullable: true),
AudioDurationSeconds = table.Column<double>(type: "double precision", nullable: true),
Name = table.Column<string>(
type: "character varying(64)",
maxLength: 64,
nullable: false
),
BackgroundColor = table.Column<string>(
type: "character varying(32)",
maxLength: 32,
nullable: false
),
BackgroundColor2 = table.Column<string>(
type: "character varying(32)",
maxLength: 32,
nullable: false
),
AccentColor = table.Column<string>(
type: "character varying(32)",
maxLength: 32,
nullable: false
),
TextColor = table.Column<string>(
type: "character varying(32)",
maxLength: 32,
nullable: false
),
BackgroundImageExtension = table.Column<string>(
type: "character varying(16)",
maxLength: 16,
nullable: true
),
AudioExtension = table.Column<string>(
type: "character varying(16)",
maxLength: 16,
nullable: true
),
AudioDurationSeconds = table.Column<double>(
type: "double precision",
nullable: true
),
Revision = table.Column<int>(type: "integer", nullable: false),
CreatedAt = table.Column<DateTimeOffset>(type: "timestamp with time zone", nullable: false)
CreatedAt = table.Column<DateTimeOffset>(
type: "timestamp with time zone",
nullable: false
),
},
constraints: table =>
{
@@ -90,13 +107,16 @@ namespace TeleWave.Infrastructure.Migrations
column: x => x.ChannelId,
principalTable: "Channels",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
});
onDelete: ReferentialAction.Cascade
);
}
);
migrationBuilder.CreateIndex(
name: "IX_BumperTemplate_ChannelId_Position",
table: "BumperTemplate",
columns: new[] { "ChannelId", "Position" });
columns: new[] { "ChannelId", "Position" }
);
// Каждому существующему каналу — дефолтный блок заставки (Position 0, без звука/фона).
migrationBuilder.Sql(
@@ -114,78 +134,85 @@ namespace TeleWave.Infrastructure.Migrations
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropTable(
name: "BumperTemplate");
migrationBuilder.DropTable(name: "BumperTemplate");
migrationBuilder.RenameColumn(
name: "NextBumperIndex",
table: "Channels",
newName: "NextJingleIndex");
newName: "NextJingleIndex"
);
migrationBuilder.DropColumn(
name: "BumperSelection",
table: "Channels");
migrationBuilder.DropColumn(name: "BumperSelection", table: "Channels");
migrationBuilder.AddColumn<int>(
name: "BumperRevision",
table: "Channels",
type: "integer",
nullable: false,
defaultValue: 0);
defaultValue: 0
);
migrationBuilder.AddColumn<string>(
name: "BumperAccentColor",
table: "Channels",
type: "text",
nullable: false,
defaultValue: "");
defaultValue: ""
);
migrationBuilder.AddColumn<string>(
name: "BumperBackgroundColor",
table: "Channels",
type: "text",
nullable: false,
defaultValue: "");
defaultValue: ""
);
migrationBuilder.AddColumn<string>(
name: "BumperBackgroundColor2",
table: "Channels",
type: "text",
nullable: false,
defaultValue: "");
defaultValue: ""
);
migrationBuilder.AddColumn<string>(
name: "BumperBackgroundExtension",
table: "Channels",
type: "text",
nullable: true);
nullable: true
);
migrationBuilder.AddColumn<int>(
name: "BumperDurationSeconds",
table: "Channels",
type: "integer",
nullable: false,
defaultValue: 0);
defaultValue: 0
);
migrationBuilder.AddColumn<int>(
name: "BumperMode",
table: "Channels",
type: "integer",
nullable: false,
defaultValue: 0);
defaultValue: 0
);
migrationBuilder.AddColumn<string>(
name: "BumperMusicExtension",
table: "Channels",
type: "text",
nullable: true);
nullable: true
);
migrationBuilder.AddColumn<string>(
name: "BumperTextColor",
table: "Channels",
type: "text",
nullable: false,
defaultValue: "");
defaultValue: ""
);
migrationBuilder.CreateTable(
name: "ChannelJingle",
@@ -194,7 +221,7 @@ namespace TeleWave.Infrastructure.Migrations
Id = table.Column<Guid>(type: "uuid", nullable: false),
ChannelId = table.Column<Guid>(type: "uuid", nullable: false),
MediaAssetId = table.Column<Guid>(type: "uuid", nullable: false),
Position = table.Column<int>(type: "integer", nullable: false)
Position = table.Column<int>(type: "integer", nullable: false),
},
constraints: table =>
{
@@ -204,13 +231,16 @@ namespace TeleWave.Infrastructure.Migrations
column: x => x.ChannelId,
principalTable: "Channels",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
});
onDelete: ReferentialAction.Cascade
);
}
);
migrationBuilder.CreateIndex(
name: "IX_ChannelJingle_ChannelId_Position",
table: "ChannelJingle",
columns: new[] { "ChannelId", "Position" });
columns: new[] { "ChannelId", "Position" }
);
}
}
}
@@ -14,15 +14,14 @@ namespace TeleWave.Infrastructure.Migrations
name: "OriginalName",
table: "Shows",
type: "text",
nullable: true);
nullable: true
);
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropColumn(
name: "OriginalName",
table: "Shows");
migrationBuilder.DropColumn(name: "OriginalName", table: "Shows");
}
}
}
@@ -17,26 +17,38 @@ namespace TeleWave.Infrastructure.Migrations
{
Id = table.Column<Guid>(type: "uuid", nullable: false),
Category = table.Column<int>(type: "integer", nullable: false),
FileExtension = table.Column<string>(type: "character varying(16)", maxLength: 16, nullable: false),
OriginalFileName = table.Column<string>(type: "character varying(512)", maxLength: 512, nullable: true),
CreatedAt = table.Column<DateTimeOffset>(type: "timestamp with time zone", nullable: false)
FileExtension = table.Column<string>(
type: "character varying(16)",
maxLength: 16,
nullable: false
),
OriginalFileName = table.Column<string>(
type: "character varying(512)",
maxLength: 512,
nullable: true
),
CreatedAt = table.Column<DateTimeOffset>(
type: "timestamp with time zone",
nullable: false
),
},
constraints: table =>
{
table.PrimaryKey("PK_Images", x => x.Id);
});
}
);
migrationBuilder.CreateIndex(
name: "IX_Images_Category_CreatedAt",
table: "Images",
columns: new[] { "Category", "CreatedAt" });
columns: new[] { "Category", "CreatedAt" }
);
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropTable(
name: "Images");
migrationBuilder.DropTable(name: "Images");
}
}
}
@@ -19,13 +19,15 @@ namespace TeleWave.Infrastructure.Migrations
nullable: true,
oldClrType: typeof(string),
oldType: "text",
oldNullable: true);
oldNullable: true
);
migrationBuilder.AddColumn<Guid>(
name: "PosterImageId",
table: "Shows",
type: "uuid",
nullable: true);
nullable: true
);
// Переносим существующие постеры шоу в общий реестр изображений: на каждый постер —
// запись Images (Category=1 ShowPoster) с расширением из старого пути; файлы перекладывает
@@ -45,17 +47,13 @@ namespace TeleWave.Infrastructure.Migrations
"""
);
migrationBuilder.DropColumn(
name: "PosterPath",
table: "Shows");
migrationBuilder.DropColumn(name: "PosterPath", table: "Shows");
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropColumn(
name: "PosterImageId",
table: "Shows");
migrationBuilder.DropColumn(name: "PosterImageId", table: "Shows");
migrationBuilder.AlterColumn<string>(
name: "OriginalName",
@@ -65,14 +63,16 @@ namespace TeleWave.Infrastructure.Migrations
oldClrType: typeof(string),
oldType: "character varying(256)",
oldMaxLength: 256,
oldNullable: true);
oldNullable: true
);
migrationBuilder.AddColumn<string>(
name: "PosterPath",
table: "Shows",
type: "character varying(256)",
maxLength: 256,
nullable: true);
nullable: true
);
}
}
}
@@ -15,13 +15,15 @@ namespace TeleWave.Infrastructure.Migrations
name: "StillImageId",
table: "ShowEpisode",
type: "uuid",
nullable: true);
nullable: true
);
migrationBuilder.AddColumn<Guid>(
name: "BackgroundImageId",
table: "BumperTemplate",
type: "uuid",
nullable: true);
nullable: true
);
// Кадры серий → реестр (Category=2 EpisodeStill); файлы перекладывает RelocateLegacyImagesAsync.
migrationBuilder.Sql(
@@ -55,39 +57,33 @@ namespace TeleWave.Infrastructure.Migrations
"""
);
migrationBuilder.DropColumn(
name: "StillPath",
table: "ShowEpisode");
migrationBuilder.DropColumn(name: "StillPath", table: "ShowEpisode");
migrationBuilder.DropColumn(
name: "BackgroundImageExtension",
table: "BumperTemplate");
migrationBuilder.DropColumn(name: "BackgroundImageExtension", table: "BumperTemplate");
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropColumn(
name: "StillImageId",
table: "ShowEpisode");
migrationBuilder.DropColumn(name: "StillImageId", table: "ShowEpisode");
migrationBuilder.DropColumn(
name: "BackgroundImageId",
table: "BumperTemplate");
migrationBuilder.DropColumn(name: "BackgroundImageId", table: "BumperTemplate");
migrationBuilder.AddColumn<string>(
name: "StillPath",
table: "ShowEpisode",
type: "character varying(256)",
maxLength: 256,
nullable: true);
nullable: true
);
migrationBuilder.AddColumn<string>(
name: "BackgroundImageExtension",
table: "BumperTemplate",
type: "character varying(16)",
maxLength: 16,
nullable: true);
nullable: true
);
}
}
}
@@ -18,14 +18,37 @@ namespace TeleWave.Infrastructure.Migrations
Id = table.Column<Guid>(type: "uuid", nullable: false),
BumperTemplateId = table.Column<Guid>(type: "uuid", nullable: false),
Position = table.Column<int>(type: "integer", nullable: false),
Name = table.Column<string>(type: "character varying(64)", maxLength: 64, nullable: false),
Name = table.Column<string>(
type: "character varying(64)",
maxLength: 64,
nullable: false
),
Kind = table.Column<int>(type: "integer", nullable: false),
NowLabel = table.Column<string>(type: "character varying(64)", maxLength: 64, nullable: false),
NextLabel = table.Column<string>(type: "character varying(64)", maxLength: 64, nullable: false),
Line1 = table.Column<string>(type: "character varying(120)", maxLength: 120, nullable: false),
Line2 = table.Column<string>(type: "character varying(120)", maxLength: 120, nullable: false),
NowLabel = table.Column<string>(
type: "character varying(64)",
maxLength: 64,
nullable: false
),
NextLabel = table.Column<string>(
type: "character varying(64)",
maxLength: 64,
nullable: false
),
Line1 = table.Column<string>(
type: "character varying(120)",
maxLength: 120,
nullable: false
),
Line2 = table.Column<string>(
type: "character varying(120)",
maxLength: 120,
nullable: false
),
Trigger = table.Column<int>(type: "integer", nullable: false),
CreatedAt = table.Column<DateTimeOffset>(type: "timestamp with time zone", nullable: false)
CreatedAt = table.Column<DateTimeOffset>(
type: "timestamp with time zone",
nullable: false
),
},
constraints: table =>
{
@@ -35,13 +58,16 @@ namespace TeleWave.Infrastructure.Migrations
column: x => x.BumperTemplateId,
principalTable: "BumperTemplate",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
});
onDelete: ReferentialAction.Cascade
);
}
);
migrationBuilder.CreateIndex(
name: "IX_BumperTextVariant_BumperTemplateId_Position",
table: "BumperTextVariant",
columns: new[] { "BumperTemplateId", "Position" });
columns: new[] { "BumperTemplateId", "Position" }
);
// Каждому блоку — дефолтный подблок «Сейчас/Далее» с прежними подписями канала; правило
// показа переносим из старой галочки (только на смене шоу → OnShowChange=0, иначе Both=2).
@@ -75,29 +101,31 @@ namespace TeleWave.Infrastructure.Migrations
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropTable(
name: "BumperTextVariant");
migrationBuilder.DropTable(name: "BumperTextVariant");
migrationBuilder.AddColumn<string>(
name: "BumperNextLabel",
table: "Channels",
type: "text",
nullable: false,
defaultValue: "");
defaultValue: ""
);
migrationBuilder.AddColumn<string>(
name: "BumperNowLabel",
table: "Channels",
type: "text",
nullable: false,
defaultValue: "");
defaultValue: ""
);
migrationBuilder.AddColumn<bool>(
name: "BumperOnlyBetweenDifferentShows",
table: "Channels",
type: "boolean",
nullable: false,
defaultValue: false);
defaultValue: false
);
}
}
}
@@ -13,26 +13,28 @@ namespace TeleWave.Infrastructure.Migrations
{
migrationBuilder.DropForeignKey(
name: "FK_BumperTextVariant_BumperTemplate_BumperTemplateId",
table: "BumperTextVariant");
table: "BumperTextVariant"
);
migrationBuilder.DropPrimaryKey(
name: "PK_BumperTextVariant",
table: "BumperTextVariant");
table: "BumperTextVariant"
);
migrationBuilder.RenameTable(
name: "BumperTextVariant",
newName: "BumperTextVariants");
migrationBuilder.RenameTable(name: "BumperTextVariant", newName: "BumperTextVariants");
migrationBuilder.RenameIndex(
name: "IX_BumperTextVariant_BumperTemplateId_Position",
table: "BumperTextVariants",
newName: "IX_BumperTextVariants_BumperTemplateId_Position");
newName: "IX_BumperTextVariants_BumperTemplateId_Position"
);
migrationBuilder.AddColumn<Guid>(
name: "BumperVariantId",
table: "ScheduleEntries",
type: "uuid",
nullable: true);
nullable: true
);
// Существующим каналам — 1.0 (заставка на каждом подходящем переходе, как было до фичи).
migrationBuilder.AddColumn<double>(
@@ -40,26 +42,30 @@ namespace TeleWave.Infrastructure.Migrations
table: "Channels",
type: "double precision",
nullable: false,
defaultValue: 1.0);
defaultValue: 1.0
);
migrationBuilder.AddColumn<double>(
name: "BumperShowChangeChance",
table: "Channels",
type: "double precision",
nullable: false,
defaultValue: 1.0);
defaultValue: 1.0
);
migrationBuilder.AddColumn<int>(
name: "Weight",
table: "BumperTextVariants",
type: "integer",
nullable: false,
defaultValue: 1);
defaultValue: 1
);
migrationBuilder.AddPrimaryKey(
name: "PK_BumperTextVariants",
table: "BumperTextVariants",
column: "Id");
column: "Id"
);
migrationBuilder.AddForeignKey(
name: "FK_BumperTextVariants_BumperTemplate_BumperTemplateId",
@@ -67,7 +73,8 @@ namespace TeleWave.Infrastructure.Migrations
column: "BumperTemplateId",
principalTable: "BumperTemplate",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
onDelete: ReferentialAction.Cascade
);
}
/// <inheritdoc />
@@ -75,41 +82,35 @@ namespace TeleWave.Infrastructure.Migrations
{
migrationBuilder.DropForeignKey(
name: "FK_BumperTextVariants_BumperTemplate_BumperTemplateId",
table: "BumperTextVariants");
table: "BumperTextVariants"
);
migrationBuilder.DropPrimaryKey(
name: "PK_BumperTextVariants",
table: "BumperTextVariants");
table: "BumperTextVariants"
);
migrationBuilder.DropColumn(
name: "BumperVariantId",
table: "ScheduleEntries");
migrationBuilder.DropColumn(name: "BumperVariantId", table: "ScheduleEntries");
migrationBuilder.DropColumn(
name: "BumperEpisodeChangeChance",
table: "Channels");
migrationBuilder.DropColumn(name: "BumperEpisodeChangeChance", table: "Channels");
migrationBuilder.DropColumn(
name: "BumperShowChangeChance",
table: "Channels");
migrationBuilder.DropColumn(name: "BumperShowChangeChance", table: "Channels");
migrationBuilder.DropColumn(
name: "Weight",
table: "BumperTextVariants");
migrationBuilder.DropColumn(name: "Weight", table: "BumperTextVariants");
migrationBuilder.RenameTable(
name: "BumperTextVariants",
newName: "BumperTextVariant");
migrationBuilder.RenameTable(name: "BumperTextVariants", newName: "BumperTextVariant");
migrationBuilder.RenameIndex(
name: "IX_BumperTextVariants_BumperTemplateId_Position",
table: "BumperTextVariant",
newName: "IX_BumperTextVariant_BumperTemplateId_Position");
newName: "IX_BumperTextVariant_BumperTemplateId_Position"
);
migrationBuilder.AddPrimaryKey(
name: "PK_BumperTextVariant",
table: "BumperTextVariant",
column: "Id");
column: "Id"
);
migrationBuilder.AddForeignKey(
name: "FK_BumperTextVariant_BumperTemplate_BumperTemplateId",
@@ -117,7 +118,8 @@ namespace TeleWave.Infrastructure.Migrations
column: "BumperTemplateId",
principalTable: "BumperTemplate",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
onDelete: ReferentialAction.Cascade
);
}
}
}
@@ -16,7 +16,8 @@ namespace TeleWave.Infrastructure.Migrations
table: "ChannelShow",
type: "integer",
nullable: false,
defaultValue: 3);
defaultValue: 3
);
migrationBuilder.CreateTable(
name: "ChannelShowHour",
@@ -25,7 +26,7 @@ namespace TeleWave.Infrastructure.Migrations
Id = table.Column<Guid>(type: "uuid", nullable: false),
ChannelShowId = table.Column<Guid>(type: "uuid", nullable: false),
StartHour = table.Column<int>(type: "integer", nullable: false),
EndHour = table.Column<int>(type: "integer", nullable: false)
EndHour = table.Column<int>(type: "integer", nullable: false),
},
constraints: table =>
{
@@ -35,24 +36,24 @@ namespace TeleWave.Infrastructure.Migrations
column: x => x.ChannelShowId,
principalTable: "ChannelShow",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
});
onDelete: ReferentialAction.Cascade
);
}
);
migrationBuilder.CreateIndex(
name: "IX_ChannelShowHour_ChannelShowId",
table: "ChannelShowHour",
column: "ChannelShowId");
column: "ChannelShowId"
);
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropTable(
name: "ChannelShowHour");
migrationBuilder.DropTable(name: "ChannelShowHour");
migrationBuilder.DropColumn(
name: "PreferredWeightMultiplier",
table: "ChannelShow");
migrationBuilder.DropColumn(name: "PreferredWeightMultiplier", table: "ChannelShow");
}
}
}
@@ -17,7 +17,8 @@ namespace TeleWave.Infrastructure.Migrations
type: "timestamp with time zone",
nullable: true,
oldClrType: typeof(DateTimeOffset),
oldType: "timestamp with time zone");
oldType: "timestamp with time zone"
);
migrationBuilder.AlterColumn<DateTimeOffset>(
name: "EndsAtUtc",
@@ -25,72 +26,77 @@ namespace TeleWave.Infrastructure.Migrations
type: "timestamp with time zone",
nullable: true,
oldClrType: typeof(DateTimeOffset),
oldType: "timestamp with time zone");
oldType: "timestamp with time zone"
);
migrationBuilder.AddColumn<int>(
name: "DayOfWeek",
table: "ProgrammingOverride",
type: "integer",
nullable: true);
nullable: true
);
migrationBuilder.AddColumn<int>(
name: "EndMinute",
table: "ProgrammingOverride",
type: "integer",
nullable: true);
nullable: true
);
migrationBuilder.AddColumn<int>(
name: "Recurrence",
table: "ProgrammingOverride",
type: "integer",
nullable: false,
defaultValue: 0);
defaultValue: 0
);
migrationBuilder.AddColumn<int>(
name: "StartMinute",
table: "ProgrammingOverride",
type: "integer",
nullable: true);
nullable: true
);
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropColumn(
name: "DayOfWeek",
table: "ProgrammingOverride");
migrationBuilder.DropColumn(name: "DayOfWeek", table: "ProgrammingOverride");
migrationBuilder.DropColumn(
name: "EndMinute",
table: "ProgrammingOverride");
migrationBuilder.DropColumn(name: "EndMinute", table: "ProgrammingOverride");
migrationBuilder.DropColumn(
name: "Recurrence",
table: "ProgrammingOverride");
migrationBuilder.DropColumn(name: "Recurrence", table: "ProgrammingOverride");
migrationBuilder.DropColumn(
name: "StartMinute",
table: "ProgrammingOverride");
migrationBuilder.DropColumn(name: "StartMinute", table: "ProgrammingOverride");
migrationBuilder.AlterColumn<DateTimeOffset>(
name: "StartsAtUtc",
table: "ProgrammingOverride",
type: "timestamp with time zone",
nullable: false,
defaultValue: new DateTimeOffset(new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified), new TimeSpan(0, 0, 0, 0, 0)),
defaultValue: new DateTimeOffset(
new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified),
new TimeSpan(0, 0, 0, 0, 0)
),
oldClrType: typeof(DateTimeOffset),
oldType: "timestamp with time zone",
oldNullable: true);
oldNullable: true
);
migrationBuilder.AlterColumn<DateTimeOffset>(
name: "EndsAtUtc",
table: "ProgrammingOverride",
type: "timestamp with time zone",
nullable: false,
defaultValue: new DateTimeOffset(new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified), new TimeSpan(0, 0, 0, 0, 0)),
defaultValue: new DateTimeOffset(
new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified),
new TimeSpan(0, 0, 0, 0, 0)
),
oldClrType: typeof(DateTimeOffset),
oldType: "timestamp with time zone",
oldNullable: true);
oldNullable: true
);
}
}
}
@@ -41,8 +41,10 @@ public class AppDbContext(DbContextOptions<AppDbContext> options)
foreach (var entityType in modelBuilder.Model.GetEntityTypes())
{
if (
entityType.ClrType.Namespace?.StartsWith("TeleWave.Domain", StringComparison.Ordinal)
!= true
entityType.ClrType.Namespace?.StartsWith(
"TeleWave.Domain",
StringComparison.Ordinal
) != true
)
continue;
@@ -48,7 +48,8 @@ public class ChannelShowConfiguration : IEntityTypeConfiguration<ChannelShow>
public void Configure(EntityTypeBuilder<ChannelShow> builder)
{
builder.HasIndex(x => new { x.ChannelId, x.ShowId });
builder.Property(x => x.PreferredWeightMultiplier)
builder
.Property(x => x.PreferredWeightMultiplier)
.HasDefaultValue(ChannelShow.DefaultPreferredWeightMultiplier);
builder
@@ -115,7 +116,12 @@ public class ProgrammingOverrideConfiguration : IEntityTypeConfiguration<Program
{
public void Configure(EntityTypeBuilder<ProgrammingOverride> builder)
{
builder.HasIndex(x => new { x.ChannelId, x.StartsAtUtc, x.EndsAtUtc });
builder.HasIndex(x => new
{
x.ChannelId,
x.StartsAtUtc,
x.EndsAtUtc,
});
builder
.HasMany(x => x.Shows)
@@ -34,41 +34,68 @@ public static class MigrationExtensions
Directory.CreateDirectory(paths.ImagesDir);
// Постеры шоу: metadata/shows/{showId}/poster{ext} → images/{imageId}{ext}.
var posters = await dbContext.Shows.AsNoTracking()
var posters = await dbContext
.Shows.AsNoTracking()
.Where(s => s.PosterImageId != null)
.Join(
dbContext.Images,
s => s.PosterImageId,
i => i.Id,
(s, i) => new { EntityId = s.Id, ImageId = i.Id, i.FileExtension }
(s, i) =>
new
{
EntityId = s.Id,
ImageId = i.Id,
i.FileExtension,
}
)
.ToListAsync(cancellationToken);
foreach (var p in posters)
Relocate(paths.ImagePath(p.ImageId, p.FileExtension), paths.MetadataShowPosterPath(p.EntityId, p.FileExtension));
Relocate(
paths.ImagePath(p.ImageId, p.FileExtension),
paths.MetadataShowPosterPath(p.EntityId, p.FileExtension)
);
// Кадры серий: metadata/episodes/{episodeId}/still{ext} → images/{imageId}{ext}.
var stills = await dbContext.Shows.AsNoTracking()
var stills = await dbContext
.Shows.AsNoTracking()
.SelectMany(s => s.Episodes)
.Where(e => e.StillImageId != null)
.Join(
dbContext.Images,
e => e.StillImageId,
i => i.Id,
(e, i) => new { EntityId = e.Id, ImageId = i.Id, i.FileExtension }
(e, i) =>
new
{
EntityId = e.Id,
ImageId = i.Id,
i.FileExtension,
}
)
.ToListAsync(cancellationToken);
foreach (var s in stills)
Relocate(paths.ImagePath(s.ImageId, s.FileExtension), paths.MetadataEpisodeStillPath(s.EntityId, s.FileExtension));
Relocate(
paths.ImagePath(s.ImageId, s.FileExtension),
paths.MetadataEpisodeStillPath(s.EntityId, s.FileExtension)
);
// Фоны блоков заставок: bumpers/{templateId}/background{ext} → images/{imageId}{ext}.
var backgrounds = await dbContext.Channels.AsNoTracking()
var backgrounds = await dbContext
.Channels.AsNoTracking()
.SelectMany(c => c.BumperTemplates)
.Where(t => t.BackgroundImageId != null)
.Join(
dbContext.Images,
t => t.BackgroundImageId,
i => i.Id,
(t, i) => new { EntityId = t.Id, ImageId = i.Id, i.FileExtension }
(t, i) =>
new
{
EntityId = t.Id,
ImageId = i.Id,
i.FileExtension,
}
)
.ToListAsync(cancellationToken);
foreach (var b in backgrounds)