Sube capa Infrastructure, Solution y archivos de configuracion del Backend

This commit is contained in:
FrancoRu
2026-09-18 13:36:47 -03:00
parent 2eb4eeef03
commit 1ef9a0bd03
205 changed files with 77651 additions and 0 deletions
+16
View File
@@ -0,0 +1,16 @@
**/bin/
**/obj/
**/.vs/
**/*.user
# Per-developer secrets (e.g. appsettings.Franco.json) are excluded; the
# glob also matches appsettings.Development.json, which the runtime image
# MUST still contain per the container-deployment spec, so it is
# explicitly re-included below. appsettings.json is never matched by this
# glob (it lacks the second ".") and always stays.
**/appsettings.*.json
!API/appsettings.Development.json
API.Tests/
Solution/
.git
Dockerfile
.dockerignore
+70
View File
@@ -0,0 +1,70 @@
# Club12 Backend — .editorconfig
#
# Codifies conventions the codebase already follows consistently (verified 2026-09-05
# by sampling across Domain/Application/Infrastructure/API), not aspirational new rules.
# One exception was found and deliberately left out below: const-field casing is mixed
# in practice (PascalCase almost everywhere, but Application/Utils/Constants/Stage/MaxTeams.cs
# uses SCREAMING_SNAKE_CASE) — picking a side wasn't part of this task, so no naming rule
# is enforced for constants here.
root = true
[*]
charset = utf-8
end_of_line = crlf
indent_style = space
indent_size = 4
insert_final_newline = true
trim_trailing_whitespace = true
[*.cs]
charset = utf-8-bom
# Allman braces (opening brace on its own line) — the only style seen in this codebase.
csharp_new_line_before_open_brace = all
csharp_new_line_before_else = true
csharp_new_line_before_catch = true
csharp_new_line_before_finally = true
# File-scoped namespaces are used everywhere.
csharp_style_namespace_declarations = file_scoped:warning
# Explicit types are used almost everywhere (`var` appears once in the whole backend) —
# this is a deliberate house style, not an oversight.
csharp_style_var_for_built_in_types = false:suggestion
csharp_style_var_when_type_is_apparent = false:suggestion
csharp_style_var_elsewhere = false:suggestion
# Plain alphabetical using order — System is not special-cased to the top.
dotnet_sort_system_directives_first = false
dotnet_separate_import_directive_groups = false
# Primary constructors are the established pattern for services/repositories with DI.
csharp_style_prefer_primary_constructors = true:suggestion
[*.{json,yml,yaml}]
indent_size = 2
[*.{csproj,props,targets}]
indent_size = 2
# Naming: interfaces and private fields — both 100% consistent across the sampled codebase.
dotnet_naming_rule.interface_should_be_prefixed_with_i.severity = warning
dotnet_naming_rule.interface_should_be_prefixed_with_i.symbols = interface_type
dotnet_naming_rule.interface_should_be_prefixed_with_i.style = prefix_i
dotnet_naming_symbols.interface_type.applicable_kinds = interface
dotnet_naming_symbols.interface_type.applicable_accessibilities = *
dotnet_naming_style.prefix_i.required_prefix = I
dotnet_naming_style.prefix_i.capitalization = pascal_case
dotnet_naming_rule.private_field_should_be_camel_case_with_underscore.severity = warning
dotnet_naming_rule.private_field_should_be_camel_case_with_underscore.symbols = private_field
dotnet_naming_rule.private_field_should_be_camel_case_with_underscore.style = underscore_camel_case
dotnet_naming_symbols.private_field.applicable_kinds = field
dotnet_naming_symbols.private_field.applicable_accessibilities = private
dotnet_naming_style.underscore_camel_case.required_prefix = _
dotnet_naming_style.underscore_camel_case.capitalization = camel_case
+10
View File
@@ -0,0 +1,10 @@
<Project>
<PropertyGroup>
<Version>1.0.0</Version>
<NoWarn>$(NoWarn);CS1591</NoWarn>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="SonarAnalyzer.CSharp" Version="9.32.0.97167" PrivateAssets="all" />
</ItemGroup>
</Project>
+32
View File
@@ -0,0 +1,32 @@
FROM mcr.microsoft.com/dotnet/sdk:8.0 AS build
WORKDIR /src
COPY API/API.csproj API/
COPY Application/Application.csproj Application/
COPY Domain/Domain.csproj Domain/
COPY Infrastructure/Infrastructure.csproj Infrastructure/
RUN dotnet restore API/API.csproj
COPY API/ API/
COPY Application/ Application/
COPY Domain/ Domain/
COPY Infrastructure/ Infrastructure/
RUN dotnet publish API/API.csproj -c Release -o /app/publish --no-restore /p:UseAppHost=false
FROM mcr.microsoft.com/dotnet/aspnet:8.0 AS runtime
RUN apt-get update \
&& apt-get install -y --no-install-recommends curl ca-certificates gnupg \
&& install -d /usr/share/postgresql-common/pgdg \
&& curl -o /usr/share/postgresql-common/pgdg/apt.postgresql.org.asc --fail https://www.postgresql.org/media/keys/ACCC4CF8.asc \
&& echo "deb [signed-by=/usr/share/postgresql-common/pgdg/apt.postgresql.org.asc] https://apt.postgresql.org/pub/repos/apt $(. /etc/os-release && echo $VERSION_CODENAME)-pgdg main" > /etc/apt/sources.list.d/pgdg.list \
&& apt-get update \
&& apt-get install -y --no-install-recommends postgresql-client-17 \
&& rm -rf /var/lib/apt/lists/*
WORKDIR /app
COPY --from=build /app/publish .
ENV ASPNETCORE_ENVIRONMENT=Production \
ASPNETCORE_HTTP_PORTS=8080
EXPOSE 8080
RUN mkdir -p /app/backups && chown $APP_UID:$APP_UID /app/backups
USER $APP_UID
HEALTHCHECK --interval=30s --timeout=5s --start-period=60s --retries=3 \
CMD curl -fsS http://localhost:8080/health || exit 1
ENTRYPOINT ["dotnet", "API.dll"]
@@ -0,0 +1,90 @@
using Application.Interfaces.Backup;
using Microsoft.Extensions.Logging;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Threading;
using System.Threading.Tasks;
namespace Infrastructure.Backup;
/// <summary>
/// IBackupStorage implementation backed by a local or mounted directory, used as the fallback storage adapter when Supabase storage is not configured.
/// </summary>
public sealed class LocalDirectoryBackupStorage : IBackupStorage
{
private readonly string _directoryPath;
private readonly ILogger<LocalDirectoryBackupStorage> _logger;
public LocalDirectoryBackupStorage(string directoryPath, ILogger<LocalDirectoryBackupStorage> logger)
{
ArgumentException.ThrowIfNullOrWhiteSpace(directoryPath);
_logger = logger;
_directoryPath = Path.GetFullPath(directoryPath);
Directory.CreateDirectory(_directoryPath);
}
public async Task StoreAsync(string name, Stream content, CancellationToken ct = default)
{
string path = ResolveSafePath(name);
await using FileStream file = File.Create(path);
await content.CopyToAsync(file, ct);
}
public Task<IReadOnlyList<BackupFile>> ListAsync(CancellationToken ct = default)
{
IReadOnlyList<BackupFile> files = Directory.EnumerateFiles(_directoryPath)
.Select(path => new BackupFile(
Path.GetFileName(path),
new DateTimeOffset(File.GetLastWriteTimeUtc(path), TimeSpan.Zero)))
.ToList();
return Task.FromResult(files);
}
public Task<Stream> OpenReadAsync(string name, CancellationToken ct = default)
{
string path = ResolveSafePath(name);
Stream stream = File.OpenRead(path);
return Task.FromResult(stream);
}
public Task DeleteAsync(string name, CancellationToken ct = default)
{
string path = ResolveSafePath(name);
if (File.Exists(path))
{
File.Delete(path);
}
else
{
_logger.LogWarning("DeleteAsync called for a backup that no longer exists: {Name}", name);
}
return Task.CompletedTask;
}
/// <summary>
/// Resolves name against the configured directory and throws ArgumentException unless the resolved path stays strictly inside it.
/// </summary>
private string ResolveSafePath(string name)
{
if (string.IsNullOrWhiteSpace(name) || Path.IsPathRooted(name))
{
throw new ArgumentException("Backup file name must be a non-empty, relative name.", nameof(name));
}
string fullPath = Path.GetFullPath(Path.Combine(_directoryPath, name));
string prefix = _directoryPath.EndsWith(Path.DirectorySeparatorChar)
? _directoryPath
: _directoryPath + Path.DirectorySeparatorChar;
return !fullPath.StartsWith(prefix, StringComparison.Ordinal)
? throw new ArgumentException(
$"Backup file name '{name}' resolves outside the configured backup directory.", nameof(name))
: fullPath;
}
}
@@ -0,0 +1,97 @@
using Application.Interfaces.Backup;
using Application.Utils.Constants.Configuration;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.Logging;
using Infrastructure.Persistance;
using Npgsql;
using System.Collections.Generic;
using System.IO;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading;
using System.Threading.Tasks;
namespace Infrastructure.Backup;
/// <summary>
/// IDatabaseBackupService implementation that shells out to pg_dump via IProcessRunner, passing connection details as a discrete argument vector instead of a shell command string.
/// </summary>
public sealed class PgDumpBackupService(
IProcessRunner processRunner,
IConfiguration configuration,
ILogger<PgDumpBackupService> logger) : IDatabaseBackupService
{
/// <summary>
/// Matches a CREATE, DROP, ALTER, or COMMENT ON EVENT TRIGGER statement so it can be stripped from the dump before restore.
/// </summary>
private static readonly Regex EventTriggerStatementPattern = new(
@"^\s*(CREATE|DROP|ALTER|COMMENT\s+ON)\s+EVENT\s+TRIGGER\b.*?;\s*$",
RegexOptions.IgnoreCase | RegexOptions.Multiline | RegexOptions.Singleline | RegexOptions.Compiled);
public async Task<Stream> CreateDumpAsync(CancellationToken ct = default)
{
string connectionString = configuration.GetConnectionString(ConfigurationKeys.DbConnection)
?? throw new BackupExecutionException(
$"ConnectionStrings:{ConfigurationKeys.DbConnection} is not configured.");
string? configuredPgDumpPath = configuration[ConfigurationKeys.Backup.PgDumpPath];
string pgDumpPath = string.IsNullOrWhiteSpace(configuredPgDumpPath) ? "pg_dump" : configuredPgDumpPath;
NpgsqlConnectionStringBuilder builder = new(connectionString);
List<string> args =
[
"-h", builder.Host ?? "localhost",
"-p", builder.Port.ToString(),
"-U", builder.Username ?? string.Empty,
"-d", builder.Database ?? string.Empty,
// These flags shift ownership and role safety to the dump so restoring into a Supabase-managed database with different owners does not fail on CREATE or ALTER OWNER statements.
"--clean", "--if-exists", "--no-owner", "--no-privileges",
// Restricting to public and Club12 schemas keeps pg_dump from capturing Supabase-platform-owned objects the app's role doesn't own, which would make --clean's DROP fail on restore.
// Club12 must be double-quoted because pg_dump's -n pattern matching lowercases an unquoted argument before comparing it against the catalog, and the schema's real name is mixed-case, so an unquoted argument silently matches nothing.
"-n", "public", "-n", $"\"{EntityConstants.Schema}\"",
];
Dictionary<string, string>? environmentVariables = null;
if (!string.IsNullOrEmpty(builder.Password))
{
environmentVariables = new Dictionary<string, string>
{
["PGPASSWORD"] = builder.Password,
};
}
ProcessResult result = await processRunner.RunAsync(pgDumpPath, args, environmentVariables, ct);
if (result.ExitCode != 0)
{
logger.LogError(
"pg_dump failed with exit code {ExitCode}. Path: '{PgDumpPath}'. StdErr: {StdErr}",
result.ExitCode, pgDumpPath, result.StdErr);
throw new BackupExecutionException(
$"pg_dump failed (exit code {result.ExitCode}) using '{pgDumpPath}'. " +
"Verify pg_dump is installed and on PATH, or set Backup:PgDumpPath to its full path. " +
$"Details: {result.StdErr}");
}
int strippedCount = EventTriggerStatementPattern.Matches(result.StdOut).Count;
string filteredDump = EventTriggerStatementPattern.Replace(result.StdOut, string.Empty);
if (strippedCount > 0)
{
logger.LogInformation(
"Stripped {Count} EVENT TRIGGER statement(s) from the pg_dump output — these are " +
"Supabase/PostgREST-managed infrastructure objects the app does not own and cannot " +
"DROP/CREATE on restore.",
strippedCount);
}
return new MemoryStream(Encoding.UTF8.GetBytes(filteredDump));
}
}
@@ -0,0 +1,64 @@
using Application.Interfaces.Backup;
using System.Collections.Generic;
using System.ComponentModel;
using System.Diagnostics;
using System.Threading;
using System.Threading.Tasks;
namespace Infrastructure.Backup;
/// <summary>
/// IProcessRunner adapter backed by Process that passes arguments via ArgumentList instead of a concatenated shell command string.
/// </summary>
public sealed class ProcessRunner : IProcessRunner
{
public async Task<ProcessResult> RunAsync(
string fileName,
IReadOnlyList<string> args,
IReadOnlyDictionary<string, string>? environmentVariables = null,
CancellationToken ct = default)
{
ProcessStartInfo startInfo = new()
{
FileName = fileName,
RedirectStandardOutput = true,
RedirectStandardError = true,
UseShellExecute = false,
CreateNoWindow = true,
};
foreach (string arg in args)
{
startInfo.ArgumentList.Add(arg);
}
if (environmentVariables is not null)
{
foreach (KeyValuePair<string, string> kvp in environmentVariables)
{
startInfo.Environment[kvp.Key] = kvp.Value;
}
}
using Process process = new() { StartInfo = startInfo };
try
{
process.Start();
}
catch (Win32Exception ex)
{
return new ProcessResult(-1, string.Empty, $"Failed to start process '{fileName}': {ex.Message}");
}
Task<string> stdOutTask = process.StandardOutput.ReadToEndAsync(ct);
Task<string> stdErrTask = process.StandardError.ReadToEndAsync(ct);
await process.WaitForExitAsync(ct);
string stdOut = await stdOutTask;
string stdErr = await stdErrTask;
return new ProcessResult(process.ExitCode, stdOut, stdErr);
}
}
@@ -0,0 +1,68 @@
using Application.Interfaces.Backup;
using Application.Utils.Constants.Configuration;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.Logging;
using Npgsql;
using System.Collections.Generic;
using System.Threading;
using System.Threading.Tasks;
namespace Infrastructure.Backup;
/// <summary>
/// IDatabaseRestoreService implementation that shells out to psql via IProcessRunner because pg_dump produces plain SQL, which only psql can replay.
/// </summary>
public sealed class PsqlDatabaseRestoreService(
IProcessRunner processRunner,
IConfiguration configuration,
ILogger<PsqlDatabaseRestoreService> logger) : IDatabaseRestoreService
{
public async Task RestoreAsync(string dumpFilePath, CancellationToken ct = default)
{
string connectionString = configuration.GetConnectionString(ConfigurationKeys.DbConnection)
?? throw new BackupExecutionException(
$"ConnectionStrings:{ConfigurationKeys.DbConnection} is not configured.");
string? configuredPsqlPath = configuration[ConfigurationKeys.Backup.PsqlPath];
string psqlPath = string.IsNullOrWhiteSpace(configuredPsqlPath) ? "psql" : configuredPsqlPath;
NpgsqlConnectionStringBuilder builder = new(connectionString);
List<string> args =
[
"-h", builder.Host ?? "localhost",
"-p", builder.Port.ToString(),
"-U", builder.Username ?? string.Empty,
"-d", builder.Database ?? string.Empty,
// ON_ERROR_STOP=1 turns the first SQL error in the dump into a non-zero exit code instead of continuing silently, so a partial or failed restore is detected instead of reported as success.
"-v", "ON_ERROR_STOP=1",
"-f", dumpFilePath,
];
Dictionary<string, string>? environmentVariables = null;
if (!string.IsNullOrEmpty(builder.Password))
{
environmentVariables = new Dictionary<string, string>
{
["PGPASSWORD"] = builder.Password,
};
}
ProcessResult result = await processRunner.RunAsync(psqlPath, args, environmentVariables, ct);
if (result.ExitCode != 0)
{
logger.LogError(
"psql restore failed with exit code {ExitCode}. Path: '{PsqlPath}'. StdErr: {StdErr}",
result.ExitCode, psqlPath, result.StdErr);
throw new BackupExecutionException(
$"psql restore failed (exit code {result.ExitCode}) using '{psqlPath}'. " +
"Verify psql is installed and on PATH, or set Backup:PsqlPath to its full path. " +
$"Details: {result.StdErr}");
}
}
}
@@ -0,0 +1,105 @@
using Application.Interfaces.Backup;
using Application.Utils.Helper.SupabaseHelper;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Threading;
using System.Threading.Tasks;
namespace Infrastructure.Backup;
/// <summary>
/// IBackupStorage implementation that reuses the existing Supabase client and credentials through ISupabaseRawStorage instead of provisioning a second Supabase client.
/// </summary>
public sealed class SupabaseBackupStorage(ISupabaseRawStorage rawStorage) : IBackupStorage
{
private const string Prefix = "backups/";
public async Task StoreAsync(string name, Stream content, CancellationToken ct = default)
{
string objectPath = ToObjectPath(name);
try
{
await rawStorage.UploadRawAsync(objectPath, content);
}
catch (Exception ex)
{
throw new BackupExecutionException(
$"Failed to upload backup '{name}' to Supabase storage: {ex.Message}", ex);
}
}
public async Task<Stream> OpenReadAsync(string name, CancellationToken ct = default)
{
string objectPath = ToObjectPath(name);
try
{
byte[] bytes = await rawStorage.DownloadRawAsync(objectPath);
return new MemoryStream(bytes);
}
catch (Exception ex)
{
throw new BackupExecutionException(
$"Failed to download backup '{name}' from Supabase storage: {ex.Message}", ex);
}
}
public async Task<IReadOnlyList<BackupFile>> ListAsync(CancellationToken ct = default)
{
try
{
IReadOnlyList<SupabaseStorageEntry> entries = await rawStorage.ListRawAsync(Prefix);
return entries
.Where(entry => !string.IsNullOrEmpty(entry.Name))
.Select(entry => new BackupFile(entry.Name, entry.UpdatedAt ?? DateTimeOffset.MinValue))
.ToList();
}
catch (Exception ex)
{
throw new BackupExecutionException($"Failed to list Supabase backups: {ex.Message}", ex);
}
}
public async Task DeleteAsync(string name, CancellationToken ct = default)
{
string objectPath = ToObjectPath(name);
try
{
await rawStorage.RemoveRawAsync(objectPath);
}
catch (Exception ex)
{
throw new BackupExecutionException(
$"Failed to delete backup '{name}' from Supabase storage: {ex.Message}", ex);
}
}
/// <summary>
/// Resolves name against the backups/ prefix and throws ArgumentException unless it is a simple, non-rooted, non-traversing relative name.
/// </summary>
private static string ToObjectPath(string name)
{
if (string.IsNullOrWhiteSpace(name))
{
throw new ArgumentException("Backup file name must be non-empty.", nameof(name));
}
if (Path.IsPathRooted(name))
{
throw new ArgumentException(
$"Backup file name '{name}' must be a relative name, not a rooted path.", nameof(name));
}
string normalized = name.Replace('\\', '/');
string[] segments = normalized.Split('/', StringSplitOptions.RemoveEmptyEntries);
return segments.Length == 0 || Array.Exists(segments, segment => segment is ".." or ".")
? throw new ArgumentException(
$"Backup file name '{name}' resolves outside the configured '{Prefix}' prefix.", nameof(name))
: Prefix + normalized;
}
}
@@ -0,0 +1,40 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Reflection;
namespace Infrastructure.Email;
/// <summary>
/// Loads HTML email templates from embedded resources and replaces named tokens with their corresponding values.
/// </summary>
internal static class EmailTemplateLoader
{
private static readonly Assembly _assembly = typeof(EmailTemplateLoader).Assembly;
/// <summary>
/// Reads the template file and replaces every key in tokens with its corresponding value.
/// </summary>
/// <param name="templateName">
/// File name without extension.
/// The file must be at Utils/Helper/Email/Templates/{templateName}.html
/// and marked as EmbeddedResource.
/// </param>
/// <param name="tokens">Dictionary of {{Token}} → replacement value pairs.</param>
public static string Render(string templateName, Dictionary<string, string> tokens)
{
string resourceName =
$"Infrastructure.Email.Templates.{templateName}.html";
using Stream? stream = _assembly.GetManifestResourceStream(resourceName) ?? throw new InvalidOperationException(
$"Email template '{templateName}' not found as embedded resource. " +
$"Ensure the file exists at 'Email/Templates/{templateName}.html' " +
$"and is marked as <EmbeddedResource> in the Infrastructure.csproj.");
using StreamReader reader = new(stream);
string template = reader.ReadToEnd();
return tokens.Aggregate(template,
(current, token) => current.Replace(token.Key, token.Value));
}
}
@@ -0,0 +1,82 @@
using Application.Interfaces.Services;
using FluentEmail.Core;
using FluentEmail.Core.Models;
using System;
using System.Threading;
using System.Threading.Tasks;
namespace Infrastructure.Email;
/// <summary>
/// Transactional email sender backed by FluentEmail and SendGrid.
/// </summary>
public sealed class FluentEmailHelper(IFluentEmailFactory emailFactory) : IEmailService
{
public async Task SendPasswordResetAsync(
string toEmail, string toUsername, string resetLink,
CancellationToken ct = default)
{
string body = EmailTemplateLoader.Render("PasswordResetTemplate", new()
{
["{{Username}}"] = toUsername,
["{{ResetLink}}"] = resetLink,
});
SendResponse result = await emailFactory.Create()
.To(toEmail)
.Subject("Restablecimiento de contraseña - Club12")
.Body(body, isHtml: true)
.SendAsync(ct);
ThrowIfFailed(result, "password reset");
}
public async Task SendWelcomeSetPasswordAsync(
string toEmail, string toUsername, string setPasswordLink,
CancellationToken ct = default)
{
string body = EmailTemplateLoader.Render("WelcomeSetPasswordTemplate", new()
{
["{{Username}}"] = toUsername,
["{{SetPasswordLink}}"] = setPasswordLink,
});
SendResponse result = await emailFactory.Create()
.To(toEmail)
.Subject("Activá tu cuenta - Club12")
.Body(body, isHtml: true)
.SendAsync(ct);
ThrowIfFailed(result, "welcome set-password");
}
public async Task SendMagicLinkAsync(
string toEmail, string toUsername, string magicLink,
CancellationToken ct = default)
{
string body = EmailTemplateLoader.Render("MagicLinkTemplate", new()
{
["{{Username}}"] = toUsername,
["{{MagicLink}}"] = magicLink,
});
SendResponse result = await emailFactory.Create()
.To(toEmail)
.Subject("Tu enlace de acceso - Club12")
.Body(body, isHtml: true)
.SendAsync(ct);
ThrowIfFailed(result, "magic link");
}
private static void ThrowIfFailed(SendResponse result, string context)
{
if (!result.Successful)
{
throw new InvalidOperationException(
$"Failed to send {context} email: {string.Join(", ", result.ErrorMessages)}");
}
}
}
@@ -0,0 +1,67 @@
<!DOCTYPE html>
<html lang="es">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
</head>
<body style="margin:0;padding:0;background:#f4f4f5;
font-family:-apple-system,BlinkMacSystemFont,'Segoe UI',sans-serif;">
<table width="100%" cellpadding="0" cellspacing="0">
<tr>
<td align="center" style="padding:40px 16px;">
<table width="480" cellpadding="0" cellspacing="0"
style="background:#fff;border-radius:8px;overflow:hidden;
box-shadow:0 1px 3px rgba(0,0,0,.1);">
<!-- Header -->
<tr>
<td style="background:#10b981;padding:24px 32px;">
<h1 style="margin:0;color:#fff;font-size:20px;font-weight:700;
letter-spacing:-.3px;">
Club12
</h1>
</td>
</tr>
<!-- Body -->
<tr>
<td style="padding:32px;">
<h2 style="margin:0 0 16px;color:#111;font-size:18px;font-weight:600;">
Tu enlace de acceso
</h2>
<p style="margin:0 0 12px;color:#444;line-height:1.7;font-size:14px;">
Hola, <strong>{{Username}}</strong>.
</p>
<p style="margin:0 0 12px;color:#444;line-height:1.7;font-size:14px;">
Tu enlace de acceso a <strong>Club12</strong> está listo.
Hacé clic en el botón para ingresar a tu cuenta.
</p>
<p style="margin:0 0 28px;color:#e55;font-size:13px;font-weight:600;">
⚠ Este enlace expira en 15 minutos y es de un solo uso.
</p>
<a href="{{MagicLink}}"
style="display:inline-block;padding:12px 28px;background:#10b981;
color:#fff;border-radius:6px;text-decoration:none;
font-weight:600;font-size:14px;">
Ingresar a Club12
</a>
</td>
</tr>
<!-- Footer -->
<tr>
<td style="padding:16px 32px;background:#f9fafb;
border-top:1px solid #e5e7eb;">
<p style="margin:0;color:#9ca3af;font-size:12px;line-height:1.6;">
Si no solicitaste este enlace, podés ignorarlo de forma segura.<br />
Nadie puede ingresar a tu cuenta sin hacer clic en él.
</p>
</td>
</tr>
</table>
</td>
</tr>
</table>
</body>
</html>
@@ -0,0 +1,68 @@
<!DOCTYPE html>
<html lang="es">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
</head>
<body style="margin:0;padding:0;background:#f4f4f5;
font-family:-apple-system,BlinkMacSystemFont,'Segoe UI',sans-serif;">
<table width="100%" cellpadding="0" cellspacing="0">
<tr>
<td align="center" style="padding:40px 16px;">
<table width="480" cellpadding="0" cellspacing="0"
style="background:#fff;border-radius:8px;overflow:hidden;
box-shadow:0 1px 3px rgba(0,0,0,.1);">
<!-- Header -->
<tr>
<td style="background:#0070f3;padding:24px 32px;">
<h1 style="margin:0;color:#fff;font-size:20px;font-weight:700;
letter-spacing:-.3px;">
Club12
</h1>
</td>
</tr>
<!-- Body -->
<tr>
<td style="padding:32px;">
<h2 style="margin:0 0 16px;color:#111;font-size:18px;font-weight:600;">
Restablecimiento de contraseña
</h2>
<p style="margin:0 0 12px;color:#444;line-height:1.7;font-size:14px;">
Hola, <strong>{{Username}}</strong>.
</p>
<p style="margin:0 0 12px;color:#444;line-height:1.7;font-size:14px;">
Un administrador ha solicitado el restablecimiento de tu contraseña
en <strong>Club12</strong>. Hacé clic en el botón para establecer
una nueva contraseña.
</p>
<p style="margin:0 0 28px;color:#e55;font-size:13px;font-weight:600;">
⚠ Este enlace expira en 24 horas.
</p>
<a href="{{ResetLink}}"
style="display:inline-block;padding:12px 28px;background:#0070f3;
color:#fff;border-radius:6px;text-decoration:none;
font-weight:600;font-size:14px;">
Restablecer contraseña
</a>
</td>
</tr>
<!-- Footer -->
<tr>
<td style="padding:16px 32px;background:#f9fafb;
border-top:1px solid #e5e7eb;">
<p style="margin:0;color:#9ca3af;font-size:12px;line-height:1.6;">
Si no esperabas este correo, podés ignorarlo de forma segura.<br />
No se realizarán cambios hasta que uses el enlace.
</p>
</td>
</tr>
</table>
</td>
</tr>
</table>
</body>
</html>
@@ -0,0 +1,56 @@
<!DOCTYPE html>
<html lang="es">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
</head>
<body style="margin:0;padding:0;background:#f4f4f5;
font-family:-apple-system,BlinkMacSystemFont,'Segoe UI',sans-serif;">
<table width="100%" cellpadding="0" cellspacing="0">
<tr>
<td align="center" style="padding:40px 16px;">
<table width="480" cellpadding="0" cellspacing="0"
style="background:#fff;border-radius:8px;overflow:hidden;
box-shadow:0 1px 3px rgba(0,0,0,.1);">
<tr>
<td style="background:#0070f3;padding:24px 32px;">
<h1 style="margin:0;color:#fff;font-size:20px;font-weight:700;">
Club12
</h1>
</td>
</tr>
<tr>
<td style="padding:32px;">
<h2 style="margin:0 0 16px;color:#111;font-size:18px;font-weight:600;">
Tu cuenta fue creada
</h2>
<p style="margin:0 0 12px;color:#444;line-height:1.7;font-size:14px;">
Hola, <strong>{{Username}}</strong>.
</p>
<p style="margin:0 0 12px;color:#444;line-height:1.7;font-size:14px;">
Tu cuenta en <strong>Club12</strong> fue creada con una contraseña temporal.
Para activar el acceso, definí tu nueva contraseña desde el siguiente enlace.
</p>
<a href="{{SetPasswordLink}}"
style="display:inline-block;padding:12px 28px;background:#0070f3;
color:#fff;border-radius:6px;text-decoration:none;
font-weight:600;font-size:14px;">
Definir contraseña
</a>
</td>
</tr>
<tr>
<td style="padding:16px 32px;background:#f9fafb;border-top:1px solid #e5e7eb;">
<p style="margin:0;color:#9ca3af;font-size:12px;line-height:1.6;">
Si no esperabas este correo, podés ignorarlo.
</p>
</td>
</tr>
</table>
</td>
</tr>
</table>
</body>
</html>
@@ -0,0 +1,30 @@
using Microsoft.AspNetCore.Identity;
using System;
namespace Infrastructure.Identity;
/// <summary>
/// Identity user for authentication, kept separate from domain entities.
/// </summary>
public class ApplicationUser : IdentityUser<Guid>
{
/// <summary>
/// Opaque refresh token stored server-side.
/// </summary>
public string? RefreshToken { get; set; }
/// <summary>
/// UTC expiry for the stored refresh token.
/// </summary>
public DateTime? RefreshTokenExpiryTime { get; set; }
/// <summary>
/// The Id of the OWNER who registered this account, when it was created by an owner rather than an admin.
/// </summary>
public Guid? CreatedByOwnerId { get; set; }
public DateTime DateCreated { get; set; } = DateTime.UtcNow;
public bool MustChangePassword { get; set; }
}
@@ -0,0 +1,49 @@
using Domain.Enums;
using Microsoft.AspNetCore.Identity;
using Microsoft.AspNetCore.Identity.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore;
using System;
namespace Infrastructure.Identity;
/// <summary>
/// EF Core context for ASP.NET Core Identity tables, generating AspNetUsers, AspNetRoles, and related tables.
/// </summary>
public class IdentityAppDbContext(DbContextOptions<IdentityAppDbContext> options)
: IdentityDbContext<ApplicationUser, IdentityRole<Guid>, Guid>(options)
{
protected override void OnModelCreating(ModelBuilder builder)
{
base.OnModelCreating(builder);
builder.Entity<ApplicationUser>()
.HasIndex(u => u.NormalizedEmail)
.IsUnique();
SeedRoles(builder);
}
private static void SeedRoles(ModelBuilder builder)
{
// Seed values 3 and 4 are intentionally skipped because the former TournamentManager and TeamManager roles were removed; Guest keeps its original seed value 5 so its role Id stays stable.
builder.Entity<IdentityRole<Guid>>().HasData(
CreateRole(1, UserRoleType.ADMIN),
CreateRole(2, UserRoleType.OWNER),
CreateRole(5, UserRoleType.GUEST)
);
}
private static IdentityRole<Guid> CreateRole(int seed, UserRoleType roleType)
{
string name = roleType.ToRoleName();
return new IdentityRole<Guid>
{
Id = new Guid($"00000000-0000-0000-0000-{seed:D12}"),
Name = name,
NormalizedName = name.ToUpperInvariant(),
ConcurrencyStamp = seed.ToString()
};
}
}
@@ -0,0 +1,78 @@
using Application.Utils.Constants.Configuration;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Design;
using Microsoft.Extensions.Configuration;
using System;
using System.IO;
using System.Linq;
namespace Infrastructure.Identity;
/// <summary>
/// Provides a design-time instance of IdentityAppDbContext for EF Core CLI tools.
/// </summary>
public sealed class IdentityAppDbContextFactory : IDesignTimeDbContextFactory<IdentityAppDbContext>
{
/// <summary>
/// Builds configuration the same way WebApplication.CreateBuilder does at runtime, with later appsettings files overriding earlier ones.
/// </summary>
public IdentityAppDbContext CreateDbContext(string[] args)
{
string basePath = ResolveBasePath();
string aspNetEnv = Environment.GetEnvironmentVariable("ASPNETCORE_ENVIRONMENT")
?? "Development";
ConfigurationBuilder builder = new();
builder.SetBasePath(basePath);
builder.AddJsonFile("appsettings.json", optional: true);
builder.AddJsonFile($"appsettings.{aspNetEnv}.json", optional: true);
if (Directory.Exists(basePath))
{
string?[] extras = Directory
.GetFiles(basePath, "appsettings.*.json")
.Select(Path.GetFileName)
.Where(f => !string.Equals(
f, $"appsettings.{aspNetEnv}.json",
StringComparison.OrdinalIgnoreCase))
.ToArray();
foreach (string? file in extras)
{
builder.AddJsonFile(file!, optional: true);
}
}
IConfigurationRoot config = builder.Build();
string connectionString = config.GetConnectionString(ConfigurationKeys.DbConnection)
?? throw new InvalidOperationException(
$"Connection string '{ConfigurationKeys.DbConnection}' not found.\n" +
$"Searched in: {basePath}\n" +
$"Files loaded: appsettings.json, appsettings.{aspNetEnv}.json + all appsettings.*.json");
DbContextOptionsBuilder<IdentityAppDbContext> optionsBuilder = new();
optionsBuilder.UseNpgsql(connectionString);
return new IdentityAppDbContext(optionsBuilder.Options);
}
private static string ResolveBasePath()
{
string current = Directory.GetCurrentDirectory();
string[] candidates =
[
current,
Path.Combine(current, "API"),
Path.Combine(current, "..", "API"),
];
string? match = Array.Find(candidates, path => File.Exists(Path.Combine(path, "appsettings.json")));
return match is null ? current : Path.GetFullPath(match);
}
}
@@ -0,0 +1,401 @@
using Application.DTOs.Auth.Request;
using Application.DTOs.Auth.Response;
using Application.Interfaces.Services;
using Application.Utils.Constants;
using Application.Utils.Constants.Auth;
using Application.Utils.Constants.Configuration;
using Domain.Enums;
using Microsoft.AspNetCore.Identity;
using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.Configuration;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Security.Claims;
using System.Security.Cryptography;
using System.Threading;
using System.Threading.Tasks;
namespace Infrastructure.Identity;
/// <summary>
/// Infrastructure implementation of IAuthenticationService backed by ASP.NET Core Identity.
/// </summary>
public sealed class IdentityAuthenticationService(
UserManager<ApplicationUser> userManager,
IAuthService authService,
IEmailService emailService,
IConfiguration configuration) : IAuthenticationService
{
private const string MagicLinkPurpose = "MagicLink";
private const int RefreshExpiryDays = 7;
private static readonly Dictionary<string, HashSet<string>> _creationPolicy =
new(StringComparer.OrdinalIgnoreCase)
{
[UserRoleType.ADMIN.ToRoleName()] = new(StringComparer.OrdinalIgnoreCase)
{
UserRoleType.ADMIN.ToRoleName(),
UserRoleType.OWNER.ToRoleName()
},
[UserRoleType.OWNER.ToRoleName()] = new(StringComparer.OrdinalIgnoreCase)
{
UserRoleType.ADMIN.ToRoleName(),
UserRoleType.OWNER.ToRoleName()
}
};
/// <inheritdoc/>
public async Task<RegisterUserResponse> RegisterAsync(
RegisterUserRequest request, string callerRole, Guid callerId, CancellationToken ct = default)
{
EnforceCreationPolicy(callerRole, request.Role);
ApplicationUser? existing = await userManager.FindByEmailAsync(request.Email);
if (existing is not null)
{
throw new InvalidOperationException(ErrorMessages.Auth.EmailAlreadyExists);
}
ApplicationUser user = new()
{
UserName = request.Username,
Email = request.Email,
EmailConfirmed = true,
PhoneNumber = request.Phone,
CreatedByOwnerId = IsOwner(callerRole) ? callerId : null,
MustChangePassword = true
};
string temporaryPassword = GenerateTemporaryPassword();
IdentityResult result = await userManager.CreateAsync(user, temporaryPassword);
if (!result.Succeeded)
{
string errors = string.Join(" | ", result.Errors.Select(e => e.Description));
throw new InvalidOperationException(ErrorMessages.Auth.UserCreationFailed(errors));
}
await userManager.AddToRoleAsync(user, request.Role.ToUpperInvariant());
string token = await userManager.GeneratePasswordResetTokenAsync(user);
string frontendUrl = configuration[ConfigurationKeys.Frontend.PasswordResetUrl]
?? throw new InvalidOperationException(
ErrorMessages.Configuration.KeyNotConfigured(ConfigurationKeys.Frontend.PasswordResetUrl));
string setPasswordLink =
$"{frontendUrl}" +
$"?email={Uri.EscapeDataString(user.Email!)}" +
$"&token={Uri.EscapeDataString(token)}";
await emailService.SendWelcomeSetPasswordAsync(user.Email!, user.UserName!, setPasswordLink, ct);
return new RegisterUserResponse(
user.Id, user.Email!, user.UserName!, request.Role.ToUpperInvariant(), user.PhoneNumber);
}
/// <inheritdoc/>
public async Task<InviteUserResponse> InviteUserAsync(
InviteUserRequest request, string callerRole, Guid callerId, CancellationToken ct = default)
{
EnforceCreationPolicy(callerRole, request.Role);
ApplicationUser? existing = await userManager.FindByEmailAsync(request.Email);
if (existing is not null)
{
throw new InvalidOperationException(ErrorMessages.Auth.EmailAlreadyExists);
}
// No password is set for an invited account; UserName mirrors the email since Identity requires a unique UserName, and MustChangePassword keeps the account gated until activation completes.
ApplicationUser user = new()
{
UserName = request.Email,
Email = request.Email,
EmailConfirmed = true,
PhoneNumber = request.Phone,
CreatedByOwnerId = IsOwner(callerRole) ? callerId : null,
MustChangePassword = true
};
IdentityResult result = await userManager.CreateAsync(user);
if (!result.Succeeded)
{
string errors = string.Join(" | ", result.Errors.Select(e => e.Description));
throw new InvalidOperationException(ErrorMessages.Auth.UserCreationFailed(errors));
}
await userManager.AddToRoleAsync(user, request.Role.ToUpperInvariant());
// The activation token is a standard Identity password-reset token, which works on a passwordless account because it derives from the SecurityStamp rather than an existing password, and it is later verified by ActivateAccountAsync's ResetPasswordAsync call.
string token = await userManager.GeneratePasswordResetTokenAsync(user);
string activationLink = BuildTokenLink(user.Email!, token, activation: true);
await emailService.SendWelcomeSetPasswordAsync(user.Email!, user.UserName!, activationLink, ct);
return new InviteUserResponse(user.Id, user.Email!, request.Role.ToUpperInvariant());
}
/// <inheritdoc/>
public async Task<TokenResponse> ActivateAccountAsync(
ActivateAccountRequest request, CancellationToken ct = default)
{
ApplicationUser user = await userManager.FindByEmailAsync(request.Email)
?? throw new UnauthorizedAccessException(ErrorMessages.Auth.InvalidPasswordResetRequest);
// ResetPasswordAsync sets the password hash whether or not one already existed, so it doubles as the first password set for an invited, passwordless account.
IdentityResult result = await userManager.ResetPasswordAsync(
user, request.Token, request.NewPassword);
if (!result.Succeeded)
{
throw new InvalidOperationException(
string.Join("; ", result.Errors.Select(e => e.Description)));
}
user.MustChangePassword = false;
await userManager.UpdateAsync(user);
IList<string> roles = await userManager.GetRolesAsync(user);
return await BuildTokenResponseAsync(user, roles, ct);
}
/// <inheritdoc/>
public async Task RequestPasswordResetAsync(
RequestPasswordResetRequest request, CancellationToken ct = default)
{
ApplicationUser? user = await userManager.FindByEmailAsync(request.Email);
// Silently no-op for an unknown email so the endpoint never reveals which addresses have accounts.
if (user is null)
{
return;
}
string token = await userManager.GeneratePasswordResetTokenAsync(user);
string resetLink = BuildTokenLink(user.Email!, token, activation: false);
await emailService.SendPasswordResetAsync(user.Email!, user.UserName!, resetLink, ct);
}
/// <inheritdoc/>
public async Task<TokenResponse> LoginAsync(LogInUserRequest request, CancellationToken ct = default)
{
ApplicationUser user = await userManager.FindByEmailAsync(request.Email)
?? throw new UnauthorizedAccessException(ErrorMessages.Auth.InvalidCredentials);
if (!await userManager.CheckPasswordAsync(user, request.Password))
{
throw new UnauthorizedAccessException(ErrorMessages.Auth.InvalidCredentials);
}
if (await userManager.IsLockedOutAsync(user))
{
throw new UnauthorizedAccessException(ErrorMessages.Auth.AccountDeactivated);
}
// The role model is now just the two password-based operator accounts; the former TeamManager-only magic-link gate was removed along with that role.
IList<string> roles = await userManager.GetRolesAsync(user);
return await BuildTokenResponseAsync(user, roles, ct);
}
/// <inheritdoc/>
public async Task<MagicLinkResponse> RequestMagicLinkAsync(
MagicLinkRequest request, CancellationToken ct = default)
{
ApplicationUser user = await userManager.FindByEmailAsync(request.Email)
?? throw new KeyNotFoundException(ErrorMessages.Auth.NoAccountForEmail);
// Magic-link was the TeamManager-only auth path; that role no longer exists and the flow is deferred, so the role gate was dropped but the token flow itself is left in place for future use.
string token = await userManager.GenerateUserTokenAsync(
user, TokenOptions.DefaultEmailProvider, MagicLinkPurpose);
string magicLink =
$"/api/auth/magic-link/login" +
$"?email={Uri.EscapeDataString(user.Email!)}" +
$"&token={Uri.EscapeDataString(token)}";
return new MagicLinkResponse("Magic link generated. Check your email.", magicLink);
}
/// <inheritdoc/>
public async Task<TokenResponse> MagicLinkLoginAsync(
MagicLinkLoginRequest request, CancellationToken ct = default)
{
ApplicationUser user = await userManager.FindByEmailAsync(request.Email)
?? throw new UnauthorizedAccessException(ErrorMessages.Auth.InvalidMagicLink);
bool valid = await userManager.VerifyUserTokenAsync(
user, TokenOptions.DefaultEmailProvider, MagicLinkPurpose, request.Token);
if (!valid)
{
throw new UnauthorizedAccessException(ErrorMessages.Auth.MagicLinkAlreadyUsed);
}
if (await userManager.IsLockedOutAsync(user))
{
throw new UnauthorizedAccessException(ErrorMessages.Auth.AccountDeactivated);
}
IList<string> roles = await userManager.GetRolesAsync(user);
return await BuildTokenResponseAsync(user, roles, ct);
}
/// <inheritdoc/>
public async Task<TokenResponse> ConfirmPasswordResetAsync(
PasswordResetConfirmRequest request, CancellationToken ct = default)
{
ApplicationUser user = await userManager.FindByEmailAsync(request.Email)
?? throw new UnauthorizedAccessException(ErrorMessages.Auth.InvalidPasswordResetRequest);
IdentityResult result = await userManager.ResetPasswordAsync(
user, request.Token, request.NewPassword);
if (!result.Succeeded)
{
throw new InvalidOperationException(
string.Join("; ", result.Errors.Select(e => e.Description)));
}
user.MustChangePassword = false;
await userManager.UpdateAsync(user);
IList<string> roles = await userManager.GetRolesAsync(user);
return await BuildTokenResponseAsync(user, roles, ct);
}
/// <inheritdoc/>
public async Task<TokenResponse> GuestAsync(CancellationToken ct = default)
{
Claim[] claims = [new(ClaimTypes.Role, UserRoleType.GUEST.ToRoleName())];
TokenResponse response = await authService.GenerateJwtTokenAsync(claims, ct);
return new TokenResponse(response.AccessToken, response.ExpiresIn, refreshToken: null);
}
/// <inheritdoc/>
public async Task<TokenResponse> RefreshAsync(
RefreshTokenRequest request, CancellationToken ct = default)
{
ApplicationUser user = await userManager.Users
.FirstOrDefaultAsync(u => u.RefreshToken == request.RefreshToken, ct)
?? throw new UnauthorizedAccessException(ErrorMessages.Auth.InvalidRefreshToken);
if (user.RefreshTokenExpiryTime <= DateTime.UtcNow)
{
throw new UnauthorizedAccessException(ErrorMessages.Auth.RefreshTokenExpired);
}
IList<string> roles = await userManager.GetRolesAsync(user);
return await BuildTokenResponseAsync(user, roles, ct);
}
/// <inheritdoc/>
public async Task LogoutAsync(Guid userId, CancellationToken ct = default)
{
ApplicationUser? user = await userManager.FindByIdAsync(userId.ToString());
if (user is not null)
{
user.RefreshToken = null;
user.RefreshTokenExpiryTime = null;
await userManager.UpdateAsync(user);
}
}
private async Task<TokenResponse> BuildTokenResponseAsync(
ApplicationUser user, IList<string> roles, CancellationToken ct)
{
List<Claim> claims =
[
new(ClaimTypes.NameIdentifier, user.Id.ToString()),
new(ClaimTypes.Email, user.Email!),
.. roles.Select(r => new Claim(ClaimTypes.Role, r))
];
if (user.MustChangePassword)
{
claims.Add(new Claim(CustomClaimTypes.MustChangePassword, "true"));
}
TokenResponse response = await authService.GenerateJwtTokenAsync(claims, ct);
user.RefreshToken = response.RefreshToken;
user.RefreshTokenExpiryTime = DateTime.UtcNow.AddDays(RefreshExpiryDays);
await userManager.UpdateAsync(user);
return response;
}
/// <summary>
/// Builds an email link that carries an Identity token, using ActivationUrl for activation links and PasswordResetUrl otherwise.
/// </summary>
private string BuildTokenLink(string email, string token, bool activation)
{
string baseUrl = activation
? configuration[ConfigurationKeys.Frontend.ActivationUrl]
?? configuration[ConfigurationKeys.Frontend.PasswordResetUrl]
?? throw new InvalidOperationException(
ErrorMessages.Configuration.KeyNotConfigured(ConfigurationKeys.Frontend.PasswordResetUrl))
: configuration[ConfigurationKeys.Frontend.PasswordResetUrl]
?? throw new InvalidOperationException(
ErrorMessages.Configuration.KeyNotConfigured(ConfigurationKeys.Frontend.PasswordResetUrl));
return $"{baseUrl}" +
$"?email={Uri.EscapeDataString(email)}" +
$"&token={Uri.EscapeDataString(token)}";
}
private static string GenerateTemporaryPassword(int length = 16)
{
if (length < 8)
{
length = 8;
}
const string upper = "ABCDEFGHJKLMNPQRSTUVWXYZ";
const string lower = "abcdefghijkmnopqrstuvwxyz";
const string digits = "23456789";
const string special = "!@#$%^&*_-+=?";
string all = upper + lower + digits + special;
char[] chars = new char[length];
chars[0] = upper[RandomNumberGenerator.GetInt32(upper.Length)];
chars[1] = lower[RandomNumberGenerator.GetInt32(lower.Length)];
chars[2] = digits[RandomNumberGenerator.GetInt32(digits.Length)];
chars[3] = special[RandomNumberGenerator.GetInt32(special.Length)];
for (int i = 4; i < chars.Length; i++)
{
chars[i] = all[RandomNumberGenerator.GetInt32(all.Length)];
}
for (int i = chars.Length - 1; i > 0; i--)
{
int j = RandomNumberGenerator.GetInt32(i + 1);
(chars[i], chars[j]) = (chars[j], chars[i]);
}
return new string(chars);
}
private static void EnforceCreationPolicy(string callerRole, string targetRole)
{
bool allowed = _creationPolicy.TryGetValue(callerRole, out HashSet<string>? permitted)
&& permitted.Contains(targetRole);
if (!allowed)
{
throw new UnauthorizedAccessException(ErrorMessages.Auth.RoleNotAllowedToCreate(callerRole, targetRole));
}
}
private static bool IsOwner(string role)
{
return role.Equals(UserRoleType.OWNER.ToRoleName(), StringComparison.OrdinalIgnoreCase);
}
}
@@ -0,0 +1,65 @@
using Application.Utils.Constants.Configuration;
using Domain.Enums;
using Microsoft.AspNetCore.Identity;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.Logging;
using System.Linq;
using System.Threading.Tasks;
namespace Infrastructure.Identity;
/// <summary>
/// Seeds the initial admin user into the Identity database at startup.
/// </summary>
public sealed class IdentitySeeder(
UserManager<ApplicationUser> userManager,
IConfiguration configuration,
ILogger<IdentitySeeder> logger)
{
public async Task SeedAsync()
{
await SeedAdminAsync();
}
private async Task SeedAdminAsync()
{
string? email = configuration[ConfigurationKeys.AdminUser.Email];
string? password = configuration[ConfigurationKeys.AdminUser.Password];
if (string.IsNullOrWhiteSpace(email) || string.IsNullOrWhiteSpace(password))
{
logger.LogWarning(
"AdminUser:Email or AdminUser:Password not configured — skipping admin seeding.");
return;
}
if (await userManager.FindByEmailAsync(email) is not null)
{
logger.LogInformation("Admin user '{Email}' already exists — skipping.", email);
return;
}
ApplicationUser admin = new()
{
UserName = email,
Email = email,
EmailConfirmed = true,
};
IdentityResult result = await userManager.CreateAsync(admin, password);
if (!result.Succeeded)
{
string errors = string.Join(", ", result.Errors.Select(e => e.Description));
logger.LogError("Failed to create admin user '{Email}': {Errors}", email, errors);
return;
}
await userManager.AddToRoleAsync(admin, UserRoleType.ADMIN.ToRoleName());
logger.LogInformation("Admin user '{Email}' created and assigned role ADMIN.", email);
}
}
@@ -0,0 +1,397 @@
using Application.DTOs.Abstract.Request;
using Application.DTOs.Abstract.Response;
using Application.DTOs.User.Request;
using Application.DTOs.User.Response;
using Application.Interfaces.Services;
using Application.Utils.Constants;
using Application.Utils.Constants.Configuration;
using Domain.Enums;
using Microsoft.AspNetCore.Identity;
using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.Configuration;
using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Threading;
using System.Threading.Tasks;
namespace Infrastructure.Identity;
/// <summary>
/// Identity-backed implementation of IUserManagementService that enforces all access-control rules, keeping controllers thin.
/// </summary>
public sealed class IdentityUserManagementService(
UserManager<ApplicationUser> userManager,
IdentityAppDbContext identityDbContext,
IEmailService emailService,
IConfiguration configuration) : IUserManagementService
{
/// <inheritdoc/>
public async Task<PaginatedResponse<UserResponse>> GetAllAsync(
string callerRole, Guid callerId,
UserFilteredRequest filter,
CancellationToken ct = default)
{
IQueryable<ApplicationUser> query = ResolveVisibleUsersQuery(callerRole);
if (!string.IsNullOrWhiteSpace(filter.UserName))
{
query = query.Where(u => u.UserName != null &&
u.UserName.ToLower().Contains(filter.UserName.ToLower()));
}
if (!string.IsNullOrWhiteSpace(filter.Email))
{
query = query.Where(u => u.Email != null &&
u.Email.ToLower().Contains(filter.Email.ToLower()));
}
if (!string.IsNullOrWhiteSpace(filter.PhoneNumber))
{
query = query.Where(u => u.PhoneNumber != null &&
u.PhoneNumber.Contains(filter.PhoneNumber));
}
if (filter.Role.HasValue)
{
string roleName = filter.Role.Value.ToRoleName();
IQueryable<Guid> userIdsWithRole =
from ur in identityDbContext.UserRoles
join r in identityDbContext.Roles on ur.RoleId equals r.Id
where r.Name == roleName
select ur.UserId;
query = query.Where(u => userIdsWithRole.Contains(u.Id));
}
int totalCount = await query.CountAsync(ct);
query = filter.OrderBy?.ToLower() switch
{
"username" => filter.Order == SortOrder.Descending
? query.OrderByDescending(u => u.UserName)
: query.OrderBy(u => u.UserName),
"email" => filter.Order == SortOrder.Descending
? query.OrderByDescending(u => u.Email)
: query.OrderBy(u => u.Email),
_ => filter.Order == SortOrder.Descending
? query.OrderByDescending(u => u.DateCreated)
: query.OrderBy(u => u.DateCreated),
};
int skip = (filter.PageNumber - 1) * filter.PageSize;
List<ApplicationUser> users = await query.Skip(skip).Take(filter.PageSize).ToListAsync(ct);
IReadOnlyList<UserResponse> items = await MapManyAsync(users);
return new PaginatedResponse<UserResponse>
{
Items = items,
Page = filter.PageNumber,
PageSize = filter.PageSize,
TotalCount = totalCount,
};
}
/// <inheritdoc/>
public async Task<UserResponse> GetByIdAsync(
string callerRole, Guid callerId, Guid userId, CancellationToken ct = default)
{
ApplicationUser user = await FindOrThrowAsync(userId);
EnforceReadAccess(user, callerRole, callerId);
return await MapOneAsync(user);
}
/// <inheritdoc/>
public async Task<UserResponse> UpdateAsync(
string callerRole, Guid callerId, Guid userId,
UpdateUserRequest request, CancellationToken ct = default)
{
ApplicationUser user = await FindOrThrowAsync(userId);
EnforceWriteAccess(user, callerRole, callerId);
if (!string.IsNullOrWhiteSpace(request.Username))
{
ThrowIfFailed(await userManager.SetUserNameAsync(user, request.Username));
}
if (!string.IsNullOrWhiteSpace(request.Email))
{
ThrowIfFailed(await userManager.SetEmailAsync(user, request.Email));
}
if (request.Phone is not null)
{
ThrowIfFailed(await userManager.SetPhoneNumberAsync(user, request.Phone));
}
if (request.Role.HasValue)
{
await ChangeRoleAsync(user, request.Role.Value, callerRole, callerId);
}
return await MapOneAsync(user);
}
/// <inheritdoc/>
public async Task ChangePasswordAsync(
string callerRole, Guid callerId, Guid userId,
ChangePasswordRequest request, CancellationToken ct = default)
{
ApplicationUser user = await FindOrThrowAsync(userId);
EnforceWriteAccess(user, callerRole, callerId);
bool isSelfUpdate = user.Id == callerId;
if (isSelfUpdate)
{
if (string.IsNullOrWhiteSpace(request.CurrentPassword))
{
throw new ArgumentException(ErrorMessages.User.CurrentPasswordRequired);
}
ThrowIfFailed(await userManager.ChangePasswordAsync(
user, request.CurrentPassword, request.NewPassword));
}
else
{
ThrowIfFailed(await userManager.RemovePasswordAsync(user));
ThrowIfFailed(await userManager.AddPasswordAsync(user, request.NewPassword));
}
user.MustChangePassword = false;
ThrowIfFailed(await userManager.UpdateAsync(user));
}
/// <summary>
/// Generates a password reset token and flags the account so MustChangePasswordMiddleware blocks access until the reset completes.
/// </summary>
public async Task<ResetPasswordResponse> ResetPasswordAsync(
string callerRole, Guid callerId, Guid userId, CancellationToken ct = default)
{
ApplicationUser user = await FindOrThrowAsync(userId);
EnforceResetPasswordAccess(callerRole);
string token = await userManager.GeneratePasswordResetTokenAsync(user);
user.MustChangePassword = true;
ThrowIfFailed(await userManager.UpdateAsync(user));
string frontendUrl = configuration[ConfigurationKeys.Frontend.PasswordResetUrl]
?? throw new InvalidOperationException(
ErrorMessages.Configuration.KeyNotConfigured(ConfigurationKeys.Frontend.PasswordResetUrl));
string resetLink =
$"{frontendUrl}" +
$"?email={Uri.EscapeDataString(user.Email!)}" +
$"&token={Uri.EscapeDataString(token)}";
await emailService.SendPasswordResetAsync(user.Email!, user.UserName!, resetLink, ct);
return new ResetPasswordResponse(user.Id);
}
/// <inheritdoc/>
public async Task DeleteAsync(
string callerRole, Guid callerId, Guid userId, CancellationToken ct = default)
{
ApplicationUser user = await FindOrThrowAsync(userId);
EnforceDeleteAccess(callerRole);
ThrowIfFailed(await userManager.DeleteAsync(user));
}
/// <inheritdoc/>
public async Task<UserResponse> SetActiveAsync(
string callerRole, Guid callerId, Guid userId, bool isActive, CancellationToken ct = default)
{
ApplicationUser user = await FindOrThrowAsync(userId);
EnforceDeleteAccess(callerRole);
if (user.Id == callerId)
{
throw new InvalidOperationException(ErrorMessages.User.CannotChangeOwnActiveState);
}
if (isActive)
{
ThrowIfFailed(await userManager.SetLockoutEndDateAsync(user, null));
}
else
{
ThrowIfFailed(await userManager.SetLockoutEnabledAsync(user, true));
ThrowIfFailed(await userManager.SetLockoutEndDateAsync(user, DateTimeOffset.MaxValue));
}
return await MapOneAsync(user);
}
private static void EnforceReadAccess(ApplicationUser target, string callerRole, Guid callerId)
{
if (IsAdmin(callerRole) || IsOwner(callerRole))
{
return;
}
if (target.Id == callerId)
{
return;
}
throw new UnauthorizedAccessException(ErrorMessages.Auth.AccessDenied);
}
/// <summary>
/// Write access currently follows the exact same rule as read access, kept as its own method for a future divergence.
/// </summary>
private static void EnforceWriteAccess(ApplicationUser target, string callerRole, Guid callerId)
{
EnforceReadAccess(target, callerRole, callerId);
}
private static void EnforceResetPasswordAccess(string callerRole)
{
if (IsAdmin(callerRole) || IsOwner(callerRole))
{
return;
}
throw new UnauthorizedAccessException(ErrorMessages.User.PasswordResetRestricted);
}
private static void EnforceDeleteAccess(string callerRole)
{
if (IsAdmin(callerRole) || IsOwner(callerRole))
{
return;
}
throw new UnauthorizedAccessException(ErrorMessages.User.InsufficientPermissionsToDelete);
}
/// <summary>
/// Which roles each caller role may assign to another user, kept as separate dictionary entries per role for a future divergence.
/// </summary>
private static readonly Dictionary<string, HashSet<string>> _roleChangePolicy =
new(StringComparer.OrdinalIgnoreCase)
{
[Roles.Admin] = new(StringComparer.OrdinalIgnoreCase)
{
Roles.Admin, Roles.Owner
},
[Roles.Owner] = new(StringComparer.OrdinalIgnoreCase)
{
Roles.Admin, Roles.Owner
}
};
/// <summary>
/// Replaces the target user's role with newRole so they end up in exactly one role, never accumulating multiple.
/// </summary>
private async Task ChangeRoleAsync(
ApplicationUser user, UserRoleType newRole, string callerRole, Guid callerId)
{
if (!Enum.IsDefined(newRole))
{
throw new ArgumentException(ErrorMessages.User.InvalidRole(newRole));
}
string targetRoleName = newRole.ToRoleName();
EnforceRoleChangeAccess(user, callerRole, callerId, targetRoleName);
IList<string> currentRoles = await userManager.GetRolesAsync(user);
if (currentRoles.Count > 0)
{
ThrowIfFailed(await userManager.RemoveFromRolesAsync(user, currentRoles));
}
ThrowIfFailed(await userManager.AddToRoleAsync(user, targetRoleName));
}
/// <summary>
/// A user may never change their own role, since that is the one path that could let someone grant themselves more privilege.
/// </summary>
private static void EnforceRoleChangeAccess(
ApplicationUser target, string callerRole, Guid callerId, string targetRoleName)
{
if (target.Id == callerId)
{
throw new InvalidOperationException(ErrorMessages.User.CannotChangeOwnRole);
}
bool hasJurisdictionOverTarget = IsAdmin(callerRole) || IsOwner(callerRole);
if (!hasJurisdictionOverTarget)
{
throw new UnauthorizedAccessException(ErrorMessages.User.InsufficientPermissionsToChangeRole);
}
bool allowedToAssignTargetRole =
_roleChangePolicy.TryGetValue(callerRole, out HashSet<string>? permittedRoles)
&& permittedRoles.Contains(targetRoleName);
if (!allowedToAssignTargetRole)
{
throw new UnauthorizedAccessException(
ErrorMessages.User.RoleNotAllowedToAssign(callerRole, targetRoleName));
}
}
private async Task<UserResponse> MapOneAsync(ApplicationUser user)
{
IList<string> roles = await userManager.GetRolesAsync(user);
string role = roles.FirstOrDefault() ?? string.Empty;
bool isActive = !(user.LockoutEnd.HasValue && user.LockoutEnd.Value > DateTimeOffset.UtcNow);
return new UserResponse(user.Id, user.Email!, user.UserName!, role,
user.PhoneNumber, user.CreatedByOwnerId, isActive);
}
private async Task<IReadOnlyList<UserResponse>> MapManyAsync(IEnumerable<ApplicationUser> users)
{
List<UserResponse> results = [];
foreach (ApplicationUser user in users)
{
results.Add(await MapOneAsync(user));
}
return results;
}
private async Task<ApplicationUser> FindOrThrowAsync(Guid userId)
{
ApplicationUser? user = await userManager.FindByIdAsync(userId.ToString());
return user ?? throw new KeyNotFoundException(ErrorMessages.User.NotFound(userId.ToString()));
}
private static void ThrowIfFailed(IdentityResult result)
{
if (!result.Succeeded)
{
throw new InvalidOperationException(
string.Join("; ", result.Errors.Select(e => e.Description)));
}
}
private IQueryable<ApplicationUser> ResolveVisibleUsersQuery(string callerRole)
{
return IsAdmin(callerRole) || IsOwner(callerRole)
? userManager.Users
: throw new UnauthorizedAccessException(ErrorMessages.User.InsufficientPermissionsToListUsers);
}
private static bool IsAdmin(string role)
{
return role == Roles.Admin;
}
private static bool IsOwner(string role)
{
return role == Roles.Owner;
}
}
@@ -0,0 +1,319 @@
// <auto-generated />
using System;
using Infrastructure.Identity;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Migrations;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
#nullable disable
namespace Infrastructure.Identity.Migrations
{
[DbContext(typeof(IdentityAppDbContext))]
[Migration("20260315043537_InitialIdentityMigration")]
partial class InitialIdentityMigration
{
/// <inheritdoc />
protected override void BuildTargetModel(ModelBuilder modelBuilder)
{
#pragma warning disable 612, 618
modelBuilder
.HasAnnotation("ProductVersion", "8.0.11")
.HasAnnotation("Relational:MaxIdentifierLength", 63);
NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder);
modelBuilder.Entity("Infrastructure.Identity.ApplicationUser", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uuid");
b.Property<int>("AccessFailedCount")
.HasColumnType("integer");
b.Property<string>("ConcurrencyStamp")
.IsConcurrencyToken()
.HasColumnType("text");
b.Property<string>("Email")
.HasMaxLength(256)
.HasColumnType("character varying(256)");
b.Property<bool>("EmailConfirmed")
.HasColumnType("boolean");
b.Property<bool>("LockoutEnabled")
.HasColumnType("boolean");
b.Property<DateTimeOffset?>("LockoutEnd")
.HasColumnType("timestamp with time zone");
b.Property<string>("NormalizedEmail")
.HasMaxLength(256)
.HasColumnType("character varying(256)");
b.Property<string>("NormalizedUserName")
.HasMaxLength(256)
.HasColumnType("character varying(256)");
b.Property<string>("PasswordHash")
.HasColumnType("text");
b.Property<string>("PhoneNumber")
.HasColumnType("text");
b.Property<bool>("PhoneNumberConfirmed")
.HasColumnType("boolean");
b.Property<string>("RefreshToken")
.HasColumnType("text");
b.Property<DateTime?>("RefreshTokenExpiryTime")
.HasColumnType("timestamp with time zone");
b.Property<string>("SecurityStamp")
.HasColumnType("text");
b.Property<bool>("TwoFactorEnabled")
.HasColumnType("boolean");
b.Property<string>("UserName")
.HasMaxLength(256)
.HasColumnType("character varying(256)");
b.HasKey("Id");
b.HasIndex("NormalizedEmail")
.HasDatabaseName("EmailIndex");
b.HasIndex("NormalizedUserName")
.IsUnique()
.HasDatabaseName("UserNameIndex");
b.ToTable("AspNetUsers", (string)null);
});
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityRole<System.Guid>", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uuid");
b.Property<string>("ConcurrencyStamp")
.IsConcurrencyToken()
.HasColumnType("text");
b.Property<string>("Name")
.HasMaxLength(256)
.HasColumnType("character varying(256)");
b.Property<string>("NormalizedName")
.HasMaxLength(256)
.HasColumnType("character varying(256)");
b.HasKey("Id");
b.HasIndex("NormalizedName")
.IsUnique()
.HasDatabaseName("RoleNameIndex");
b.ToTable("AspNetRoles", (string)null);
b.HasData(
new
{
Id = new Guid("00000000-0000-0000-0000-000000000001"),
ConcurrencyStamp = "1",
Name = "ADMIN",
NormalizedName = "ADMIN"
},
new
{
Id = new Guid("00000000-0000-0000-0000-000000000002"),
ConcurrencyStamp = "2",
Name = "OWNER",
NormalizedName = "OWNER"
},
new
{
Id = new Guid("00000000-0000-0000-0000-000000000003"),
ConcurrencyStamp = "3",
Name = "TOURNAMENT_MANAGER",
NormalizedName = "TOURNAMENT_MANAGER"
},
new
{
Id = new Guid("00000000-0000-0000-0000-000000000004"),
ConcurrencyStamp = "4",
Name = "TEAM_MANAGER",
NormalizedName = "TEAM_MANAGER"
},
new
{
Id = new Guid("00000000-0000-0000-0000-000000000005"),
ConcurrencyStamp = "5",
Name = "GUEST",
NormalizedName = "GUEST"
});
});
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityRoleClaim<System.Guid>", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("integer");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
b.Property<string>("ClaimType")
.HasColumnType("text");
b.Property<string>("ClaimValue")
.HasColumnType("text");
b.Property<Guid>("RoleId")
.HasColumnType("uuid");
b.HasKey("Id");
b.HasIndex("RoleId");
b.ToTable("AspNetRoleClaims", (string)null);
});
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserClaim<System.Guid>", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("integer");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
b.Property<string>("ClaimType")
.HasColumnType("text");
b.Property<string>("ClaimValue")
.HasColumnType("text");
b.Property<Guid>("UserId")
.HasColumnType("uuid");
b.HasKey("Id");
b.HasIndex("UserId");
b.ToTable("AspNetUserClaims", (string)null);
});
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserLogin<System.Guid>", b =>
{
b.Property<string>("LoginProvider")
.HasColumnType("text");
b.Property<string>("ProviderKey")
.HasColumnType("text");
b.Property<string>("ProviderDisplayName")
.HasColumnType("text");
b.Property<Guid>("UserId")
.HasColumnType("uuid");
b.HasKey("LoginProvider", "ProviderKey");
b.HasIndex("UserId");
b.ToTable("AspNetUserLogins", (string)null);
});
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserRole<System.Guid>", b =>
{
b.Property<Guid>("UserId")
.HasColumnType("uuid");
b.Property<Guid>("RoleId")
.HasColumnType("uuid");
b.HasKey("UserId", "RoleId");
b.HasIndex("RoleId");
b.ToTable("AspNetUserRoles", (string)null);
});
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserToken<System.Guid>", b =>
{
b.Property<Guid>("UserId")
.HasColumnType("uuid");
b.Property<string>("LoginProvider")
.HasColumnType("text");
b.Property<string>("Name")
.HasColumnType("text");
b.Property<string>("Value")
.HasColumnType("text");
b.HasKey("UserId", "LoginProvider", "Name");
b.ToTable("AspNetUserTokens", (string)null);
});
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityRoleClaim<System.Guid>", b =>
{
b.HasOne("Microsoft.AspNetCore.Identity.IdentityRole<System.Guid>", null)
.WithMany()
.HasForeignKey("RoleId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
});
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserClaim<System.Guid>", b =>
{
b.HasOne("Infrastructure.Identity.ApplicationUser", null)
.WithMany()
.HasForeignKey("UserId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
});
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserLogin<System.Guid>", b =>
{
b.HasOne("Infrastructure.Identity.ApplicationUser", null)
.WithMany()
.HasForeignKey("UserId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
});
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserRole<System.Guid>", b =>
{
b.HasOne("Microsoft.AspNetCore.Identity.IdentityRole<System.Guid>", null)
.WithMany()
.HasForeignKey("RoleId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("Infrastructure.Identity.ApplicationUser", null)
.WithMany()
.HasForeignKey("UserId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
});
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserToken<System.Guid>", b =>
{
b.HasOne("Infrastructure.Identity.ApplicationUser", null)
.WithMany()
.HasForeignKey("UserId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
});
#pragma warning restore 612, 618
}
}
}
@@ -0,0 +1,240 @@
using Microsoft.EntityFrameworkCore.Migrations;
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
using System;
#nullable disable
#pragma warning disable CA1814 // Prefer jagged arrays over multidimensional
namespace Infrastructure.Identity.Migrations;
/// <inheritdoc />
public partial class InitialIdentityMigration : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.CreateTable(
name: "AspNetRoles",
columns: table => new
{
Id = table.Column<Guid>(type: "uuid", 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)
},
constraints: table =>
{
table.PrimaryKey("PK_AspNetRoles", x => x.Id);
});
migrationBuilder.CreateTable(
name: "AspNetUsers",
columns: table => new
{
Id = table.Column<Guid>(type: "uuid", nullable: false),
RefreshToken = table.Column<string>(type: "text", nullable: true),
RefreshTokenExpiryTime = table.Column<DateTime>(type: "timestamp with time zone", nullable: true),
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),
ConcurrencyStamp = table.Column<string>(type: "text", nullable: true),
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),
LockoutEnabled = table.Column<bool>(type: "boolean", nullable: false),
AccessFailedCount = table.Column<int>(type: "integer", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_AspNetUsers", x => x.Id);
});
migrationBuilder.CreateTable(
name: "AspNetRoleClaims",
columns: table => new
{
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)
},
constraints: table =>
{
table.PrimaryKey("PK_AspNetRoleClaims", x => x.Id);
table.ForeignKey(
name: "FK_AspNetRoleClaims_AspNetRoles_RoleId",
column: x => x.RoleId,
principalTable: "AspNetRoles",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateTable(
name: "AspNetUserClaims",
columns: table => new
{
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)
},
constraints: table =>
{
table.PrimaryKey("PK_AspNetUserClaims", x => x.Id);
table.ForeignKey(
name: "FK_AspNetUserClaims_AspNetUsers_UserId",
column: x => x.UserId,
principalTable: "AspNetUsers",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateTable(
name: "AspNetUserLogins",
columns: table => new
{
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)
},
constraints: table =>
{
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);
});
migrationBuilder.CreateTable(
name: "AspNetUserRoles",
columns: table => new
{
UserId = table.Column<Guid>(type: "uuid", nullable: false),
RoleId = table.Column<Guid>(type: "uuid", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_AspNetUserRoles", x => new { x.UserId, x.RoleId });
table.ForeignKey(
name: "FK_AspNetUserRoles_AspNetRoles_RoleId",
column: x => x.RoleId,
principalTable: "AspNetRoles",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
table.ForeignKey(
name: "FK_AspNetUserRoles_AspNetUsers_UserId",
column: x => x.UserId,
principalTable: "AspNetUsers",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateTable(
name: "AspNetUserTokens",
columns: table => new
{
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)
},
constraints: table =>
{
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);
});
migrationBuilder.InsertData(
table: "AspNetRoles",
columns: new[] { "Id", "ConcurrencyStamp", "Name", "NormalizedName" },
values: new object[,]
{
{ new Guid("00000000-0000-0000-0000-000000000001"), "1", "ADMIN", "ADMIN" },
{ new Guid("00000000-0000-0000-0000-000000000002"), "2", "OWNER", "OWNER" },
{ new Guid("00000000-0000-0000-0000-000000000003"), "3", "TOURNAMENT_MANAGER", "TOURNAMENT_MANAGER" },
{ new Guid("00000000-0000-0000-0000-000000000004"), "4", "TEAM_MANAGER", "TEAM_MANAGER" },
{ new Guid("00000000-0000-0000-0000-000000000005"), "5", "GUEST", "GUEST" }
});
migrationBuilder.CreateIndex(
name: "IX_AspNetRoleClaims_RoleId",
table: "AspNetRoleClaims",
column: "RoleId");
migrationBuilder.CreateIndex(
name: "RoleNameIndex",
table: "AspNetRoles",
column: "NormalizedName",
unique: true);
migrationBuilder.CreateIndex(
name: "IX_AspNetUserClaims_UserId",
table: "AspNetUserClaims",
column: "UserId");
migrationBuilder.CreateIndex(
name: "IX_AspNetUserLogins_UserId",
table: "AspNetUserLogins",
column: "UserId");
migrationBuilder.CreateIndex(
name: "IX_AspNetUserRoles_RoleId",
table: "AspNetUserRoles",
column: "RoleId");
migrationBuilder.CreateIndex(
name: "EmailIndex",
table: "AspNetUsers",
column: "NormalizedEmail");
migrationBuilder.CreateIndex(
name: "UserNameIndex",
table: "AspNetUsers",
column: "NormalizedUserName",
unique: true);
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropTable(
name: "AspNetRoleClaims");
migrationBuilder.DropTable(
name: "AspNetUserClaims");
migrationBuilder.DropTable(
name: "AspNetUserLogins");
migrationBuilder.DropTable(
name: "AspNetUserRoles");
migrationBuilder.DropTable(
name: "AspNetUserTokens");
migrationBuilder.DropTable(
name: "AspNetRoles");
migrationBuilder.DropTable(
name: "AspNetUsers");
}
}
@@ -0,0 +1,322 @@
// <auto-generated />
using System;
using Infrastructure.Identity;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Migrations;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
#nullable disable
namespace Infrastructure.Identity.Migrations
{
[DbContext(typeof(IdentityAppDbContext))]
[Migration("20260316030250_changesPropsForUsers")]
partial class changesPropsForUsers
{
/// <inheritdoc />
protected override void BuildTargetModel(ModelBuilder modelBuilder)
{
#pragma warning disable 612, 618
modelBuilder
.HasAnnotation("ProductVersion", "8.0.11")
.HasAnnotation("Relational:MaxIdentifierLength", 63);
NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder);
modelBuilder.Entity("Infrastructure.Identity.ApplicationUser", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uuid");
b.Property<int>("AccessFailedCount")
.HasColumnType("integer");
b.Property<string>("ConcurrencyStamp")
.IsConcurrencyToken()
.HasColumnType("text");
b.Property<Guid?>("CreatedByOwnerId")
.HasColumnType("uuid");
b.Property<string>("Email")
.HasMaxLength(256)
.HasColumnType("character varying(256)");
b.Property<bool>("EmailConfirmed")
.HasColumnType("boolean");
b.Property<bool>("LockoutEnabled")
.HasColumnType("boolean");
b.Property<DateTimeOffset?>("LockoutEnd")
.HasColumnType("timestamp with time zone");
b.Property<string>("NormalizedEmail")
.HasMaxLength(256)
.HasColumnType("character varying(256)");
b.Property<string>("NormalizedUserName")
.HasMaxLength(256)
.HasColumnType("character varying(256)");
b.Property<string>("PasswordHash")
.HasColumnType("text");
b.Property<string>("PhoneNumber")
.HasColumnType("text");
b.Property<bool>("PhoneNumberConfirmed")
.HasColumnType("boolean");
b.Property<string>("RefreshToken")
.HasColumnType("text");
b.Property<DateTime?>("RefreshTokenExpiryTime")
.HasColumnType("timestamp with time zone");
b.Property<string>("SecurityStamp")
.HasColumnType("text");
b.Property<bool>("TwoFactorEnabled")
.HasColumnType("boolean");
b.Property<string>("UserName")
.HasMaxLength(256)
.HasColumnType("character varying(256)");
b.HasKey("Id");
b.HasIndex("NormalizedEmail")
.HasDatabaseName("EmailIndex");
b.HasIndex("NormalizedUserName")
.IsUnique()
.HasDatabaseName("UserNameIndex");
b.ToTable("AspNetUsers", (string)null);
});
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityRole<System.Guid>", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uuid");
b.Property<string>("ConcurrencyStamp")
.IsConcurrencyToken()
.HasColumnType("text");
b.Property<string>("Name")
.HasMaxLength(256)
.HasColumnType("character varying(256)");
b.Property<string>("NormalizedName")
.HasMaxLength(256)
.HasColumnType("character varying(256)");
b.HasKey("Id");
b.HasIndex("NormalizedName")
.IsUnique()
.HasDatabaseName("RoleNameIndex");
b.ToTable("AspNetRoles", (string)null);
b.HasData(
new
{
Id = new Guid("00000000-0000-0000-0000-000000000001"),
ConcurrencyStamp = "1",
Name = "ADMIN",
NormalizedName = "ADMIN"
},
new
{
Id = new Guid("00000000-0000-0000-0000-000000000002"),
ConcurrencyStamp = "2",
Name = "OWNER",
NormalizedName = "OWNER"
},
new
{
Id = new Guid("00000000-0000-0000-0000-000000000003"),
ConcurrencyStamp = "3",
Name = "TOURNAMENT_MANAGER",
NormalizedName = "TOURNAMENT_MANAGER"
},
new
{
Id = new Guid("00000000-0000-0000-0000-000000000004"),
ConcurrencyStamp = "4",
Name = "TEAM_MANAGER",
NormalizedName = "TEAM_MANAGER"
},
new
{
Id = new Guid("00000000-0000-0000-0000-000000000005"),
ConcurrencyStamp = "5",
Name = "GUEST",
NormalizedName = "GUEST"
});
});
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityRoleClaim<System.Guid>", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("integer");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
b.Property<string>("ClaimType")
.HasColumnType("text");
b.Property<string>("ClaimValue")
.HasColumnType("text");
b.Property<Guid>("RoleId")
.HasColumnType("uuid");
b.HasKey("Id");
b.HasIndex("RoleId");
b.ToTable("AspNetRoleClaims", (string)null);
});
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserClaim<System.Guid>", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("integer");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
b.Property<string>("ClaimType")
.HasColumnType("text");
b.Property<string>("ClaimValue")
.HasColumnType("text");
b.Property<Guid>("UserId")
.HasColumnType("uuid");
b.HasKey("Id");
b.HasIndex("UserId");
b.ToTable("AspNetUserClaims", (string)null);
});
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserLogin<System.Guid>", b =>
{
b.Property<string>("LoginProvider")
.HasColumnType("text");
b.Property<string>("ProviderKey")
.HasColumnType("text");
b.Property<string>("ProviderDisplayName")
.HasColumnType("text");
b.Property<Guid>("UserId")
.HasColumnType("uuid");
b.HasKey("LoginProvider", "ProviderKey");
b.HasIndex("UserId");
b.ToTable("AspNetUserLogins", (string)null);
});
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserRole<System.Guid>", b =>
{
b.Property<Guid>("UserId")
.HasColumnType("uuid");
b.Property<Guid>("RoleId")
.HasColumnType("uuid");
b.HasKey("UserId", "RoleId");
b.HasIndex("RoleId");
b.ToTable("AspNetUserRoles", (string)null);
});
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserToken<System.Guid>", b =>
{
b.Property<Guid>("UserId")
.HasColumnType("uuid");
b.Property<string>("LoginProvider")
.HasColumnType("text");
b.Property<string>("Name")
.HasColumnType("text");
b.Property<string>("Value")
.HasColumnType("text");
b.HasKey("UserId", "LoginProvider", "Name");
b.ToTable("AspNetUserTokens", (string)null);
});
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityRoleClaim<System.Guid>", b =>
{
b.HasOne("Microsoft.AspNetCore.Identity.IdentityRole<System.Guid>", null)
.WithMany()
.HasForeignKey("RoleId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
});
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserClaim<System.Guid>", b =>
{
b.HasOne("Infrastructure.Identity.ApplicationUser", null)
.WithMany()
.HasForeignKey("UserId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
});
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserLogin<System.Guid>", b =>
{
b.HasOne("Infrastructure.Identity.ApplicationUser", null)
.WithMany()
.HasForeignKey("UserId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
});
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserRole<System.Guid>", b =>
{
b.HasOne("Microsoft.AspNetCore.Identity.IdentityRole<System.Guid>", null)
.WithMany()
.HasForeignKey("RoleId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("Infrastructure.Identity.ApplicationUser", null)
.WithMany()
.HasForeignKey("UserId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
});
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserToken<System.Guid>", b =>
{
b.HasOne("Infrastructure.Identity.ApplicationUser", null)
.WithMany()
.HasForeignKey("UserId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
});
#pragma warning restore 612, 618
}
}
}
@@ -0,0 +1,29 @@
using Microsoft.EntityFrameworkCore.Migrations;
using System;
#nullable disable
namespace Infrastructure.Identity.Migrations;
/// <inheritdoc />
public partial class changesPropsForUsers : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.AddColumn<Guid>(
name: "CreatedByOwnerId",
table: "AspNetUsers",
type: "uuid",
nullable: true);
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropColumn(
name: "CreatedByOwnerId",
table: "AspNetUsers");
}
}
@@ -0,0 +1,325 @@
// <auto-generated />
using System;
using Infrastructure.Identity;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Migrations;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
#nullable disable
namespace Infrastructure.Identity.Migrations
{
[DbContext(typeof(IdentityAppDbContext))]
[Migration("20260316031655_addDateCreatedForUsers")]
partial class addDateCreatedForUsers
{
/// <inheritdoc />
protected override void BuildTargetModel(ModelBuilder modelBuilder)
{
#pragma warning disable 612, 618
modelBuilder
.HasAnnotation("ProductVersion", "8.0.11")
.HasAnnotation("Relational:MaxIdentifierLength", 63);
NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder);
modelBuilder.Entity("Infrastructure.Identity.ApplicationUser", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uuid");
b.Property<int>("AccessFailedCount")
.HasColumnType("integer");
b.Property<string>("ConcurrencyStamp")
.IsConcurrencyToken()
.HasColumnType("text");
b.Property<Guid?>("CreatedByOwnerId")
.HasColumnType("uuid");
b.Property<DateTime>("DateCreated")
.HasColumnType("timestamp with time zone");
b.Property<string>("Email")
.HasMaxLength(256)
.HasColumnType("character varying(256)");
b.Property<bool>("EmailConfirmed")
.HasColumnType("boolean");
b.Property<bool>("LockoutEnabled")
.HasColumnType("boolean");
b.Property<DateTimeOffset?>("LockoutEnd")
.HasColumnType("timestamp with time zone");
b.Property<string>("NormalizedEmail")
.HasMaxLength(256)
.HasColumnType("character varying(256)");
b.Property<string>("NormalizedUserName")
.HasMaxLength(256)
.HasColumnType("character varying(256)");
b.Property<string>("PasswordHash")
.HasColumnType("text");
b.Property<string>("PhoneNumber")
.HasColumnType("text");
b.Property<bool>("PhoneNumberConfirmed")
.HasColumnType("boolean");
b.Property<string>("RefreshToken")
.HasColumnType("text");
b.Property<DateTime?>("RefreshTokenExpiryTime")
.HasColumnType("timestamp with time zone");
b.Property<string>("SecurityStamp")
.HasColumnType("text");
b.Property<bool>("TwoFactorEnabled")
.HasColumnType("boolean");
b.Property<string>("UserName")
.HasMaxLength(256)
.HasColumnType("character varying(256)");
b.HasKey("Id");
b.HasIndex("NormalizedEmail")
.HasDatabaseName("EmailIndex");
b.HasIndex("NormalizedUserName")
.IsUnique()
.HasDatabaseName("UserNameIndex");
b.ToTable("AspNetUsers", (string)null);
});
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityRole<System.Guid>", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uuid");
b.Property<string>("ConcurrencyStamp")
.IsConcurrencyToken()
.HasColumnType("text");
b.Property<string>("Name")
.HasMaxLength(256)
.HasColumnType("character varying(256)");
b.Property<string>("NormalizedName")
.HasMaxLength(256)
.HasColumnType("character varying(256)");
b.HasKey("Id");
b.HasIndex("NormalizedName")
.IsUnique()
.HasDatabaseName("RoleNameIndex");
b.ToTable("AspNetRoles", (string)null);
b.HasData(
new
{
Id = new Guid("00000000-0000-0000-0000-000000000001"),
ConcurrencyStamp = "1",
Name = "ADMIN",
NormalizedName = "ADMIN"
},
new
{
Id = new Guid("00000000-0000-0000-0000-000000000002"),
ConcurrencyStamp = "2",
Name = "OWNER",
NormalizedName = "OWNER"
},
new
{
Id = new Guid("00000000-0000-0000-0000-000000000003"),
ConcurrencyStamp = "3",
Name = "TOURNAMENT_MANAGER",
NormalizedName = "TOURNAMENT_MANAGER"
},
new
{
Id = new Guid("00000000-0000-0000-0000-000000000004"),
ConcurrencyStamp = "4",
Name = "TEAM_MANAGER",
NormalizedName = "TEAM_MANAGER"
},
new
{
Id = new Guid("00000000-0000-0000-0000-000000000005"),
ConcurrencyStamp = "5",
Name = "GUEST",
NormalizedName = "GUEST"
});
});
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityRoleClaim<System.Guid>", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("integer");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
b.Property<string>("ClaimType")
.HasColumnType("text");
b.Property<string>("ClaimValue")
.HasColumnType("text");
b.Property<Guid>("RoleId")
.HasColumnType("uuid");
b.HasKey("Id");
b.HasIndex("RoleId");
b.ToTable("AspNetRoleClaims", (string)null);
});
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserClaim<System.Guid>", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("integer");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
b.Property<string>("ClaimType")
.HasColumnType("text");
b.Property<string>("ClaimValue")
.HasColumnType("text");
b.Property<Guid>("UserId")
.HasColumnType("uuid");
b.HasKey("Id");
b.HasIndex("UserId");
b.ToTable("AspNetUserClaims", (string)null);
});
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserLogin<System.Guid>", b =>
{
b.Property<string>("LoginProvider")
.HasColumnType("text");
b.Property<string>("ProviderKey")
.HasColumnType("text");
b.Property<string>("ProviderDisplayName")
.HasColumnType("text");
b.Property<Guid>("UserId")
.HasColumnType("uuid");
b.HasKey("LoginProvider", "ProviderKey");
b.HasIndex("UserId");
b.ToTable("AspNetUserLogins", (string)null);
});
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserRole<System.Guid>", b =>
{
b.Property<Guid>("UserId")
.HasColumnType("uuid");
b.Property<Guid>("RoleId")
.HasColumnType("uuid");
b.HasKey("UserId", "RoleId");
b.HasIndex("RoleId");
b.ToTable("AspNetUserRoles", (string)null);
});
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserToken<System.Guid>", b =>
{
b.Property<Guid>("UserId")
.HasColumnType("uuid");
b.Property<string>("LoginProvider")
.HasColumnType("text");
b.Property<string>("Name")
.HasColumnType("text");
b.Property<string>("Value")
.HasColumnType("text");
b.HasKey("UserId", "LoginProvider", "Name");
b.ToTable("AspNetUserTokens", (string)null);
});
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityRoleClaim<System.Guid>", b =>
{
b.HasOne("Microsoft.AspNetCore.Identity.IdentityRole<System.Guid>", null)
.WithMany()
.HasForeignKey("RoleId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
});
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserClaim<System.Guid>", b =>
{
b.HasOne("Infrastructure.Identity.ApplicationUser", null)
.WithMany()
.HasForeignKey("UserId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
});
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserLogin<System.Guid>", b =>
{
b.HasOne("Infrastructure.Identity.ApplicationUser", null)
.WithMany()
.HasForeignKey("UserId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
});
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserRole<System.Guid>", b =>
{
b.HasOne("Microsoft.AspNetCore.Identity.IdentityRole<System.Guid>", null)
.WithMany()
.HasForeignKey("RoleId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("Infrastructure.Identity.ApplicationUser", null)
.WithMany()
.HasForeignKey("UserId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
});
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserToken<System.Guid>", b =>
{
b.HasOne("Infrastructure.Identity.ApplicationUser", null)
.WithMany()
.HasForeignKey("UserId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
});
#pragma warning restore 612, 618
}
}
}
@@ -0,0 +1,30 @@
using Microsoft.EntityFrameworkCore.Migrations;
using System;
#nullable disable
namespace Infrastructure.Identity.Migrations;
/// <inheritdoc />
public partial class addDateCreatedForUsers : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.AddColumn<DateTime>(
name: "DateCreated",
table: "AspNetUsers",
type: "timestamp with time zone",
nullable: false,
defaultValue: new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified));
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropColumn(
name: "DateCreated",
table: "AspNetUsers");
}
}
@@ -0,0 +1,328 @@
// <auto-generated />
using System;
using Infrastructure.Identity;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Migrations;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
#nullable disable
namespace Infrastructure.Identity.Migrations
{
[DbContext(typeof(IdentityAppDbContext))]
[Migration("20260316042032_addMustChangePassword")]
partial class addMustChangePassword
{
/// <inheritdoc />
protected override void BuildTargetModel(ModelBuilder modelBuilder)
{
#pragma warning disable 612, 618
modelBuilder
.HasAnnotation("ProductVersion", "8.0.11")
.HasAnnotation("Relational:MaxIdentifierLength", 63);
NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder);
modelBuilder.Entity("Infrastructure.Identity.ApplicationUser", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uuid");
b.Property<int>("AccessFailedCount")
.HasColumnType("integer");
b.Property<string>("ConcurrencyStamp")
.IsConcurrencyToken()
.HasColumnType("text");
b.Property<Guid?>("CreatedByOwnerId")
.HasColumnType("uuid");
b.Property<DateTime>("DateCreated")
.HasColumnType("timestamp with time zone");
b.Property<string>("Email")
.HasMaxLength(256)
.HasColumnType("character varying(256)");
b.Property<bool>("EmailConfirmed")
.HasColumnType("boolean");
b.Property<bool>("LockoutEnabled")
.HasColumnType("boolean");
b.Property<DateTimeOffset?>("LockoutEnd")
.HasColumnType("timestamp with time zone");
b.Property<bool>("MustChangePassword")
.HasColumnType("boolean");
b.Property<string>("NormalizedEmail")
.HasMaxLength(256)
.HasColumnType("character varying(256)");
b.Property<string>("NormalizedUserName")
.HasMaxLength(256)
.HasColumnType("character varying(256)");
b.Property<string>("PasswordHash")
.HasColumnType("text");
b.Property<string>("PhoneNumber")
.HasColumnType("text");
b.Property<bool>("PhoneNumberConfirmed")
.HasColumnType("boolean");
b.Property<string>("RefreshToken")
.HasColumnType("text");
b.Property<DateTime?>("RefreshTokenExpiryTime")
.HasColumnType("timestamp with time zone");
b.Property<string>("SecurityStamp")
.HasColumnType("text");
b.Property<bool>("TwoFactorEnabled")
.HasColumnType("boolean");
b.Property<string>("UserName")
.HasMaxLength(256)
.HasColumnType("character varying(256)");
b.HasKey("Id");
b.HasIndex("NormalizedEmail")
.HasDatabaseName("EmailIndex");
b.HasIndex("NormalizedUserName")
.IsUnique()
.HasDatabaseName("UserNameIndex");
b.ToTable("AspNetUsers", (string)null);
});
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityRole<System.Guid>", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uuid");
b.Property<string>("ConcurrencyStamp")
.IsConcurrencyToken()
.HasColumnType("text");
b.Property<string>("Name")
.HasMaxLength(256)
.HasColumnType("character varying(256)");
b.Property<string>("NormalizedName")
.HasMaxLength(256)
.HasColumnType("character varying(256)");
b.HasKey("Id");
b.HasIndex("NormalizedName")
.IsUnique()
.HasDatabaseName("RoleNameIndex");
b.ToTable("AspNetRoles", (string)null);
b.HasData(
new
{
Id = new Guid("00000000-0000-0000-0000-000000000001"),
ConcurrencyStamp = "1",
Name = "ADMIN",
NormalizedName = "ADMIN"
},
new
{
Id = new Guid("00000000-0000-0000-0000-000000000002"),
ConcurrencyStamp = "2",
Name = "OWNER",
NormalizedName = "OWNER"
},
new
{
Id = new Guid("00000000-0000-0000-0000-000000000003"),
ConcurrencyStamp = "3",
Name = "TOURNAMENT_MANAGER",
NormalizedName = "TOURNAMENT_MANAGER"
},
new
{
Id = new Guid("00000000-0000-0000-0000-000000000004"),
ConcurrencyStamp = "4",
Name = "TEAM_MANAGER",
NormalizedName = "TEAM_MANAGER"
},
new
{
Id = new Guid("00000000-0000-0000-0000-000000000005"),
ConcurrencyStamp = "5",
Name = "GUEST",
NormalizedName = "GUEST"
});
});
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityRoleClaim<System.Guid>", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("integer");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
b.Property<string>("ClaimType")
.HasColumnType("text");
b.Property<string>("ClaimValue")
.HasColumnType("text");
b.Property<Guid>("RoleId")
.HasColumnType("uuid");
b.HasKey("Id");
b.HasIndex("RoleId");
b.ToTable("AspNetRoleClaims", (string)null);
});
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserClaim<System.Guid>", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("integer");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
b.Property<string>("ClaimType")
.HasColumnType("text");
b.Property<string>("ClaimValue")
.HasColumnType("text");
b.Property<Guid>("UserId")
.HasColumnType("uuid");
b.HasKey("Id");
b.HasIndex("UserId");
b.ToTable("AspNetUserClaims", (string)null);
});
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserLogin<System.Guid>", b =>
{
b.Property<string>("LoginProvider")
.HasColumnType("text");
b.Property<string>("ProviderKey")
.HasColumnType("text");
b.Property<string>("ProviderDisplayName")
.HasColumnType("text");
b.Property<Guid>("UserId")
.HasColumnType("uuid");
b.HasKey("LoginProvider", "ProviderKey");
b.HasIndex("UserId");
b.ToTable("AspNetUserLogins", (string)null);
});
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserRole<System.Guid>", b =>
{
b.Property<Guid>("UserId")
.HasColumnType("uuid");
b.Property<Guid>("RoleId")
.HasColumnType("uuid");
b.HasKey("UserId", "RoleId");
b.HasIndex("RoleId");
b.ToTable("AspNetUserRoles", (string)null);
});
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserToken<System.Guid>", b =>
{
b.Property<Guid>("UserId")
.HasColumnType("uuid");
b.Property<string>("LoginProvider")
.HasColumnType("text");
b.Property<string>("Name")
.HasColumnType("text");
b.Property<string>("Value")
.HasColumnType("text");
b.HasKey("UserId", "LoginProvider", "Name");
b.ToTable("AspNetUserTokens", (string)null);
});
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityRoleClaim<System.Guid>", b =>
{
b.HasOne("Microsoft.AspNetCore.Identity.IdentityRole<System.Guid>", null)
.WithMany()
.HasForeignKey("RoleId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
});
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserClaim<System.Guid>", b =>
{
b.HasOne("Infrastructure.Identity.ApplicationUser", null)
.WithMany()
.HasForeignKey("UserId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
});
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserLogin<System.Guid>", b =>
{
b.HasOne("Infrastructure.Identity.ApplicationUser", null)
.WithMany()
.HasForeignKey("UserId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
});
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserRole<System.Guid>", b =>
{
b.HasOne("Microsoft.AspNetCore.Identity.IdentityRole<System.Guid>", null)
.WithMany()
.HasForeignKey("RoleId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("Infrastructure.Identity.ApplicationUser", null)
.WithMany()
.HasForeignKey("UserId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
});
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserToken<System.Guid>", b =>
{
b.HasOne("Infrastructure.Identity.ApplicationUser", null)
.WithMany()
.HasForeignKey("UserId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
});
#pragma warning restore 612, 618
}
}
}
@@ -0,0 +1,28 @@
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace Infrastructure.Identity.Migrations;
/// <inheritdoc />
public partial class addMustChangePassword : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.AddColumn<bool>(
name: "MustChangePassword",
table: "AspNetUsers",
type: "boolean",
nullable: false,
defaultValue: false);
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropColumn(
name: "MustChangePassword",
table: "AspNetUsers");
}
}
@@ -0,0 +1,329 @@
// <auto-generated />
using System;
using Infrastructure.Identity;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Migrations;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
#nullable disable
namespace Infrastructure.Identity.Migrations
{
[DbContext(typeof(IdentityAppDbContext))]
[Migration("20260326215327_AddNewPropsForIdentity")]
partial class AddNewPropsForIdentity
{
/// <inheritdoc />
protected override void BuildTargetModel(ModelBuilder modelBuilder)
{
#pragma warning disable 612, 618
modelBuilder
.HasAnnotation("ProductVersion", "8.0.11")
.HasAnnotation("Relational:MaxIdentifierLength", 63);
NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder);
modelBuilder.Entity("Infrastructure.Identity.ApplicationUser", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uuid");
b.Property<int>("AccessFailedCount")
.HasColumnType("integer");
b.Property<string>("ConcurrencyStamp")
.IsConcurrencyToken()
.HasColumnType("text");
b.Property<Guid?>("CreatedByOwnerId")
.HasColumnType("uuid");
b.Property<DateTime>("DateCreated")
.HasColumnType("timestamp with time zone");
b.Property<string>("Email")
.HasMaxLength(256)
.HasColumnType("character varying(256)");
b.Property<bool>("EmailConfirmed")
.HasColumnType("boolean");
b.Property<bool>("LockoutEnabled")
.HasColumnType("boolean");
b.Property<DateTimeOffset?>("LockoutEnd")
.HasColumnType("timestamp with time zone");
b.Property<bool>("MustChangePassword")
.HasColumnType("boolean");
b.Property<string>("NormalizedEmail")
.HasMaxLength(256)
.HasColumnType("character varying(256)");
b.Property<string>("NormalizedUserName")
.HasMaxLength(256)
.HasColumnType("character varying(256)");
b.Property<string>("PasswordHash")
.HasColumnType("text");
b.Property<string>("PhoneNumber")
.HasColumnType("text");
b.Property<bool>("PhoneNumberConfirmed")
.HasColumnType("boolean");
b.Property<string>("RefreshToken")
.HasColumnType("text");
b.Property<DateTime?>("RefreshTokenExpiryTime")
.HasColumnType("timestamp with time zone");
b.Property<string>("SecurityStamp")
.HasColumnType("text");
b.Property<bool>("TwoFactorEnabled")
.HasColumnType("boolean");
b.Property<string>("UserName")
.HasMaxLength(256)
.HasColumnType("character varying(256)");
b.HasKey("Id");
b.HasIndex("NormalizedEmail")
.IsUnique()
.HasDatabaseName("EmailIndex");
b.HasIndex("NormalizedUserName")
.IsUnique()
.HasDatabaseName("UserNameIndex");
b.ToTable("AspNetUsers", (string)null);
});
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityRole<System.Guid>", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uuid");
b.Property<string>("ConcurrencyStamp")
.IsConcurrencyToken()
.HasColumnType("text");
b.Property<string>("Name")
.HasMaxLength(256)
.HasColumnType("character varying(256)");
b.Property<string>("NormalizedName")
.HasMaxLength(256)
.HasColumnType("character varying(256)");
b.HasKey("Id");
b.HasIndex("NormalizedName")
.IsUnique()
.HasDatabaseName("RoleNameIndex");
b.ToTable("AspNetRoles", (string)null);
b.HasData(
new
{
Id = new Guid("00000000-0000-0000-0000-000000000001"),
ConcurrencyStamp = "1",
Name = "ADMIN",
NormalizedName = "ADMIN"
},
new
{
Id = new Guid("00000000-0000-0000-0000-000000000002"),
ConcurrencyStamp = "2",
Name = "OWNER",
NormalizedName = "OWNER"
},
new
{
Id = new Guid("00000000-0000-0000-0000-000000000003"),
ConcurrencyStamp = "3",
Name = "TOURNAMENT_MANAGER",
NormalizedName = "TOURNAMENT_MANAGER"
},
new
{
Id = new Guid("00000000-0000-0000-0000-000000000004"),
ConcurrencyStamp = "4",
Name = "TEAM_MANAGER",
NormalizedName = "TEAM_MANAGER"
},
new
{
Id = new Guid("00000000-0000-0000-0000-000000000005"),
ConcurrencyStamp = "5",
Name = "GUEST",
NormalizedName = "GUEST"
});
});
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityRoleClaim<System.Guid>", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("integer");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
b.Property<string>("ClaimType")
.HasColumnType("text");
b.Property<string>("ClaimValue")
.HasColumnType("text");
b.Property<Guid>("RoleId")
.HasColumnType("uuid");
b.HasKey("Id");
b.HasIndex("RoleId");
b.ToTable("AspNetRoleClaims", (string)null);
});
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserClaim<System.Guid>", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("integer");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
b.Property<string>("ClaimType")
.HasColumnType("text");
b.Property<string>("ClaimValue")
.HasColumnType("text");
b.Property<Guid>("UserId")
.HasColumnType("uuid");
b.HasKey("Id");
b.HasIndex("UserId");
b.ToTable("AspNetUserClaims", (string)null);
});
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserLogin<System.Guid>", b =>
{
b.Property<string>("LoginProvider")
.HasColumnType("text");
b.Property<string>("ProviderKey")
.HasColumnType("text");
b.Property<string>("ProviderDisplayName")
.HasColumnType("text");
b.Property<Guid>("UserId")
.HasColumnType("uuid");
b.HasKey("LoginProvider", "ProviderKey");
b.HasIndex("UserId");
b.ToTable("AspNetUserLogins", (string)null);
});
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserRole<System.Guid>", b =>
{
b.Property<Guid>("UserId")
.HasColumnType("uuid");
b.Property<Guid>("RoleId")
.HasColumnType("uuid");
b.HasKey("UserId", "RoleId");
b.HasIndex("RoleId");
b.ToTable("AspNetUserRoles", (string)null);
});
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserToken<System.Guid>", b =>
{
b.Property<Guid>("UserId")
.HasColumnType("uuid");
b.Property<string>("LoginProvider")
.HasColumnType("text");
b.Property<string>("Name")
.HasColumnType("text");
b.Property<string>("Value")
.HasColumnType("text");
b.HasKey("UserId", "LoginProvider", "Name");
b.ToTable("AspNetUserTokens", (string)null);
});
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityRoleClaim<System.Guid>", b =>
{
b.HasOne("Microsoft.AspNetCore.Identity.IdentityRole<System.Guid>", null)
.WithMany()
.HasForeignKey("RoleId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
});
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserClaim<System.Guid>", b =>
{
b.HasOne("Infrastructure.Identity.ApplicationUser", null)
.WithMany()
.HasForeignKey("UserId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
});
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserLogin<System.Guid>", b =>
{
b.HasOne("Infrastructure.Identity.ApplicationUser", null)
.WithMany()
.HasForeignKey("UserId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
});
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserRole<System.Guid>", b =>
{
b.HasOne("Microsoft.AspNetCore.Identity.IdentityRole<System.Guid>", null)
.WithMany()
.HasForeignKey("RoleId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("Infrastructure.Identity.ApplicationUser", null)
.WithMany()
.HasForeignKey("UserId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
});
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserToken<System.Guid>", b =>
{
b.HasOne("Infrastructure.Identity.ApplicationUser", null)
.WithMany()
.HasForeignKey("UserId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
});
#pragma warning restore 612, 618
}
}
}
@@ -0,0 +1,36 @@
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace Infrastructure.Identity.Migrations;
/// <inheritdoc />
public partial class AddNewPropsForIdentity : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropIndex(
name: "EmailIndex",
table: "AspNetUsers");
migrationBuilder.CreateIndex(
name: "EmailIndex",
table: "AspNetUsers",
column: "NormalizedEmail",
unique: true);
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropIndex(
name: "EmailIndex",
table: "AspNetUsers");
migrationBuilder.CreateIndex(
name: "EmailIndex",
table: "AspNetUsers",
column: "NormalizedEmail");
}
}
@@ -0,0 +1,315 @@
// <auto-generated />
using System;
using Infrastructure.Identity;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Migrations;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
#nullable disable
namespace Infrastructure.Identity.Migrations
{
[DbContext(typeof(IdentityAppDbContext))]
[Migration("20260828021949_RemoveTournamentAndTeamManagerRoles")]
partial class RemoveTournamentAndTeamManagerRoles
{
/// <inheritdoc />
protected override void BuildTargetModel(ModelBuilder modelBuilder)
{
#pragma warning disable 612, 618
modelBuilder
.HasAnnotation("ProductVersion", "8.0.30")
.HasAnnotation("Relational:MaxIdentifierLength", 63);
NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder);
modelBuilder.Entity("Infrastructure.Identity.ApplicationUser", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uuid");
b.Property<int>("AccessFailedCount")
.HasColumnType("integer");
b.Property<string>("ConcurrencyStamp")
.IsConcurrencyToken()
.HasColumnType("text");
b.Property<Guid?>("CreatedByOwnerId")
.HasColumnType("uuid");
b.Property<DateTime>("DateCreated")
.HasColumnType("timestamp with time zone");
b.Property<string>("Email")
.HasMaxLength(256)
.HasColumnType("character varying(256)");
b.Property<bool>("EmailConfirmed")
.HasColumnType("boolean");
b.Property<bool>("LockoutEnabled")
.HasColumnType("boolean");
b.Property<DateTimeOffset?>("LockoutEnd")
.HasColumnType("timestamp with time zone");
b.Property<bool>("MustChangePassword")
.HasColumnType("boolean");
b.Property<string>("NormalizedEmail")
.HasMaxLength(256)
.HasColumnType("character varying(256)");
b.Property<string>("NormalizedUserName")
.HasMaxLength(256)
.HasColumnType("character varying(256)");
b.Property<string>("PasswordHash")
.HasColumnType("text");
b.Property<string>("PhoneNumber")
.HasColumnType("text");
b.Property<bool>("PhoneNumberConfirmed")
.HasColumnType("boolean");
b.Property<string>("RefreshToken")
.HasColumnType("text");
b.Property<DateTime?>("RefreshTokenExpiryTime")
.HasColumnType("timestamp with time zone");
b.Property<string>("SecurityStamp")
.HasColumnType("text");
b.Property<bool>("TwoFactorEnabled")
.HasColumnType("boolean");
b.Property<string>("UserName")
.HasMaxLength(256)
.HasColumnType("character varying(256)");
b.HasKey("Id");
b.HasIndex("NormalizedEmail")
.IsUnique()
.HasDatabaseName("EmailIndex");
b.HasIndex("NormalizedUserName")
.IsUnique()
.HasDatabaseName("UserNameIndex");
b.ToTable("AspNetUsers", (string)null);
});
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityRole<System.Guid>", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uuid");
b.Property<string>("ConcurrencyStamp")
.IsConcurrencyToken()
.HasColumnType("text");
b.Property<string>("Name")
.HasMaxLength(256)
.HasColumnType("character varying(256)");
b.Property<string>("NormalizedName")
.HasMaxLength(256)
.HasColumnType("character varying(256)");
b.HasKey("Id");
b.HasIndex("NormalizedName")
.IsUnique()
.HasDatabaseName("RoleNameIndex");
b.ToTable("AspNetRoles", (string)null);
b.HasData(
new
{
Id = new Guid("00000000-0000-0000-0000-000000000001"),
ConcurrencyStamp = "1",
Name = "ADMIN",
NormalizedName = "ADMIN"
},
new
{
Id = new Guid("00000000-0000-0000-0000-000000000002"),
ConcurrencyStamp = "2",
Name = "OWNER",
NormalizedName = "OWNER"
},
new
{
Id = new Guid("00000000-0000-0000-0000-000000000005"),
ConcurrencyStamp = "5",
Name = "GUEST",
NormalizedName = "GUEST"
});
});
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityRoleClaim<System.Guid>", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("integer");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
b.Property<string>("ClaimType")
.HasColumnType("text");
b.Property<string>("ClaimValue")
.HasColumnType("text");
b.Property<Guid>("RoleId")
.HasColumnType("uuid");
b.HasKey("Id");
b.HasIndex("RoleId");
b.ToTable("AspNetRoleClaims", (string)null);
});
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserClaim<System.Guid>", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("integer");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
b.Property<string>("ClaimType")
.HasColumnType("text");
b.Property<string>("ClaimValue")
.HasColumnType("text");
b.Property<Guid>("UserId")
.HasColumnType("uuid");
b.HasKey("Id");
b.HasIndex("UserId");
b.ToTable("AspNetUserClaims", (string)null);
});
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserLogin<System.Guid>", b =>
{
b.Property<string>("LoginProvider")
.HasColumnType("text");
b.Property<string>("ProviderKey")
.HasColumnType("text");
b.Property<string>("ProviderDisplayName")
.HasColumnType("text");
b.Property<Guid>("UserId")
.HasColumnType("uuid");
b.HasKey("LoginProvider", "ProviderKey");
b.HasIndex("UserId");
b.ToTable("AspNetUserLogins", (string)null);
});
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserRole<System.Guid>", b =>
{
b.Property<Guid>("UserId")
.HasColumnType("uuid");
b.Property<Guid>("RoleId")
.HasColumnType("uuid");
b.HasKey("UserId", "RoleId");
b.HasIndex("RoleId");
b.ToTable("AspNetUserRoles", (string)null);
});
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserToken<System.Guid>", b =>
{
b.Property<Guid>("UserId")
.HasColumnType("uuid");
b.Property<string>("LoginProvider")
.HasColumnType("text");
b.Property<string>("Name")
.HasColumnType("text");
b.Property<string>("Value")
.HasColumnType("text");
b.HasKey("UserId", "LoginProvider", "Name");
b.ToTable("AspNetUserTokens", (string)null);
});
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityRoleClaim<System.Guid>", b =>
{
b.HasOne("Microsoft.AspNetCore.Identity.IdentityRole<System.Guid>", null)
.WithMany()
.HasForeignKey("RoleId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
});
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserClaim<System.Guid>", b =>
{
b.HasOne("Infrastructure.Identity.ApplicationUser", null)
.WithMany()
.HasForeignKey("UserId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
});
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserLogin<System.Guid>", b =>
{
b.HasOne("Infrastructure.Identity.ApplicationUser", null)
.WithMany()
.HasForeignKey("UserId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
});
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserRole<System.Guid>", b =>
{
b.HasOne("Microsoft.AspNetCore.Identity.IdentityRole<System.Guid>", null)
.WithMany()
.HasForeignKey("RoleId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("Infrastructure.Identity.ApplicationUser", null)
.WithMany()
.HasForeignKey("UserId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
});
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserToken<System.Guid>", b =>
{
b.HasOne("Infrastructure.Identity.ApplicationUser", null)
.WithMany()
.HasForeignKey("UserId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
});
#pragma warning restore 612, 618
}
}
}
@@ -0,0 +1,40 @@
using System;
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
#pragma warning disable CA1814 // Prefer jagged arrays over multidimensional
namespace Infrastructure.Identity.Migrations
{
/// <inheritdoc />
public partial class RemoveTournamentAndTeamManagerRoles : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.DeleteData(
table: "AspNetRoles",
keyColumn: "Id",
keyValue: new Guid("00000000-0000-0000-0000-000000000003"));
migrationBuilder.DeleteData(
table: "AspNetRoles",
keyColumn: "Id",
keyValue: new Guid("00000000-0000-0000-0000-000000000004"));
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.InsertData(
table: "AspNetRoles",
columns: new[] { "Id", "ConcurrencyStamp", "Name", "NormalizedName" },
values: new object[,]
{
{ new Guid("00000000-0000-0000-0000-000000000003"), "3", "TOURNAMENT_MANAGER", "TOURNAMENT_MANAGER" },
{ new Guid("00000000-0000-0000-0000-000000000004"), "4", "TEAM_MANAGER", "TEAM_MANAGER" }
});
}
}
}
@@ -0,0 +1,312 @@
// <auto-generated />
using System;
using Infrastructure.Identity;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
#nullable disable
namespace Infrastructure.Identity.Migrations
{
[DbContext(typeof(IdentityAppDbContext))]
partial class IdentityAppDbContextModelSnapshot : ModelSnapshot
{
protected override void BuildModel(ModelBuilder modelBuilder)
{
#pragma warning disable 612, 618
modelBuilder
.HasAnnotation("ProductVersion", "8.0.30")
.HasAnnotation("Relational:MaxIdentifierLength", 63);
NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder);
modelBuilder.Entity("Infrastructure.Identity.ApplicationUser", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uuid");
b.Property<int>("AccessFailedCount")
.HasColumnType("integer");
b.Property<string>("ConcurrencyStamp")
.IsConcurrencyToken()
.HasColumnType("text");
b.Property<Guid?>("CreatedByOwnerId")
.HasColumnType("uuid");
b.Property<DateTime>("DateCreated")
.HasColumnType("timestamp with time zone");
b.Property<string>("Email")
.HasMaxLength(256)
.HasColumnType("character varying(256)");
b.Property<bool>("EmailConfirmed")
.HasColumnType("boolean");
b.Property<bool>("LockoutEnabled")
.HasColumnType("boolean");
b.Property<DateTimeOffset?>("LockoutEnd")
.HasColumnType("timestamp with time zone");
b.Property<bool>("MustChangePassword")
.HasColumnType("boolean");
b.Property<string>("NormalizedEmail")
.HasMaxLength(256)
.HasColumnType("character varying(256)");
b.Property<string>("NormalizedUserName")
.HasMaxLength(256)
.HasColumnType("character varying(256)");
b.Property<string>("PasswordHash")
.HasColumnType("text");
b.Property<string>("PhoneNumber")
.HasColumnType("text");
b.Property<bool>("PhoneNumberConfirmed")
.HasColumnType("boolean");
b.Property<string>("RefreshToken")
.HasColumnType("text");
b.Property<DateTime?>("RefreshTokenExpiryTime")
.HasColumnType("timestamp with time zone");
b.Property<string>("SecurityStamp")
.HasColumnType("text");
b.Property<bool>("TwoFactorEnabled")
.HasColumnType("boolean");
b.Property<string>("UserName")
.HasMaxLength(256)
.HasColumnType("character varying(256)");
b.HasKey("Id");
b.HasIndex("NormalizedEmail")
.IsUnique()
.HasDatabaseName("EmailIndex");
b.HasIndex("NormalizedUserName")
.IsUnique()
.HasDatabaseName("UserNameIndex");
b.ToTable("AspNetUsers", (string)null);
});
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityRole<System.Guid>", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uuid");
b.Property<string>("ConcurrencyStamp")
.IsConcurrencyToken()
.HasColumnType("text");
b.Property<string>("Name")
.HasMaxLength(256)
.HasColumnType("character varying(256)");
b.Property<string>("NormalizedName")
.HasMaxLength(256)
.HasColumnType("character varying(256)");
b.HasKey("Id");
b.HasIndex("NormalizedName")
.IsUnique()
.HasDatabaseName("RoleNameIndex");
b.ToTable("AspNetRoles", (string)null);
b.HasData(
new
{
Id = new Guid("00000000-0000-0000-0000-000000000001"),
ConcurrencyStamp = "1",
Name = "ADMIN",
NormalizedName = "ADMIN"
},
new
{
Id = new Guid("00000000-0000-0000-0000-000000000002"),
ConcurrencyStamp = "2",
Name = "OWNER",
NormalizedName = "OWNER"
},
new
{
Id = new Guid("00000000-0000-0000-0000-000000000005"),
ConcurrencyStamp = "5",
Name = "GUEST",
NormalizedName = "GUEST"
});
});
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityRoleClaim<System.Guid>", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("integer");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
b.Property<string>("ClaimType")
.HasColumnType("text");
b.Property<string>("ClaimValue")
.HasColumnType("text");
b.Property<Guid>("RoleId")
.HasColumnType("uuid");
b.HasKey("Id");
b.HasIndex("RoleId");
b.ToTable("AspNetRoleClaims", (string)null);
});
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserClaim<System.Guid>", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("integer");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
b.Property<string>("ClaimType")
.HasColumnType("text");
b.Property<string>("ClaimValue")
.HasColumnType("text");
b.Property<Guid>("UserId")
.HasColumnType("uuid");
b.HasKey("Id");
b.HasIndex("UserId");
b.ToTable("AspNetUserClaims", (string)null);
});
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserLogin<System.Guid>", b =>
{
b.Property<string>("LoginProvider")
.HasColumnType("text");
b.Property<string>("ProviderKey")
.HasColumnType("text");
b.Property<string>("ProviderDisplayName")
.HasColumnType("text");
b.Property<Guid>("UserId")
.HasColumnType("uuid");
b.HasKey("LoginProvider", "ProviderKey");
b.HasIndex("UserId");
b.ToTable("AspNetUserLogins", (string)null);
});
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserRole<System.Guid>", b =>
{
b.Property<Guid>("UserId")
.HasColumnType("uuid");
b.Property<Guid>("RoleId")
.HasColumnType("uuid");
b.HasKey("UserId", "RoleId");
b.HasIndex("RoleId");
b.ToTable("AspNetUserRoles", (string)null);
});
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserToken<System.Guid>", b =>
{
b.Property<Guid>("UserId")
.HasColumnType("uuid");
b.Property<string>("LoginProvider")
.HasColumnType("text");
b.Property<string>("Name")
.HasColumnType("text");
b.Property<string>("Value")
.HasColumnType("text");
b.HasKey("UserId", "LoginProvider", "Name");
b.ToTable("AspNetUserTokens", (string)null);
});
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityRoleClaim<System.Guid>", b =>
{
b.HasOne("Microsoft.AspNetCore.Identity.IdentityRole<System.Guid>", null)
.WithMany()
.HasForeignKey("RoleId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
});
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserClaim<System.Guid>", b =>
{
b.HasOne("Infrastructure.Identity.ApplicationUser", null)
.WithMany()
.HasForeignKey("UserId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
});
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserLogin<System.Guid>", b =>
{
b.HasOne("Infrastructure.Identity.ApplicationUser", null)
.WithMany()
.HasForeignKey("UserId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
});
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserRole<System.Guid>", b =>
{
b.HasOne("Microsoft.AspNetCore.Identity.IdentityRole<System.Guid>", null)
.WithMany()
.HasForeignKey("RoleId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("Infrastructure.Identity.ApplicationUser", null)
.WithMany()
.HasForeignKey("UserId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
});
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserToken<System.Guid>", b =>
{
b.HasOne("Infrastructure.Identity.ApplicationUser", null)
.WithMany()
.HasForeignKey("UserId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
});
#pragma warning restore 612, 618
}
}
}
@@ -0,0 +1,37 @@
<Project Sdk="Microsoft.NET.Sdk">
<ItemGroup>
<PackageReference Include="AutoMapper" Version="16.2.0">
<NoWarn>NU1903</NoWarn>
</PackageReference>
<PackageReference Include="FluentEmail.MailKit" Version="3.0.2" />
<PackageReference Include="Microsoft.AspNetCore.Identity.EntityFrameworkCore" Version="8.0.30" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="8.0.30">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="8.0.30">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="8.0.1" />
<PackageReference Include="Npgsql.EntityFrameworkCore.PostgreSQL" Version="8.0.11" />
<PackageReference Include="Supabase" Version="1.6.0" />
<PackageReference Include="Supabase.Storage" Version="2.7.0" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Application\Application.csproj" />
<ProjectReference Include="..\Domain\Domain.csproj" />
</ItemGroup>
<ItemGroup>
<Folder Include="Identity\Migrations\" />
</ItemGroup>
<ItemGroup>
<EmbeddedResource Include="Email\Templates\*.html" />
<EmbeddedResource Include="Persistance\Seeding\Assets\*.pdf" />
</ItemGroup>
<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<Nullable>enable</Nullable>
<GenerateDocumentationFile>true</GenerateDocumentationFile>
</PropertyGroup>
</Project>
@@ -0,0 +1,625 @@
// <auto-generated />
using System;
using Infrastructure.Persistance;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Migrations;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
#nullable disable
namespace Persistance.Migrations
{
[DbContext(typeof(ApplicationDBContext))]
[Migration("20250316201442_InitialMigration")]
partial class InitialMigration
{
/// <inheritdoc />
protected override void BuildTargetModel(ModelBuilder modelBuilder)
{
#pragma warning disable 612, 618
modelBuilder
.HasAnnotation("ProductVersion", "8.0.11")
.HasAnnotation("Relational:MaxIdentifierLength", 63);
NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder);
modelBuilder.Entity("Entities.Models.BlogPostEntity.BlogPost", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uuid");
b.Property<string>("Author")
.IsRequired()
.HasMaxLength(50)
.HasColumnType("character varying(50)");
b.Property<DateTime>("DateCreated")
.HasColumnType("timestamp with time zone")
.HasColumnName("DateCreated");
b.Property<DateTime?>("DateUpdated")
.HasColumnType("timestamp with time zone")
.HasColumnName("DateUpdated");
b.Property<string>("MarkdownText")
.IsRequired()
.HasColumnType("text");
b.Property<string>("PhotoUrl")
.HasMaxLength(2048)
.HasColumnType("character varying(2048)");
b.Property<string>("Title")
.IsRequired()
.HasColumnType("text");
b.Property<int>("Views")
.HasColumnType("integer");
b.HasKey("Id");
b.ToTable("BlogPosts", "Club12");
});
modelBuilder.Entity("Entities.Models.DivisionEntity.Division", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uuid");
b.Property<DateTime>("DateCreated")
.HasColumnType("timestamp with time zone")
.HasColumnName("DateCreated");
b.Property<DateTime?>("DateUpdated")
.HasColumnType("timestamp with time zone")
.HasColumnName("DateUpdated");
b.Property<bool>("IsFinished")
.HasColumnType("boolean");
b.Property<string>("Name")
.IsRequired()
.HasMaxLength(30)
.HasColumnType("character varying(30)");
b.Property<bool>("PlayoffsGenerated")
.HasColumnType("boolean");
b.Property<Guid>("TournamentId")
.HasColumnType("uuid");
b.HasKey("Id");
b.HasIndex("TournamentId");
b.ToTable("Divisions", "Club12");
});
modelBuilder.Entity("Entities.Models.MatchEntity.Match", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uuid");
b.Property<DateTime>("DateCreated")
.HasColumnType("timestamp with time zone")
.HasColumnName("DateCreated");
b.Property<DateTime?>("DateUpdated")
.HasColumnType("timestamp with time zone")
.HasColumnName("DateUpdated");
b.Property<Guid>("DivisionId")
.HasColumnType("uuid");
b.Property<int?>("GameNumber")
.HasColumnType("integer");
b.Property<int?>("HomeScore")
.HasColumnType("integer");
b.Property<Guid>("HomeTeamId")
.HasColumnType("uuid");
b.Property<bool>("IsFinished")
.HasColumnType("boolean");
b.Property<DateTime>("MatchDate")
.HasColumnType("timestamp with time zone");
b.Property<int?>("MatchWeek")
.HasColumnType("integer");
b.Property<string>("RoundName")
.HasColumnType("text");
b.Property<string>("Type")
.IsRequired()
.HasColumnType("text");
b.Property<Guid?>("VenueId")
.HasColumnType("uuid");
b.Property<int?>("VisitorScore")
.HasColumnType("integer");
b.Property<Guid>("VisitorTeamId")
.HasColumnType("uuid");
b.Property<Guid?>("WinningTeamId")
.HasColumnType("uuid");
b.HasKey("Id");
b.HasIndex("DivisionId");
b.HasIndex("HomeTeamId");
b.HasIndex("VenueId");
b.HasIndex("VisitorTeamId");
b.HasIndex("WinningTeamId");
b.ToTable("Matches", "Club12");
});
modelBuilder.Entity("Entities.Models.PlayerEntity.Player", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uuid");
b.Property<DateTime>("BirthDate")
.HasColumnType("timestamp with time zone");
b.Property<string>("Category")
.HasMaxLength(50)
.HasColumnType("character varying(50)");
b.Property<string>("Club")
.HasMaxLength(100)
.HasColumnType("character varying(100)");
b.Property<DateTime>("DateCreated")
.HasColumnType("timestamp with time zone")
.HasColumnName("DateCreated");
b.Property<DateTime?>("DateUpdated")
.HasColumnType("timestamp with time zone")
.HasColumnName("DateUpdated");
b.Property<string>("DocumentNumber")
.IsRequired()
.HasMaxLength(15)
.HasColumnType("character varying(15)");
b.Property<bool>("IsFederated")
.HasColumnType("boolean");
b.Property<bool>("IsSanctioned")
.HasColumnType("boolean");
b.Property<string>("LastName")
.IsRequired()
.HasMaxLength(70)
.HasColumnType("character varying(70)");
b.Property<string>("Names")
.IsRequired()
.HasMaxLength(70)
.HasColumnType("character varying(70)");
b.Property<string>("PhoneNumber")
.HasColumnType("text");
b.Property<string>("SocialSecurity")
.IsRequired()
.HasMaxLength(100)
.HasColumnType("character varying(100)");
b.Property<Guid>("TeamId")
.HasColumnType("uuid");
b.HasKey("Id");
b.HasIndex("TeamId");
b.ToTable("Players", "Club12");
});
modelBuilder.Entity("Entities.Models.PlayerSanctionEntity.PlayerSanction", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uuid");
b.Property<DateTime>("DateCreated")
.HasColumnType("timestamp with time zone")
.HasColumnName("DateCreated");
b.Property<DateTime?>("DateUpdated")
.HasColumnType("timestamp with time zone")
.HasColumnName("DateUpdated");
b.Property<string>("Description")
.IsRequired()
.HasMaxLength(255)
.HasColumnType("character varying(255)");
b.Property<int>("Duration")
.HasColumnType("integer");
b.Property<DateTime>("IssuedDate")
.HasColumnType("timestamp with time zone");
b.Property<Guid>("PlayerId")
.HasColumnType("uuid");
b.HasKey("Id");
b.HasIndex("PlayerId");
b.ToTable("PlayerSanctions", "Club12");
});
modelBuilder.Entity("Entities.Models.PlayerStatisticEntity.PlayerStatistic", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uuid");
b.Property<DateTime>("DateCreated")
.HasColumnType("timestamp with time zone")
.HasColumnName("DateCreated");
b.Property<DateTime?>("DateUpdated")
.HasColumnType("timestamp with time zone")
.HasColumnName("DateUpdated");
b.Property<Guid>("MatchId")
.HasColumnType("uuid");
b.Property<Guid>("PlayerId")
.HasColumnType("uuid");
b.Property<int>("Value")
.HasColumnType("integer");
b.HasKey("Id");
b.HasIndex("MatchId");
b.HasIndex("PlayerId");
b.ToTable("PlayersStatistics", "Club12");
});
modelBuilder.Entity("Entities.Models.StaffEntity.Staff", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uuid");
b.Property<DateTime>("DateCreated")
.HasColumnType("timestamp with time zone")
.HasColumnName("DateCreated");
b.Property<DateTime?>("DateUpdated")
.HasColumnType("timestamp with time zone")
.HasColumnName("DateUpdated");
b.Property<string>("LastName")
.IsRequired()
.HasMaxLength(50)
.HasColumnType("character varying(50)");
b.Property<string>("Names")
.IsRequired()
.HasMaxLength(50)
.HasColumnType("character varying(50)");
b.Property<string>("PhoneNumber")
.IsRequired()
.HasMaxLength(15)
.HasColumnType("character varying(15)");
b.Property<Guid>("TeamId")
.HasColumnType("uuid");
b.Property<string>("Type")
.IsRequired()
.HasColumnType("text");
b.HasKey("Id");
b.HasIndex("TeamId");
b.ToTable("Staffs", "Club12");
});
modelBuilder.Entity("Entities.Models.TeamEntity.Team", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uuid");
b.Property<DateTime>("DateCreated")
.HasColumnType("timestamp with time zone")
.HasColumnName("DateCreated");
b.Property<DateTime?>("DateUpdated")
.HasColumnType("timestamp with time zone")
.HasColumnName("DateUpdated");
b.Property<Guid>("DivisionId")
.HasColumnType("uuid");
b.Property<string>("LogoUrl")
.IsRequired()
.HasColumnType("text");
b.Property<string>("Name")
.IsRequired()
.HasColumnType("text");
b.Property<string>("ShirtColor")
.IsRequired()
.HasColumnType("text");
b.Property<string>("ThreeLetterCode")
.IsRequired()
.HasColumnType("text");
b.HasKey("Id");
b.HasIndex("DivisionId");
b.ToTable("Teams", "Club12");
});
modelBuilder.Entity("Entities.Models.TournamentEntity.Tournament", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uuid");
b.Property<DateTime>("DateCreated")
.HasColumnType("timestamp with time zone")
.HasColumnName("DateCreated");
b.Property<DateTime?>("DateUpdated")
.HasColumnType("timestamp with time zone")
.HasColumnName("DateUpdated");
b.Property<string>("Description")
.IsRequired()
.HasColumnType("text");
b.Property<string>("Name")
.IsRequired()
.HasColumnType("text");
b.HasKey("Id");
b.ToTable("Tournaments", "Club12");
});
modelBuilder.Entity("Entities.Models.UserEntity.User", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uuid");
b.Property<DateTime>("DateCreated")
.HasColumnType("timestamp with time zone")
.HasColumnName("DateCreated");
b.Property<DateTime?>("DateUpdated")
.HasColumnType("timestamp with time zone")
.HasColumnName("DateUpdated");
b.Property<string>("Password")
.IsRequired()
.HasMaxLength(64)
.HasColumnType("character varying(64)");
b.Property<string>("RefreshToken")
.HasMaxLength(256)
.HasColumnType("character varying(256)");
b.Property<DateTime?>("RefreshTokenExpiryTime")
.HasColumnType("timestamp with time zone");
b.Property<string>("Role")
.IsRequired()
.HasMaxLength(10)
.HasColumnType("character varying(10)");
b.Property<string>("Username")
.IsRequired()
.HasMaxLength(25)
.HasColumnType("character varying(25)");
b.HasKey("Id");
b.ToTable("Users", "Club12");
});
modelBuilder.Entity("Entities.Models.VenueEntity.Venue", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uuid");
b.Property<string>("Address")
.IsRequired()
.HasMaxLength(200)
.HasColumnType("character varying(200)");
b.Property<DateTime>("DateCreated")
.HasColumnType("timestamp with time zone")
.HasColumnName("DateCreated");
b.Property<DateTime?>("DateUpdated")
.HasColumnType("timestamp with time zone")
.HasColumnName("DateUpdated");
b.Property<string>("Name")
.IsRequired()
.HasMaxLength(50)
.HasColumnType("character varying(50)");
b.Property<string>("PhotoUrl")
.HasColumnType("text");
b.HasKey("Id");
b.ToTable("Venues", "Club12");
});
modelBuilder.Entity("Entities.Models.DivisionEntity.Division", b =>
{
b.HasOne("Entities.Models.TournamentEntity.Tournament", "Tournament")
.WithMany("Divisions")
.HasForeignKey("TournamentId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Tournament");
});
modelBuilder.Entity("Entities.Models.MatchEntity.Match", b =>
{
b.HasOne("Entities.Models.DivisionEntity.Division", "Division")
.WithMany("Matches")
.HasForeignKey("DivisionId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("Entities.Models.TeamEntity.Team", "HomeTeam")
.WithMany()
.HasForeignKey("HomeTeamId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("Entities.Models.VenueEntity.Venue", "Venue")
.WithMany()
.HasForeignKey("VenueId");
b.HasOne("Entities.Models.TeamEntity.Team", "VisitorTeam")
.WithMany()
.HasForeignKey("VisitorTeamId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("Entities.Models.TeamEntity.Team", "WinningTeam")
.WithMany()
.HasForeignKey("WinningTeamId");
b.Navigation("Division");
b.Navigation("HomeTeam");
b.Navigation("Venue");
b.Navigation("VisitorTeam");
b.Navigation("WinningTeam");
});
modelBuilder.Entity("Entities.Models.PlayerEntity.Player", b =>
{
b.HasOne("Entities.Models.TeamEntity.Team", "Team")
.WithMany("Players")
.HasForeignKey("TeamId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Team");
});
modelBuilder.Entity("Entities.Models.PlayerSanctionEntity.PlayerSanction", b =>
{
b.HasOne("Entities.Models.PlayerEntity.Player", "Player")
.WithMany()
.HasForeignKey("PlayerId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Player");
});
modelBuilder.Entity("Entities.Models.PlayerStatisticEntity.PlayerStatistic", b =>
{
b.HasOne("Entities.Models.MatchEntity.Match", "Match")
.WithMany("PlayerStatistics")
.HasForeignKey("MatchId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("Entities.Models.PlayerEntity.Player", "Player")
.WithMany()
.HasForeignKey("PlayerId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Match");
b.Navigation("Player");
});
modelBuilder.Entity("Entities.Models.StaffEntity.Staff", b =>
{
b.HasOne("Entities.Models.TeamEntity.Team", "Team")
.WithMany("Staff")
.HasForeignKey("TeamId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Team");
});
modelBuilder.Entity("Entities.Models.TeamEntity.Team", b =>
{
b.HasOne("Entities.Models.DivisionEntity.Division", "Division")
.WithMany("Teams")
.HasForeignKey("DivisionId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Division");
});
modelBuilder.Entity("Entities.Models.DivisionEntity.Division", b =>
{
b.Navigation("Matches");
b.Navigation("Teams");
});
modelBuilder.Entity("Entities.Models.MatchEntity.Match", b =>
{
b.Navigation("PlayerStatistics");
});
modelBuilder.Entity("Entities.Models.TeamEntity.Team", b =>
{
b.Navigation("Players");
b.Navigation("Staff");
});
modelBuilder.Entity("Entities.Models.TournamentEntity.Tournament", b =>
{
b.Navigation("Divisions");
});
#pragma warning restore 612, 618
}
}
}
@@ -0,0 +1,434 @@
using Microsoft.EntityFrameworkCore.Migrations;
using System;
#nullable disable
namespace Persistance.Migrations;
/// <inheritdoc />
public partial class InitialMigration : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.EnsureSchema(
name: "Club12");
migrationBuilder.CreateTable(
name: "BlogPosts",
schema: "Club12",
columns: table => new
{
Id = table.Column<Guid>(type: "uuid", nullable: false),
Author = table.Column<string>(type: "character varying(50)", maxLength: 50, nullable: false),
Title = table.Column<string>(type: "text", nullable: false),
Views = table.Column<int>(type: "integer", nullable: false),
PhotoUrl = table.Column<string>(type: "character varying(2048)", maxLength: 2048, nullable: true),
MarkdownText = table.Column<string>(type: "text", nullable: false),
DateCreated = table.Column<DateTime>(type: "timestamp with time zone", nullable: false),
DateUpdated = table.Column<DateTime>(type: "timestamp with time zone", nullable: true)
},
constraints: table =>
{
table.PrimaryKey("PK_BlogPosts", x => x.Id);
});
migrationBuilder.CreateTable(
name: "Tournaments",
schema: "Club12",
columns: table => new
{
Id = table.Column<Guid>(type: "uuid", nullable: false),
Description = table.Column<string>(type: "text", nullable: false),
Name = table.Column<string>(type: "text", nullable: false),
DateCreated = table.Column<DateTime>(type: "timestamp with time zone", nullable: false),
DateUpdated = table.Column<DateTime>(type: "timestamp with time zone", nullable: true)
},
constraints: table =>
{
table.PrimaryKey("PK_Tournaments", x => x.Id);
});
migrationBuilder.CreateTable(
name: "Users",
schema: "Club12",
columns: table => new
{
Id = table.Column<Guid>(type: "uuid", nullable: false),
Username = table.Column<string>(type: "character varying(25)", maxLength: 25, nullable: false),
Password = table.Column<string>(type: "character varying(64)", maxLength: 64, nullable: false),
Role = table.Column<string>(type: "character varying(10)", maxLength: 10, nullable: false),
RefreshToken = table.Column<string>(type: "character varying(256)", maxLength: 256, nullable: true),
RefreshTokenExpiryTime = table.Column<DateTime>(type: "timestamp with time zone", nullable: true),
DateCreated = table.Column<DateTime>(type: "timestamp with time zone", nullable: false),
DateUpdated = table.Column<DateTime>(type: "timestamp with time zone", nullable: true)
},
constraints: table =>
{
table.PrimaryKey("PK_Users", x => x.Id);
});
migrationBuilder.CreateTable(
name: "Venues",
schema: "Club12",
columns: table => new
{
Id = table.Column<Guid>(type: "uuid", nullable: false),
Name = table.Column<string>(type: "character varying(50)", maxLength: 50, nullable: false),
Address = table.Column<string>(type: "character varying(200)", maxLength: 200, nullable: false),
PhotoUrl = table.Column<string>(type: "text", nullable: true),
DateCreated = table.Column<DateTime>(type: "timestamp with time zone", nullable: false),
DateUpdated = table.Column<DateTime>(type: "timestamp with time zone", nullable: true)
},
constraints: table =>
{
table.PrimaryKey("PK_Venues", x => x.Id);
});
migrationBuilder.CreateTable(
name: "Divisions",
schema: "Club12",
columns: table => new
{
Id = table.Column<Guid>(type: "uuid", nullable: false),
Name = table.Column<string>(type: "character varying(30)", maxLength: 30, nullable: false),
IsFinished = table.Column<bool>(type: "boolean", nullable: false),
TournamentId = table.Column<Guid>(type: "uuid", nullable: false),
PlayoffsGenerated = table.Column<bool>(type: "boolean", nullable: false),
DateCreated = table.Column<DateTime>(type: "timestamp with time zone", nullable: false),
DateUpdated = table.Column<DateTime>(type: "timestamp with time zone", nullable: true)
},
constraints: table =>
{
table.PrimaryKey("PK_Divisions", x => x.Id);
table.ForeignKey(
name: "FK_Divisions_Tournaments_TournamentId",
column: x => x.TournamentId,
principalSchema: "Club12",
principalTable: "Tournaments",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateTable(
name: "Teams",
schema: "Club12",
columns: table => new
{
Id = table.Column<Guid>(type: "uuid", nullable: false),
Name = table.Column<string>(type: "text", nullable: false),
ThreeLetterCode = table.Column<string>(type: "text", nullable: false),
LogoUrl = table.Column<string>(type: "text", nullable: false),
ShirtColor = table.Column<string>(type: "text", nullable: false),
DivisionId = table.Column<Guid>(type: "uuid", nullable: false),
DateCreated = table.Column<DateTime>(type: "timestamp with time zone", nullable: false),
DateUpdated = table.Column<DateTime>(type: "timestamp with time zone", nullable: true)
},
constraints: table =>
{
table.PrimaryKey("PK_Teams", x => x.Id);
table.ForeignKey(
name: "FK_Teams_Divisions_DivisionId",
column: x => x.DivisionId,
principalSchema: "Club12",
principalTable: "Divisions",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateTable(
name: "Matches",
schema: "Club12",
columns: table => new
{
Id = table.Column<Guid>(type: "uuid", nullable: false),
MatchDate = table.Column<DateTime>(type: "timestamp with time zone", nullable: false),
Type = table.Column<string>(type: "text", nullable: false),
MatchWeek = table.Column<int>(type: "integer", nullable: true),
RoundName = table.Column<string>(type: "text", nullable: true),
GameNumber = table.Column<int>(type: "integer", nullable: true),
HomeTeamId = table.Column<Guid>(type: "uuid", nullable: false),
VisitorTeamId = table.Column<Guid>(type: "uuid", nullable: false),
HomeScore = table.Column<int>(type: "integer", nullable: true),
VisitorScore = table.Column<int>(type: "integer", nullable: true),
IsFinished = table.Column<bool>(type: "boolean", nullable: false),
WinningTeamId = table.Column<Guid>(type: "uuid", nullable: true),
DivisionId = table.Column<Guid>(type: "uuid", nullable: false),
VenueId = table.Column<Guid>(type: "uuid", nullable: true),
DateCreated = table.Column<DateTime>(type: "timestamp with time zone", nullable: false),
DateUpdated = table.Column<DateTime>(type: "timestamp with time zone", nullable: true)
},
constraints: table =>
{
table.PrimaryKey("PK_Matches", x => x.Id);
table.ForeignKey(
name: "FK_Matches_Divisions_DivisionId",
column: x => x.DivisionId,
principalSchema: "Club12",
principalTable: "Divisions",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
table.ForeignKey(
name: "FK_Matches_Teams_HomeTeamId",
column: x => x.HomeTeamId,
principalSchema: "Club12",
principalTable: "Teams",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
table.ForeignKey(
name: "FK_Matches_Teams_VisitorTeamId",
column: x => x.VisitorTeamId,
principalSchema: "Club12",
principalTable: "Teams",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
table.ForeignKey(
name: "FK_Matches_Teams_WinningTeamId",
column: x => x.WinningTeamId,
principalSchema: "Club12",
principalTable: "Teams",
principalColumn: "Id");
table.ForeignKey(
name: "FK_Matches_Venues_VenueId",
column: x => x.VenueId,
principalSchema: "Club12",
principalTable: "Venues",
principalColumn: "Id");
});
migrationBuilder.CreateTable(
name: "Players",
schema: "Club12",
columns: table => new
{
Id = table.Column<Guid>(type: "uuid", nullable: false),
Names = table.Column<string>(type: "character varying(70)", maxLength: 70, nullable: false),
LastName = table.Column<string>(type: "character varying(70)", maxLength: 70, nullable: false),
DocumentNumber = table.Column<string>(type: "character varying(15)", maxLength: 15, nullable: false),
IsSanctioned = table.Column<bool>(type: "boolean", nullable: false),
IsFederated = table.Column<bool>(type: "boolean", nullable: false),
PhoneNumber = table.Column<string>(type: "text", nullable: true),
Club = table.Column<string>(type: "character varying(100)", maxLength: 100, nullable: true),
Category = table.Column<string>(type: "character varying(50)", maxLength: 50, nullable: true),
BirthDate = table.Column<DateTime>(type: "timestamp with time zone", nullable: false),
SocialSecurity = table.Column<string>(type: "character varying(100)", maxLength: 100, nullable: false),
TeamId = table.Column<Guid>(type: "uuid", nullable: false),
DateCreated = table.Column<DateTime>(type: "timestamp with time zone", nullable: false),
DateUpdated = table.Column<DateTime>(type: "timestamp with time zone", nullable: true)
},
constraints: table =>
{
table.PrimaryKey("PK_Players", x => x.Id);
table.ForeignKey(
name: "FK_Players_Teams_TeamId",
column: x => x.TeamId,
principalSchema: "Club12",
principalTable: "Teams",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateTable(
name: "Staffs",
schema: "Club12",
columns: table => new
{
Id = table.Column<Guid>(type: "uuid", nullable: false),
Names = table.Column<string>(type: "character varying(50)", maxLength: 50, nullable: false),
LastName = table.Column<string>(type: "character varying(50)", maxLength: 50, nullable: false),
PhoneNumber = table.Column<string>(type: "character varying(15)", maxLength: 15, nullable: false),
Type = table.Column<string>(type: "text", nullable: false),
TeamId = table.Column<Guid>(type: "uuid", nullable: false),
DateCreated = table.Column<DateTime>(type: "timestamp with time zone", nullable: false),
DateUpdated = table.Column<DateTime>(type: "timestamp with time zone", nullable: true)
},
constraints: table =>
{
table.PrimaryKey("PK_Staffs", x => x.Id);
table.ForeignKey(
name: "FK_Staffs_Teams_TeamId",
column: x => x.TeamId,
principalSchema: "Club12",
principalTable: "Teams",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateTable(
name: "PlayerSanctions",
schema: "Club12",
columns: table => new
{
Id = table.Column<Guid>(type: "uuid", nullable: false),
Duration = table.Column<int>(type: "integer", nullable: false),
IssuedDate = table.Column<DateTime>(type: "timestamp with time zone", nullable: false),
Description = table.Column<string>(type: "character varying(255)", maxLength: 255, nullable: false),
PlayerId = table.Column<Guid>(type: "uuid", nullable: false),
DateCreated = table.Column<DateTime>(type: "timestamp with time zone", nullable: false),
DateUpdated = table.Column<DateTime>(type: "timestamp with time zone", nullable: true)
},
constraints: table =>
{
table.PrimaryKey("PK_PlayerSanctions", x => x.Id);
table.ForeignKey(
name: "FK_PlayerSanctions_Players_PlayerId",
column: x => x.PlayerId,
principalSchema: "Club12",
principalTable: "Players",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateTable(
name: "PlayersStatistics",
schema: "Club12",
columns: table => new
{
Id = table.Column<Guid>(type: "uuid", nullable: false),
Value = table.Column<int>(type: "integer", nullable: false),
MatchId = table.Column<Guid>(type: "uuid", nullable: false),
PlayerId = table.Column<Guid>(type: "uuid", nullable: false),
DateCreated = table.Column<DateTime>(type: "timestamp with time zone", nullable: false),
DateUpdated = table.Column<DateTime>(type: "timestamp with time zone", nullable: true)
},
constraints: table =>
{
table.PrimaryKey("PK_PlayersStatistics", x => x.Id);
table.ForeignKey(
name: "FK_PlayersStatistics_Matches_MatchId",
column: x => x.MatchId,
principalSchema: "Club12",
principalTable: "Matches",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
table.ForeignKey(
name: "FK_PlayersStatistics_Players_PlayerId",
column: x => x.PlayerId,
principalSchema: "Club12",
principalTable: "Players",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateIndex(
name: "IX_Divisions_TournamentId",
schema: "Club12",
table: "Divisions",
column: "TournamentId");
migrationBuilder.CreateIndex(
name: "IX_Matches_DivisionId",
schema: "Club12",
table: "Matches",
column: "DivisionId");
migrationBuilder.CreateIndex(
name: "IX_Matches_HomeTeamId",
schema: "Club12",
table: "Matches",
column: "HomeTeamId");
migrationBuilder.CreateIndex(
name: "IX_Matches_VenueId",
schema: "Club12",
table: "Matches",
column: "VenueId");
migrationBuilder.CreateIndex(
name: "IX_Matches_VisitorTeamId",
schema: "Club12",
table: "Matches",
column: "VisitorTeamId");
migrationBuilder.CreateIndex(
name: "IX_Matches_WinningTeamId",
schema: "Club12",
table: "Matches",
column: "WinningTeamId");
migrationBuilder.CreateIndex(
name: "IX_Players_TeamId",
schema: "Club12",
table: "Players",
column: "TeamId");
migrationBuilder.CreateIndex(
name: "IX_PlayerSanctions_PlayerId",
schema: "Club12",
table: "PlayerSanctions",
column: "PlayerId");
migrationBuilder.CreateIndex(
name: "IX_PlayersStatistics_MatchId",
schema: "Club12",
table: "PlayersStatistics",
column: "MatchId");
migrationBuilder.CreateIndex(
name: "IX_PlayersStatistics_PlayerId",
schema: "Club12",
table: "PlayersStatistics",
column: "PlayerId");
migrationBuilder.CreateIndex(
name: "IX_Staffs_TeamId",
schema: "Club12",
table: "Staffs",
column: "TeamId");
migrationBuilder.CreateIndex(
name: "IX_Teams_DivisionId",
schema: "Club12",
table: "Teams",
column: "DivisionId");
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropTable(
name: "BlogPosts",
schema: "Club12");
migrationBuilder.DropTable(
name: "PlayerSanctions",
schema: "Club12");
migrationBuilder.DropTable(
name: "PlayersStatistics",
schema: "Club12");
migrationBuilder.DropTable(
name: "Staffs",
schema: "Club12");
migrationBuilder.DropTable(
name: "Users",
schema: "Club12");
migrationBuilder.DropTable(
name: "Matches",
schema: "Club12");
migrationBuilder.DropTable(
name: "Players",
schema: "Club12");
migrationBuilder.DropTable(
name: "Venues",
schema: "Club12");
migrationBuilder.DropTable(
name: "Teams",
schema: "Club12");
migrationBuilder.DropTable(
name: "Divisions",
schema: "Club12");
migrationBuilder.DropTable(
name: "Tournaments",
schema: "Club12");
}
}
@@ -0,0 +1,697 @@
// <auto-generated />
using System;
using Infrastructure.Persistance;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Migrations;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
#nullable disable
namespace Persistance.Migrations
{
[DbContext(typeof(ApplicationDBContext))]
[Migration("20250317005231_LatestChanges")]
partial class LatestChanges
{
/// <inheritdoc />
protected override void BuildTargetModel(ModelBuilder modelBuilder)
{
#pragma warning disable 612, 618
modelBuilder
.HasAnnotation("ProductVersion", "8.0.11")
.HasAnnotation("Relational:MaxIdentifierLength", 63);
NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder);
modelBuilder.Entity("Entities.Models.BlogPostEntity.BlogPost", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uuid");
b.Property<string>("Author")
.IsRequired()
.HasMaxLength(50)
.HasColumnType("character varying(50)");
b.Property<DateTime>("DateCreated")
.HasColumnType("timestamp with time zone")
.HasColumnName("DateCreated");
b.Property<DateTime?>("DateUpdated")
.HasColumnType("timestamp with time zone")
.HasColumnName("DateUpdated");
b.Property<string>("MarkdownText")
.IsRequired()
.HasColumnType("text");
b.Property<string>("PhotoUrl")
.HasMaxLength(2048)
.HasColumnType("character varying(2048)");
b.Property<string>("Title")
.IsRequired()
.HasColumnType("text");
b.Property<int>("Views")
.HasColumnType("integer");
b.HasKey("Id");
b.ToTable("BlogPosts", "Club12");
});
modelBuilder.Entity("Entities.Models.DivisionEntity.Division", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uuid");
b.Property<DateTime>("DateCreated")
.HasColumnType("timestamp with time zone")
.HasColumnName("DateCreated");
b.Property<DateTime?>("DateUpdated")
.HasColumnType("timestamp with time zone")
.HasColumnName("DateUpdated");
b.Property<bool>("IsFinished")
.HasColumnType("boolean");
b.Property<string>("Name")
.IsRequired()
.HasMaxLength(30)
.HasColumnType("character varying(30)");
b.Property<bool>("PlayoffsGenerated")
.HasColumnType("boolean");
b.Property<Guid>("TournamentId")
.HasColumnType("uuid");
b.HasKey("Id");
b.HasIndex("TournamentId");
b.ToTable("Divisions", "Club12");
});
modelBuilder.Entity("Entities.Models.MatchEntity.Match", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uuid");
b.Property<DateTime>("DateCreated")
.HasColumnType("timestamp with time zone")
.HasColumnName("DateCreated");
b.Property<DateTime?>("DateUpdated")
.HasColumnType("timestamp with time zone")
.HasColumnName("DateUpdated");
b.Property<Guid>("DivisionId")
.HasColumnType("uuid");
b.Property<int?>("GameNumber")
.HasColumnType("integer");
b.Property<int?>("HomeScore")
.HasColumnType("integer");
b.Property<Guid?>("HomeTeamId")
.HasColumnType("uuid");
b.Property<bool>("IsFinished")
.HasColumnType("boolean");
b.Property<DateTime>("MatchDate")
.HasColumnType("timestamp with time zone");
b.Property<int?>("MatchWeek")
.HasColumnType("integer");
b.Property<Guid?>("PlayoffSeriesId")
.HasColumnType("uuid");
b.Property<string>("Type")
.IsRequired()
.HasColumnType("text");
b.Property<Guid?>("VenueId")
.HasColumnType("uuid");
b.Property<int?>("VisitorScore")
.HasColumnType("integer");
b.Property<Guid>("VisitorTeamId")
.HasColumnType("uuid");
b.Property<Guid?>("WinningTeamId")
.HasColumnType("uuid");
b.HasKey("Id");
b.HasIndex("DivisionId");
b.HasIndex("HomeTeamId");
b.HasIndex("PlayoffSeriesId");
b.HasIndex("VenueId");
b.HasIndex("VisitorTeamId");
b.HasIndex("WinningTeamId");
b.ToTable("Matches", "Club12");
});
modelBuilder.Entity("Entities.Models.PlayerEntity.Player", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uuid");
b.Property<DateTime>("BirthDate")
.HasColumnType("timestamp with time zone");
b.Property<string>("Category")
.HasMaxLength(50)
.HasColumnType("character varying(50)");
b.Property<string>("Club")
.HasMaxLength(100)
.HasColumnType("character varying(100)");
b.Property<DateTime>("DateCreated")
.HasColumnType("timestamp with time zone")
.HasColumnName("DateCreated");
b.Property<DateTime?>("DateUpdated")
.HasColumnType("timestamp with time zone")
.HasColumnName("DateUpdated");
b.Property<string>("DocumentNumber")
.IsRequired()
.HasMaxLength(15)
.HasColumnType("character varying(15)");
b.Property<bool>("IsFederated")
.HasColumnType("boolean");
b.Property<bool>("IsSanctioned")
.HasColumnType("boolean");
b.Property<string>("LastName")
.IsRequired()
.HasMaxLength(70)
.HasColumnType("character varying(70)");
b.Property<string>("Names")
.IsRequired()
.HasMaxLength(70)
.HasColumnType("character varying(70)");
b.Property<string>("PhoneNumber")
.HasColumnType("text");
b.Property<string>("SocialSecurity")
.IsRequired()
.HasMaxLength(100)
.HasColumnType("character varying(100)");
b.Property<Guid>("TeamId")
.HasColumnType("uuid");
b.HasKey("Id");
b.HasIndex("TeamId");
b.ToTable("Players", "Club12");
});
modelBuilder.Entity("Entities.Models.PlayerSanctionEntity.PlayerSanction", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uuid");
b.Property<DateTime>("DateCreated")
.HasColumnType("timestamp with time zone")
.HasColumnName("DateCreated");
b.Property<DateTime?>("DateUpdated")
.HasColumnType("timestamp with time zone")
.HasColumnName("DateUpdated");
b.Property<string>("Description")
.IsRequired()
.HasMaxLength(255)
.HasColumnType("character varying(255)");
b.Property<int>("Duration")
.HasColumnType("integer");
b.Property<DateTime>("IssuedDate")
.HasColumnType("timestamp with time zone");
b.Property<Guid>("PlayerId")
.HasColumnType("uuid");
b.HasKey("Id");
b.HasIndex("PlayerId");
b.ToTable("PlayerSanctions", "Club12");
});
modelBuilder.Entity("Entities.Models.PlayerStatisticEntity.PlayerStatistic", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uuid");
b.Property<DateTime>("DateCreated")
.HasColumnType("timestamp with time zone")
.HasColumnName("DateCreated");
b.Property<DateTime?>("DateUpdated")
.HasColumnType("timestamp with time zone")
.HasColumnName("DateUpdated");
b.Property<Guid>("MatchId")
.HasColumnType("uuid");
b.Property<Guid>("PlayerId")
.HasColumnType("uuid");
b.Property<int>("Value")
.HasColumnType("integer");
b.HasKey("Id");
b.HasIndex("MatchId");
b.HasIndex("PlayerId");
b.ToTable("PlayersStatistics", "Club12");
});
modelBuilder.Entity("Entities.Models.PlayoffSeriesEntity.PlayoffSeries", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uuid");
b.Property<DateTime>("DateCreated")
.HasColumnType("timestamp with time zone")
.HasColumnName("DateCreated");
b.Property<DateTime?>("DateUpdated")
.HasColumnType("timestamp with time zone")
.HasColumnName("DateUpdated");
b.Property<int>("GamesRequiredToWin")
.HasColumnType("integer");
b.Property<int>("HomeTeamWins")
.HasColumnType("integer");
b.Property<bool>("IsFinished")
.HasColumnType("boolean");
b.Property<Guid?>("NextSeriesId")
.HasColumnType("uuid");
b.Property<int>("RoundName")
.HasColumnType("integer");
b.Property<int>("VisitorTeamWins")
.HasColumnType("integer");
b.Property<Guid?>("WinningTeamId")
.HasColumnType("uuid");
b.HasKey("Id");
b.HasIndex("NextSeriesId");
b.HasIndex("WinningTeamId");
b.ToTable("PlayoffSeries", "Club12");
});
modelBuilder.Entity("Entities.Models.StaffEntity.Staff", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uuid");
b.Property<DateTime>("DateCreated")
.HasColumnType("timestamp with time zone")
.HasColumnName("DateCreated");
b.Property<DateTime?>("DateUpdated")
.HasColumnType("timestamp with time zone")
.HasColumnName("DateUpdated");
b.Property<string>("LastName")
.IsRequired()
.HasMaxLength(50)
.HasColumnType("character varying(50)");
b.Property<string>("Names")
.IsRequired()
.HasMaxLength(50)
.HasColumnType("character varying(50)");
b.Property<string>("PhoneNumber")
.IsRequired()
.HasMaxLength(15)
.HasColumnType("character varying(15)");
b.Property<Guid>("TeamId")
.HasColumnType("uuid");
b.Property<string>("Type")
.IsRequired()
.HasColumnType("text");
b.HasKey("Id");
b.HasIndex("TeamId");
b.ToTable("Staffs", "Club12");
});
modelBuilder.Entity("Entities.Models.TeamEntity.Team", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uuid");
b.Property<DateTime>("DateCreated")
.HasColumnType("timestamp with time zone")
.HasColumnName("DateCreated");
b.Property<DateTime?>("DateUpdated")
.HasColumnType("timestamp with time zone")
.HasColumnName("DateUpdated");
b.Property<Guid>("DivisionId")
.HasColumnType("uuid");
b.Property<string>("LogoUrl")
.IsRequired()
.HasColumnType("text");
b.Property<string>("Name")
.IsRequired()
.HasColumnType("text");
b.Property<int>("Seed")
.HasColumnType("integer");
b.Property<string>("ShirtColor")
.IsRequired()
.HasColumnType("text");
b.Property<string>("ThreeLetterCode")
.IsRequired()
.HasColumnType("text");
b.HasKey("Id");
b.HasIndex("DivisionId");
b.ToTable("Teams", "Club12");
});
modelBuilder.Entity("Entities.Models.TournamentEntity.Tournament", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uuid");
b.Property<DateTime>("DateCreated")
.HasColumnType("timestamp with time zone")
.HasColumnName("DateCreated");
b.Property<DateTime?>("DateUpdated")
.HasColumnType("timestamp with time zone")
.HasColumnName("DateUpdated");
b.Property<string>("Description")
.IsRequired()
.HasColumnType("text");
b.Property<string>("Name")
.IsRequired()
.HasColumnType("text");
b.HasKey("Id");
b.ToTable("Tournaments", "Club12");
});
modelBuilder.Entity("Entities.Models.UserEntity.User", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uuid");
b.Property<DateTime>("DateCreated")
.HasColumnType("timestamp with time zone")
.HasColumnName("DateCreated");
b.Property<DateTime?>("DateUpdated")
.HasColumnType("timestamp with time zone")
.HasColumnName("DateUpdated");
b.Property<string>("Password")
.IsRequired()
.HasMaxLength(64)
.HasColumnType("character varying(64)");
b.Property<string>("RefreshToken")
.HasMaxLength(256)
.HasColumnType("character varying(256)");
b.Property<DateTime?>("RefreshTokenExpiryTime")
.HasColumnType("timestamp with time zone");
b.Property<string>("Role")
.IsRequired()
.HasMaxLength(10)
.HasColumnType("character varying(10)");
b.Property<string>("Username")
.IsRequired()
.HasMaxLength(25)
.HasColumnType("character varying(25)");
b.HasKey("Id");
b.ToTable("Users", "Club12");
});
modelBuilder.Entity("Entities.Models.VenueEntity.Venue", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uuid");
b.Property<string>("Address")
.IsRequired()
.HasMaxLength(200)
.HasColumnType("character varying(200)");
b.Property<DateTime>("DateCreated")
.HasColumnType("timestamp with time zone")
.HasColumnName("DateCreated");
b.Property<DateTime?>("DateUpdated")
.HasColumnType("timestamp with time zone")
.HasColumnName("DateUpdated");
b.Property<string>("Name")
.IsRequired()
.HasMaxLength(50)
.HasColumnType("character varying(50)");
b.Property<string>("PhotoUrl")
.HasColumnType("text");
b.HasKey("Id");
b.ToTable("Venues", "Club12");
});
modelBuilder.Entity("Entities.Models.DivisionEntity.Division", b =>
{
b.HasOne("Entities.Models.TournamentEntity.Tournament", "Tournament")
.WithMany("Divisions")
.HasForeignKey("TournamentId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Tournament");
});
modelBuilder.Entity("Entities.Models.MatchEntity.Match", b =>
{
b.HasOne("Entities.Models.DivisionEntity.Division", "Division")
.WithMany("Matches")
.HasForeignKey("DivisionId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("Entities.Models.TeamEntity.Team", "HomeTeam")
.WithMany()
.HasForeignKey("HomeTeamId");
b.HasOne("Entities.Models.PlayoffSeriesEntity.PlayoffSeries", "PlayoffSeries")
.WithMany("Matches")
.HasForeignKey("PlayoffSeriesId");
b.HasOne("Entities.Models.VenueEntity.Venue", "Venue")
.WithMany()
.HasForeignKey("VenueId");
b.HasOne("Entities.Models.TeamEntity.Team", "VisitorTeam")
.WithMany()
.HasForeignKey("VisitorTeamId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("Entities.Models.TeamEntity.Team", "WinningTeam")
.WithMany()
.HasForeignKey("WinningTeamId");
b.Navigation("Division");
b.Navigation("HomeTeam");
b.Navigation("PlayoffSeries");
b.Navigation("Venue");
b.Navigation("VisitorTeam");
b.Navigation("WinningTeam");
});
modelBuilder.Entity("Entities.Models.PlayerEntity.Player", b =>
{
b.HasOne("Entities.Models.TeamEntity.Team", "Team")
.WithMany("Players")
.HasForeignKey("TeamId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Team");
});
modelBuilder.Entity("Entities.Models.PlayerSanctionEntity.PlayerSanction", b =>
{
b.HasOne("Entities.Models.PlayerEntity.Player", "Player")
.WithMany()
.HasForeignKey("PlayerId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Player");
});
modelBuilder.Entity("Entities.Models.PlayerStatisticEntity.PlayerStatistic", b =>
{
b.HasOne("Entities.Models.MatchEntity.Match", "Match")
.WithMany("PlayerStatistics")
.HasForeignKey("MatchId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("Entities.Models.PlayerEntity.Player", "Player")
.WithMany()
.HasForeignKey("PlayerId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Match");
b.Navigation("Player");
});
modelBuilder.Entity("Entities.Models.PlayoffSeriesEntity.PlayoffSeries", b =>
{
b.HasOne("Entities.Models.PlayoffSeriesEntity.PlayoffSeries", "NextSeries")
.WithMany()
.HasForeignKey("NextSeriesId");
b.HasOne("Entities.Models.TeamEntity.Team", "WinningTeam")
.WithMany()
.HasForeignKey("WinningTeamId");
b.Navigation("NextSeries");
b.Navigation("WinningTeam");
});
modelBuilder.Entity("Entities.Models.StaffEntity.Staff", b =>
{
b.HasOne("Entities.Models.TeamEntity.Team", "Team")
.WithMany("Staff")
.HasForeignKey("TeamId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Team");
});
modelBuilder.Entity("Entities.Models.TeamEntity.Team", b =>
{
b.HasOne("Entities.Models.DivisionEntity.Division", "Division")
.WithMany("Teams")
.HasForeignKey("DivisionId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Division");
});
modelBuilder.Entity("Entities.Models.DivisionEntity.Division", b =>
{
b.Navigation("Matches");
b.Navigation("Teams");
});
modelBuilder.Entity("Entities.Models.MatchEntity.Match", b =>
{
b.Navigation("PlayerStatistics");
});
modelBuilder.Entity("Entities.Models.PlayoffSeriesEntity.PlayoffSeries", b =>
{
b.Navigation("Matches");
});
modelBuilder.Entity("Entities.Models.TeamEntity.Team", b =>
{
b.Navigation("Players");
b.Navigation("Staff");
});
modelBuilder.Entity("Entities.Models.TournamentEntity.Tournament", b =>
{
b.Navigation("Divisions");
});
#pragma warning restore 612, 618
}
}
}
@@ -0,0 +1,179 @@
using Microsoft.EntityFrameworkCore.Migrations;
using System;
#nullable disable
namespace Persistance.Migrations;
/// <inheritdoc />
public partial class LatestChanges : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropForeignKey(
name: "FK_Matches_Teams_HomeTeamId",
schema: "Club12",
table: "Matches");
migrationBuilder.DropColumn(
name: "RoundName",
schema: "Club12",
table: "Matches");
migrationBuilder.AddColumn<int>(
name: "Seed",
schema: "Club12",
table: "Teams",
type: "integer",
nullable: false,
defaultValue: 0);
migrationBuilder.AlterColumn<Guid>(
name: "HomeTeamId",
schema: "Club12",
table: "Matches",
type: "uuid",
nullable: true,
oldClrType: typeof(Guid),
oldType: "uuid");
migrationBuilder.AddColumn<Guid>(
name: "PlayoffSeriesId",
schema: "Club12",
table: "Matches",
type: "uuid",
nullable: true);
migrationBuilder.CreateTable(
name: "PlayoffSeries",
schema: "Club12",
columns: table => new
{
Id = table.Column<Guid>(type: "uuid", nullable: false),
RoundName = table.Column<int>(type: "integer", nullable: false),
WinningTeamId = table.Column<Guid>(type: "uuid", nullable: true),
IsFinished = table.Column<bool>(type: "boolean", nullable: false),
GamesRequiredToWin = table.Column<int>(type: "integer", nullable: false),
HomeTeamWins = table.Column<int>(type: "integer", nullable: false),
VisitorTeamWins = table.Column<int>(type: "integer", nullable: false),
NextSeriesId = table.Column<Guid>(type: "uuid", nullable: true),
DateCreated = table.Column<DateTime>(type: "timestamp with time zone", nullable: false),
DateUpdated = table.Column<DateTime>(type: "timestamp with time zone", nullable: true)
},
constraints: table =>
{
table.PrimaryKey("PK_PlayoffSeries", x => x.Id);
table.ForeignKey(
name: "FK_PlayoffSeries_PlayoffSeries_NextSeriesId",
column: x => x.NextSeriesId,
principalSchema: "Club12",
principalTable: "PlayoffSeries",
principalColumn: "Id");
table.ForeignKey(
name: "FK_PlayoffSeries_Teams_WinningTeamId",
column: x => x.WinningTeamId,
principalSchema: "Club12",
principalTable: "Teams",
principalColumn: "Id");
});
migrationBuilder.CreateIndex(
name: "IX_Matches_PlayoffSeriesId",
schema: "Club12",
table: "Matches",
column: "PlayoffSeriesId");
migrationBuilder.CreateIndex(
name: "IX_PlayoffSeries_NextSeriesId",
schema: "Club12",
table: "PlayoffSeries",
column: "NextSeriesId");
migrationBuilder.CreateIndex(
name: "IX_PlayoffSeries_WinningTeamId",
schema: "Club12",
table: "PlayoffSeries",
column: "WinningTeamId");
migrationBuilder.AddForeignKey(
name: "FK_Matches_PlayoffSeries_PlayoffSeriesId",
schema: "Club12",
table: "Matches",
column: "PlayoffSeriesId",
principalSchema: "Club12",
principalTable: "PlayoffSeries",
principalColumn: "Id");
migrationBuilder.AddForeignKey(
name: "FK_Matches_Teams_HomeTeamId",
schema: "Club12",
table: "Matches",
column: "HomeTeamId",
principalSchema: "Club12",
principalTable: "Teams",
principalColumn: "Id");
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropForeignKey(
name: "FK_Matches_PlayoffSeries_PlayoffSeriesId",
schema: "Club12",
table: "Matches");
migrationBuilder.DropForeignKey(
name: "FK_Matches_Teams_HomeTeamId",
schema: "Club12",
table: "Matches");
migrationBuilder.DropTable(
name: "PlayoffSeries",
schema: "Club12");
migrationBuilder.DropIndex(
name: "IX_Matches_PlayoffSeriesId",
schema: "Club12",
table: "Matches");
migrationBuilder.DropColumn(
name: "Seed",
schema: "Club12",
table: "Teams");
migrationBuilder.DropColumn(
name: "PlayoffSeriesId",
schema: "Club12",
table: "Matches");
migrationBuilder.AlterColumn<Guid>(
name: "HomeTeamId",
schema: "Club12",
table: "Matches",
type: "uuid",
nullable: false,
defaultValue: Guid.Empty,
oldClrType: typeof(Guid),
oldType: "uuid",
oldNullable: true);
migrationBuilder.AddColumn<string>(
name: "RoundName",
schema: "Club12",
table: "Matches",
type: "text",
nullable: true);
migrationBuilder.AddForeignKey(
name: "FK_Matches_Teams_HomeTeamId",
schema: "Club12",
table: "Matches",
column: "HomeTeamId",
principalSchema: "Club12",
principalTable: "Teams",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
}
}
@@ -0,0 +1,679 @@
// <auto-generated />
using System;
using Infrastructure.Persistance;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Migrations;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
#nullable disable
namespace Persistance.Migrations
{
[DbContext(typeof(ApplicationDBContext))]
[Migration("20250724231610_AddStageEntity")]
partial class AddStageEntity
{
/// <inheritdoc />
protected override void BuildTargetModel(ModelBuilder modelBuilder)
{
#pragma warning disable 612, 618
modelBuilder
.HasAnnotation("ProductVersion", "8.0.11")
.HasAnnotation("Relational:MaxIdentifierLength", 63);
NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder);
modelBuilder.Entity("Entities.Models.BlogPosts.BlogPost", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uuid");
b.Property<string>("Author")
.IsRequired()
.HasMaxLength(50)
.HasColumnType("character varying(50)");
b.Property<DateTime>("DateCreated")
.HasColumnType("timestamp with time zone")
.HasColumnName("DateCreated");
b.Property<DateTime?>("DateUpdated")
.HasColumnType("timestamp with time zone")
.HasColumnName("DateUpdated");
b.Property<string>("MarkdownText")
.IsRequired()
.HasColumnType("text");
b.Property<string>("PhotoUrl")
.HasMaxLength(2048)
.HasColumnType("character varying(2048)");
b.Property<string>("Title")
.IsRequired()
.HasColumnType("text");
b.Property<int>("Views")
.HasColumnType("integer");
b.HasKey("Id");
b.ToTable("BlogPosts", "Club12");
});
modelBuilder.Entity("Entities.Models.Divisions.Division", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uuid");
b.Property<DateTime>("DateCreated")
.HasColumnType("timestamp with time zone")
.HasColumnName("DateCreated");
b.Property<DateTime?>("DateUpdated")
.HasColumnType("timestamp with time zone")
.HasColumnName("DateUpdated");
b.Property<bool>("IsFinished")
.HasColumnType("boolean");
b.Property<string>("Name")
.IsRequired()
.HasMaxLength(30)
.HasColumnType("character varying(30)");
b.Property<bool>("PlayoffsGenerated")
.HasColumnType("boolean");
b.Property<Guid>("TournamentId")
.HasColumnType("uuid");
b.HasKey("Id");
b.HasIndex("TournamentId");
b.ToTable("Divisions", "Club12");
});
modelBuilder.Entity("Entities.Models.Matches.Match", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uuid");
b.Property<DateTime>("DateCreated")
.HasColumnType("timestamp with time zone")
.HasColumnName("DateCreated");
b.Property<DateTime?>("DateUpdated")
.HasColumnType("timestamp with time zone")
.HasColumnName("DateUpdated");
b.Property<Guid?>("DivisionId")
.HasColumnType("uuid");
b.Property<int?>("HomeScore")
.HasColumnType("integer");
b.Property<Guid?>("HomeTeamId")
.HasColumnType("uuid");
b.Property<bool>("IsFinished")
.HasColumnType("boolean");
b.Property<DateTime>("MatchDate")
.HasColumnType("timestamp with time zone");
b.Property<Guid>("StageId")
.HasColumnType("uuid");
b.Property<string>("Type")
.IsRequired()
.HasColumnType("text");
b.Property<int?>("VisitorScore")
.HasColumnType("integer");
b.Property<Guid>("VisitorTeamId")
.HasColumnType("uuid");
b.Property<Guid?>("WinningTeamId")
.HasColumnType("uuid");
b.HasKey("Id");
b.HasIndex("DivisionId");
b.HasIndex("HomeTeamId");
b.HasIndex("StageId");
b.HasIndex("VisitorTeamId");
b.HasIndex("WinningTeamId");
b.ToTable("Matches", "Club12");
});
modelBuilder.Entity("Entities.Models.PlayerSanctions.PlayerSanction", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uuid");
b.Property<DateTime>("DateCreated")
.HasColumnType("timestamp with time zone")
.HasColumnName("DateCreated");
b.Property<DateTime?>("DateUpdated")
.HasColumnType("timestamp with time zone")
.HasColumnName("DateUpdated");
b.Property<string>("Description")
.IsRequired()
.HasMaxLength(255)
.HasColumnType("character varying(255)");
b.Property<int>("Duration")
.HasColumnType("integer");
b.Property<DateTime>("IssuedDate")
.HasColumnType("timestamp with time zone");
b.Property<Guid>("PlayerId")
.HasColumnType("uuid");
b.HasKey("Id");
b.HasIndex("PlayerId");
b.ToTable("PlayerSanctions", "Club12");
});
modelBuilder.Entity("Entities.Models.PlayerStatistics.PlayerStatistic", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uuid");
b.Property<DateTime>("DateCreated")
.HasColumnType("timestamp with time zone")
.HasColumnName("DateCreated");
b.Property<DateTime?>("DateUpdated")
.HasColumnType("timestamp with time zone")
.HasColumnName("DateUpdated");
b.Property<Guid>("MatchId")
.HasColumnType("uuid");
b.Property<Guid>("PlayerId")
.HasColumnType("uuid");
b.Property<int>("Value")
.HasColumnType("integer");
b.HasKey("Id");
b.HasIndex("MatchId");
b.HasIndex("PlayerId");
b.ToTable("PlayersStatistics", "Club12");
});
modelBuilder.Entity("Entities.Models.Players.Player", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uuid");
b.Property<DateTime>("BirthDate")
.HasColumnType("timestamp with time zone");
b.Property<string>("Category")
.HasMaxLength(50)
.HasColumnType("character varying(50)");
b.Property<string>("Club")
.HasMaxLength(100)
.HasColumnType("character varying(100)");
b.Property<DateTime>("DateCreated")
.HasColumnType("timestamp with time zone")
.HasColumnName("DateCreated");
b.Property<DateTime?>("DateUpdated")
.HasColumnType("timestamp with time zone")
.HasColumnName("DateUpdated");
b.Property<string>("DocumentNumber")
.IsRequired()
.HasMaxLength(15)
.HasColumnType("character varying(15)");
b.Property<bool>("IsFederated")
.HasColumnType("boolean");
b.Property<bool>("IsSanctioned")
.HasColumnType("boolean");
b.Property<string>("LastName")
.IsRequired()
.HasMaxLength(70)
.HasColumnType("character varying(70)");
b.Property<string>("Names")
.IsRequired()
.HasMaxLength(70)
.HasColumnType("character varying(70)");
b.Property<string>("PhoneNumber")
.HasColumnType("text");
b.Property<string>("SocialSecurity")
.IsRequired()
.HasMaxLength(100)
.HasColumnType("character varying(100)");
b.Property<Guid>("TeamId")
.HasColumnType("uuid");
b.HasKey("Id");
b.HasIndex("TeamId");
b.ToTable("Players", "Club12");
});
modelBuilder.Entity("Entities.Models.Staffs.Staff", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uuid");
b.Property<DateTime>("DateCreated")
.HasColumnType("timestamp with time zone")
.HasColumnName("DateCreated");
b.Property<DateTime?>("DateUpdated")
.HasColumnType("timestamp with time zone")
.HasColumnName("DateUpdated");
b.Property<string>("LastName")
.IsRequired()
.HasMaxLength(50)
.HasColumnType("character varying(50)");
b.Property<string>("Names")
.IsRequired()
.HasMaxLength(50)
.HasColumnType("character varying(50)");
b.Property<string>("PhoneNumber")
.IsRequired()
.HasMaxLength(15)
.HasColumnType("character varying(15)");
b.Property<Guid>("TeamId")
.HasColumnType("uuid");
b.Property<string>("Type")
.IsRequired()
.HasColumnType("text");
b.HasKey("Id");
b.HasIndex("TeamId");
b.ToTable("Staffs", "Club12");
});
modelBuilder.Entity("Entities.Models.Stages.Stage", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uuid");
b.Property<DateTime>("DateCreated")
.HasColumnType("timestamp with time zone")
.HasColumnName("DateCreated");
b.Property<DateTime?>("DateUpdated")
.HasColumnType("timestamp with time zone")
.HasColumnName("DateUpdated");
b.Property<string>("Description")
.HasMaxLength(1000)
.HasColumnType("character varying(1000)");
b.Property<Guid>("DivisionId")
.HasColumnType("uuid");
b.Property<DateTime>("EndDate")
.HasColumnType("timestamp with time zone");
b.Property<bool>("IsActive")
.HasColumnType("boolean");
b.Property<bool>("IsElimination")
.HasColumnType("boolean");
b.Property<string>("Name")
.IsRequired()
.HasMaxLength(100)
.HasColumnType("character varying(100)");
b.Property<string>("StageType")
.IsRequired()
.HasColumnType("text");
b.Property<DateTime>("StartDate")
.HasColumnType("timestamp with time zone");
b.HasKey("Id");
b.HasIndex("DivisionId");
b.ToTable("Stages", "Club12");
});
modelBuilder.Entity("Entities.Models.Teams.Team", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uuid");
b.Property<DateTime>("DateCreated")
.HasColumnType("timestamp with time zone")
.HasColumnName("DateCreated");
b.Property<DateTime?>("DateUpdated")
.HasColumnType("timestamp with time zone")
.HasColumnName("DateUpdated");
b.Property<Guid>("DivisionId")
.HasColumnType("uuid");
b.Property<string>("LogoUrl")
.IsRequired()
.HasColumnType("text");
b.Property<string>("Name")
.IsRequired()
.HasColumnType("text");
b.Property<int>("Seed")
.HasColumnType("integer");
b.Property<string>("ShirtColor")
.IsRequired()
.HasColumnType("text");
b.Property<string>("ThreeLetterCode")
.IsRequired()
.HasColumnType("text");
b.HasKey("Id");
b.HasIndex("DivisionId");
b.ToTable("Teams", "Club12");
});
modelBuilder.Entity("Entities.Models.Tournaments.Tournament", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uuid");
b.Property<DateTime>("DateCreated")
.HasColumnType("timestamp with time zone")
.HasColumnName("DateCreated");
b.Property<DateTime?>("DateUpdated")
.HasColumnType("timestamp with time zone")
.HasColumnName("DateUpdated");
b.Property<string>("Description")
.IsRequired()
.HasColumnType("text");
b.Property<string>("Name")
.IsRequired()
.HasColumnType("text");
b.HasKey("Id");
b.ToTable("Tournaments", "Club12");
});
modelBuilder.Entity("Entities.Models.Users.User", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uuid");
b.Property<DateTime>("DateCreated")
.HasColumnType("timestamp with time zone")
.HasColumnName("DateCreated");
b.Property<DateTime?>("DateUpdated")
.HasColumnType("timestamp with time zone")
.HasColumnName("DateUpdated");
b.Property<string>("Password")
.IsRequired()
.HasMaxLength(64)
.HasColumnType("character varying(64)");
b.Property<string>("RefreshToken")
.HasMaxLength(256)
.HasColumnType("character varying(256)");
b.Property<DateTime?>("RefreshTokenExpiryTime")
.HasColumnType("timestamp with time zone");
b.Property<string>("Role")
.IsRequired()
.HasMaxLength(10)
.HasColumnType("character varying(10)");
b.Property<string>("Username")
.IsRequired()
.HasMaxLength(25)
.HasColumnType("character varying(25)");
b.HasKey("Id");
b.ToTable("Users", "Club12");
});
modelBuilder.Entity("Entities.Models.Venues.Venue", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uuid");
b.Property<string>("Address")
.IsRequired()
.HasMaxLength(200)
.HasColumnType("character varying(200)");
b.Property<DateTime>("DateCreated")
.HasColumnType("timestamp with time zone")
.HasColumnName("DateCreated");
b.Property<DateTime?>("DateUpdated")
.HasColumnType("timestamp with time zone")
.HasColumnName("DateUpdated");
b.Property<string>("Name")
.IsRequired()
.HasMaxLength(50)
.HasColumnType("character varying(50)");
b.Property<string>("PhotoUrl")
.HasColumnType("text");
b.HasKey("Id");
b.ToTable("Venues", "Club12");
});
modelBuilder.Entity("Entities.Models.Divisions.Division", b =>
{
b.HasOne("Entities.Models.Tournaments.Tournament", "Tournament")
.WithMany("Divisions")
.HasForeignKey("TournamentId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Tournament");
});
modelBuilder.Entity("Entities.Models.Matches.Match", b =>
{
b.HasOne("Entities.Models.Divisions.Division", null)
.WithMany("Matches")
.HasForeignKey("DivisionId");
b.HasOne("Entities.Models.Teams.Team", "HomeTeam")
.WithMany()
.HasForeignKey("HomeTeamId");
b.HasOne("Entities.Models.Stages.Stage", "Stage")
.WithMany("Matches")
.HasForeignKey("StageId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("Entities.Models.Teams.Team", "VisitorTeam")
.WithMany()
.HasForeignKey("VisitorTeamId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("Entities.Models.Teams.Team", "WinningTeam")
.WithMany()
.HasForeignKey("WinningTeamId");
b.Navigation("HomeTeam");
b.Navigation("Stage");
b.Navigation("VisitorTeam");
b.Navigation("WinningTeam");
});
modelBuilder.Entity("Entities.Models.PlayerSanctions.PlayerSanction", b =>
{
b.HasOne("Entities.Models.Players.Player", "Player")
.WithMany()
.HasForeignKey("PlayerId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Player");
});
modelBuilder.Entity("Entities.Models.PlayerStatistics.PlayerStatistic", b =>
{
b.HasOne("Entities.Models.Matches.Match", "Match")
.WithMany("PlayerStatistics")
.HasForeignKey("MatchId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("Entities.Models.Players.Player", "Player")
.WithMany()
.HasForeignKey("PlayerId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Match");
b.Navigation("Player");
});
modelBuilder.Entity("Entities.Models.Players.Player", b =>
{
b.HasOne("Entities.Models.Teams.Team", "Team")
.WithMany("Players")
.HasForeignKey("TeamId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Team");
});
modelBuilder.Entity("Entities.Models.Staffs.Staff", b =>
{
b.HasOne("Entities.Models.Teams.Team", "Team")
.WithMany("Staff")
.HasForeignKey("TeamId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Team");
});
modelBuilder.Entity("Entities.Models.Stages.Stage", b =>
{
b.HasOne("Entities.Models.Divisions.Division", "Division")
.WithMany()
.HasForeignKey("DivisionId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Division");
});
modelBuilder.Entity("Entities.Models.Teams.Team", b =>
{
b.HasOne("Entities.Models.Divisions.Division", "Division")
.WithMany("Teams")
.HasForeignKey("DivisionId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Division");
});
modelBuilder.Entity("Entities.Models.Divisions.Division", b =>
{
b.Navigation("Matches");
b.Navigation("Teams");
});
modelBuilder.Entity("Entities.Models.Matches.Match", b =>
{
b.Navigation("PlayerStatistics");
});
modelBuilder.Entity("Entities.Models.Stages.Stage", b =>
{
b.Navigation("Matches");
});
modelBuilder.Entity("Entities.Models.Teams.Team", b =>
{
b.Navigation("Players");
b.Navigation("Staff");
});
modelBuilder.Entity("Entities.Models.Tournaments.Tournament", b =>
{
b.Navigation("Divisions");
});
#pragma warning restore 612, 618
}
}
}
@@ -0,0 +1,293 @@
using Microsoft.EntityFrameworkCore.Migrations;
using System;
#nullable disable
namespace Persistance.Migrations;
/// <inheritdoc />
public partial class AddStageEntity : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropForeignKey(
name: "FK_Matches_Divisions_DivisionId",
schema: "Club12",
table: "Matches");
migrationBuilder.DropForeignKey(
name: "FK_Matches_PlayoffSeries_PlayoffSeriesId",
schema: "Club12",
table: "Matches");
migrationBuilder.DropForeignKey(
name: "FK_Matches_Venues_VenueId",
schema: "Club12",
table: "Matches");
migrationBuilder.DropTable(
name: "PlayoffSeries",
schema: "Club12");
migrationBuilder.DropIndex(
name: "IX_Matches_PlayoffSeriesId",
schema: "Club12",
table: "Matches");
migrationBuilder.DropIndex(
name: "IX_Matches_VenueId",
schema: "Club12",
table: "Matches");
migrationBuilder.DropColumn(
name: "GameNumber",
schema: "Club12",
table: "Matches");
migrationBuilder.DropColumn(
name: "MatchWeek",
schema: "Club12",
table: "Matches");
migrationBuilder.DropColumn(
name: "PlayoffSeriesId",
schema: "Club12",
table: "Matches");
migrationBuilder.DropColumn(
name: "VenueId",
schema: "Club12",
table: "Matches");
migrationBuilder.AlterColumn<Guid>(
name: "DivisionId",
schema: "Club12",
table: "Matches",
type: "uuid",
nullable: true,
oldClrType: typeof(Guid),
oldType: "uuid");
migrationBuilder.AddColumn<Guid>(
name: "StageId",
schema: "Club12",
table: "Matches",
type: "uuid",
nullable: false,
defaultValue: Guid.Empty);
migrationBuilder.CreateTable(
name: "Stages",
schema: "Club12",
columns: table => new
{
Id = table.Column<Guid>(type: "uuid", nullable: false),
Name = table.Column<string>(type: "character varying(100)", maxLength: 100, nullable: false),
Description = table.Column<string>(type: "character varying(1000)", maxLength: 1000, nullable: true),
StageType = table.Column<string>(type: "text", nullable: false),
IsActive = table.Column<bool>(type: "boolean", nullable: false),
IsElimination = table.Column<bool>(type: "boolean", nullable: false),
StartDate = table.Column<DateTime>(type: "timestamp with time zone", nullable: false),
EndDate = table.Column<DateTime>(type: "timestamp with time zone", nullable: false),
DivisionId = table.Column<Guid>(type: "uuid", nullable: false),
DateCreated = table.Column<DateTime>(type: "timestamp with time zone", nullable: false),
DateUpdated = table.Column<DateTime>(type: "timestamp with time zone", nullable: true)
},
constraints: table =>
{
table.PrimaryKey("PK_Stages", x => x.Id);
table.ForeignKey(
name: "FK_Stages_Divisions_DivisionId",
column: x => x.DivisionId,
principalSchema: "Club12",
principalTable: "Divisions",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateIndex(
name: "IX_Matches_StageId",
schema: "Club12",
table: "Matches",
column: "StageId");
migrationBuilder.CreateIndex(
name: "IX_Stages_DivisionId",
schema: "Club12",
table: "Stages",
column: "DivisionId");
migrationBuilder.AddForeignKey(
name: "FK_Matches_Divisions_DivisionId",
schema: "Club12",
table: "Matches",
column: "DivisionId",
principalSchema: "Club12",
principalTable: "Divisions",
principalColumn: "Id");
migrationBuilder.AddForeignKey(
name: "FK_Matches_Stages_StageId",
schema: "Club12",
table: "Matches",
column: "StageId",
principalSchema: "Club12",
principalTable: "Stages",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropForeignKey(
name: "FK_Matches_Divisions_DivisionId",
schema: "Club12",
table: "Matches");
migrationBuilder.DropForeignKey(
name: "FK_Matches_Stages_StageId",
schema: "Club12",
table: "Matches");
migrationBuilder.DropTable(
name: "Stages",
schema: "Club12");
migrationBuilder.DropIndex(
name: "IX_Matches_StageId",
schema: "Club12",
table: "Matches");
migrationBuilder.DropColumn(
name: "StageId",
schema: "Club12",
table: "Matches");
migrationBuilder.AlterColumn<Guid>(
name: "DivisionId",
schema: "Club12",
table: "Matches",
type: "uuid",
nullable: false,
defaultValue: Guid.Empty,
oldClrType: typeof(Guid),
oldType: "uuid",
oldNullable: true);
migrationBuilder.AddColumn<int>(
name: "GameNumber",
schema: "Club12",
table: "Matches",
type: "integer",
nullable: true);
migrationBuilder.AddColumn<int>(
name: "MatchWeek",
schema: "Club12",
table: "Matches",
type: "integer",
nullable: true);
migrationBuilder.AddColumn<Guid>(
name: "PlayoffSeriesId",
schema: "Club12",
table: "Matches",
type: "uuid",
nullable: true);
migrationBuilder.AddColumn<Guid>(
name: "VenueId",
schema: "Club12",
table: "Matches",
type: "uuid",
nullable: true);
migrationBuilder.CreateTable(
name: "PlayoffSeries",
schema: "Club12",
columns: table => new
{
Id = table.Column<Guid>(type: "uuid", nullable: false),
NextSeriesId = table.Column<Guid>(type: "uuid", nullable: true),
WinningTeamId = table.Column<Guid>(type: "uuid", nullable: true),
DateCreated = table.Column<DateTime>(type: "timestamp with time zone", nullable: false),
DateUpdated = table.Column<DateTime>(type: "timestamp with time zone", nullable: true),
GamesRequiredToWin = table.Column<int>(type: "integer", nullable: false),
HomeTeamWins = table.Column<int>(type: "integer", nullable: false),
IsFinished = table.Column<bool>(type: "boolean", nullable: false),
RoundName = table.Column<int>(type: "integer", nullable: false),
VisitorTeamWins = table.Column<int>(type: "integer", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_PlayoffSeries", x => x.Id);
table.ForeignKey(
name: "FK_PlayoffSeries_PlayoffSeries_NextSeriesId",
column: x => x.NextSeriesId,
principalSchema: "Club12",
principalTable: "PlayoffSeries",
principalColumn: "Id");
table.ForeignKey(
name: "FK_PlayoffSeries_Teams_WinningTeamId",
column: x => x.WinningTeamId,
principalSchema: "Club12",
principalTable: "Teams",
principalColumn: "Id");
});
migrationBuilder.CreateIndex(
name: "IX_Matches_PlayoffSeriesId",
schema: "Club12",
table: "Matches",
column: "PlayoffSeriesId");
migrationBuilder.CreateIndex(
name: "IX_Matches_VenueId",
schema: "Club12",
table: "Matches",
column: "VenueId");
migrationBuilder.CreateIndex(
name: "IX_PlayoffSeries_NextSeriesId",
schema: "Club12",
table: "PlayoffSeries",
column: "NextSeriesId");
migrationBuilder.CreateIndex(
name: "IX_PlayoffSeries_WinningTeamId",
schema: "Club12",
table: "PlayoffSeries",
column: "WinningTeamId");
migrationBuilder.AddForeignKey(
name: "FK_Matches_Divisions_DivisionId",
schema: "Club12",
table: "Matches",
column: "DivisionId",
principalSchema: "Club12",
principalTable: "Divisions",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
migrationBuilder.AddForeignKey(
name: "FK_Matches_PlayoffSeries_PlayoffSeriesId",
schema: "Club12",
table: "Matches",
column: "PlayoffSeriesId",
principalSchema: "Club12",
principalTable: "PlayoffSeries",
principalColumn: "Id");
migrationBuilder.AddForeignKey(
name: "FK_Matches_Venues_VenueId",
schema: "Club12",
table: "Matches",
column: "VenueId",
principalSchema: "Club12",
principalTable: "Venues",
principalColumn: "Id");
}
}
@@ -0,0 +1,685 @@
// <auto-generated />
using System;
using Infrastructure.Persistance;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Migrations;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
#nullable disable
namespace Persistance.Migrations
{
[DbContext(typeof(ApplicationDBContext))]
[Migration("20250726012040_AddUniqueNameAndDivisionIdInsideStageTable")]
partial class AddUniqueNameAndDivisionIdInsideStageTable
{
/// <inheritdoc />
protected override void BuildTargetModel(ModelBuilder modelBuilder)
{
#pragma warning disable 612, 618
modelBuilder
.HasAnnotation("ProductVersion", "8.0.11")
.HasAnnotation("Relational:MaxIdentifierLength", 63);
NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder);
modelBuilder.Entity("Entities.Models.BlogPosts.BlogPost", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uuid");
b.Property<string>("Author")
.IsRequired()
.HasMaxLength(50)
.HasColumnType("character varying(50)");
b.Property<DateTime>("DateCreated")
.HasColumnType("timestamp with time zone")
.HasColumnName("DateCreated");
b.Property<DateTime?>("DateUpdated")
.HasColumnType("timestamp with time zone")
.HasColumnName("DateUpdated");
b.Property<string>("MarkdownText")
.IsRequired()
.HasColumnType("text");
b.Property<string>("PhotoUrl")
.HasMaxLength(2048)
.HasColumnType("character varying(2048)");
b.Property<string>("Title")
.IsRequired()
.HasColumnType("text");
b.Property<int>("Views")
.HasColumnType("integer");
b.HasKey("Id");
b.ToTable("BlogPosts", "Club12");
});
modelBuilder.Entity("Entities.Models.Divisions.Division", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uuid");
b.Property<DateTime>("DateCreated")
.HasColumnType("timestamp with time zone")
.HasColumnName("DateCreated");
b.Property<DateTime?>("DateUpdated")
.HasColumnType("timestamp with time zone")
.HasColumnName("DateUpdated");
b.Property<bool>("IsFinished")
.HasColumnType("boolean");
b.Property<string>("Name")
.IsRequired()
.HasMaxLength(30)
.HasColumnType("character varying(30)");
b.Property<bool>("PlayoffsGenerated")
.HasColumnType("boolean");
b.Property<Guid>("TournamentId")
.HasColumnType("uuid");
b.HasKey("Id");
b.HasIndex("TournamentId");
b.ToTable("Divisions", "Club12");
});
modelBuilder.Entity("Entities.Models.Matches.Match", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uuid");
b.Property<DateTime>("DateCreated")
.HasColumnType("timestamp with time zone")
.HasColumnName("DateCreated");
b.Property<DateTime?>("DateUpdated")
.HasColumnType("timestamp with time zone")
.HasColumnName("DateUpdated");
b.Property<Guid?>("DivisionId")
.HasColumnType("uuid");
b.Property<int?>("HomeScore")
.HasColumnType("integer");
b.Property<Guid?>("HomeTeamId")
.HasColumnType("uuid");
b.Property<bool>("IsFinished")
.HasColumnType("boolean");
b.Property<DateTime>("MatchDate")
.HasColumnType("timestamp with time zone");
b.Property<Guid>("StageId")
.HasColumnType("uuid");
b.Property<string>("Type")
.IsRequired()
.HasColumnType("text");
b.Property<int?>("VisitorScore")
.HasColumnType("integer");
b.Property<Guid>("VisitorTeamId")
.HasColumnType("uuid");
b.Property<Guid?>("WinningTeamId")
.HasColumnType("uuid");
b.HasKey("Id");
b.HasIndex("DivisionId");
b.HasIndex("HomeTeamId");
b.HasIndex("StageId");
b.HasIndex("VisitorTeamId");
b.HasIndex("WinningTeamId");
b.ToTable("Matches", "Club12");
});
modelBuilder.Entity("Entities.Models.PlayerSanctions.PlayerSanction", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uuid");
b.Property<DateTime>("DateCreated")
.HasColumnType("timestamp with time zone")
.HasColumnName("DateCreated");
b.Property<DateTime?>("DateUpdated")
.HasColumnType("timestamp with time zone")
.HasColumnName("DateUpdated");
b.Property<string>("Description")
.IsRequired()
.HasMaxLength(255)
.HasColumnType("character varying(255)");
b.Property<int>("Duration")
.HasColumnType("integer");
b.Property<DateTime>("IssuedDate")
.HasColumnType("timestamp with time zone");
b.Property<Guid>("PlayerId")
.HasColumnType("uuid");
b.HasKey("Id");
b.HasIndex("PlayerId");
b.ToTable("PlayerSanctions", "Club12");
});
modelBuilder.Entity("Entities.Models.PlayerStatistics.PlayerStatistic", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uuid");
b.Property<DateTime>("DateCreated")
.HasColumnType("timestamp with time zone")
.HasColumnName("DateCreated");
b.Property<DateTime?>("DateUpdated")
.HasColumnType("timestamp with time zone")
.HasColumnName("DateUpdated");
b.Property<Guid>("MatchId")
.HasColumnType("uuid");
b.Property<Guid>("PlayerId")
.HasColumnType("uuid");
b.Property<int>("Value")
.HasColumnType("integer");
b.HasKey("Id");
b.HasIndex("MatchId");
b.HasIndex("PlayerId");
b.ToTable("PlayersStatistics", "Club12");
});
modelBuilder.Entity("Entities.Models.Players.Player", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uuid");
b.Property<DateTime>("BirthDate")
.HasColumnType("timestamp with time zone");
b.Property<string>("Category")
.HasMaxLength(50)
.HasColumnType("character varying(50)");
b.Property<string>("Club")
.HasMaxLength(100)
.HasColumnType("character varying(100)");
b.Property<DateTime>("DateCreated")
.HasColumnType("timestamp with time zone")
.HasColumnName("DateCreated");
b.Property<DateTime?>("DateUpdated")
.HasColumnType("timestamp with time zone")
.HasColumnName("DateUpdated");
b.Property<string>("DocumentNumber")
.IsRequired()
.HasMaxLength(15)
.HasColumnType("character varying(15)");
b.Property<bool>("IsFederated")
.HasColumnType("boolean");
b.Property<bool>("IsSanctioned")
.HasColumnType("boolean");
b.Property<string>("LastName")
.IsRequired()
.HasMaxLength(70)
.HasColumnType("character varying(70)");
b.Property<string>("Names")
.IsRequired()
.HasMaxLength(70)
.HasColumnType("character varying(70)");
b.Property<string>("PhoneNumber")
.HasColumnType("text");
b.Property<string>("SocialSecurity")
.IsRequired()
.HasMaxLength(100)
.HasColumnType("character varying(100)");
b.Property<Guid>("TeamId")
.HasColumnType("uuid");
b.HasKey("Id");
b.HasIndex("TeamId");
b.ToTable("Players", "Club12");
});
modelBuilder.Entity("Entities.Models.Staffs.Staff", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uuid");
b.Property<DateTime>("DateCreated")
.HasColumnType("timestamp with time zone")
.HasColumnName("DateCreated");
b.Property<DateTime?>("DateUpdated")
.HasColumnType("timestamp with time zone")
.HasColumnName("DateUpdated");
b.Property<string>("LastName")
.IsRequired()
.HasMaxLength(50)
.HasColumnType("character varying(50)");
b.Property<string>("Names")
.IsRequired()
.HasMaxLength(50)
.HasColumnType("character varying(50)");
b.Property<string>("PhoneNumber")
.IsRequired()
.HasMaxLength(15)
.HasColumnType("character varying(15)");
b.Property<Guid>("TeamId")
.HasColumnType("uuid");
b.Property<string>("Type")
.IsRequired()
.HasColumnType("text");
b.HasKey("Id");
b.HasIndex("TeamId");
b.ToTable("Staffs", "Club12");
});
modelBuilder.Entity("Entities.Models.Stages.Stage", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uuid");
b.Property<DateTime>("DateCreated")
.HasColumnType("timestamp with time zone")
.HasColumnName("DateCreated");
b.Property<DateTime?>("DateUpdated")
.HasColumnType("timestamp with time zone")
.HasColumnName("DateUpdated");
b.Property<string>("Description")
.HasMaxLength(1000)
.HasColumnType("character varying(1000)");
b.Property<Guid>("DivisionId")
.HasColumnType("uuid");
b.Property<DateTime>("EndDate")
.HasColumnType("timestamp with time zone");
b.Property<bool>("IsActive")
.HasColumnType("boolean");
b.Property<bool>("IsElimination")
.HasColumnType("boolean");
b.Property<string>("Name")
.IsRequired()
.HasMaxLength(100)
.HasColumnType("character varying(100)");
b.Property<string>("StageType")
.IsRequired()
.HasColumnType("text");
b.Property<DateTime>("StartDate")
.HasColumnType("timestamp with time zone");
b.HasKey("Id");
b.HasIndex("DivisionId");
b.HasIndex("Name", "DivisionId")
.IsUnique()
.HasDatabaseName("CONSTRAINT_UNIQUE_STAGE_NAME_AND_DIVISIONID");
b.ToTable("Stages", "Club12");
});
modelBuilder.Entity("Entities.Models.Teams.Team", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uuid");
b.Property<DateTime>("DateCreated")
.HasColumnType("timestamp with time zone")
.HasColumnName("DateCreated");
b.Property<DateTime?>("DateUpdated")
.HasColumnType("timestamp with time zone")
.HasColumnName("DateUpdated");
b.Property<Guid>("DivisionId")
.HasColumnType("uuid");
b.Property<string>("LogoUrl")
.IsRequired()
.HasColumnType("text");
b.Property<string>("Name")
.IsRequired()
.HasColumnType("text");
b.Property<int>("Seed")
.HasColumnType("integer");
b.Property<string>("ShirtColor")
.IsRequired()
.HasColumnType("text");
b.Property<string>("ThreeLetterCode")
.IsRequired()
.HasColumnType("text");
b.HasKey("Id");
b.HasIndex("DivisionId");
b.ToTable("Teams", "Club12");
});
modelBuilder.Entity("Entities.Models.Tournaments.Tournament", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uuid");
b.Property<DateTime>("DateCreated")
.HasColumnType("timestamp with time zone")
.HasColumnName("DateCreated");
b.Property<DateTime?>("DateUpdated")
.HasColumnType("timestamp with time zone")
.HasColumnName("DateUpdated");
b.Property<string>("Description")
.IsRequired()
.HasColumnType("text");
b.Property<string>("Name")
.IsRequired()
.HasColumnType("text");
b.HasKey("Id");
b.ToTable("Tournaments", "Club12");
});
modelBuilder.Entity("Entities.Models.Users.User", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uuid");
b.Property<DateTime>("DateCreated")
.HasColumnType("timestamp with time zone")
.HasColumnName("DateCreated");
b.Property<DateTime?>("DateUpdated")
.HasColumnType("timestamp with time zone")
.HasColumnName("DateUpdated");
b.Property<string>("Password")
.IsRequired()
.HasMaxLength(64)
.HasColumnType("character varying(64)");
b.Property<string>("RefreshToken")
.HasMaxLength(256)
.HasColumnType("character varying(256)");
b.Property<DateTime?>("RefreshTokenExpiryTime")
.HasColumnType("timestamp with time zone");
b.Property<string>("Role")
.IsRequired()
.HasMaxLength(10)
.HasColumnType("character varying(10)");
b.Property<string>("Username")
.IsRequired()
.HasMaxLength(25)
.HasColumnType("character varying(25)");
b.HasKey("Id");
b.ToTable("Users", "Club12");
});
modelBuilder.Entity("Entities.Models.Venues.Venue", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uuid");
b.Property<string>("Address")
.IsRequired()
.HasMaxLength(200)
.HasColumnType("character varying(200)");
b.Property<DateTime>("DateCreated")
.HasColumnType("timestamp with time zone")
.HasColumnName("DateCreated");
b.Property<DateTime?>("DateUpdated")
.HasColumnType("timestamp with time zone")
.HasColumnName("DateUpdated");
b.Property<string>("Name")
.IsRequired()
.HasMaxLength(50)
.HasColumnType("character varying(50)");
b.Property<string>("PhotoUrl")
.HasColumnType("text");
b.HasKey("Id");
b.ToTable("Venues", "Club12");
});
modelBuilder.Entity("Entities.Models.Divisions.Division", b =>
{
b.HasOne("Entities.Models.Tournaments.Tournament", "Tournament")
.WithMany("Divisions")
.HasForeignKey("TournamentId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Tournament");
});
modelBuilder.Entity("Entities.Models.Matches.Match", b =>
{
b.HasOne("Entities.Models.Divisions.Division", null)
.WithMany("Matches")
.HasForeignKey("DivisionId");
b.HasOne("Entities.Models.Teams.Team", "HomeTeam")
.WithMany()
.HasForeignKey("HomeTeamId");
b.HasOne("Entities.Models.Stages.Stage", "Stage")
.WithMany("Matches")
.HasForeignKey("StageId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("Entities.Models.Teams.Team", "VisitorTeam")
.WithMany()
.HasForeignKey("VisitorTeamId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("Entities.Models.Teams.Team", "WinningTeam")
.WithMany()
.HasForeignKey("WinningTeamId");
b.Navigation("HomeTeam");
b.Navigation("Stage");
b.Navigation("VisitorTeam");
b.Navigation("WinningTeam");
});
modelBuilder.Entity("Entities.Models.PlayerSanctions.PlayerSanction", b =>
{
b.HasOne("Entities.Models.Players.Player", "Player")
.WithMany()
.HasForeignKey("PlayerId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Player");
});
modelBuilder.Entity("Entities.Models.PlayerStatistics.PlayerStatistic", b =>
{
b.HasOne("Entities.Models.Matches.Match", "Match")
.WithMany("PlayerStatistics")
.HasForeignKey("MatchId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("Entities.Models.Players.Player", "Player")
.WithMany()
.HasForeignKey("PlayerId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Match");
b.Navigation("Player");
});
modelBuilder.Entity("Entities.Models.Players.Player", b =>
{
b.HasOne("Entities.Models.Teams.Team", "Team")
.WithMany("Players")
.HasForeignKey("TeamId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Team");
});
modelBuilder.Entity("Entities.Models.Staffs.Staff", b =>
{
b.HasOne("Entities.Models.Teams.Team", "Team")
.WithMany("Staff")
.HasForeignKey("TeamId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Team");
});
modelBuilder.Entity("Entities.Models.Stages.Stage", b =>
{
b.HasOne("Entities.Models.Divisions.Division", "Division")
.WithMany("Stages")
.HasForeignKey("DivisionId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Division");
});
modelBuilder.Entity("Entities.Models.Teams.Team", b =>
{
b.HasOne("Entities.Models.Divisions.Division", "Division")
.WithMany("Teams")
.HasForeignKey("DivisionId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Division");
});
modelBuilder.Entity("Entities.Models.Divisions.Division", b =>
{
b.Navigation("Matches");
b.Navigation("Stages");
b.Navigation("Teams");
});
modelBuilder.Entity("Entities.Models.Matches.Match", b =>
{
b.Navigation("PlayerStatistics");
});
modelBuilder.Entity("Entities.Models.Stages.Stage", b =>
{
b.Navigation("Matches");
});
modelBuilder.Entity("Entities.Models.Teams.Team", b =>
{
b.Navigation("Players");
b.Navigation("Staff");
});
modelBuilder.Entity("Entities.Models.Tournaments.Tournament", b =>
{
b.Navigation("Divisions");
});
#pragma warning restore 612, 618
}
}
}
@@ -0,0 +1,29 @@
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace Persistance.Migrations;
/// <inheritdoc />
public partial class AddUniqueNameAndDivisionIdInsideStageTable : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.CreateIndex(
name: "CONSTRAINT_UNIQUE_STAGE_NAME_AND_DIVISIONID",
schema: "Club12",
table: "Stages",
columns: new[] { "Name", "DivisionId" },
unique: true);
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropIndex(
name: "CONSTRAINT_UNIQUE_STAGE_NAME_AND_DIVISIONID",
schema: "Club12",
table: "Stages");
}
}
@@ -0,0 +1,678 @@
// <auto-generated />
using System;
using Infrastructure.Persistance;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Migrations;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
#nullable disable
namespace Persistance.Migrations
{
[DbContext(typeof(ApplicationDBContext))]
[Migration("20250729230926_removeFK_DivisionIdToTeam")]
partial class removeFK_DivisionIdToTeam
{
/// <inheritdoc />
protected override void BuildTargetModel(ModelBuilder modelBuilder)
{
#pragma warning disable 612, 618
modelBuilder
.HasAnnotation("ProductVersion", "8.0.11")
.HasAnnotation("Relational:MaxIdentifierLength", 63);
NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder);
modelBuilder.Entity("Entities.Models.BlogPosts.BlogPost", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uuid");
b.Property<string>("Author")
.IsRequired()
.HasMaxLength(50)
.HasColumnType("character varying(50)");
b.Property<DateTime>("DateCreated")
.HasColumnType("timestamp with time zone")
.HasColumnName("DateCreated");
b.Property<DateTime?>("DateUpdated")
.HasColumnType("timestamp with time zone")
.HasColumnName("DateUpdated");
b.Property<string>("MarkdownText")
.IsRequired()
.HasColumnType("text");
b.Property<string>("PhotoUrl")
.HasMaxLength(2048)
.HasColumnType("character varying(2048)");
b.Property<string>("Title")
.IsRequired()
.HasColumnType("text");
b.Property<int>("Views")
.HasColumnType("integer");
b.HasKey("Id");
b.ToTable("BlogPosts", "Club12");
});
modelBuilder.Entity("Entities.Models.Divisions.Division", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uuid");
b.Property<DateTime>("DateCreated")
.HasColumnType("timestamp with time zone")
.HasColumnName("DateCreated");
b.Property<DateTime?>("DateUpdated")
.HasColumnType("timestamp with time zone")
.HasColumnName("DateUpdated");
b.Property<bool>("IsFinished")
.HasColumnType("boolean");
b.Property<string>("Name")
.IsRequired()
.HasMaxLength(30)
.HasColumnType("character varying(30)");
b.Property<bool>("PlayoffsGenerated")
.HasColumnType("boolean");
b.Property<Guid>("TournamentId")
.HasColumnType("uuid");
b.HasKey("Id");
b.HasIndex("TournamentId");
b.ToTable("Divisions", "Club12");
});
modelBuilder.Entity("Entities.Models.Matches.Match", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uuid");
b.Property<DateTime>("DateCreated")
.HasColumnType("timestamp with time zone")
.HasColumnName("DateCreated");
b.Property<DateTime?>("DateUpdated")
.HasColumnType("timestamp with time zone")
.HasColumnName("DateUpdated");
b.Property<Guid?>("DivisionId")
.HasColumnType("uuid");
b.Property<int?>("HomeScore")
.HasColumnType("integer");
b.Property<Guid?>("HomeTeamId")
.HasColumnType("uuid");
b.Property<bool>("IsFinished")
.HasColumnType("boolean");
b.Property<DateTime>("MatchDate")
.HasColumnType("timestamp with time zone");
b.Property<Guid>("StageId")
.HasColumnType("uuid");
b.Property<string>("Type")
.IsRequired()
.HasColumnType("text");
b.Property<int?>("VisitorScore")
.HasColumnType("integer");
b.Property<Guid>("VisitorTeamId")
.HasColumnType("uuid");
b.Property<Guid?>("WinningTeamId")
.HasColumnType("uuid");
b.HasKey("Id");
b.HasIndex("DivisionId");
b.HasIndex("HomeTeamId");
b.HasIndex("StageId");
b.HasIndex("VisitorTeamId");
b.HasIndex("WinningTeamId");
b.ToTable("Matches", "Club12");
});
modelBuilder.Entity("Entities.Models.PlayerSanctions.PlayerSanction", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uuid");
b.Property<DateTime>("DateCreated")
.HasColumnType("timestamp with time zone")
.HasColumnName("DateCreated");
b.Property<DateTime?>("DateUpdated")
.HasColumnType("timestamp with time zone")
.HasColumnName("DateUpdated");
b.Property<string>("Description")
.IsRequired()
.HasMaxLength(255)
.HasColumnType("character varying(255)");
b.Property<int>("Duration")
.HasColumnType("integer");
b.Property<DateTime>("IssuedDate")
.HasColumnType("timestamp with time zone");
b.Property<Guid>("PlayerId")
.HasColumnType("uuid");
b.HasKey("Id");
b.HasIndex("PlayerId");
b.ToTable("PlayerSanctions", "Club12");
});
modelBuilder.Entity("Entities.Models.PlayerStatistics.PlayerStatistic", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uuid");
b.Property<DateTime>("DateCreated")
.HasColumnType("timestamp with time zone")
.HasColumnName("DateCreated");
b.Property<DateTime?>("DateUpdated")
.HasColumnType("timestamp with time zone")
.HasColumnName("DateUpdated");
b.Property<Guid>("MatchId")
.HasColumnType("uuid");
b.Property<Guid>("PlayerId")
.HasColumnType("uuid");
b.Property<int>("Value")
.HasColumnType("integer");
b.HasKey("Id");
b.HasIndex("MatchId");
b.HasIndex("PlayerId");
b.ToTable("PlayersStatistics", "Club12");
});
modelBuilder.Entity("Entities.Models.Players.Player", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uuid");
b.Property<DateTime>("BirthDate")
.HasColumnType("timestamp with time zone");
b.Property<string>("Category")
.HasMaxLength(50)
.HasColumnType("character varying(50)");
b.Property<string>("Club")
.HasMaxLength(100)
.HasColumnType("character varying(100)");
b.Property<DateTime>("DateCreated")
.HasColumnType("timestamp with time zone")
.HasColumnName("DateCreated");
b.Property<DateTime?>("DateUpdated")
.HasColumnType("timestamp with time zone")
.HasColumnName("DateUpdated");
b.Property<string>("DocumentNumber")
.IsRequired()
.HasMaxLength(15)
.HasColumnType("character varying(15)");
b.Property<bool>("IsFederated")
.HasColumnType("boolean");
b.Property<bool>("IsSanctioned")
.HasColumnType("boolean");
b.Property<string>("LastName")
.IsRequired()
.HasMaxLength(70)
.HasColumnType("character varying(70)");
b.Property<string>("Names")
.IsRequired()
.HasMaxLength(70)
.HasColumnType("character varying(70)");
b.Property<string>("PhoneNumber")
.HasColumnType("text");
b.Property<string>("SocialSecurity")
.IsRequired()
.HasMaxLength(100)
.HasColumnType("character varying(100)");
b.Property<Guid>("TeamId")
.HasColumnType("uuid");
b.HasKey("Id");
b.HasIndex("TeamId");
b.ToTable("Players", "Club12");
});
modelBuilder.Entity("Entities.Models.Staffs.Staff", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uuid");
b.Property<DateTime>("DateCreated")
.HasColumnType("timestamp with time zone")
.HasColumnName("DateCreated");
b.Property<DateTime?>("DateUpdated")
.HasColumnType("timestamp with time zone")
.HasColumnName("DateUpdated");
b.Property<string>("LastName")
.IsRequired()
.HasMaxLength(50)
.HasColumnType("character varying(50)");
b.Property<string>("Names")
.IsRequired()
.HasMaxLength(50)
.HasColumnType("character varying(50)");
b.Property<string>("PhoneNumber")
.IsRequired()
.HasMaxLength(15)
.HasColumnType("character varying(15)");
b.Property<Guid>("TeamId")
.HasColumnType("uuid");
b.Property<string>("Type")
.IsRequired()
.HasColumnType("text");
b.HasKey("Id");
b.HasIndex("TeamId");
b.ToTable("Staffs", "Club12");
});
modelBuilder.Entity("Entities.Models.Stages.Stage", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uuid");
b.Property<DateTime>("DateCreated")
.HasColumnType("timestamp with time zone")
.HasColumnName("DateCreated");
b.Property<DateTime?>("DateUpdated")
.HasColumnType("timestamp with time zone")
.HasColumnName("DateUpdated");
b.Property<string>("Description")
.HasMaxLength(1000)
.HasColumnType("character varying(1000)");
b.Property<Guid>("DivisionId")
.HasColumnType("uuid");
b.Property<DateTime>("EndDate")
.HasColumnType("timestamp with time zone");
b.Property<bool>("IsActive")
.HasColumnType("boolean");
b.Property<bool>("IsElimination")
.HasColumnType("boolean");
b.Property<string>("Name")
.IsRequired()
.HasMaxLength(100)
.HasColumnType("character varying(100)");
b.Property<string>("StageType")
.IsRequired()
.HasColumnType("text");
b.Property<DateTime>("StartDate")
.HasColumnType("timestamp with time zone");
b.HasKey("Id");
b.HasIndex("DivisionId");
b.HasIndex("Name", "DivisionId")
.IsUnique()
.HasDatabaseName("CONSTRAINT_UNIQUE_STAGE_NAME_AND_DIVISIONID");
b.ToTable("Stages", "Club12");
});
modelBuilder.Entity("Entities.Models.Teams.Team", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uuid");
b.Property<DateTime>("DateCreated")
.HasColumnType("timestamp with time zone")
.HasColumnName("DateCreated");
b.Property<DateTime?>("DateUpdated")
.HasColumnType("timestamp with time zone")
.HasColumnName("DateUpdated");
b.Property<Guid?>("DivisionId")
.HasColumnType("uuid");
b.Property<string>("LogoUrl")
.IsRequired()
.HasColumnType("text");
b.Property<string>("Name")
.IsRequired()
.HasColumnType("text");
b.Property<string>("ShirtColor")
.IsRequired()
.HasColumnType("text");
b.Property<string>("ThreeLetterCode")
.IsRequired()
.HasColumnType("text");
b.HasKey("Id");
b.HasIndex("DivisionId");
b.ToTable("Teams", "Club12");
});
modelBuilder.Entity("Entities.Models.Tournaments.Tournament", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uuid");
b.Property<DateTime>("DateCreated")
.HasColumnType("timestamp with time zone")
.HasColumnName("DateCreated");
b.Property<DateTime?>("DateUpdated")
.HasColumnType("timestamp with time zone")
.HasColumnName("DateUpdated");
b.Property<string>("Description")
.IsRequired()
.HasColumnType("text");
b.Property<string>("Name")
.IsRequired()
.HasColumnType("text");
b.HasKey("Id");
b.ToTable("Tournaments", "Club12");
});
modelBuilder.Entity("Entities.Models.Users.User", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uuid");
b.Property<DateTime>("DateCreated")
.HasColumnType("timestamp with time zone")
.HasColumnName("DateCreated");
b.Property<DateTime?>("DateUpdated")
.HasColumnType("timestamp with time zone")
.HasColumnName("DateUpdated");
b.Property<string>("Password")
.IsRequired()
.HasMaxLength(64)
.HasColumnType("character varying(64)");
b.Property<string>("RefreshToken")
.HasMaxLength(256)
.HasColumnType("character varying(256)");
b.Property<DateTime?>("RefreshTokenExpiryTime")
.HasColumnType("timestamp with time zone");
b.Property<string>("Role")
.IsRequired()
.HasMaxLength(10)
.HasColumnType("character varying(10)");
b.Property<string>("Username")
.IsRequired()
.HasMaxLength(25)
.HasColumnType("character varying(25)");
b.HasKey("Id");
b.ToTable("Users", "Club12");
});
modelBuilder.Entity("Entities.Models.Venues.Venue", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uuid");
b.Property<string>("Address")
.IsRequired()
.HasMaxLength(200)
.HasColumnType("character varying(200)");
b.Property<DateTime>("DateCreated")
.HasColumnType("timestamp with time zone")
.HasColumnName("DateCreated");
b.Property<DateTime?>("DateUpdated")
.HasColumnType("timestamp with time zone")
.HasColumnName("DateUpdated");
b.Property<string>("Name")
.IsRequired()
.HasMaxLength(50)
.HasColumnType("character varying(50)");
b.Property<string>("PhotoUrl")
.HasColumnType("text");
b.HasKey("Id");
b.ToTable("Venues", "Club12");
});
modelBuilder.Entity("Entities.Models.Divisions.Division", b =>
{
b.HasOne("Entities.Models.Tournaments.Tournament", "Tournament")
.WithMany("Divisions")
.HasForeignKey("TournamentId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Tournament");
});
modelBuilder.Entity("Entities.Models.Matches.Match", b =>
{
b.HasOne("Entities.Models.Divisions.Division", null)
.WithMany("Matches")
.HasForeignKey("DivisionId");
b.HasOne("Entities.Models.Teams.Team", "HomeTeam")
.WithMany()
.HasForeignKey("HomeTeamId");
b.HasOne("Entities.Models.Stages.Stage", "Stage")
.WithMany("Matches")
.HasForeignKey("StageId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("Entities.Models.Teams.Team", "VisitorTeam")
.WithMany()
.HasForeignKey("VisitorTeamId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("Entities.Models.Teams.Team", "WinningTeam")
.WithMany()
.HasForeignKey("WinningTeamId");
b.Navigation("HomeTeam");
b.Navigation("Stage");
b.Navigation("VisitorTeam");
b.Navigation("WinningTeam");
});
modelBuilder.Entity("Entities.Models.PlayerSanctions.PlayerSanction", b =>
{
b.HasOne("Entities.Models.Players.Player", "Player")
.WithMany()
.HasForeignKey("PlayerId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Player");
});
modelBuilder.Entity("Entities.Models.PlayerStatistics.PlayerStatistic", b =>
{
b.HasOne("Entities.Models.Matches.Match", "Match")
.WithMany("PlayerStatistics")
.HasForeignKey("MatchId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("Entities.Models.Players.Player", "Player")
.WithMany()
.HasForeignKey("PlayerId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Match");
b.Navigation("Player");
});
modelBuilder.Entity("Entities.Models.Players.Player", b =>
{
b.HasOne("Entities.Models.Teams.Team", "Team")
.WithMany("Players")
.HasForeignKey("TeamId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Team");
});
modelBuilder.Entity("Entities.Models.Staffs.Staff", b =>
{
b.HasOne("Entities.Models.Teams.Team", "Team")
.WithMany("Staff")
.HasForeignKey("TeamId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Team");
});
modelBuilder.Entity("Entities.Models.Stages.Stage", b =>
{
b.HasOne("Entities.Models.Divisions.Division", "Division")
.WithMany("Stages")
.HasForeignKey("DivisionId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Division");
});
modelBuilder.Entity("Entities.Models.Teams.Team", b =>
{
b.HasOne("Entities.Models.Divisions.Division", null)
.WithMany("Teams")
.HasForeignKey("DivisionId");
});
modelBuilder.Entity("Entities.Models.Divisions.Division", b =>
{
b.Navigation("Matches");
b.Navigation("Stages");
b.Navigation("Teams");
});
modelBuilder.Entity("Entities.Models.Matches.Match", b =>
{
b.Navigation("PlayerStatistics");
});
modelBuilder.Entity("Entities.Models.Stages.Stage", b =>
{
b.Navigation("Matches");
});
modelBuilder.Entity("Entities.Models.Teams.Team", b =>
{
b.Navigation("Players");
b.Navigation("Staff");
});
modelBuilder.Entity("Entities.Models.Tournaments.Tournament", b =>
{
b.Navigation("Divisions");
});
#pragma warning restore 612, 618
}
}
}
@@ -0,0 +1,81 @@
using Microsoft.EntityFrameworkCore.Migrations;
using System;
#nullable disable
namespace Persistance.Migrations;
/// <inheritdoc />
public partial class removeFK_DivisionIdToTeam : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropForeignKey(
name: "FK_Teams_Divisions_DivisionId",
schema: "Club12",
table: "Teams");
migrationBuilder.DropColumn(
name: "Seed",
schema: "Club12",
table: "Teams");
migrationBuilder.AlterColumn<Guid>(
name: "DivisionId",
schema: "Club12",
table: "Teams",
type: "uuid",
nullable: true,
oldClrType: typeof(Guid),
oldType: "uuid");
migrationBuilder.AddForeignKey(
name: "FK_Teams_Divisions_DivisionId",
schema: "Club12",
table: "Teams",
column: "DivisionId",
principalSchema: "Club12",
principalTable: "Divisions",
principalColumn: "Id");
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropForeignKey(
name: "FK_Teams_Divisions_DivisionId",
schema: "Club12",
table: "Teams");
migrationBuilder.AlterColumn<Guid>(
name: "DivisionId",
schema: "Club12",
table: "Teams",
type: "uuid",
nullable: false,
defaultValue: Guid.Empty,
oldClrType: typeof(Guid),
oldType: "uuid",
oldNullable: true);
migrationBuilder.AddColumn<int>(
name: "Seed",
schema: "Club12",
table: "Teams",
type: "integer",
nullable: false,
defaultValue: 0);
migrationBuilder.AddForeignKey(
name: "FK_Teams_Divisions_DivisionId",
schema: "Club12",
table: "Teams",
column: "DivisionId",
principalSchema: "Club12",
principalTable: "Divisions",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
}
}
@@ -0,0 +1,674 @@
// <auto-generated />
using System;
using Infrastructure.Persistance;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Migrations;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
#nullable disable
namespace Persistance.Migrations
{
[DbContext(typeof(ApplicationDBContext))]
[Migration("20250731014937_AddContraintToUniqueDocumentNumberInsidePlayerTable")]
partial class AddContraintToUniqueDocumentNumberInsidePlayerTable
{
/// <inheritdoc />
protected override void BuildTargetModel(ModelBuilder modelBuilder)
{
#pragma warning disable 612, 618
modelBuilder
.HasAnnotation("ProductVersion", "8.0.11")
.HasAnnotation("Relational:MaxIdentifierLength", 63);
NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder);
modelBuilder.Entity("Entities.Models.BlogPosts.BlogPost", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uuid");
b.Property<string>("Author")
.IsRequired()
.HasMaxLength(50)
.HasColumnType("character varying(50)");
b.Property<DateTime>("DateCreated")
.HasColumnType("timestamp with time zone")
.HasColumnName("DateCreated");
b.Property<DateTime?>("DateUpdated")
.HasColumnType("timestamp with time zone")
.HasColumnName("DateUpdated");
b.Property<string>("MarkdownText")
.IsRequired()
.HasColumnType("text");
b.Property<string>("PhotoUrl")
.HasMaxLength(2048)
.HasColumnType("character varying(2048)");
b.Property<string>("Title")
.IsRequired()
.HasColumnType("text");
b.Property<int>("Views")
.HasColumnType("integer");
b.HasKey("Id");
b.ToTable("BlogPosts", "Club12");
});
modelBuilder.Entity("Entities.Models.Divisions.Division", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uuid");
b.Property<DateTime>("DateCreated")
.HasColumnType("timestamp with time zone")
.HasColumnName("DateCreated");
b.Property<DateTime?>("DateUpdated")
.HasColumnType("timestamp with time zone")
.HasColumnName("DateUpdated");
b.Property<bool>("IsFinished")
.HasColumnType("boolean");
b.Property<string>("Name")
.IsRequired()
.HasMaxLength(30)
.HasColumnType("character varying(30)");
b.Property<bool>("PlayoffsGenerated")
.HasColumnType("boolean");
b.Property<Guid>("TournamentId")
.HasColumnType("uuid");
b.HasKey("Id");
b.HasIndex("TournamentId");
b.ToTable("Divisions", "Club12");
});
modelBuilder.Entity("Entities.Models.Matches.Match", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uuid");
b.Property<DateTime>("DateCreated")
.HasColumnType("timestamp with time zone")
.HasColumnName("DateCreated");
b.Property<DateTime?>("DateUpdated")
.HasColumnType("timestamp with time zone")
.HasColumnName("DateUpdated");
b.Property<Guid?>("DivisionId")
.HasColumnType("uuid");
b.Property<int?>("HomeScore")
.HasColumnType("integer");
b.Property<Guid?>("HomeTeamId")
.HasColumnType("uuid");
b.Property<bool>("IsFinished")
.HasColumnType("boolean");
b.Property<DateTime>("MatchDate")
.HasColumnType("timestamp with time zone");
b.Property<Guid>("StageId")
.HasColumnType("uuid");
b.Property<string>("Type")
.IsRequired()
.HasColumnType("text");
b.Property<int?>("VisitorScore")
.HasColumnType("integer");
b.Property<Guid>("VisitorTeamId")
.HasColumnType("uuid");
b.Property<Guid?>("WinningTeamId")
.HasColumnType("uuid");
b.HasKey("Id");
b.HasIndex("DivisionId");
b.HasIndex("HomeTeamId");
b.HasIndex("StageId");
b.HasIndex("VisitorTeamId");
b.HasIndex("WinningTeamId");
b.ToTable("Matches", "Club12");
});
modelBuilder.Entity("Entities.Models.PlayerSanctions.PlayerSanction", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uuid");
b.Property<DateTime>("DateCreated")
.HasColumnType("timestamp with time zone")
.HasColumnName("DateCreated");
b.Property<DateTime?>("DateUpdated")
.HasColumnType("timestamp with time zone")
.HasColumnName("DateUpdated");
b.Property<string>("Description")
.IsRequired()
.HasMaxLength(255)
.HasColumnType("character varying(255)");
b.Property<int>("Duration")
.HasColumnType("integer");
b.Property<DateTime>("IssuedDate")
.HasColumnType("timestamp with time zone");
b.Property<Guid>("PlayerId")
.HasColumnType("uuid");
b.HasKey("Id");
b.HasIndex("PlayerId");
b.ToTable("PlayerSanctions", "Club12");
});
modelBuilder.Entity("Entities.Models.PlayerStatistics.PlayerStatistic", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uuid");
b.Property<DateTime>("DateCreated")
.HasColumnType("timestamp with time zone")
.HasColumnName("DateCreated");
b.Property<DateTime?>("DateUpdated")
.HasColumnType("timestamp with time zone")
.HasColumnName("DateUpdated");
b.Property<Guid>("MatchId")
.HasColumnType("uuid");
b.Property<Guid>("PlayerId")
.HasColumnType("uuid");
b.Property<int>("Value")
.HasColumnType("integer");
b.HasKey("Id");
b.HasIndex("MatchId");
b.HasIndex("PlayerId");
b.ToTable("PlayersStatistics", "Club12");
});
modelBuilder.Entity("Entities.Models.Players.Player", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uuid");
b.Property<DateTime>("BirthDate")
.HasColumnType("timestamp with time zone");
b.Property<DateTime>("DateCreated")
.HasColumnType("timestamp with time zone")
.HasColumnName("DateCreated");
b.Property<DateTime?>("DateUpdated")
.HasColumnType("timestamp with time zone")
.HasColumnName("DateUpdated");
b.Property<string>("DocumentNumber")
.IsRequired()
.HasMaxLength(15)
.HasColumnType("character varying(15)");
b.Property<string>("FirstName")
.IsRequired()
.HasMaxLength(70)
.HasColumnType("character varying(70)");
b.Property<bool>("IsSanctioned")
.HasColumnType("boolean");
b.Property<string>("LastName")
.IsRequired()
.HasMaxLength(70)
.HasColumnType("character varying(70)");
b.Property<string>("PhoneNumber")
.HasColumnType("text");
b.Property<string>("SecondName")
.HasMaxLength(70)
.HasColumnType("character varying(70)");
b.Property<string>("SocialSecurity")
.IsRequired()
.HasMaxLength(100)
.HasColumnType("character varying(100)");
b.Property<Guid>("TeamId")
.HasColumnType("uuid");
b.HasKey("Id");
b.HasIndex("DocumentNumber")
.IsUnique();
b.HasIndex("TeamId");
b.ToTable("Players", "Club12");
});
modelBuilder.Entity("Entities.Models.Staffs.Staff", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uuid");
b.Property<DateTime>("DateCreated")
.HasColumnType("timestamp with time zone")
.HasColumnName("DateCreated");
b.Property<DateTime?>("DateUpdated")
.HasColumnType("timestamp with time zone")
.HasColumnName("DateUpdated");
b.Property<string>("LastName")
.IsRequired()
.HasMaxLength(50)
.HasColumnType("character varying(50)");
b.Property<string>("Names")
.IsRequired()
.HasMaxLength(50)
.HasColumnType("character varying(50)");
b.Property<string>("PhoneNumber")
.IsRequired()
.HasMaxLength(15)
.HasColumnType("character varying(15)");
b.Property<Guid>("TeamId")
.HasColumnType("uuid");
b.Property<string>("Type")
.IsRequired()
.HasColumnType("text");
b.HasKey("Id");
b.HasIndex("TeamId");
b.ToTable("Staffs", "Club12");
});
modelBuilder.Entity("Entities.Models.Stages.Stage", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uuid");
b.Property<DateTime>("DateCreated")
.HasColumnType("timestamp with time zone")
.HasColumnName("DateCreated");
b.Property<DateTime?>("DateUpdated")
.HasColumnType("timestamp with time zone")
.HasColumnName("DateUpdated");
b.Property<string>("Description")
.HasMaxLength(1000)
.HasColumnType("character varying(1000)");
b.Property<Guid>("DivisionId")
.HasColumnType("uuid");
b.Property<DateTime>("EndDate")
.HasColumnType("timestamp with time zone");
b.Property<bool>("IsActive")
.HasColumnType("boolean");
b.Property<bool>("IsElimination")
.HasColumnType("boolean");
b.Property<string>("Name")
.IsRequired()
.HasMaxLength(100)
.HasColumnType("character varying(100)");
b.Property<string>("StageType")
.IsRequired()
.HasColumnType("text");
b.Property<DateTime>("StartDate")
.HasColumnType("timestamp with time zone");
b.HasKey("Id");
b.HasIndex("DivisionId");
b.HasIndex("Name", "DivisionId")
.IsUnique()
.HasDatabaseName("CONSTRAINT_UNIQUE_STAGE_NAME_AND_DIVISIONID");
b.ToTable("Stages", "Club12");
});
modelBuilder.Entity("Entities.Models.Teams.Team", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uuid");
b.Property<DateTime>("DateCreated")
.HasColumnType("timestamp with time zone")
.HasColumnName("DateCreated");
b.Property<DateTime?>("DateUpdated")
.HasColumnType("timestamp with time zone")
.HasColumnName("DateUpdated");
b.Property<Guid?>("DivisionId")
.HasColumnType("uuid");
b.Property<string>("LogoUrl")
.IsRequired()
.HasColumnType("text");
b.Property<string>("Name")
.IsRequired()
.HasColumnType("text");
b.Property<string>("ShirtColor")
.IsRequired()
.HasColumnType("text");
b.Property<string>("ThreeLetterCode")
.IsRequired()
.HasColumnType("text");
b.HasKey("Id");
b.HasIndex("DivisionId");
b.ToTable("Teams", "Club12");
});
modelBuilder.Entity("Entities.Models.Tournaments.Tournament", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uuid");
b.Property<DateTime>("DateCreated")
.HasColumnType("timestamp with time zone")
.HasColumnName("DateCreated");
b.Property<DateTime?>("DateUpdated")
.HasColumnType("timestamp with time zone")
.HasColumnName("DateUpdated");
b.Property<string>("Description")
.IsRequired()
.HasColumnType("text");
b.Property<string>("Name")
.IsRequired()
.HasColumnType("text");
b.HasKey("Id");
b.ToTable("Tournaments", "Club12");
});
modelBuilder.Entity("Entities.Models.Users.User", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uuid");
b.Property<DateTime>("DateCreated")
.HasColumnType("timestamp with time zone")
.HasColumnName("DateCreated");
b.Property<DateTime?>("DateUpdated")
.HasColumnType("timestamp with time zone")
.HasColumnName("DateUpdated");
b.Property<string>("Password")
.IsRequired()
.HasMaxLength(64)
.HasColumnType("character varying(64)");
b.Property<string>("RefreshToken")
.HasMaxLength(256)
.HasColumnType("character varying(256)");
b.Property<DateTime?>("RefreshTokenExpiryTime")
.HasColumnType("timestamp with time zone");
b.Property<string>("Role")
.IsRequired()
.HasMaxLength(10)
.HasColumnType("character varying(10)");
b.Property<string>("Username")
.IsRequired()
.HasMaxLength(25)
.HasColumnType("character varying(25)");
b.HasKey("Id");
b.ToTable("Users", "Club12");
});
modelBuilder.Entity("Entities.Models.Venues.Venue", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uuid");
b.Property<string>("Address")
.IsRequired()
.HasMaxLength(200)
.HasColumnType("character varying(200)");
b.Property<DateTime>("DateCreated")
.HasColumnType("timestamp with time zone")
.HasColumnName("DateCreated");
b.Property<DateTime?>("DateUpdated")
.HasColumnType("timestamp with time zone")
.HasColumnName("DateUpdated");
b.Property<string>("Name")
.IsRequired()
.HasMaxLength(50)
.HasColumnType("character varying(50)");
b.Property<string>("PhotoUrl")
.HasColumnType("text");
b.HasKey("Id");
b.ToTable("Venues", "Club12");
});
modelBuilder.Entity("Entities.Models.Divisions.Division", b =>
{
b.HasOne("Entities.Models.Tournaments.Tournament", "Tournament")
.WithMany("Divisions")
.HasForeignKey("TournamentId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Tournament");
});
modelBuilder.Entity("Entities.Models.Matches.Match", b =>
{
b.HasOne("Entities.Models.Divisions.Division", null)
.WithMany("Matches")
.HasForeignKey("DivisionId");
b.HasOne("Entities.Models.Teams.Team", "HomeTeam")
.WithMany()
.HasForeignKey("HomeTeamId");
b.HasOne("Entities.Models.Stages.Stage", "Stage")
.WithMany("Matches")
.HasForeignKey("StageId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("Entities.Models.Teams.Team", "VisitorTeam")
.WithMany()
.HasForeignKey("VisitorTeamId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("Entities.Models.Teams.Team", "WinningTeam")
.WithMany()
.HasForeignKey("WinningTeamId");
b.Navigation("HomeTeam");
b.Navigation("Stage");
b.Navigation("VisitorTeam");
b.Navigation("WinningTeam");
});
modelBuilder.Entity("Entities.Models.PlayerSanctions.PlayerSanction", b =>
{
b.HasOne("Entities.Models.Players.Player", "Player")
.WithMany()
.HasForeignKey("PlayerId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Player");
});
modelBuilder.Entity("Entities.Models.PlayerStatistics.PlayerStatistic", b =>
{
b.HasOne("Entities.Models.Matches.Match", "Match")
.WithMany("PlayerStatistics")
.HasForeignKey("MatchId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("Entities.Models.Players.Player", "Player")
.WithMany()
.HasForeignKey("PlayerId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Match");
b.Navigation("Player");
});
modelBuilder.Entity("Entities.Models.Players.Player", b =>
{
b.HasOne("Entities.Models.Teams.Team", "Team")
.WithMany("Players")
.HasForeignKey("TeamId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Team");
});
modelBuilder.Entity("Entities.Models.Staffs.Staff", b =>
{
b.HasOne("Entities.Models.Teams.Team", "Team")
.WithMany("Staff")
.HasForeignKey("TeamId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Team");
});
modelBuilder.Entity("Entities.Models.Stages.Stage", b =>
{
b.HasOne("Entities.Models.Divisions.Division", "Division")
.WithMany("Stages")
.HasForeignKey("DivisionId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Division");
});
modelBuilder.Entity("Entities.Models.Teams.Team", b =>
{
b.HasOne("Entities.Models.Divisions.Division", null)
.WithMany("Teams")
.HasForeignKey("DivisionId");
});
modelBuilder.Entity("Entities.Models.Divisions.Division", b =>
{
b.Navigation("Matches");
b.Navigation("Stages");
b.Navigation("Teams");
});
modelBuilder.Entity("Entities.Models.Matches.Match", b =>
{
b.Navigation("PlayerStatistics");
});
modelBuilder.Entity("Entities.Models.Stages.Stage", b =>
{
b.Navigation("Matches");
});
modelBuilder.Entity("Entities.Models.Teams.Team", b =>
{
b.Navigation("Players");
b.Navigation("Staff");
});
modelBuilder.Entity("Entities.Models.Tournaments.Tournament", b =>
{
b.Navigation("Divisions");
});
#pragma warning restore 612, 618
}
}
}
@@ -0,0 +1,93 @@
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace Persistance.Migrations;
/// <inheritdoc />
public partial class AddContraintToUniqueDocumentNumberInsidePlayerTable : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropColumn(
name: "Category",
schema: "Club12",
table: "Players");
migrationBuilder.DropColumn(
name: "Club",
schema: "Club12",
table: "Players");
migrationBuilder.DropColumn(
name: "IsFederated",
schema: "Club12",
table: "Players");
migrationBuilder.RenameColumn(
name: "Names",
schema: "Club12",
table: "Players",
newName: "FirstName");
migrationBuilder.AddColumn<string>(
name: "SecondName",
schema: "Club12",
table: "Players",
type: "character varying(70)",
maxLength: 70,
nullable: true);
migrationBuilder.CreateIndex(
name: "IX_Players_DocumentNumber",
schema: "Club12",
table: "Players",
column: "DocumentNumber",
unique: true);
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropIndex(
name: "IX_Players_DocumentNumber",
schema: "Club12",
table: "Players");
migrationBuilder.DropColumn(
name: "SecondName",
schema: "Club12",
table: "Players");
migrationBuilder.RenameColumn(
name: "FirstName",
schema: "Club12",
table: "Players",
newName: "Names");
migrationBuilder.AddColumn<string>(
name: "Category",
schema: "Club12",
table: "Players",
type: "character varying(50)",
maxLength: 50,
nullable: true);
migrationBuilder.AddColumn<string>(
name: "Club",
schema: "Club12",
table: "Players",
type: "character varying(100)",
maxLength: 100,
nullable: true);
migrationBuilder.AddColumn<bool>(
name: "IsFederated",
schema: "Club12",
table: "Players",
type: "boolean",
nullable: false,
defaultValue: false);
}
}
@@ -0,0 +1,685 @@
// <auto-generated />
using System;
using Infrastructure.Persistance;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Migrations;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
#nullable disable
namespace Persistance.Migrations
{
[DbContext(typeof(ApplicationDBContext))]
[Migration("20250801010149_addVenueIntoMatch")]
partial class addVenueIntoMatch
{
/// <inheritdoc />
protected override void BuildTargetModel(ModelBuilder modelBuilder)
{
#pragma warning disable 612, 618
modelBuilder
.HasAnnotation("ProductVersion", "8.0.11")
.HasAnnotation("Relational:MaxIdentifierLength", 63);
NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder);
modelBuilder.Entity("Entities.Models.BlogPosts.BlogPost", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uuid");
b.Property<string>("Author")
.IsRequired()
.HasMaxLength(50)
.HasColumnType("character varying(50)");
b.Property<DateTime>("DateCreated")
.HasColumnType("timestamp with time zone")
.HasColumnName("DateCreated");
b.Property<DateTime?>("DateUpdated")
.HasColumnType("timestamp with time zone")
.HasColumnName("DateUpdated");
b.Property<string>("MarkdownText")
.IsRequired()
.HasColumnType("text");
b.Property<string>("PhotoUrl")
.HasMaxLength(2048)
.HasColumnType("character varying(2048)");
b.Property<string>("Title")
.IsRequired()
.HasColumnType("text");
b.Property<int>("Views")
.HasColumnType("integer");
b.HasKey("Id");
b.ToTable("BlogPosts", "Club12");
});
modelBuilder.Entity("Entities.Models.Divisions.Division", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uuid");
b.Property<DateTime>("DateCreated")
.HasColumnType("timestamp with time zone")
.HasColumnName("DateCreated");
b.Property<DateTime?>("DateUpdated")
.HasColumnType("timestamp with time zone")
.HasColumnName("DateUpdated");
b.Property<bool>("IsFinished")
.HasColumnType("boolean");
b.Property<string>("Name")
.IsRequired()
.HasMaxLength(30)
.HasColumnType("character varying(30)");
b.Property<bool>("PlayoffsGenerated")
.HasColumnType("boolean");
b.Property<Guid>("TournamentId")
.HasColumnType("uuid");
b.HasKey("Id");
b.HasIndex("TournamentId");
b.ToTable("Divisions", "Club12");
});
modelBuilder.Entity("Entities.Models.Matches.Match", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uuid");
b.Property<DateTime>("DateCreated")
.HasColumnType("timestamp with time zone")
.HasColumnName("DateCreated");
b.Property<DateTime?>("DateUpdated")
.HasColumnType("timestamp with time zone")
.HasColumnName("DateUpdated");
b.Property<Guid?>("DivisionId")
.HasColumnType("uuid");
b.Property<int?>("HomeScore")
.HasColumnType("integer");
b.Property<Guid?>("HomeTeamId")
.HasColumnType("uuid");
b.Property<bool>("IsFinished")
.HasColumnType("boolean");
b.Property<DateTime>("MatchDate")
.HasColumnType("timestamp with time zone");
b.Property<Guid>("StageId")
.HasColumnType("uuid");
b.Property<string>("Type")
.IsRequired()
.HasColumnType("text");
b.Property<Guid?>("VenueId")
.HasColumnType("uuid");
b.Property<int?>("VisitorScore")
.HasColumnType("integer");
b.Property<Guid>("VisitorTeamId")
.HasColumnType("uuid");
b.Property<Guid?>("WinningTeamId")
.HasColumnType("uuid");
b.HasKey("Id");
b.HasIndex("DivisionId");
b.HasIndex("HomeTeamId");
b.HasIndex("StageId");
b.HasIndex("VenueId");
b.HasIndex("VisitorTeamId");
b.HasIndex("WinningTeamId");
b.ToTable("Matches", "Club12");
});
modelBuilder.Entity("Entities.Models.PlayerSanctions.PlayerSanction", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uuid");
b.Property<DateTime>("DateCreated")
.HasColumnType("timestamp with time zone")
.HasColumnName("DateCreated");
b.Property<DateTime?>("DateUpdated")
.HasColumnType("timestamp with time zone")
.HasColumnName("DateUpdated");
b.Property<string>("Description")
.IsRequired()
.HasMaxLength(255)
.HasColumnType("character varying(255)");
b.Property<int>("Duration")
.HasColumnType("integer");
b.Property<DateTime>("IssuedDate")
.HasColumnType("timestamp with time zone");
b.Property<Guid>("PlayerId")
.HasColumnType("uuid");
b.HasKey("Id");
b.HasIndex("PlayerId");
b.ToTable("PlayerSanctions", "Club12");
});
modelBuilder.Entity("Entities.Models.PlayerStatistics.PlayerStatistic", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uuid");
b.Property<DateTime>("DateCreated")
.HasColumnType("timestamp with time zone")
.HasColumnName("DateCreated");
b.Property<DateTime?>("DateUpdated")
.HasColumnType("timestamp with time zone")
.HasColumnName("DateUpdated");
b.Property<Guid>("MatchId")
.HasColumnType("uuid");
b.Property<Guid>("PlayerId")
.HasColumnType("uuid");
b.Property<int>("Value")
.HasColumnType("integer");
b.HasKey("Id");
b.HasIndex("MatchId");
b.HasIndex("PlayerId");
b.ToTable("PlayersStatistics", "Club12");
});
modelBuilder.Entity("Entities.Models.Players.Player", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uuid");
b.Property<DateTime>("BirthDate")
.HasColumnType("timestamp with time zone");
b.Property<DateTime>("DateCreated")
.HasColumnType("timestamp with time zone")
.HasColumnName("DateCreated");
b.Property<DateTime?>("DateUpdated")
.HasColumnType("timestamp with time zone")
.HasColumnName("DateUpdated");
b.Property<string>("DocumentNumber")
.IsRequired()
.HasMaxLength(15)
.HasColumnType("character varying(15)");
b.Property<string>("FirstName")
.IsRequired()
.HasMaxLength(70)
.HasColumnType("character varying(70)");
b.Property<bool>("IsSanctioned")
.HasColumnType("boolean");
b.Property<string>("LastName")
.IsRequired()
.HasMaxLength(70)
.HasColumnType("character varying(70)");
b.Property<string>("PhoneNumber")
.HasColumnType("text");
b.Property<string>("SecondName")
.HasMaxLength(70)
.HasColumnType("character varying(70)");
b.Property<string>("SocialSecurity")
.IsRequired()
.HasMaxLength(100)
.HasColumnType("character varying(100)");
b.Property<Guid>("TeamId")
.HasColumnType("uuid");
b.HasKey("Id");
b.HasIndex("DocumentNumber")
.IsUnique();
b.HasIndex("TeamId");
b.ToTable("Players", "Club12");
});
modelBuilder.Entity("Entities.Models.Staffs.Staff", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uuid");
b.Property<DateTime>("DateCreated")
.HasColumnType("timestamp with time zone")
.HasColumnName("DateCreated");
b.Property<DateTime?>("DateUpdated")
.HasColumnType("timestamp with time zone")
.HasColumnName("DateUpdated");
b.Property<string>("LastName")
.IsRequired()
.HasMaxLength(50)
.HasColumnType("character varying(50)");
b.Property<string>("Names")
.IsRequired()
.HasMaxLength(50)
.HasColumnType("character varying(50)");
b.Property<string>("PhoneNumber")
.IsRequired()
.HasMaxLength(15)
.HasColumnType("character varying(15)");
b.Property<Guid>("TeamId")
.HasColumnType("uuid");
b.Property<string>("Type")
.IsRequired()
.HasColumnType("text");
b.HasKey("Id");
b.HasIndex("TeamId");
b.ToTable("Staffs", "Club12");
});
modelBuilder.Entity("Entities.Models.Stages.Stage", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uuid");
b.Property<DateTime>("DateCreated")
.HasColumnType("timestamp with time zone")
.HasColumnName("DateCreated");
b.Property<DateTime?>("DateUpdated")
.HasColumnType("timestamp with time zone")
.HasColumnName("DateUpdated");
b.Property<string>("Description")
.HasMaxLength(1000)
.HasColumnType("character varying(1000)");
b.Property<Guid>("DivisionId")
.HasColumnType("uuid");
b.Property<DateTime>("EndDate")
.HasColumnType("timestamp with time zone");
b.Property<bool>("IsActive")
.HasColumnType("boolean");
b.Property<bool>("IsElimination")
.HasColumnType("boolean");
b.Property<string>("Name")
.IsRequired()
.HasMaxLength(100)
.HasColumnType("character varying(100)");
b.Property<string>("StageType")
.IsRequired()
.HasColumnType("text");
b.Property<DateTime>("StartDate")
.HasColumnType("timestamp with time zone");
b.HasKey("Id");
b.HasIndex("DivisionId");
b.HasIndex("Name", "DivisionId")
.IsUnique()
.HasDatabaseName("CONSTRAINT_UNIQUE_STAGE_NAME_AND_DIVISIONID");
b.ToTable("Stages", "Club12");
});
modelBuilder.Entity("Entities.Models.Teams.Team", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uuid");
b.Property<DateTime>("DateCreated")
.HasColumnType("timestamp with time zone")
.HasColumnName("DateCreated");
b.Property<DateTime?>("DateUpdated")
.HasColumnType("timestamp with time zone")
.HasColumnName("DateUpdated");
b.Property<Guid?>("DivisionId")
.HasColumnType("uuid");
b.Property<string>("LogoUrl")
.IsRequired()
.HasColumnType("text");
b.Property<string>("Name")
.IsRequired()
.HasColumnType("text");
b.Property<string>("ShirtColor")
.IsRequired()
.HasColumnType("text");
b.Property<string>("ThreeLetterCode")
.IsRequired()
.HasColumnType("text");
b.HasKey("Id");
b.HasIndex("DivisionId");
b.ToTable("Teams", "Club12");
});
modelBuilder.Entity("Entities.Models.Tournaments.Tournament", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uuid");
b.Property<DateTime>("DateCreated")
.HasColumnType("timestamp with time zone")
.HasColumnName("DateCreated");
b.Property<DateTime?>("DateUpdated")
.HasColumnType("timestamp with time zone")
.HasColumnName("DateUpdated");
b.Property<string>("Description")
.IsRequired()
.HasColumnType("text");
b.Property<string>("Name")
.IsRequired()
.HasColumnType("text");
b.HasKey("Id");
b.ToTable("Tournaments", "Club12");
});
modelBuilder.Entity("Entities.Models.Users.User", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uuid");
b.Property<DateTime>("DateCreated")
.HasColumnType("timestamp with time zone")
.HasColumnName("DateCreated");
b.Property<DateTime?>("DateUpdated")
.HasColumnType("timestamp with time zone")
.HasColumnName("DateUpdated");
b.Property<string>("Password")
.IsRequired()
.HasMaxLength(64)
.HasColumnType("character varying(64)");
b.Property<string>("RefreshToken")
.HasMaxLength(256)
.HasColumnType("character varying(256)");
b.Property<DateTime?>("RefreshTokenExpiryTime")
.HasColumnType("timestamp with time zone");
b.Property<string>("Role")
.IsRequired()
.HasMaxLength(10)
.HasColumnType("character varying(10)");
b.Property<string>("Username")
.IsRequired()
.HasMaxLength(25)
.HasColumnType("character varying(25)");
b.HasKey("Id");
b.ToTable("Users", "Club12");
});
modelBuilder.Entity("Entities.Models.Venues.Venue", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uuid");
b.Property<string>("Address")
.IsRequired()
.HasMaxLength(200)
.HasColumnType("character varying(200)");
b.Property<DateTime>("DateCreated")
.HasColumnType("timestamp with time zone")
.HasColumnName("DateCreated");
b.Property<DateTime?>("DateUpdated")
.HasColumnType("timestamp with time zone")
.HasColumnName("DateUpdated");
b.Property<string>("Name")
.IsRequired()
.HasMaxLength(50)
.HasColumnType("character varying(50)");
b.Property<string>("PhotoUrl")
.HasColumnType("text");
b.HasKey("Id");
b.ToTable("Venues", "Club12");
});
modelBuilder.Entity("Entities.Models.Divisions.Division", b =>
{
b.HasOne("Entities.Models.Tournaments.Tournament", "Tournament")
.WithMany("Divisions")
.HasForeignKey("TournamentId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Tournament");
});
modelBuilder.Entity("Entities.Models.Matches.Match", b =>
{
b.HasOne("Entities.Models.Divisions.Division", null)
.WithMany("Matches")
.HasForeignKey("DivisionId");
b.HasOne("Entities.Models.Teams.Team", "HomeTeam")
.WithMany()
.HasForeignKey("HomeTeamId");
b.HasOne("Entities.Models.Stages.Stage", "Stage")
.WithMany("Matches")
.HasForeignKey("StageId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("Entities.Models.Venues.Venue", "Venue")
.WithMany()
.HasForeignKey("VenueId");
b.HasOne("Entities.Models.Teams.Team", "VisitorTeam")
.WithMany()
.HasForeignKey("VisitorTeamId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("Entities.Models.Teams.Team", "WinningTeam")
.WithMany()
.HasForeignKey("WinningTeamId");
b.Navigation("HomeTeam");
b.Navigation("Stage");
b.Navigation("Venue");
b.Navigation("VisitorTeam");
b.Navigation("WinningTeam");
});
modelBuilder.Entity("Entities.Models.PlayerSanctions.PlayerSanction", b =>
{
b.HasOne("Entities.Models.Players.Player", "Player")
.WithMany()
.HasForeignKey("PlayerId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Player");
});
modelBuilder.Entity("Entities.Models.PlayerStatistics.PlayerStatistic", b =>
{
b.HasOne("Entities.Models.Matches.Match", "Match")
.WithMany("PlayerStatistics")
.HasForeignKey("MatchId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("Entities.Models.Players.Player", "Player")
.WithMany()
.HasForeignKey("PlayerId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Match");
b.Navigation("Player");
});
modelBuilder.Entity("Entities.Models.Players.Player", b =>
{
b.HasOne("Entities.Models.Teams.Team", "Team")
.WithMany("Players")
.HasForeignKey("TeamId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Team");
});
modelBuilder.Entity("Entities.Models.Staffs.Staff", b =>
{
b.HasOne("Entities.Models.Teams.Team", "Team")
.WithMany("Staff")
.HasForeignKey("TeamId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Team");
});
modelBuilder.Entity("Entities.Models.Stages.Stage", b =>
{
b.HasOne("Entities.Models.Divisions.Division", "Division")
.WithMany("Stages")
.HasForeignKey("DivisionId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Division");
});
modelBuilder.Entity("Entities.Models.Teams.Team", b =>
{
b.HasOne("Entities.Models.Divisions.Division", null)
.WithMany("Teams")
.HasForeignKey("DivisionId");
});
modelBuilder.Entity("Entities.Models.Divisions.Division", b =>
{
b.Navigation("Matches");
b.Navigation("Stages");
b.Navigation("Teams");
});
modelBuilder.Entity("Entities.Models.Matches.Match", b =>
{
b.Navigation("PlayerStatistics");
});
modelBuilder.Entity("Entities.Models.Stages.Stage", b =>
{
b.Navigation("Matches");
});
modelBuilder.Entity("Entities.Models.Teams.Team", b =>
{
b.Navigation("Players");
b.Navigation("Staff");
});
modelBuilder.Entity("Entities.Models.Tournaments.Tournament", b =>
{
b.Navigation("Divisions");
});
#pragma warning restore 612, 618
}
}
}
@@ -0,0 +1,56 @@
using Microsoft.EntityFrameworkCore.Migrations;
using System;
#nullable disable
namespace Persistance.Migrations;
/// <inheritdoc />
public partial class addVenueIntoMatch : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.AddColumn<Guid>(
name: "VenueId",
schema: "Club12",
table: "Matches",
type: "uuid",
nullable: true);
migrationBuilder.CreateIndex(
name: "IX_Matches_VenueId",
schema: "Club12",
table: "Matches",
column: "VenueId");
migrationBuilder.AddForeignKey(
name: "FK_Matches_Venues_VenueId",
schema: "Club12",
table: "Matches",
column: "VenueId",
principalSchema: "Club12",
principalTable: "Venues",
principalColumn: "Id");
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropForeignKey(
name: "FK_Matches_Venues_VenueId",
schema: "Club12",
table: "Matches");
migrationBuilder.DropIndex(
name: "IX_Matches_VenueId",
schema: "Club12",
table: "Matches");
migrationBuilder.DropColumn(
name: "VenueId",
schema: "Club12",
table: "Matches");
}
}
@@ -0,0 +1,685 @@
// <auto-generated />
using System;
using Infrastructure.Persistance;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Migrations;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
#nullable disable
namespace Persistance.Migrations
{
[DbContext(typeof(ApplicationDBContext))]
[Migration("20250804000142_ChangeDateTimeWithTimeZoneToDateTimeWithoutTimeZone")]
partial class ChangeDateTimeWithTimeZoneToDateTimeWithoutTimeZone
{
/// <inheritdoc />
protected override void BuildTargetModel(ModelBuilder modelBuilder)
{
#pragma warning disable 612, 618
modelBuilder
.HasAnnotation("ProductVersion", "8.0.11")
.HasAnnotation("Relational:MaxIdentifierLength", 63);
NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder);
modelBuilder.Entity("Entities.Models.BlogPosts.BlogPost", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uuid");
b.Property<string>("Author")
.IsRequired()
.HasMaxLength(50)
.HasColumnType("character varying(50)");
b.Property<DateTime>("DateCreated")
.HasColumnType("timestamp without time zone")
.HasColumnName("DateCreated");
b.Property<DateTime?>("DateUpdated")
.HasColumnType("timestamp without time zone")
.HasColumnName("DateUpdated");
b.Property<string>("MarkdownText")
.IsRequired()
.HasColumnType("text");
b.Property<string>("PhotoUrl")
.HasMaxLength(2048)
.HasColumnType("character varying(2048)");
b.Property<string>("Title")
.IsRequired()
.HasColumnType("text");
b.Property<int>("Views")
.HasColumnType("integer");
b.HasKey("Id");
b.ToTable("BlogPosts", "Club12");
});
modelBuilder.Entity("Entities.Models.Divisions.Division", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uuid");
b.Property<DateTime>("DateCreated")
.HasColumnType("timestamp without time zone")
.HasColumnName("DateCreated");
b.Property<DateTime?>("DateUpdated")
.HasColumnType("timestamp without time zone")
.HasColumnName("DateUpdated");
b.Property<bool>("IsFinished")
.HasColumnType("boolean");
b.Property<string>("Name")
.IsRequired()
.HasMaxLength(30)
.HasColumnType("character varying(30)");
b.Property<bool>("PlayoffsGenerated")
.HasColumnType("boolean");
b.Property<Guid>("TournamentId")
.HasColumnType("uuid");
b.HasKey("Id");
b.HasIndex("TournamentId");
b.ToTable("Divisions", "Club12");
});
modelBuilder.Entity("Entities.Models.Matches.Match", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uuid");
b.Property<DateTime>("DateCreated")
.HasColumnType("timestamp without time zone")
.HasColumnName("DateCreated");
b.Property<DateTime?>("DateUpdated")
.HasColumnType("timestamp without time zone")
.HasColumnName("DateUpdated");
b.Property<Guid?>("DivisionId")
.HasColumnType("uuid");
b.Property<int?>("HomeScore")
.HasColumnType("integer");
b.Property<Guid?>("HomeTeamId")
.HasColumnType("uuid");
b.Property<bool>("IsFinished")
.HasColumnType("boolean");
b.Property<DateTime>("MatchDate")
.HasColumnType("timestamp without time zone");
b.Property<Guid>("StageId")
.HasColumnType("uuid");
b.Property<string>("Type")
.IsRequired()
.HasColumnType("text");
b.Property<Guid?>("VenueId")
.HasColumnType("uuid");
b.Property<int?>("VisitorScore")
.HasColumnType("integer");
b.Property<Guid>("VisitorTeamId")
.HasColumnType("uuid");
b.Property<Guid?>("WinningTeamId")
.HasColumnType("uuid");
b.HasKey("Id");
b.HasIndex("DivisionId");
b.HasIndex("HomeTeamId");
b.HasIndex("StageId");
b.HasIndex("VenueId");
b.HasIndex("VisitorTeamId");
b.HasIndex("WinningTeamId");
b.ToTable("Matches", "Club12");
});
modelBuilder.Entity("Entities.Models.PlayerSanctions.PlayerSanction", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uuid");
b.Property<DateTime>("DateCreated")
.HasColumnType("timestamp without time zone")
.HasColumnName("DateCreated");
b.Property<DateTime?>("DateUpdated")
.HasColumnType("timestamp without time zone")
.HasColumnName("DateUpdated");
b.Property<string>("Description")
.IsRequired()
.HasMaxLength(255)
.HasColumnType("character varying(255)");
b.Property<int>("Duration")
.HasColumnType("integer");
b.Property<DateTime>("IssuedDate")
.HasColumnType("timestamp without time zone");
b.Property<Guid>("PlayerId")
.HasColumnType("uuid");
b.HasKey("Id");
b.HasIndex("PlayerId");
b.ToTable("PlayerSanctions", "Club12");
});
modelBuilder.Entity("Entities.Models.PlayerStatistics.PlayerStatistic", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uuid");
b.Property<DateTime>("DateCreated")
.HasColumnType("timestamp without time zone")
.HasColumnName("DateCreated");
b.Property<DateTime?>("DateUpdated")
.HasColumnType("timestamp without time zone")
.HasColumnName("DateUpdated");
b.Property<Guid>("MatchId")
.HasColumnType("uuid");
b.Property<Guid>("PlayerId")
.HasColumnType("uuid");
b.Property<int>("Value")
.HasColumnType("integer");
b.HasKey("Id");
b.HasIndex("MatchId");
b.HasIndex("PlayerId");
b.ToTable("PlayersStatistics", "Club12");
});
modelBuilder.Entity("Entities.Models.Players.Player", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uuid");
b.Property<DateTime>("BirthDate")
.HasColumnType("timestamp without time zone");
b.Property<DateTime>("DateCreated")
.HasColumnType("timestamp without time zone")
.HasColumnName("DateCreated");
b.Property<DateTime?>("DateUpdated")
.HasColumnType("timestamp without time zone")
.HasColumnName("DateUpdated");
b.Property<string>("DocumentNumber")
.IsRequired()
.HasMaxLength(15)
.HasColumnType("character varying(15)");
b.Property<string>("FirstName")
.IsRequired()
.HasMaxLength(70)
.HasColumnType("character varying(70)");
b.Property<bool>("IsSanctioned")
.HasColumnType("boolean");
b.Property<string>("LastName")
.IsRequired()
.HasMaxLength(70)
.HasColumnType("character varying(70)");
b.Property<string>("PhoneNumber")
.HasColumnType("text");
b.Property<string>("SecondName")
.HasMaxLength(70)
.HasColumnType("character varying(70)");
b.Property<string>("SocialSecurity")
.IsRequired()
.HasMaxLength(100)
.HasColumnType("character varying(100)");
b.Property<Guid>("TeamId")
.HasColumnType("uuid");
b.HasKey("Id");
b.HasIndex("DocumentNumber")
.IsUnique();
b.HasIndex("TeamId");
b.ToTable("Players", "Club12");
});
modelBuilder.Entity("Entities.Models.Staffs.Staff", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uuid");
b.Property<DateTime>("DateCreated")
.HasColumnType("timestamp without time zone")
.HasColumnName("DateCreated");
b.Property<DateTime?>("DateUpdated")
.HasColumnType("timestamp without time zone")
.HasColumnName("DateUpdated");
b.Property<string>("LastName")
.IsRequired()
.HasMaxLength(50)
.HasColumnType("character varying(50)");
b.Property<string>("Names")
.IsRequired()
.HasMaxLength(50)
.HasColumnType("character varying(50)");
b.Property<string>("PhoneNumber")
.IsRequired()
.HasMaxLength(15)
.HasColumnType("character varying(15)");
b.Property<Guid>("TeamId")
.HasColumnType("uuid");
b.Property<string>("Type")
.IsRequired()
.HasColumnType("text");
b.HasKey("Id");
b.HasIndex("TeamId");
b.ToTable("Staffs", "Club12");
});
modelBuilder.Entity("Entities.Models.Stages.Stage", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uuid");
b.Property<DateTime>("DateCreated")
.HasColumnType("timestamp without time zone")
.HasColumnName("DateCreated");
b.Property<DateTime?>("DateUpdated")
.HasColumnType("timestamp without time zone")
.HasColumnName("DateUpdated");
b.Property<string>("Description")
.HasMaxLength(1000)
.HasColumnType("character varying(1000)");
b.Property<Guid>("DivisionId")
.HasColumnType("uuid");
b.Property<DateTime>("EndDate")
.HasColumnType("timestamp without time zone");
b.Property<bool>("IsActive")
.HasColumnType("boolean");
b.Property<bool>("IsElimination")
.HasColumnType("boolean");
b.Property<string>("Name")
.IsRequired()
.HasMaxLength(100)
.HasColumnType("character varying(100)");
b.Property<string>("StageType")
.IsRequired()
.HasColumnType("text");
b.Property<DateTime>("StartDate")
.HasColumnType("timestamp without time zone");
b.HasKey("Id");
b.HasIndex("DivisionId");
b.HasIndex("Name", "DivisionId")
.IsUnique()
.HasDatabaseName("CONSTRAINT_UNIQUE_STAGE_NAME_AND_DIVISIONID");
b.ToTable("Stages", "Club12");
});
modelBuilder.Entity("Entities.Models.Teams.Team", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uuid");
b.Property<DateTime>("DateCreated")
.HasColumnType("timestamp without time zone")
.HasColumnName("DateCreated");
b.Property<DateTime?>("DateUpdated")
.HasColumnType("timestamp without time zone")
.HasColumnName("DateUpdated");
b.Property<Guid?>("DivisionId")
.HasColumnType("uuid");
b.Property<string>("LogoUrl")
.IsRequired()
.HasColumnType("text");
b.Property<string>("Name")
.IsRequired()
.HasColumnType("text");
b.Property<string>("ShirtColor")
.IsRequired()
.HasColumnType("text");
b.Property<string>("ThreeLetterCode")
.IsRequired()
.HasColumnType("text");
b.HasKey("Id");
b.HasIndex("DivisionId");
b.ToTable("Teams", "Club12");
});
modelBuilder.Entity("Entities.Models.Tournaments.Tournament", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uuid");
b.Property<DateTime>("DateCreated")
.HasColumnType("timestamp without time zone")
.HasColumnName("DateCreated");
b.Property<DateTime?>("DateUpdated")
.HasColumnType("timestamp without time zone")
.HasColumnName("DateUpdated");
b.Property<string>("Description")
.IsRequired()
.HasColumnType("text");
b.Property<string>("Name")
.IsRequired()
.HasColumnType("text");
b.HasKey("Id");
b.ToTable("Tournaments", "Club12");
});
modelBuilder.Entity("Entities.Models.Users.User", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uuid");
b.Property<DateTime>("DateCreated")
.HasColumnType("timestamp without time zone")
.HasColumnName("DateCreated");
b.Property<DateTime?>("DateUpdated")
.HasColumnType("timestamp without time zone")
.HasColumnName("DateUpdated");
b.Property<string>("Password")
.IsRequired()
.HasMaxLength(64)
.HasColumnType("character varying(64)");
b.Property<string>("RefreshToken")
.HasMaxLength(256)
.HasColumnType("character varying(256)");
b.Property<DateTime?>("RefreshTokenExpiryTime")
.HasColumnType("timestamp without time zone");
b.Property<string>("Role")
.IsRequired()
.HasMaxLength(10)
.HasColumnType("character varying(10)");
b.Property<string>("Username")
.IsRequired()
.HasMaxLength(25)
.HasColumnType("character varying(25)");
b.HasKey("Id");
b.ToTable("Users", "Club12");
});
modelBuilder.Entity("Entities.Models.Venues.Venue", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uuid");
b.Property<string>("Address")
.IsRequired()
.HasMaxLength(200)
.HasColumnType("character varying(200)");
b.Property<DateTime>("DateCreated")
.HasColumnType("timestamp without time zone")
.HasColumnName("DateCreated");
b.Property<DateTime?>("DateUpdated")
.HasColumnType("timestamp without time zone")
.HasColumnName("DateUpdated");
b.Property<string>("Name")
.IsRequired()
.HasMaxLength(50)
.HasColumnType("character varying(50)");
b.Property<string>("PhotoUrl")
.HasColumnType("text");
b.HasKey("Id");
b.ToTable("Venues", "Club12");
});
modelBuilder.Entity("Entities.Models.Divisions.Division", b =>
{
b.HasOne("Entities.Models.Tournaments.Tournament", "Tournament")
.WithMany("Divisions")
.HasForeignKey("TournamentId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Tournament");
});
modelBuilder.Entity("Entities.Models.Matches.Match", b =>
{
b.HasOne("Entities.Models.Divisions.Division", null)
.WithMany("Matches")
.HasForeignKey("DivisionId");
b.HasOne("Entities.Models.Teams.Team", "HomeTeam")
.WithMany()
.HasForeignKey("HomeTeamId");
b.HasOne("Entities.Models.Stages.Stage", "Stage")
.WithMany("Matches")
.HasForeignKey("StageId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("Entities.Models.Venues.Venue", "Venue")
.WithMany()
.HasForeignKey("VenueId");
b.HasOne("Entities.Models.Teams.Team", "VisitorTeam")
.WithMany()
.HasForeignKey("VisitorTeamId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("Entities.Models.Teams.Team", "WinningTeam")
.WithMany()
.HasForeignKey("WinningTeamId");
b.Navigation("HomeTeam");
b.Navigation("Stage");
b.Navigation("Venue");
b.Navigation("VisitorTeam");
b.Navigation("WinningTeam");
});
modelBuilder.Entity("Entities.Models.PlayerSanctions.PlayerSanction", b =>
{
b.HasOne("Entities.Models.Players.Player", "Player")
.WithMany()
.HasForeignKey("PlayerId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Player");
});
modelBuilder.Entity("Entities.Models.PlayerStatistics.PlayerStatistic", b =>
{
b.HasOne("Entities.Models.Matches.Match", "Match")
.WithMany("PlayerStatistics")
.HasForeignKey("MatchId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("Entities.Models.Players.Player", "Player")
.WithMany()
.HasForeignKey("PlayerId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Match");
b.Navigation("Player");
});
modelBuilder.Entity("Entities.Models.Players.Player", b =>
{
b.HasOne("Entities.Models.Teams.Team", "Team")
.WithMany("Players")
.HasForeignKey("TeamId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Team");
});
modelBuilder.Entity("Entities.Models.Staffs.Staff", b =>
{
b.HasOne("Entities.Models.Teams.Team", "Team")
.WithMany("Staff")
.HasForeignKey("TeamId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Team");
});
modelBuilder.Entity("Entities.Models.Stages.Stage", b =>
{
b.HasOne("Entities.Models.Divisions.Division", "Division")
.WithMany("Stages")
.HasForeignKey("DivisionId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Division");
});
modelBuilder.Entity("Entities.Models.Teams.Team", b =>
{
b.HasOne("Entities.Models.Divisions.Division", null)
.WithMany("Teams")
.HasForeignKey("DivisionId");
});
modelBuilder.Entity("Entities.Models.Divisions.Division", b =>
{
b.Navigation("Matches");
b.Navigation("Stages");
b.Navigation("Teams");
});
modelBuilder.Entity("Entities.Models.Matches.Match", b =>
{
b.Navigation("PlayerStatistics");
});
modelBuilder.Entity("Entities.Models.Stages.Stage", b =>
{
b.Navigation("Matches");
});
modelBuilder.Entity("Entities.Models.Teams.Team", b =>
{
b.Navigation("Players");
b.Navigation("Staff");
});
modelBuilder.Entity("Entities.Models.Tournaments.Tournament", b =>
{
b.Navigation("Divisions");
});
#pragma warning restore 612, 618
}
}
}
@@ -0,0 +1,585 @@
using Microsoft.EntityFrameworkCore.Migrations;
using System;
#nullable disable
namespace Persistance.Migrations;
/// <inheritdoc />
public partial class ChangeDateTimeWithTimeZoneToDateTimeWithoutTimeZone : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.AlterColumn<DateTime>(
name: "DateUpdated",
schema: "Club12",
table: "Venues",
type: "timestamp without time zone",
nullable: true,
oldClrType: typeof(DateTime),
oldType: "timestamp with time zone",
oldNullable: true);
migrationBuilder.AlterColumn<DateTime>(
name: "DateCreated",
schema: "Club12",
table: "Venues",
type: "timestamp without time zone",
nullable: false,
oldClrType: typeof(DateTime),
oldType: "timestamp with time zone");
migrationBuilder.AlterColumn<DateTime>(
name: "RefreshTokenExpiryTime",
schema: "Club12",
table: "Users",
type: "timestamp without time zone",
nullable: true,
oldClrType: typeof(DateTime),
oldType: "timestamp with time zone",
oldNullable: true);
migrationBuilder.AlterColumn<DateTime>(
name: "DateUpdated",
schema: "Club12",
table: "Users",
type: "timestamp without time zone",
nullable: true,
oldClrType: typeof(DateTime),
oldType: "timestamp with time zone",
oldNullable: true);
migrationBuilder.AlterColumn<DateTime>(
name: "DateCreated",
schema: "Club12",
table: "Users",
type: "timestamp without time zone",
nullable: false,
oldClrType: typeof(DateTime),
oldType: "timestamp with time zone");
migrationBuilder.AlterColumn<DateTime>(
name: "DateUpdated",
schema: "Club12",
table: "Tournaments",
type: "timestamp without time zone",
nullable: true,
oldClrType: typeof(DateTime),
oldType: "timestamp with time zone",
oldNullable: true);
migrationBuilder.AlterColumn<DateTime>(
name: "DateCreated",
schema: "Club12",
table: "Tournaments",
type: "timestamp without time zone",
nullable: false,
oldClrType: typeof(DateTime),
oldType: "timestamp with time zone");
migrationBuilder.AlterColumn<DateTime>(
name: "DateUpdated",
schema: "Club12",
table: "Teams",
type: "timestamp without time zone",
nullable: true,
oldClrType: typeof(DateTime),
oldType: "timestamp with time zone",
oldNullable: true);
migrationBuilder.AlterColumn<DateTime>(
name: "DateCreated",
schema: "Club12",
table: "Teams",
type: "timestamp without time zone",
nullable: false,
oldClrType: typeof(DateTime),
oldType: "timestamp with time zone");
migrationBuilder.AlterColumn<DateTime>(
name: "StartDate",
schema: "Club12",
table: "Stages",
type: "timestamp without time zone",
nullable: false,
oldClrType: typeof(DateTime),
oldType: "timestamp with time zone");
migrationBuilder.AlterColumn<DateTime>(
name: "EndDate",
schema: "Club12",
table: "Stages",
type: "timestamp without time zone",
nullable: false,
oldClrType: typeof(DateTime),
oldType: "timestamp with time zone");
migrationBuilder.AlterColumn<DateTime>(
name: "DateUpdated",
schema: "Club12",
table: "Stages",
type: "timestamp without time zone",
nullable: true,
oldClrType: typeof(DateTime),
oldType: "timestamp with time zone",
oldNullable: true);
migrationBuilder.AlterColumn<DateTime>(
name: "DateCreated",
schema: "Club12",
table: "Stages",
type: "timestamp without time zone",
nullable: false,
oldClrType: typeof(DateTime),
oldType: "timestamp with time zone");
migrationBuilder.AlterColumn<DateTime>(
name: "DateUpdated",
schema: "Club12",
table: "Staffs",
type: "timestamp without time zone",
nullable: true,
oldClrType: typeof(DateTime),
oldType: "timestamp with time zone",
oldNullable: true);
migrationBuilder.AlterColumn<DateTime>(
name: "DateCreated",
schema: "Club12",
table: "Staffs",
type: "timestamp without time zone",
nullable: false,
oldClrType: typeof(DateTime),
oldType: "timestamp with time zone");
migrationBuilder.AlterColumn<DateTime>(
name: "DateUpdated",
schema: "Club12",
table: "PlayersStatistics",
type: "timestamp without time zone",
nullable: true,
oldClrType: typeof(DateTime),
oldType: "timestamp with time zone",
oldNullable: true);
migrationBuilder.AlterColumn<DateTime>(
name: "DateCreated",
schema: "Club12",
table: "PlayersStatistics",
type: "timestamp without time zone",
nullable: false,
oldClrType: typeof(DateTime),
oldType: "timestamp with time zone");
migrationBuilder.AlterColumn<DateTime>(
name: "IssuedDate",
schema: "Club12",
table: "PlayerSanctions",
type: "timestamp without time zone",
nullable: false,
oldClrType: typeof(DateTime),
oldType: "timestamp with time zone");
migrationBuilder.AlterColumn<DateTime>(
name: "DateUpdated",
schema: "Club12",
table: "PlayerSanctions",
type: "timestamp without time zone",
nullable: true,
oldClrType: typeof(DateTime),
oldType: "timestamp with time zone",
oldNullable: true);
migrationBuilder.AlterColumn<DateTime>(
name: "DateCreated",
schema: "Club12",
table: "PlayerSanctions",
type: "timestamp without time zone",
nullable: false,
oldClrType: typeof(DateTime),
oldType: "timestamp with time zone");
migrationBuilder.AlterColumn<DateTime>(
name: "DateUpdated",
schema: "Club12",
table: "Players",
type: "timestamp without time zone",
nullable: true,
oldClrType: typeof(DateTime),
oldType: "timestamp with time zone",
oldNullable: true);
migrationBuilder.AlterColumn<DateTime>(
name: "DateCreated",
schema: "Club12",
table: "Players",
type: "timestamp without time zone",
nullable: false,
oldClrType: typeof(DateTime),
oldType: "timestamp with time zone");
migrationBuilder.AlterColumn<DateTime>(
name: "BirthDate",
schema: "Club12",
table: "Players",
type: "timestamp without time zone",
nullable: false,
oldClrType: typeof(DateTime),
oldType: "timestamp with time zone");
migrationBuilder.AlterColumn<DateTime>(
name: "MatchDate",
schema: "Club12",
table: "Matches",
type: "timestamp without time zone",
nullable: false,
oldClrType: typeof(DateTime),
oldType: "timestamp with time zone");
migrationBuilder.AlterColumn<DateTime>(
name: "DateUpdated",
schema: "Club12",
table: "Matches",
type: "timestamp without time zone",
nullable: true,
oldClrType: typeof(DateTime),
oldType: "timestamp with time zone",
oldNullable: true);
migrationBuilder.AlterColumn<DateTime>(
name: "DateCreated",
schema: "Club12",
table: "Matches",
type: "timestamp without time zone",
nullable: false,
oldClrType: typeof(DateTime),
oldType: "timestamp with time zone");
migrationBuilder.AlterColumn<DateTime>(
name: "DateUpdated",
schema: "Club12",
table: "Divisions",
type: "timestamp without time zone",
nullable: true,
oldClrType: typeof(DateTime),
oldType: "timestamp with time zone",
oldNullable: true);
migrationBuilder.AlterColumn<DateTime>(
name: "DateCreated",
schema: "Club12",
table: "Divisions",
type: "timestamp without time zone",
nullable: false,
oldClrType: typeof(DateTime),
oldType: "timestamp with time zone");
migrationBuilder.AlterColumn<DateTime>(
name: "DateUpdated",
schema: "Club12",
table: "BlogPosts",
type: "timestamp without time zone",
nullable: true,
oldClrType: typeof(DateTime),
oldType: "timestamp with time zone",
oldNullable: true);
migrationBuilder.AlterColumn<DateTime>(
name: "DateCreated",
schema: "Club12",
table: "BlogPosts",
type: "timestamp without time zone",
nullable: false,
oldClrType: typeof(DateTime),
oldType: "timestamp with time zone");
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.AlterColumn<DateTime>(
name: "DateUpdated",
schema: "Club12",
table: "Venues",
type: "timestamp with time zone",
nullable: true,
oldClrType: typeof(DateTime),
oldType: "timestamp without time zone",
oldNullable: true);
migrationBuilder.AlterColumn<DateTime>(
name: "DateCreated",
schema: "Club12",
table: "Venues",
type: "timestamp with time zone",
nullable: false,
oldClrType: typeof(DateTime),
oldType: "timestamp without time zone");
migrationBuilder.AlterColumn<DateTime>(
name: "RefreshTokenExpiryTime",
schema: "Club12",
table: "Users",
type: "timestamp with time zone",
nullable: true,
oldClrType: typeof(DateTime),
oldType: "timestamp without time zone",
oldNullable: true);
migrationBuilder.AlterColumn<DateTime>(
name: "DateUpdated",
schema: "Club12",
table: "Users",
type: "timestamp with time zone",
nullable: true,
oldClrType: typeof(DateTime),
oldType: "timestamp without time zone",
oldNullable: true);
migrationBuilder.AlterColumn<DateTime>(
name: "DateCreated",
schema: "Club12",
table: "Users",
type: "timestamp with time zone",
nullable: false,
oldClrType: typeof(DateTime),
oldType: "timestamp without time zone");
migrationBuilder.AlterColumn<DateTime>(
name: "DateUpdated",
schema: "Club12",
table: "Tournaments",
type: "timestamp with time zone",
nullable: true,
oldClrType: typeof(DateTime),
oldType: "timestamp without time zone",
oldNullable: true);
migrationBuilder.AlterColumn<DateTime>(
name: "DateCreated",
schema: "Club12",
table: "Tournaments",
type: "timestamp with time zone",
nullable: false,
oldClrType: typeof(DateTime),
oldType: "timestamp without time zone");
migrationBuilder.AlterColumn<DateTime>(
name: "DateUpdated",
schema: "Club12",
table: "Teams",
type: "timestamp with time zone",
nullable: true,
oldClrType: typeof(DateTime),
oldType: "timestamp without time zone",
oldNullable: true);
migrationBuilder.AlterColumn<DateTime>(
name: "DateCreated",
schema: "Club12",
table: "Teams",
type: "timestamp with time zone",
nullable: false,
oldClrType: typeof(DateTime),
oldType: "timestamp without time zone");
migrationBuilder.AlterColumn<DateTime>(
name: "StartDate",
schema: "Club12",
table: "Stages",
type: "timestamp with time zone",
nullable: false,
oldClrType: typeof(DateTime),
oldType: "timestamp without time zone");
migrationBuilder.AlterColumn<DateTime>(
name: "EndDate",
schema: "Club12",
table: "Stages",
type: "timestamp with time zone",
nullable: false,
oldClrType: typeof(DateTime),
oldType: "timestamp without time zone");
migrationBuilder.AlterColumn<DateTime>(
name: "DateUpdated",
schema: "Club12",
table: "Stages",
type: "timestamp with time zone",
nullable: true,
oldClrType: typeof(DateTime),
oldType: "timestamp without time zone",
oldNullable: true);
migrationBuilder.AlterColumn<DateTime>(
name: "DateCreated",
schema: "Club12",
table: "Stages",
type: "timestamp with time zone",
nullable: false,
oldClrType: typeof(DateTime),
oldType: "timestamp without time zone");
migrationBuilder.AlterColumn<DateTime>(
name: "DateUpdated",
schema: "Club12",
table: "Staffs",
type: "timestamp with time zone",
nullable: true,
oldClrType: typeof(DateTime),
oldType: "timestamp without time zone",
oldNullable: true);
migrationBuilder.AlterColumn<DateTime>(
name: "DateCreated",
schema: "Club12",
table: "Staffs",
type: "timestamp with time zone",
nullable: false,
oldClrType: typeof(DateTime),
oldType: "timestamp without time zone");
migrationBuilder.AlterColumn<DateTime>(
name: "DateUpdated",
schema: "Club12",
table: "PlayersStatistics",
type: "timestamp with time zone",
nullable: true,
oldClrType: typeof(DateTime),
oldType: "timestamp without time zone",
oldNullable: true);
migrationBuilder.AlterColumn<DateTime>(
name: "DateCreated",
schema: "Club12",
table: "PlayersStatistics",
type: "timestamp with time zone",
nullable: false,
oldClrType: typeof(DateTime),
oldType: "timestamp without time zone");
migrationBuilder.AlterColumn<DateTime>(
name: "IssuedDate",
schema: "Club12",
table: "PlayerSanctions",
type: "timestamp with time zone",
nullable: false,
oldClrType: typeof(DateTime),
oldType: "timestamp without time zone");
migrationBuilder.AlterColumn<DateTime>(
name: "DateUpdated",
schema: "Club12",
table: "PlayerSanctions",
type: "timestamp with time zone",
nullable: true,
oldClrType: typeof(DateTime),
oldType: "timestamp without time zone",
oldNullable: true);
migrationBuilder.AlterColumn<DateTime>(
name: "DateCreated",
schema: "Club12",
table: "PlayerSanctions",
type: "timestamp with time zone",
nullable: false,
oldClrType: typeof(DateTime),
oldType: "timestamp without time zone");
migrationBuilder.AlterColumn<DateTime>(
name: "DateUpdated",
schema: "Club12",
table: "Players",
type: "timestamp with time zone",
nullable: true,
oldClrType: typeof(DateTime),
oldType: "timestamp without time zone",
oldNullable: true);
migrationBuilder.AlterColumn<DateTime>(
name: "DateCreated",
schema: "Club12",
table: "Players",
type: "timestamp with time zone",
nullable: false,
oldClrType: typeof(DateTime),
oldType: "timestamp without time zone");
migrationBuilder.AlterColumn<DateTime>(
name: "BirthDate",
schema: "Club12",
table: "Players",
type: "timestamp with time zone",
nullable: false,
oldClrType: typeof(DateTime),
oldType: "timestamp without time zone");
migrationBuilder.AlterColumn<DateTime>(
name: "MatchDate",
schema: "Club12",
table: "Matches",
type: "timestamp with time zone",
nullable: false,
oldClrType: typeof(DateTime),
oldType: "timestamp without time zone");
migrationBuilder.AlterColumn<DateTime>(
name: "DateUpdated",
schema: "Club12",
table: "Matches",
type: "timestamp with time zone",
nullable: true,
oldClrType: typeof(DateTime),
oldType: "timestamp without time zone",
oldNullable: true);
migrationBuilder.AlterColumn<DateTime>(
name: "DateCreated",
schema: "Club12",
table: "Matches",
type: "timestamp with time zone",
nullable: false,
oldClrType: typeof(DateTime),
oldType: "timestamp without time zone");
migrationBuilder.AlterColumn<DateTime>(
name: "DateUpdated",
schema: "Club12",
table: "Divisions",
type: "timestamp with time zone",
nullable: true,
oldClrType: typeof(DateTime),
oldType: "timestamp without time zone",
oldNullable: true);
migrationBuilder.AlterColumn<DateTime>(
name: "DateCreated",
schema: "Club12",
table: "Divisions",
type: "timestamp with time zone",
nullable: false,
oldClrType: typeof(DateTime),
oldType: "timestamp without time zone");
migrationBuilder.AlterColumn<DateTime>(
name: "DateUpdated",
schema: "Club12",
table: "BlogPosts",
type: "timestamp with time zone",
nullable: true,
oldClrType: typeof(DateTime),
oldType: "timestamp without time zone",
oldNullable: true);
migrationBuilder.AlterColumn<DateTime>(
name: "DateCreated",
schema: "Club12",
table: "BlogPosts",
type: "timestamp with time zone",
nullable: false,
oldClrType: typeof(DateTime),
oldType: "timestamp without time zone");
}
}
@@ -0,0 +1,698 @@
// <auto-generated />
using System;
using Infrastructure.Persistance;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Migrations;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
#nullable disable
namespace Persistance.Migrations
{
[DbContext(typeof(ApplicationDBContext))]
[Migration("20250809010120_addMatchIdIntoPlayerSanctionEntity")]
partial class addMatchIdIntoPlayerSanctionEntity
{
/// <inheritdoc />
protected override void BuildTargetModel(ModelBuilder modelBuilder)
{
#pragma warning disable 612, 618
modelBuilder
.HasAnnotation("ProductVersion", "8.0.11")
.HasAnnotation("Relational:MaxIdentifierLength", 63);
NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder);
modelBuilder.Entity("Entities.Models.BlogPosts.BlogPost", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uuid");
b.Property<string>("Author")
.IsRequired()
.HasMaxLength(50)
.HasColumnType("character varying(50)");
b.Property<DateTime>("DateCreated")
.HasColumnType("timestamp without time zone")
.HasColumnName("DateCreated");
b.Property<DateTime?>("DateUpdated")
.HasColumnType("timestamp without time zone")
.HasColumnName("DateUpdated");
b.Property<string>("MarkdownText")
.IsRequired()
.HasColumnType("text");
b.Property<string>("PhotoUrl")
.HasMaxLength(2048)
.HasColumnType("character varying(2048)");
b.Property<string>("Title")
.IsRequired()
.HasColumnType("text");
b.Property<int>("Views")
.HasColumnType("integer");
b.HasKey("Id");
b.ToTable("BlogPosts", "Club12");
});
modelBuilder.Entity("Entities.Models.Divisions.Division", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uuid");
b.Property<DateTime>("DateCreated")
.HasColumnType("timestamp without time zone")
.HasColumnName("DateCreated");
b.Property<DateTime?>("DateUpdated")
.HasColumnType("timestamp without time zone")
.HasColumnName("DateUpdated");
b.Property<bool>("IsFinished")
.HasColumnType("boolean");
b.Property<string>("Name")
.IsRequired()
.HasMaxLength(30)
.HasColumnType("character varying(30)");
b.Property<bool>("PlayoffsGenerated")
.HasColumnType("boolean");
b.Property<Guid>("TournamentId")
.HasColumnType("uuid");
b.HasKey("Id");
b.HasIndex("TournamentId");
b.ToTable("Divisions", "Club12");
});
modelBuilder.Entity("Entities.Models.Matches.Match", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uuid");
b.Property<DateTime>("DateCreated")
.HasColumnType("timestamp without time zone")
.HasColumnName("DateCreated");
b.Property<DateTime?>("DateUpdated")
.HasColumnType("timestamp without time zone")
.HasColumnName("DateUpdated");
b.Property<Guid?>("DivisionId")
.HasColumnType("uuid");
b.Property<int?>("HomeScore")
.HasColumnType("integer");
b.Property<Guid?>("HomeTeamId")
.HasColumnType("uuid");
b.Property<bool>("IsFinished")
.HasColumnType("boolean");
b.Property<DateTime>("MatchDate")
.HasColumnType("timestamp without time zone");
b.Property<Guid>("StageId")
.HasColumnType("uuid");
b.Property<string>("Type")
.IsRequired()
.HasColumnType("text");
b.Property<Guid?>("VenueId")
.HasColumnType("uuid");
b.Property<int?>("VisitorScore")
.HasColumnType("integer");
b.Property<Guid>("VisitorTeamId")
.HasColumnType("uuid");
b.Property<Guid?>("WinningTeamId")
.HasColumnType("uuid");
b.HasKey("Id");
b.HasIndex("DivisionId");
b.HasIndex("HomeTeamId");
b.HasIndex("StageId");
b.HasIndex("VenueId");
b.HasIndex("VisitorTeamId");
b.HasIndex("WinningTeamId");
b.ToTable("Matches", "Club12");
});
modelBuilder.Entity("Entities.Models.PlayerSanctions.PlayerSanction", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uuid");
b.Property<DateTime>("DateCreated")
.HasColumnType("timestamp without time zone")
.HasColumnName("DateCreated");
b.Property<DateTime?>("DateUpdated")
.HasColumnType("timestamp without time zone")
.HasColumnName("DateUpdated");
b.Property<string>("Description")
.IsRequired()
.HasMaxLength(255)
.HasColumnType("character varying(255)");
b.Property<int>("Duration")
.HasColumnType("integer");
b.Property<DateTime>("IssuedDate")
.HasColumnType("timestamp without time zone");
b.Property<Guid>("MatchId")
.HasColumnType("uuid");
b.Property<Guid>("PlayerId")
.HasColumnType("uuid");
b.HasKey("Id");
b.HasIndex("MatchId");
b.HasIndex("PlayerId");
b.ToTable("PlayerSanctions", "Club12");
});
modelBuilder.Entity("Entities.Models.PlayerStatistics.PlayerStatistic", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uuid");
b.Property<DateTime>("DateCreated")
.HasColumnType("timestamp without time zone")
.HasColumnName("DateCreated");
b.Property<DateTime?>("DateUpdated")
.HasColumnType("timestamp without time zone")
.HasColumnName("DateUpdated");
b.Property<Guid>("MatchId")
.HasColumnType("uuid");
b.Property<Guid>("PlayerId")
.HasColumnType("uuid");
b.Property<int>("Value")
.HasColumnType("integer");
b.HasKey("Id");
b.HasIndex("MatchId");
b.HasIndex("PlayerId");
b.ToTable("PlayersStatistics", "Club12");
});
modelBuilder.Entity("Entities.Models.Players.Player", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uuid");
b.Property<DateTime>("BirthDate")
.HasColumnType("timestamp without time zone");
b.Property<DateTime>("DateCreated")
.HasColumnType("timestamp without time zone")
.HasColumnName("DateCreated");
b.Property<DateTime?>("DateUpdated")
.HasColumnType("timestamp without time zone")
.HasColumnName("DateUpdated");
b.Property<string>("DocumentNumber")
.IsRequired()
.HasMaxLength(15)
.HasColumnType("character varying(15)");
b.Property<string>("FirstName")
.IsRequired()
.HasMaxLength(70)
.HasColumnType("character varying(70)");
b.Property<bool>("IsSanctioned")
.HasColumnType("boolean");
b.Property<string>("LastName")
.IsRequired()
.HasMaxLength(70)
.HasColumnType("character varying(70)");
b.Property<string>("PhoneNumber")
.HasColumnType("text");
b.Property<string>("SecondName")
.HasMaxLength(70)
.HasColumnType("character varying(70)");
b.Property<string>("SocialSecurity")
.IsRequired()
.HasMaxLength(100)
.HasColumnType("character varying(100)");
b.Property<Guid>("TeamId")
.HasColumnType("uuid");
b.HasKey("Id");
b.HasIndex("DocumentNumber")
.IsUnique();
b.HasIndex("TeamId");
b.ToTable("Players", "Club12");
});
modelBuilder.Entity("Entities.Models.Staffs.Staff", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uuid");
b.Property<DateTime>("DateCreated")
.HasColumnType("timestamp without time zone")
.HasColumnName("DateCreated");
b.Property<DateTime?>("DateUpdated")
.HasColumnType("timestamp without time zone")
.HasColumnName("DateUpdated");
b.Property<string>("LastName")
.IsRequired()
.HasMaxLength(50)
.HasColumnType("character varying(50)");
b.Property<string>("Names")
.IsRequired()
.HasMaxLength(50)
.HasColumnType("character varying(50)");
b.Property<string>("PhoneNumber")
.IsRequired()
.HasMaxLength(15)
.HasColumnType("character varying(15)");
b.Property<Guid>("TeamId")
.HasColumnType("uuid");
b.Property<string>("Type")
.IsRequired()
.HasColumnType("text");
b.HasKey("Id");
b.HasIndex("TeamId");
b.ToTable("Staffs", "Club12");
});
modelBuilder.Entity("Entities.Models.Stages.Stage", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uuid");
b.Property<DateTime>("DateCreated")
.HasColumnType("timestamp without time zone")
.HasColumnName("DateCreated");
b.Property<DateTime?>("DateUpdated")
.HasColumnType("timestamp without time zone")
.HasColumnName("DateUpdated");
b.Property<string>("Description")
.HasMaxLength(1000)
.HasColumnType("character varying(1000)");
b.Property<Guid>("DivisionId")
.HasColumnType("uuid");
b.Property<DateTime>("EndDate")
.HasColumnType("timestamp without time zone");
b.Property<bool>("IsActive")
.HasColumnType("boolean");
b.Property<bool>("IsElimination")
.HasColumnType("boolean");
b.Property<string>("Name")
.IsRequired()
.HasMaxLength(100)
.HasColumnType("character varying(100)");
b.Property<string>("StageType")
.IsRequired()
.HasColumnType("text");
b.Property<DateTime>("StartDate")
.HasColumnType("timestamp without time zone");
b.HasKey("Id");
b.HasIndex("DivisionId");
b.HasIndex("Name", "DivisionId")
.IsUnique()
.HasDatabaseName("CONSTRAINT_UNIQUE_STAGE_NAME_AND_DIVISIONID");
b.ToTable("Stages", "Club12");
});
modelBuilder.Entity("Entities.Models.Teams.Team", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uuid");
b.Property<DateTime>("DateCreated")
.HasColumnType("timestamp without time zone")
.HasColumnName("DateCreated");
b.Property<DateTime?>("DateUpdated")
.HasColumnType("timestamp without time zone")
.HasColumnName("DateUpdated");
b.Property<Guid?>("DivisionId")
.HasColumnType("uuid");
b.Property<string>("LogoUrl")
.IsRequired()
.HasColumnType("text");
b.Property<string>("Name")
.IsRequired()
.HasColumnType("text");
b.Property<string>("ShirtColor")
.IsRequired()
.HasColumnType("text");
b.Property<string>("ThreeLetterCode")
.IsRequired()
.HasColumnType("text");
b.HasKey("Id");
b.HasIndex("DivisionId");
b.ToTable("Teams", "Club12");
});
modelBuilder.Entity("Entities.Models.Tournaments.Tournament", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uuid");
b.Property<DateTime>("DateCreated")
.HasColumnType("timestamp without time zone")
.HasColumnName("DateCreated");
b.Property<DateTime?>("DateUpdated")
.HasColumnType("timestamp without time zone")
.HasColumnName("DateUpdated");
b.Property<string>("Description")
.IsRequired()
.HasColumnType("text");
b.Property<string>("Name")
.IsRequired()
.HasColumnType("text");
b.HasKey("Id");
b.ToTable("Tournaments", "Club12");
});
modelBuilder.Entity("Entities.Models.Users.User", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uuid");
b.Property<DateTime>("DateCreated")
.HasColumnType("timestamp without time zone")
.HasColumnName("DateCreated");
b.Property<DateTime?>("DateUpdated")
.HasColumnType("timestamp without time zone")
.HasColumnName("DateUpdated");
b.Property<string>("Password")
.IsRequired()
.HasMaxLength(64)
.HasColumnType("character varying(64)");
b.Property<string>("RefreshToken")
.HasMaxLength(256)
.HasColumnType("character varying(256)");
b.Property<DateTime?>("RefreshTokenExpiryTime")
.HasColumnType("timestamp without time zone");
b.Property<string>("Role")
.IsRequired()
.HasMaxLength(10)
.HasColumnType("character varying(10)");
b.Property<string>("Username")
.IsRequired()
.HasMaxLength(25)
.HasColumnType("character varying(25)");
b.HasKey("Id");
b.ToTable("Users", "Club12");
});
modelBuilder.Entity("Entities.Models.Venues.Venue", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uuid");
b.Property<string>("Address")
.IsRequired()
.HasMaxLength(200)
.HasColumnType("character varying(200)");
b.Property<DateTime>("DateCreated")
.HasColumnType("timestamp without time zone")
.HasColumnName("DateCreated");
b.Property<DateTime?>("DateUpdated")
.HasColumnType("timestamp without time zone")
.HasColumnName("DateUpdated");
b.Property<string>("Name")
.IsRequired()
.HasMaxLength(50)
.HasColumnType("character varying(50)");
b.Property<string>("PhotoUrl")
.HasColumnType("text");
b.HasKey("Id");
b.ToTable("Venues", "Club12");
});
modelBuilder.Entity("Entities.Models.Divisions.Division", b =>
{
b.HasOne("Entities.Models.Tournaments.Tournament", "Tournament")
.WithMany("Divisions")
.HasForeignKey("TournamentId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Tournament");
});
modelBuilder.Entity("Entities.Models.Matches.Match", b =>
{
b.HasOne("Entities.Models.Divisions.Division", null)
.WithMany("Matches")
.HasForeignKey("DivisionId");
b.HasOne("Entities.Models.Teams.Team", "HomeTeam")
.WithMany()
.HasForeignKey("HomeTeamId");
b.HasOne("Entities.Models.Stages.Stage", "Stage")
.WithMany("Matches")
.HasForeignKey("StageId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("Entities.Models.Venues.Venue", "Venue")
.WithMany()
.HasForeignKey("VenueId");
b.HasOne("Entities.Models.Teams.Team", "VisitorTeam")
.WithMany()
.HasForeignKey("VisitorTeamId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("Entities.Models.Teams.Team", "WinningTeam")
.WithMany()
.HasForeignKey("WinningTeamId");
b.Navigation("HomeTeam");
b.Navigation("Stage");
b.Navigation("Venue");
b.Navigation("VisitorTeam");
b.Navigation("WinningTeam");
});
modelBuilder.Entity("Entities.Models.PlayerSanctions.PlayerSanction", b =>
{
b.HasOne("Entities.Models.Matches.Match", "Match")
.WithMany()
.HasForeignKey("MatchId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("Entities.Models.Players.Player", "Player")
.WithMany()
.HasForeignKey("PlayerId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Match");
b.Navigation("Player");
});
modelBuilder.Entity("Entities.Models.PlayerStatistics.PlayerStatistic", b =>
{
b.HasOne("Entities.Models.Matches.Match", "Match")
.WithMany("PlayerStatistics")
.HasForeignKey("MatchId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("Entities.Models.Players.Player", "Player")
.WithMany()
.HasForeignKey("PlayerId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Match");
b.Navigation("Player");
});
modelBuilder.Entity("Entities.Models.Players.Player", b =>
{
b.HasOne("Entities.Models.Teams.Team", "Team")
.WithMany("Players")
.HasForeignKey("TeamId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Team");
});
modelBuilder.Entity("Entities.Models.Staffs.Staff", b =>
{
b.HasOne("Entities.Models.Teams.Team", "Team")
.WithMany("Staff")
.HasForeignKey("TeamId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Team");
});
modelBuilder.Entity("Entities.Models.Stages.Stage", b =>
{
b.HasOne("Entities.Models.Divisions.Division", "Division")
.WithMany("Stages")
.HasForeignKey("DivisionId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Division");
});
modelBuilder.Entity("Entities.Models.Teams.Team", b =>
{
b.HasOne("Entities.Models.Divisions.Division", null)
.WithMany("Teams")
.HasForeignKey("DivisionId");
});
modelBuilder.Entity("Entities.Models.Divisions.Division", b =>
{
b.Navigation("Matches");
b.Navigation("Stages");
b.Navigation("Teams");
});
modelBuilder.Entity("Entities.Models.Matches.Match", b =>
{
b.Navigation("PlayerStatistics");
});
modelBuilder.Entity("Entities.Models.Stages.Stage", b =>
{
b.Navigation("Matches");
});
modelBuilder.Entity("Entities.Models.Teams.Team", b =>
{
b.Navigation("Players");
b.Navigation("Staff");
});
modelBuilder.Entity("Entities.Models.Tournaments.Tournament", b =>
{
b.Navigation("Divisions");
});
#pragma warning restore 612, 618
}
}
}
@@ -0,0 +1,58 @@
using Microsoft.EntityFrameworkCore.Migrations;
using System;
#nullable disable
namespace Persistance.Migrations;
/// <inheritdoc />
public partial class addMatchIdIntoPlayerSanctionEntity : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.AddColumn<Guid>(
name: "MatchId",
schema: "Club12",
table: "PlayerSanctions",
type: "uuid",
nullable: false,
defaultValue: Guid.Empty);
migrationBuilder.CreateIndex(
name: "IX_PlayerSanctions_MatchId",
schema: "Club12",
table: "PlayerSanctions",
column: "MatchId");
migrationBuilder.AddForeignKey(
name: "FK_PlayerSanctions_Matches_MatchId",
schema: "Club12",
table: "PlayerSanctions",
column: "MatchId",
principalSchema: "Club12",
principalTable: "Matches",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropForeignKey(
name: "FK_PlayerSanctions_Matches_MatchId",
schema: "Club12",
table: "PlayerSanctions");
migrationBuilder.DropIndex(
name: "IX_PlayerSanctions_MatchId",
schema: "Club12",
table: "PlayerSanctions");
migrationBuilder.DropColumn(
name: "MatchId",
schema: "Club12",
table: "PlayerSanctions");
}
}
@@ -0,0 +1,729 @@
// <auto-generated />
using System;
using Infrastructure.Persistance;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Migrations;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
#nullable disable
namespace Persistance.Migrations
{
[DbContext(typeof(ApplicationDBContext))]
[Migration("20250816164236_AddChangesInTournamentEntity")]
partial class AddChangesInTournamentEntity
{
/// <inheritdoc />
protected override void BuildTargetModel(ModelBuilder modelBuilder)
{
#pragma warning disable 612, 618
modelBuilder
.HasAnnotation("ProductVersion", "8.0.11")
.HasAnnotation("Relational:MaxIdentifierLength", 63);
NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder);
modelBuilder.Entity("Entities.Models.BlogPosts.BlogPost", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uuid");
b.Property<string>("Author")
.IsRequired()
.HasMaxLength(50)
.HasColumnType("character varying(50)");
b.Property<DateTime>("DateCreated")
.HasColumnType("timestamp without time zone")
.HasColumnName("DateCreated");
b.Property<DateTime?>("DateUpdated")
.HasColumnType("timestamp without time zone")
.HasColumnName("DateUpdated");
b.Property<string>("MarkdownText")
.IsRequired()
.HasColumnType("text");
b.Property<string>("PhotoUrl")
.HasMaxLength(2048)
.HasColumnType("character varying(2048)");
b.Property<string>("Title")
.IsRequired()
.HasColumnType("text");
b.Property<int>("Views")
.HasColumnType("integer");
b.HasKey("Id");
b.ToTable("BlogPosts", "Club12");
});
modelBuilder.Entity("Entities.Models.Divisions.Division", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uuid");
b.Property<DateTime>("DateCreated")
.HasColumnType("timestamp without time zone")
.HasColumnName("DateCreated");
b.Property<DateTime?>("DateUpdated")
.HasColumnType("timestamp without time zone")
.HasColumnName("DateUpdated");
b.Property<bool>("IsFinished")
.HasColumnType("boolean");
b.Property<string>("Name")
.IsRequired()
.HasMaxLength(30)
.HasColumnType("character varying(30)");
b.Property<bool>("PlayoffsGenerated")
.HasColumnType("boolean");
b.Property<Guid>("TournamentId")
.HasColumnType("uuid");
b.HasKey("Id");
b.HasIndex("TournamentId");
b.ToTable("Divisions", "Club12");
});
modelBuilder.Entity("Entities.Models.Matches.Match", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uuid");
b.Property<DateTime>("DateCreated")
.HasColumnType("timestamp without time zone")
.HasColumnName("DateCreated");
b.Property<DateTime?>("DateUpdated")
.HasColumnType("timestamp without time zone")
.HasColumnName("DateUpdated");
b.Property<Guid?>("DivisionId")
.HasColumnType("uuid");
b.Property<int?>("HomeScore")
.HasColumnType("integer");
b.Property<Guid?>("HomeTeamId")
.HasColumnType("uuid");
b.Property<bool>("IsFinished")
.HasColumnType("boolean");
b.Property<DateTime>("MatchDate")
.HasColumnType("timestamp without time zone");
b.Property<Guid>("StageId")
.HasColumnType("uuid");
b.Property<string>("Type")
.IsRequired()
.HasColumnType("text");
b.Property<Guid?>("VenueId")
.HasColumnType("uuid");
b.Property<int?>("VisitorScore")
.HasColumnType("integer");
b.Property<Guid>("VisitorTeamId")
.HasColumnType("uuid");
b.Property<Guid?>("WinningTeamId")
.HasColumnType("uuid");
b.HasKey("Id");
b.HasIndex("DivisionId");
b.HasIndex("HomeTeamId");
b.HasIndex("StageId");
b.HasIndex("VenueId");
b.HasIndex("VisitorTeamId");
b.HasIndex("WinningTeamId");
b.ToTable("Matches", "Club12");
});
modelBuilder.Entity("Entities.Models.PlayerSanctions.PlayerSanction", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uuid");
b.Property<DateTime>("DateCreated")
.HasColumnType("timestamp without time zone")
.HasColumnName("DateCreated");
b.Property<DateTime?>("DateUpdated")
.HasColumnType("timestamp without time zone")
.HasColumnName("DateUpdated");
b.Property<string>("Description")
.IsRequired()
.HasMaxLength(255)
.HasColumnType("character varying(255)");
b.Property<int>("Duration")
.HasColumnType("integer");
b.Property<DateTime>("IssuedDate")
.HasColumnType("timestamp without time zone");
b.Property<Guid>("MatchId")
.HasColumnType("uuid");
b.Property<Guid>("PlayerId")
.HasColumnType("uuid");
b.HasKey("Id");
b.HasIndex("MatchId");
b.HasIndex("PlayerId");
b.ToTable("PlayerSanctions", "Club12");
});
modelBuilder.Entity("Entities.Models.PlayerStatistics.PlayerStatistic", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uuid");
b.Property<DateTime>("DateCreated")
.HasColumnType("timestamp without time zone")
.HasColumnName("DateCreated");
b.Property<DateTime?>("DateUpdated")
.HasColumnType("timestamp without time zone")
.HasColumnName("DateUpdated");
b.Property<Guid>("MatchId")
.HasColumnType("uuid");
b.Property<Guid>("PlayerId")
.HasColumnType("uuid");
b.Property<int>("Value")
.HasColumnType("integer");
b.HasKey("Id");
b.HasIndex("MatchId");
b.HasIndex("PlayerId");
b.ToTable("PlayersStatistics", "Club12");
});
modelBuilder.Entity("Entities.Models.Players.Player", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uuid");
b.Property<DateTime>("BirthDate")
.HasColumnType("timestamp without time zone");
b.Property<DateTime>("DateCreated")
.HasColumnType("timestamp without time zone")
.HasColumnName("DateCreated");
b.Property<DateTime?>("DateUpdated")
.HasColumnType("timestamp without time zone")
.HasColumnName("DateUpdated");
b.Property<string>("DocumentNumber")
.IsRequired()
.HasMaxLength(15)
.HasColumnType("character varying(15)");
b.Property<string>("FirstName")
.IsRequired()
.HasMaxLength(70)
.HasColumnType("character varying(70)");
b.Property<bool>("IsSanctioned")
.HasColumnType("boolean");
b.Property<string>("LastName")
.IsRequired()
.HasMaxLength(70)
.HasColumnType("character varying(70)");
b.Property<string>("PhoneNumber")
.HasColumnType("text");
b.Property<string>("SecondName")
.HasMaxLength(70)
.HasColumnType("character varying(70)");
b.Property<string>("SocialSecurity")
.IsRequired()
.HasMaxLength(100)
.HasColumnType("character varying(100)");
b.Property<Guid>("TeamId")
.HasColumnType("uuid");
b.HasKey("Id");
b.HasIndex("DocumentNumber")
.IsUnique();
b.HasIndex("TeamId");
b.ToTable("Players", "Club12");
});
modelBuilder.Entity("Entities.Models.Staffs.Staff", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uuid");
b.Property<DateTime>("DateCreated")
.HasColumnType("timestamp without time zone")
.HasColumnName("DateCreated");
b.Property<DateTime?>("DateUpdated")
.HasColumnType("timestamp without time zone")
.HasColumnName("DateUpdated");
b.Property<string>("LastName")
.IsRequired()
.HasMaxLength(50)
.HasColumnType("character varying(50)");
b.Property<string>("Names")
.IsRequired()
.HasMaxLength(50)
.HasColumnType("character varying(50)");
b.Property<string>("PhoneNumber")
.IsRequired()
.HasMaxLength(15)
.HasColumnType("character varying(15)");
b.Property<Guid>("TeamId")
.HasColumnType("uuid");
b.Property<string>("Type")
.IsRequired()
.HasColumnType("text");
b.HasKey("Id");
b.HasIndex("TeamId");
b.ToTable("Staffs", "Club12");
});
modelBuilder.Entity("Entities.Models.Stages.Stage", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uuid");
b.Property<DateTime>("DateCreated")
.HasColumnType("timestamp without time zone")
.HasColumnName("DateCreated");
b.Property<DateTime?>("DateUpdated")
.HasColumnType("timestamp without time zone")
.HasColumnName("DateUpdated");
b.Property<string>("Description")
.HasMaxLength(1000)
.HasColumnType("character varying(1000)");
b.Property<Guid>("DivisionId")
.HasColumnType("uuid");
b.Property<DateTime>("EndDate")
.HasColumnType("timestamp without time zone");
b.Property<bool>("IsActive")
.HasColumnType("boolean");
b.Property<bool>("IsElimination")
.HasColumnType("boolean");
b.Property<string>("Name")
.IsRequired()
.HasMaxLength(100)
.HasColumnType("character varying(100)");
b.Property<string>("StageType")
.IsRequired()
.HasColumnType("text");
b.Property<DateTime>("StartDate")
.HasColumnType("timestamp without time zone");
b.HasKey("Id");
b.HasIndex("DivisionId");
b.HasIndex("Name", "DivisionId")
.IsUnique()
.HasDatabaseName("CONSTRAINT_UNIQUE_STAGE_NAME_AND_DIVISIONID");
b.ToTable("Stages", "Club12");
});
modelBuilder.Entity("Entities.Models.Teams.Team", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uuid");
b.Property<DateTime>("DateCreated")
.HasColumnType("timestamp without time zone")
.HasColumnName("DateCreated");
b.Property<DateTime?>("DateUpdated")
.HasColumnType("timestamp without time zone")
.HasColumnName("DateUpdated");
b.Property<Guid?>("DivisionId")
.HasColumnType("uuid");
b.Property<string>("LogoUrl")
.IsRequired()
.HasColumnType("text");
b.Property<string>("Name")
.IsRequired()
.HasColumnType("text");
b.Property<string>("ShirtColor")
.IsRequired()
.HasColumnType("text");
b.Property<string>("ThreeLetterCode")
.IsRequired()
.HasColumnType("text");
b.Property<Guid?>("TournamentId")
.HasColumnType("uuid");
b.HasKey("Id");
b.HasIndex("DivisionId");
b.HasIndex("TournamentId");
b.ToTable("Teams", "Club12");
});
modelBuilder.Entity("Entities.Models.Tournaments.Tournament", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uuid");
b.Property<DateTime>("DateCreated")
.HasColumnType("timestamp without time zone")
.HasColumnName("DateCreated");
b.Property<DateTime?>("DateUpdated")
.HasColumnType("timestamp without time zone")
.HasColumnName("DateUpdated");
b.Property<string>("Description")
.IsRequired()
.HasColumnType("text");
b.Property<bool>("IsFinished")
.HasColumnType("boolean");
b.Property<int>("MaxTeams")
.HasColumnType("integer");
b.Property<int>("MinTeams")
.HasColumnType("integer");
b.Property<string>("Name")
.IsRequired()
.HasColumnType("text");
b.Property<DateTime>("StartDate")
.HasColumnType("timestamp without time zone");
b.Property<DateTime>("TeamRegistrationDeadline")
.HasColumnType("timestamp without time zone");
b.HasKey("Id");
b.ToTable("Tournaments", "Club12", t =>
{
t.HasCheckConstraint("CK_Tournament_DeadlineBeforeStart", "[TeamRegistrationDeadline] < [StartDate]");
});
});
modelBuilder.Entity("Entities.Models.Users.User", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uuid");
b.Property<DateTime>("DateCreated")
.HasColumnType("timestamp without time zone")
.HasColumnName("DateCreated");
b.Property<DateTime?>("DateUpdated")
.HasColumnType("timestamp without time zone")
.HasColumnName("DateUpdated");
b.Property<string>("Password")
.IsRequired()
.HasMaxLength(64)
.HasColumnType("character varying(64)");
b.Property<string>("RefreshToken")
.HasMaxLength(256)
.HasColumnType("character varying(256)");
b.Property<DateTime?>("RefreshTokenExpiryTime")
.HasColumnType("timestamp without time zone");
b.Property<string>("Role")
.IsRequired()
.HasMaxLength(10)
.HasColumnType("character varying(10)");
b.Property<string>("Username")
.IsRequired()
.HasMaxLength(25)
.HasColumnType("character varying(25)");
b.HasKey("Id");
b.ToTable("Users", "Club12");
});
modelBuilder.Entity("Entities.Models.Venues.Venue", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uuid");
b.Property<string>("Address")
.IsRequired()
.HasMaxLength(200)
.HasColumnType("character varying(200)");
b.Property<DateTime>("DateCreated")
.HasColumnType("timestamp without time zone")
.HasColumnName("DateCreated");
b.Property<DateTime?>("DateUpdated")
.HasColumnType("timestamp without time zone")
.HasColumnName("DateUpdated");
b.Property<string>("Name")
.IsRequired()
.HasMaxLength(50)
.HasColumnType("character varying(50)");
b.Property<string>("PhotoUrl")
.HasColumnType("text");
b.HasKey("Id");
b.ToTable("Venues", "Club12");
});
modelBuilder.Entity("Entities.Models.Divisions.Division", b =>
{
b.HasOne("Entities.Models.Tournaments.Tournament", "Tournament")
.WithMany("Divisions")
.HasForeignKey("TournamentId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Tournament");
});
modelBuilder.Entity("Entities.Models.Matches.Match", b =>
{
b.HasOne("Entities.Models.Divisions.Division", null)
.WithMany("Matches")
.HasForeignKey("DivisionId");
b.HasOne("Entities.Models.Teams.Team", "HomeTeam")
.WithMany()
.HasForeignKey("HomeTeamId");
b.HasOne("Entities.Models.Stages.Stage", "Stage")
.WithMany("Matches")
.HasForeignKey("StageId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("Entities.Models.Venues.Venue", "Venue")
.WithMany()
.HasForeignKey("VenueId");
b.HasOne("Entities.Models.Teams.Team", "VisitorTeam")
.WithMany()
.HasForeignKey("VisitorTeamId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("Entities.Models.Teams.Team", "WinningTeam")
.WithMany()
.HasForeignKey("WinningTeamId");
b.Navigation("HomeTeam");
b.Navigation("Stage");
b.Navigation("Venue");
b.Navigation("VisitorTeam");
b.Navigation("WinningTeam");
});
modelBuilder.Entity("Entities.Models.PlayerSanctions.PlayerSanction", b =>
{
b.HasOne("Entities.Models.Matches.Match", "Match")
.WithMany()
.HasForeignKey("MatchId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("Entities.Models.Players.Player", "Player")
.WithMany()
.HasForeignKey("PlayerId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Match");
b.Navigation("Player");
});
modelBuilder.Entity("Entities.Models.PlayerStatistics.PlayerStatistic", b =>
{
b.HasOne("Entities.Models.Matches.Match", "Match")
.WithMany("PlayerStatistics")
.HasForeignKey("MatchId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("Entities.Models.Players.Player", "Player")
.WithMany()
.HasForeignKey("PlayerId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Match");
b.Navigation("Player");
});
modelBuilder.Entity("Entities.Models.Players.Player", b =>
{
b.HasOne("Entities.Models.Teams.Team", "Team")
.WithMany("Players")
.HasForeignKey("TeamId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Team");
});
modelBuilder.Entity("Entities.Models.Staffs.Staff", b =>
{
b.HasOne("Entities.Models.Teams.Team", "Team")
.WithMany("Staff")
.HasForeignKey("TeamId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Team");
});
modelBuilder.Entity("Entities.Models.Stages.Stage", b =>
{
b.HasOne("Entities.Models.Divisions.Division", "Division")
.WithMany("Stages")
.HasForeignKey("DivisionId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Division");
});
modelBuilder.Entity("Entities.Models.Teams.Team", b =>
{
b.HasOne("Entities.Models.Divisions.Division", null)
.WithMany("Teams")
.HasForeignKey("DivisionId");
b.HasOne("Entities.Models.Tournaments.Tournament", "Tournament")
.WithMany("Teams")
.HasForeignKey("TournamentId");
b.Navigation("Tournament");
});
modelBuilder.Entity("Entities.Models.Divisions.Division", b =>
{
b.Navigation("Matches");
b.Navigation("Stages");
b.Navigation("Teams");
});
modelBuilder.Entity("Entities.Models.Matches.Match", b =>
{
b.Navigation("PlayerStatistics");
});
modelBuilder.Entity("Entities.Models.Stages.Stage", b =>
{
b.Navigation("Matches");
});
modelBuilder.Entity("Entities.Models.Teams.Team", b =>
{
b.Navigation("Players");
b.Navigation("Staff");
});
modelBuilder.Entity("Entities.Models.Tournaments.Tournament", b =>
{
b.Navigation("Divisions");
b.Navigation("Teams");
});
#pragma warning restore 612, 618
}
}
}
@@ -0,0 +1,132 @@
using Microsoft.EntityFrameworkCore.Migrations;
using System;
#nullable disable
namespace Persistance.Migrations;
/// <inheritdoc />
public partial class AddChangesInTournamentEntity : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.AddColumn<bool>(
name: "IsFinished",
schema: "Club12",
table: "Tournaments",
type: "boolean",
nullable: false,
defaultValue: false);
migrationBuilder.AddColumn<int>(
name: "MaxTeams",
schema: "Club12",
table: "Tournaments",
type: "integer",
nullable: false,
defaultValue: 0);
migrationBuilder.AddColumn<int>(
name: "MinTeams",
schema: "Club12",
table: "Tournaments",
type: "integer",
nullable: false,
defaultValue: 0);
migrationBuilder.AddColumn<DateTime>(
name: "StartDate",
schema: "Club12",
table: "Tournaments",
type: "timestamp without time zone",
nullable: false,
defaultValue: new DateTime(2, 2, 2, 0, 0, 0, 0, DateTimeKind.Unspecified));
migrationBuilder.AddColumn<DateTime>(
name: "TeamRegistrationDeadline",
schema: "Club12",
table: "Tournaments",
type: "timestamp without time zone",
nullable: false,
defaultValue: new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified));
migrationBuilder.AddColumn<Guid>(
name: "TournamentId",
schema: "Club12",
table: "Teams",
type: "uuid",
nullable: true);
migrationBuilder.AddCheckConstraint(
name: "CK_Tournament_DeadlineBeforeStart",
schema: "Club12",
table: "Tournaments",
sql: "\"TeamRegistrationDeadline\" < \"StartDate\"");
migrationBuilder.CreateIndex(
name: "IX_Teams_TournamentId",
schema: "Club12",
table: "Teams",
column: "TournamentId");
migrationBuilder.AddForeignKey(
name: "FK_Teams_Tournaments_TournamentId",
schema: "Club12",
table: "Teams",
column: "TournamentId",
principalSchema: "Club12",
principalTable: "Tournaments",
principalColumn: "Id");
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropForeignKey(
name: "FK_Teams_Tournaments_TournamentId",
schema: "Club12",
table: "Teams");
migrationBuilder.DropCheckConstraint(
name: "CK_Tournament_DeadlineBeforeStart",
schema: "Club12",
table: "Tournaments");
migrationBuilder.DropIndex(
name: "IX_Teams_TournamentId",
schema: "Club12",
table: "Teams");
migrationBuilder.DropColumn(
name: "IsFinished",
schema: "Club12",
table: "Tournaments");
migrationBuilder.DropColumn(
name: "MaxTeams",
schema: "Club12",
table: "Tournaments");
migrationBuilder.DropColumn(
name: "MinTeams",
schema: "Club12",
table: "Tournaments");
migrationBuilder.DropColumn(
name: "StartDate",
schema: "Club12",
table: "Tournaments");
migrationBuilder.DropColumn(
name: "TeamRegistrationDeadline",
schema: "Club12",
table: "Tournaments");
migrationBuilder.DropColumn(
name: "TournamentId",
schema: "Club12",
table: "Teams");
}
}
@@ -0,0 +1,707 @@
// <auto-generated />
using System;
using Infrastructure.Persistance;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Migrations;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
#nullable disable
namespace Persistance.Migrations
{
[DbContext(typeof(ApplicationDBContext))]
[Migration("20260201150715_ChangesEntities")]
partial class ChangesEntities
{
/// <inheritdoc />
protected override void BuildTargetModel(ModelBuilder modelBuilder)
{
#pragma warning disable 612, 618
modelBuilder
.HasAnnotation("ProductVersion", "8.0.11")
.HasAnnotation("Relational:MaxIdentifierLength", 63);
NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder);
modelBuilder.Entity("Entities.Models.BlogPosts.BlogPost", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uuid");
b.Property<string>("Author")
.IsRequired()
.HasMaxLength(50)
.HasColumnType("character varying(50)");
b.Property<DateTime>("DateCreated")
.HasColumnType("timestamp without time zone")
.HasColumnName("DateCreated");
b.Property<DateTime?>("DateUpdated")
.HasColumnType("timestamp without time zone")
.HasColumnName("DateUpdated");
b.Property<string>("MarkdownText")
.IsRequired()
.HasColumnType("text");
b.Property<string>("PhotoUrl")
.HasMaxLength(2048)
.HasColumnType("character varying(2048)");
b.Property<string>("Title")
.IsRequired()
.HasColumnType("text");
b.Property<int>("Views")
.HasColumnType("integer");
b.HasKey("Id");
b.ToTable("BlogPosts", "Club12");
});
modelBuilder.Entity("Entities.Models.Divisions.Division", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uuid");
b.Property<bool>("CanGenerateStageAutomated")
.HasColumnType("boolean");
b.Property<DateTime>("DateCreated")
.HasColumnType("timestamp without time zone")
.HasColumnName("DateCreated");
b.Property<DateTime?>("DateUpdated")
.HasColumnType("timestamp without time zone")
.HasColumnName("DateUpdated");
b.Property<bool>("IsFinished")
.HasColumnType("boolean");
b.Property<string>("Name")
.IsRequired()
.HasMaxLength(30)
.HasColumnType("character varying(30)");
b.Property<Guid>("TournamentId")
.HasColumnType("uuid");
b.HasKey("Id");
b.HasIndex("TournamentId");
b.ToTable("Divisions", "Club12");
});
modelBuilder.Entity("Entities.Models.Matches.Match", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uuid");
b.Property<DateTime>("DateCreated")
.HasColumnType("timestamp without time zone")
.HasColumnName("DateCreated");
b.Property<DateTime?>("DateUpdated")
.HasColumnType("timestamp without time zone")
.HasColumnName("DateUpdated");
b.Property<int?>("HomeScore")
.HasColumnType("integer");
b.Property<Guid?>("HomeTeamId")
.HasColumnType("uuid");
b.Property<bool>("IsFinished")
.HasColumnType("boolean");
b.Property<DateTime>("MatchDate")
.HasColumnType("timestamp without time zone");
b.Property<Guid>("StageId")
.HasColumnType("uuid");
b.Property<string>("Type")
.IsRequired()
.HasColumnType("text");
b.Property<Guid?>("VenueId")
.HasColumnType("uuid");
b.Property<int?>("VisitorScore")
.HasColumnType("integer");
b.Property<Guid>("VisitorTeamId")
.HasColumnType("uuid");
b.Property<Guid?>("WinningTeamId")
.HasColumnType("uuid");
b.HasKey("Id");
b.HasIndex("HomeTeamId");
b.HasIndex("StageId");
b.HasIndex("VenueId");
b.HasIndex("VisitorTeamId");
b.HasIndex("WinningTeamId");
b.ToTable("Matches", "Club12");
});
modelBuilder.Entity("Entities.Models.PlayerSanctions.PlayerSanction", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uuid");
b.Property<DateTime>("DateCreated")
.HasColumnType("timestamp without time zone")
.HasColumnName("DateCreated");
b.Property<DateTime?>("DateUpdated")
.HasColumnType("timestamp without time zone")
.HasColumnName("DateUpdated");
b.Property<string>("Description")
.IsRequired()
.HasMaxLength(255)
.HasColumnType("character varying(255)");
b.Property<int>("Duration")
.HasColumnType("integer");
b.Property<DateTime>("IssuedDate")
.HasColumnType("timestamp without time zone");
b.Property<Guid>("MatchId")
.HasColumnType("uuid");
b.Property<Guid>("PlayerId")
.HasColumnType("uuid");
b.HasKey("Id");
b.HasIndex("MatchId");
b.HasIndex("PlayerId");
b.ToTable("PlayerSanctions", "Club12");
});
modelBuilder.Entity("Entities.Models.PlayerStatistics.PlayerStatistic", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uuid");
b.Property<DateTime>("DateCreated")
.HasColumnType("timestamp without time zone")
.HasColumnName("DateCreated");
b.Property<DateTime?>("DateUpdated")
.HasColumnType("timestamp without time zone")
.HasColumnName("DateUpdated");
b.Property<Guid>("MatchId")
.HasColumnType("uuid");
b.Property<Guid>("PlayerId")
.HasColumnType("uuid");
b.Property<int>("Value")
.HasColumnType("integer");
b.HasKey("Id");
b.HasIndex("MatchId");
b.HasIndex("PlayerId");
b.ToTable("PlayersStatistics", "Club12");
});
modelBuilder.Entity("Entities.Models.Players.Player", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uuid");
b.Property<DateTime>("BirthDate")
.HasColumnType("timestamp without time zone");
b.Property<DateTime>("DateCreated")
.HasColumnType("timestamp without time zone")
.HasColumnName("DateCreated");
b.Property<DateTime?>("DateUpdated")
.HasColumnType("timestamp without time zone")
.HasColumnName("DateUpdated");
b.Property<string>("DocumentNumber")
.IsRequired()
.HasMaxLength(15)
.HasColumnType("character varying(15)");
b.Property<string>("FirstName")
.IsRequired()
.HasMaxLength(70)
.HasColumnType("character varying(70)");
b.Property<bool>("IsSanctioned")
.HasColumnType("boolean");
b.Property<string>("LastName")
.IsRequired()
.HasMaxLength(70)
.HasColumnType("character varying(70)");
b.Property<string>("PhoneNumber")
.HasColumnType("text");
b.Property<string>("SecondName")
.HasMaxLength(70)
.HasColumnType("character varying(70)");
b.Property<string>("SocialSecurity")
.IsRequired()
.HasMaxLength(100)
.HasColumnType("character varying(100)");
b.Property<Guid>("TeamId")
.HasColumnType("uuid");
b.HasKey("Id");
b.HasIndex("DocumentNumber")
.IsUnique();
b.HasIndex("TeamId");
b.ToTable("Players", "Club12");
});
modelBuilder.Entity("Entities.Models.Staffs.Staff", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uuid");
b.Property<DateTime>("DateCreated")
.HasColumnType("timestamp without time zone")
.HasColumnName("DateCreated");
b.Property<DateTime?>("DateUpdated")
.HasColumnType("timestamp without time zone")
.HasColumnName("DateUpdated");
b.Property<string>("LastName")
.IsRequired()
.HasMaxLength(50)
.HasColumnType("character varying(50)");
b.Property<string>("Names")
.IsRequired()
.HasMaxLength(50)
.HasColumnType("character varying(50)");
b.Property<string>("PhoneNumber")
.IsRequired()
.HasMaxLength(15)
.HasColumnType("character varying(15)");
b.Property<Guid>("TeamId")
.HasColumnType("uuid");
b.Property<string>("Type")
.IsRequired()
.HasColumnType("text");
b.HasKey("Id");
b.HasIndex("TeamId");
b.ToTable("Staffs", "Club12");
});
modelBuilder.Entity("Entities.Models.Stages.Stage", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uuid");
b.Property<DateTime>("DateCreated")
.HasColumnType("timestamp without time zone")
.HasColumnName("DateCreated");
b.Property<DateTime?>("DateUpdated")
.HasColumnType("timestamp without time zone")
.HasColumnName("DateUpdated");
b.Property<string>("Description")
.HasMaxLength(1000)
.HasColumnType("character varying(1000)");
b.Property<Guid>("DivisionId")
.HasColumnType("uuid");
b.Property<DateTime>("EndDate")
.HasColumnType("timestamp without time zone");
b.Property<bool>("IsActive")
.HasColumnType("boolean");
b.Property<bool>("IsElimination")
.HasColumnType("boolean");
b.Property<string>("Name")
.IsRequired()
.HasMaxLength(100)
.HasColumnType("character varying(100)");
b.Property<string>("StageType")
.IsRequired()
.HasColumnType("text");
b.Property<DateTime>("StartDate")
.HasColumnType("timestamp without time zone");
b.HasKey("Id");
b.HasIndex("DivisionId");
b.HasIndex("Name", "DivisionId")
.IsUnique()
.HasDatabaseName("CONSTRAINT_UNIQUE_STAGE_NAME_AND_DIVISIONID");
b.ToTable("Stages", "Club12");
});
modelBuilder.Entity("Entities.Models.Teams.Team", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uuid");
b.Property<DateTime>("DateCreated")
.HasColumnType("timestamp without time zone")
.HasColumnName("DateCreated");
b.Property<DateTime?>("DateUpdated")
.HasColumnType("timestamp without time zone")
.HasColumnName("DateUpdated");
b.Property<string>("LogoUrl")
.IsRequired()
.HasColumnType("text");
b.Property<string>("Name")
.IsRequired()
.HasColumnType("text");
b.Property<string>("ShirtColor")
.IsRequired()
.HasColumnType("text");
b.Property<string>("ThreeLetterCode")
.IsRequired()
.HasColumnType("text");
b.Property<Guid?>("TournamentId")
.HasColumnType("uuid");
b.HasKey("Id");
b.HasIndex("TournamentId");
b.ToTable("Teams", "Club12");
});
modelBuilder.Entity("Entities.Models.Tournaments.Tournament", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uuid");
b.Property<DateTime>("DateCreated")
.HasColumnType("timestamp without time zone")
.HasColumnName("DateCreated");
b.Property<DateTime?>("DateUpdated")
.HasColumnType("timestamp without time zone")
.HasColumnName("DateUpdated");
b.Property<string>("Description")
.IsRequired()
.HasColumnType("text");
b.Property<bool>("IsFinished")
.HasColumnType("boolean");
b.Property<int>("MaxTeams")
.HasColumnType("integer");
b.Property<int>("MinTeams")
.HasColumnType("integer");
b.Property<string>("Name")
.IsRequired()
.HasColumnType("text");
b.Property<DateTime>("StartDate")
.HasColumnType("timestamp without time zone");
b.Property<DateTime>("TeamRegistrationDeadline")
.HasColumnType("timestamp without time zone");
b.HasKey("Id");
b.ToTable("Tournaments", "Club12", t =>
{
t.HasCheckConstraint("CK_Tournament_DeadlineBeforeStart", "\"TeamRegistrationDeadline\" < \"StartDate\"");
});
});
modelBuilder.Entity("Entities.Models.Users.User", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uuid");
b.Property<DateTime>("DateCreated")
.HasColumnType("timestamp without time zone")
.HasColumnName("DateCreated");
b.Property<DateTime?>("DateUpdated")
.HasColumnType("timestamp without time zone")
.HasColumnName("DateUpdated");
b.Property<string>("Password")
.IsRequired()
.HasMaxLength(64)
.HasColumnType("character varying(64)");
b.Property<string>("RefreshToken")
.HasMaxLength(256)
.HasColumnType("character varying(256)");
b.Property<DateTime?>("RefreshTokenExpiryTime")
.HasColumnType("timestamp without time zone");
b.Property<string>("Role")
.IsRequired()
.HasMaxLength(10)
.HasColumnType("character varying(10)");
b.Property<string>("Username")
.IsRequired()
.HasMaxLength(25)
.HasColumnType("character varying(25)");
b.HasKey("Id");
b.ToTable("Users", "Club12");
});
modelBuilder.Entity("Entities.Models.Venues.Venue", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uuid");
b.Property<string>("Address")
.IsRequired()
.HasMaxLength(200)
.HasColumnType("character varying(200)");
b.Property<DateTime>("DateCreated")
.HasColumnType("timestamp without time zone")
.HasColumnName("DateCreated");
b.Property<DateTime?>("DateUpdated")
.HasColumnType("timestamp without time zone")
.HasColumnName("DateUpdated");
b.Property<string>("Name")
.IsRequired()
.HasMaxLength(50)
.HasColumnType("character varying(50)");
b.Property<string>("PhotoUrl")
.HasColumnType("text");
b.HasKey("Id");
b.ToTable("Venues", "Club12");
});
modelBuilder.Entity("Entities.Models.Divisions.Division", b =>
{
b.HasOne("Entities.Models.Tournaments.Tournament", "Tournament")
.WithMany("Divisions")
.HasForeignKey("TournamentId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Tournament");
});
modelBuilder.Entity("Entities.Models.Matches.Match", b =>
{
b.HasOne("Entities.Models.Teams.Team", "HomeTeam")
.WithMany()
.HasForeignKey("HomeTeamId");
b.HasOne("Entities.Models.Stages.Stage", "Stage")
.WithMany("Matches")
.HasForeignKey("StageId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("Entities.Models.Venues.Venue", "Venue")
.WithMany()
.HasForeignKey("VenueId");
b.HasOne("Entities.Models.Teams.Team", "VisitorTeam")
.WithMany()
.HasForeignKey("VisitorTeamId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("Entities.Models.Teams.Team", "WinningTeam")
.WithMany()
.HasForeignKey("WinningTeamId");
b.Navigation("HomeTeam");
b.Navigation("Stage");
b.Navigation("Venue");
b.Navigation("VisitorTeam");
b.Navigation("WinningTeam");
});
modelBuilder.Entity("Entities.Models.PlayerSanctions.PlayerSanction", b =>
{
b.HasOne("Entities.Models.Matches.Match", "Match")
.WithMany()
.HasForeignKey("MatchId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("Entities.Models.Players.Player", "Player")
.WithMany()
.HasForeignKey("PlayerId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Match");
b.Navigation("Player");
});
modelBuilder.Entity("Entities.Models.PlayerStatistics.PlayerStatistic", b =>
{
b.HasOne("Entities.Models.Matches.Match", "Match")
.WithMany("PlayerStatistics")
.HasForeignKey("MatchId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("Entities.Models.Players.Player", "Player")
.WithMany()
.HasForeignKey("PlayerId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Match");
b.Navigation("Player");
});
modelBuilder.Entity("Entities.Models.Players.Player", b =>
{
b.HasOne("Entities.Models.Teams.Team", "Team")
.WithMany("Players")
.HasForeignKey("TeamId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Team");
});
modelBuilder.Entity("Entities.Models.Staffs.Staff", b =>
{
b.HasOne("Entities.Models.Teams.Team", "Team")
.WithMany("Staff")
.HasForeignKey("TeamId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Team");
});
modelBuilder.Entity("Entities.Models.Stages.Stage", b =>
{
b.HasOne("Entities.Models.Divisions.Division", "Division")
.WithMany("Stages")
.HasForeignKey("DivisionId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Division");
});
modelBuilder.Entity("Entities.Models.Teams.Team", b =>
{
b.HasOne("Entities.Models.Tournaments.Tournament", "Tournament")
.WithMany("Teams")
.HasForeignKey("TournamentId");
b.Navigation("Tournament");
});
modelBuilder.Entity("Entities.Models.Divisions.Division", b =>
{
b.Navigation("Stages");
});
modelBuilder.Entity("Entities.Models.Matches.Match", b =>
{
b.Navigation("PlayerStatistics");
});
modelBuilder.Entity("Entities.Models.Stages.Stage", b =>
{
b.Navigation("Matches");
});
modelBuilder.Entity("Entities.Models.Teams.Team", b =>
{
b.Navigation("Players");
b.Navigation("Staff");
});
modelBuilder.Entity("Entities.Models.Tournaments.Tournament", b =>
{
b.Navigation("Divisions");
b.Navigation("Teams");
});
#pragma warning restore 612, 618
}
}
}
@@ -0,0 +1,139 @@
using Microsoft.EntityFrameworkCore.Migrations;
using System;
#nullable disable
namespace Persistance.Migrations;
/// <inheritdoc />
public partial class ChangesEntities : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropForeignKey(
name: "FK_Matches_Divisions_DivisionId",
schema: "Club12",
table: "Matches");
migrationBuilder.DropForeignKey(
name: "FK_Teams_Divisions_DivisionId",
schema: "Club12",
table: "Teams");
migrationBuilder.DropCheckConstraint(
name: "CK_Tournament_DeadlineBeforeStart",
schema: "Club12",
table: "Tournaments");
migrationBuilder.DropIndex(
name: "IX_Teams_DivisionId",
schema: "Club12",
table: "Teams");
migrationBuilder.DropIndex(
name: "IX_Matches_DivisionId",
schema: "Club12",
table: "Matches");
migrationBuilder.DropColumn(
name: "DivisionId",
schema: "Club12",
table: "Teams");
migrationBuilder.DropColumn(
name: "DivisionId",
schema: "Club12",
table: "Matches");
migrationBuilder.RenameColumn(
name: "PlayoffsGenerated",
schema: "Club12",
table: "Divisions",
newName: "CanGenerateStageAutomated");
migrationBuilder.AddCheckConstraint(
name: "CK_Tournament_DeadlineBeforeStart",
schema: "Club12",
table: "Tournaments",
sql: "\"TeamRegistrationDeadline\" < \"StartDate\"");
migrationBuilder.Sql(
@"
UPDATE
""Club12"".""Divisions""
SET
""CanGenerateStageAutomated"" = CASE
WHEN (SELECT COUNT(*) FROM ""Club12"".""Stages"" WHERE ""Stages"".""DivisionId"" = ""Divisions"".""Id"") = 0 THEN TRUE
ELSE FALSE
END
"
);
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropCheckConstraint(
name: "CK_Tournament_DeadlineBeforeStart",
schema: "Club12",
table: "Tournaments");
migrationBuilder.RenameColumn(
name: "CanGenerateStageAutomated",
schema: "Club12",
table: "Divisions",
newName: "PlayoffsGenerated");
migrationBuilder.AddColumn<Guid>(
name: "DivisionId",
schema: "Club12",
table: "Teams",
type: "uuid",
nullable: true);
migrationBuilder.AddColumn<Guid>(
name: "DivisionId",
schema: "Club12",
table: "Matches",
type: "uuid",
nullable: true);
migrationBuilder.AddCheckConstraint(
name: "CK_Tournament_DeadlineBeforeStart",
schema: "Club12",
table: "Tournaments",
sql: "\"TeamRegistrationDeadline\" < \"StartDate\"");
migrationBuilder.CreateIndex(
name: "IX_Teams_DivisionId",
schema: "Club12",
table: "Teams",
column: "DivisionId");
migrationBuilder.CreateIndex(
name: "IX_Matches_DivisionId",
schema: "Club12",
table: "Matches",
column: "DivisionId");
migrationBuilder.AddForeignKey(
name: "FK_Matches_Divisions_DivisionId",
schema: "Club12",
table: "Matches",
column: "DivisionId",
principalSchema: "Club12",
principalTable: "Divisions",
principalColumn: "Id");
migrationBuilder.AddForeignKey(
name: "FK_Teams_Divisions_DivisionId",
schema: "Club12",
table: "Teams",
column: "DivisionId",
principalSchema: "Club12",
principalTable: "Divisions",
principalColumn: "Id");
}
}
@@ -0,0 +1,710 @@
// <auto-generated />
using System;
using Infrastructure.Persistance;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Migrations;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
#nullable disable
namespace Persistance.Migrations
{
[DbContext(typeof(ApplicationDBContext))]
[Migration("20260204033209_addOrderColumnIntoStage")]
partial class addOrderColumnIntoStage
{
/// <inheritdoc />
protected override void BuildTargetModel(ModelBuilder modelBuilder)
{
#pragma warning disable 612, 618
modelBuilder
.HasAnnotation("ProductVersion", "8.0.11")
.HasAnnotation("Relational:MaxIdentifierLength", 63);
NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder);
modelBuilder.Entity("Entities.Models.BlogPosts.BlogPost", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uuid");
b.Property<string>("Author")
.IsRequired()
.HasMaxLength(50)
.HasColumnType("character varying(50)");
b.Property<DateTime>("DateCreated")
.HasColumnType("timestamp without time zone")
.HasColumnName("DateCreated");
b.Property<DateTime?>("DateUpdated")
.HasColumnType("timestamp without time zone")
.HasColumnName("DateUpdated");
b.Property<string>("MarkdownText")
.IsRequired()
.HasColumnType("text");
b.Property<string>("PhotoUrl")
.HasMaxLength(2048)
.HasColumnType("character varying(2048)");
b.Property<string>("Title")
.IsRequired()
.HasColumnType("text");
b.Property<int>("Views")
.HasColumnType("integer");
b.HasKey("Id");
b.ToTable("BlogPosts", "Club12");
});
modelBuilder.Entity("Entities.Models.Divisions.Division", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uuid");
b.Property<bool>("CanGenerateStageAutomated")
.HasColumnType("boolean");
b.Property<DateTime>("DateCreated")
.HasColumnType("timestamp without time zone")
.HasColumnName("DateCreated");
b.Property<DateTime?>("DateUpdated")
.HasColumnType("timestamp without time zone")
.HasColumnName("DateUpdated");
b.Property<bool>("IsFinished")
.HasColumnType("boolean");
b.Property<string>("Name")
.IsRequired()
.HasMaxLength(30)
.HasColumnType("character varying(30)");
b.Property<Guid>("TournamentId")
.HasColumnType("uuid");
b.HasKey("Id");
b.HasIndex("TournamentId");
b.ToTable("Divisions", "Club12");
});
modelBuilder.Entity("Entities.Models.Matches.Match", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uuid");
b.Property<DateTime>("DateCreated")
.HasColumnType("timestamp without time zone")
.HasColumnName("DateCreated");
b.Property<DateTime?>("DateUpdated")
.HasColumnType("timestamp without time zone")
.HasColumnName("DateUpdated");
b.Property<int?>("HomeScore")
.HasColumnType("integer");
b.Property<Guid?>("HomeTeamId")
.HasColumnType("uuid");
b.Property<bool>("IsFinished")
.HasColumnType("boolean");
b.Property<DateTime>("MatchDate")
.HasColumnType("timestamp without time zone");
b.Property<Guid>("StageId")
.HasColumnType("uuid");
b.Property<string>("Type")
.IsRequired()
.HasColumnType("text");
b.Property<Guid?>("VenueId")
.HasColumnType("uuid");
b.Property<int?>("VisitorScore")
.HasColumnType("integer");
b.Property<Guid>("VisitorTeamId")
.HasColumnType("uuid");
b.Property<Guid?>("WinningTeamId")
.HasColumnType("uuid");
b.HasKey("Id");
b.HasIndex("HomeTeamId");
b.HasIndex("StageId");
b.HasIndex("VenueId");
b.HasIndex("VisitorTeamId");
b.HasIndex("WinningTeamId");
b.ToTable("Matches", "Club12");
});
modelBuilder.Entity("Entities.Models.PlayerSanctions.PlayerSanction", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uuid");
b.Property<DateTime>("DateCreated")
.HasColumnType("timestamp without time zone")
.HasColumnName("DateCreated");
b.Property<DateTime?>("DateUpdated")
.HasColumnType("timestamp without time zone")
.HasColumnName("DateUpdated");
b.Property<string>("Description")
.IsRequired()
.HasMaxLength(255)
.HasColumnType("character varying(255)");
b.Property<int>("Duration")
.HasColumnType("integer");
b.Property<DateTime>("IssuedDate")
.HasColumnType("timestamp without time zone");
b.Property<Guid>("MatchId")
.HasColumnType("uuid");
b.Property<Guid>("PlayerId")
.HasColumnType("uuid");
b.HasKey("Id");
b.HasIndex("MatchId");
b.HasIndex("PlayerId");
b.ToTable("PlayerSanctions", "Club12");
});
modelBuilder.Entity("Entities.Models.PlayerStatistics.PlayerStatistic", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uuid");
b.Property<DateTime>("DateCreated")
.HasColumnType("timestamp without time zone")
.HasColumnName("DateCreated");
b.Property<DateTime?>("DateUpdated")
.HasColumnType("timestamp without time zone")
.HasColumnName("DateUpdated");
b.Property<Guid>("MatchId")
.HasColumnType("uuid");
b.Property<Guid>("PlayerId")
.HasColumnType("uuid");
b.Property<int>("Value")
.HasColumnType("integer");
b.HasKey("Id");
b.HasIndex("MatchId");
b.HasIndex("PlayerId");
b.ToTable("PlayersStatistics", "Club12");
});
modelBuilder.Entity("Entities.Models.Players.Player", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uuid");
b.Property<DateTime>("BirthDate")
.HasColumnType("timestamp without time zone");
b.Property<DateTime>("DateCreated")
.HasColumnType("timestamp without time zone")
.HasColumnName("DateCreated");
b.Property<DateTime?>("DateUpdated")
.HasColumnType("timestamp without time zone")
.HasColumnName("DateUpdated");
b.Property<string>("DocumentNumber")
.IsRequired()
.HasMaxLength(15)
.HasColumnType("character varying(15)");
b.Property<string>("FirstName")
.IsRequired()
.HasMaxLength(70)
.HasColumnType("character varying(70)");
b.Property<bool>("IsSanctioned")
.HasColumnType("boolean");
b.Property<string>("LastName")
.IsRequired()
.HasMaxLength(70)
.HasColumnType("character varying(70)");
b.Property<string>("PhoneNumber")
.HasColumnType("text");
b.Property<string>("SecondName")
.HasMaxLength(70)
.HasColumnType("character varying(70)");
b.Property<string>("SocialSecurity")
.IsRequired()
.HasMaxLength(100)
.HasColumnType("character varying(100)");
b.Property<Guid>("TeamId")
.HasColumnType("uuid");
b.HasKey("Id");
b.HasIndex("DocumentNumber")
.IsUnique();
b.HasIndex("TeamId");
b.ToTable("Players", "Club12");
});
modelBuilder.Entity("Entities.Models.Staffs.Staff", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uuid");
b.Property<DateTime>("DateCreated")
.HasColumnType("timestamp without time zone")
.HasColumnName("DateCreated");
b.Property<DateTime?>("DateUpdated")
.HasColumnType("timestamp without time zone")
.HasColumnName("DateUpdated");
b.Property<string>("LastName")
.IsRequired()
.HasMaxLength(50)
.HasColumnType("character varying(50)");
b.Property<string>("Names")
.IsRequired()
.HasMaxLength(50)
.HasColumnType("character varying(50)");
b.Property<string>("PhoneNumber")
.IsRequired()
.HasMaxLength(15)
.HasColumnType("character varying(15)");
b.Property<Guid>("TeamId")
.HasColumnType("uuid");
b.Property<string>("Type")
.IsRequired()
.HasColumnType("text");
b.HasKey("Id");
b.HasIndex("TeamId");
b.ToTable("Staffs", "Club12");
});
modelBuilder.Entity("Entities.Models.Stages.Stage", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uuid");
b.Property<DateTime>("DateCreated")
.HasColumnType("timestamp without time zone")
.HasColumnName("DateCreated");
b.Property<DateTime?>("DateUpdated")
.HasColumnType("timestamp without time zone")
.HasColumnName("DateUpdated");
b.Property<string>("Description")
.HasMaxLength(1000)
.HasColumnType("character varying(1000)");
b.Property<Guid>("DivisionId")
.HasColumnType("uuid");
b.Property<DateTime>("EndDate")
.HasColumnType("timestamp without time zone");
b.Property<bool>("IsActive")
.HasColumnType("boolean");
b.Property<bool>("IsElimination")
.HasColumnType("boolean");
b.Property<string>("Name")
.IsRequired()
.HasMaxLength(100)
.HasColumnType("character varying(100)");
b.Property<int>("Order")
.HasColumnType("integer");
b.Property<string>("StageType")
.IsRequired()
.HasColumnType("text");
b.Property<DateTime>("StartDate")
.HasColumnType("timestamp without time zone");
b.HasKey("Id");
b.HasIndex("DivisionId");
b.HasIndex("Name", "DivisionId")
.IsUnique()
.HasDatabaseName("CONSTRAINT_UNIQUE_STAGE_NAME_AND_DIVISIONID");
b.ToTable("Stages", "Club12");
});
modelBuilder.Entity("Entities.Models.Teams.Team", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uuid");
b.Property<DateTime>("DateCreated")
.HasColumnType("timestamp without time zone")
.HasColumnName("DateCreated");
b.Property<DateTime?>("DateUpdated")
.HasColumnType("timestamp without time zone")
.HasColumnName("DateUpdated");
b.Property<string>("LogoUrl")
.IsRequired()
.HasColumnType("text");
b.Property<string>("Name")
.IsRequired()
.HasColumnType("text");
b.Property<string>("ShirtColor")
.IsRequired()
.HasColumnType("text");
b.Property<string>("ThreeLetterCode")
.IsRequired()
.HasColumnType("text");
b.Property<Guid?>("TournamentId")
.HasColumnType("uuid");
b.HasKey("Id");
b.HasIndex("TournamentId");
b.ToTable("Teams", "Club12");
});
modelBuilder.Entity("Entities.Models.Tournaments.Tournament", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uuid");
b.Property<DateTime>("DateCreated")
.HasColumnType("timestamp without time zone")
.HasColumnName("DateCreated");
b.Property<DateTime?>("DateUpdated")
.HasColumnType("timestamp without time zone")
.HasColumnName("DateUpdated");
b.Property<string>("Description")
.IsRequired()
.HasColumnType("text");
b.Property<bool>("IsFinished")
.HasColumnType("boolean");
b.Property<int>("MaxTeams")
.HasColumnType("integer");
b.Property<int>("MinTeams")
.HasColumnType("integer");
b.Property<string>("Name")
.IsRequired()
.HasColumnType("text");
b.Property<DateTime>("StartDate")
.HasColumnType("timestamp without time zone");
b.Property<DateTime>("TeamRegistrationDeadline")
.HasColumnType("timestamp without time zone");
b.HasKey("Id");
b.ToTable("Tournaments", "Club12", t =>
{
t.HasCheckConstraint("CK_Tournament_DeadlineBeforeStart", "\"TeamRegistrationDeadline\" < \"StartDate\"");
});
});
modelBuilder.Entity("Entities.Models.Users.User", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uuid");
b.Property<DateTime>("DateCreated")
.HasColumnType("timestamp without time zone")
.HasColumnName("DateCreated");
b.Property<DateTime?>("DateUpdated")
.HasColumnType("timestamp without time zone")
.HasColumnName("DateUpdated");
b.Property<string>("Password")
.IsRequired()
.HasMaxLength(64)
.HasColumnType("character varying(64)");
b.Property<string>("RefreshToken")
.HasMaxLength(256)
.HasColumnType("character varying(256)");
b.Property<DateTime?>("RefreshTokenExpiryTime")
.HasColumnType("timestamp without time zone");
b.Property<string>("Role")
.IsRequired()
.HasMaxLength(10)
.HasColumnType("character varying(10)");
b.Property<string>("Username")
.IsRequired()
.HasMaxLength(25)
.HasColumnType("character varying(25)");
b.HasKey("Id");
b.ToTable("Users", "Club12");
});
modelBuilder.Entity("Entities.Models.Venues.Venue", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uuid");
b.Property<string>("Address")
.IsRequired()
.HasMaxLength(200)
.HasColumnType("character varying(200)");
b.Property<DateTime>("DateCreated")
.HasColumnType("timestamp without time zone")
.HasColumnName("DateCreated");
b.Property<DateTime?>("DateUpdated")
.HasColumnType("timestamp without time zone")
.HasColumnName("DateUpdated");
b.Property<string>("Name")
.IsRequired()
.HasMaxLength(50)
.HasColumnType("character varying(50)");
b.Property<string>("PhotoUrl")
.HasColumnType("text");
b.HasKey("Id");
b.ToTable("Venues", "Club12");
});
modelBuilder.Entity("Entities.Models.Divisions.Division", b =>
{
b.HasOne("Entities.Models.Tournaments.Tournament", "Tournament")
.WithMany("Divisions")
.HasForeignKey("TournamentId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Tournament");
});
modelBuilder.Entity("Entities.Models.Matches.Match", b =>
{
b.HasOne("Entities.Models.Teams.Team", "HomeTeam")
.WithMany()
.HasForeignKey("HomeTeamId");
b.HasOne("Entities.Models.Stages.Stage", "Stage")
.WithMany("Matches")
.HasForeignKey("StageId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("Entities.Models.Venues.Venue", "Venue")
.WithMany()
.HasForeignKey("VenueId");
b.HasOne("Entities.Models.Teams.Team", "VisitorTeam")
.WithMany()
.HasForeignKey("VisitorTeamId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("Entities.Models.Teams.Team", "WinningTeam")
.WithMany()
.HasForeignKey("WinningTeamId");
b.Navigation("HomeTeam");
b.Navigation("Stage");
b.Navigation("Venue");
b.Navigation("VisitorTeam");
b.Navigation("WinningTeam");
});
modelBuilder.Entity("Entities.Models.PlayerSanctions.PlayerSanction", b =>
{
b.HasOne("Entities.Models.Matches.Match", "Match")
.WithMany()
.HasForeignKey("MatchId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("Entities.Models.Players.Player", "Player")
.WithMany()
.HasForeignKey("PlayerId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Match");
b.Navigation("Player");
});
modelBuilder.Entity("Entities.Models.PlayerStatistics.PlayerStatistic", b =>
{
b.HasOne("Entities.Models.Matches.Match", "Match")
.WithMany("PlayerStatistics")
.HasForeignKey("MatchId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("Entities.Models.Players.Player", "Player")
.WithMany()
.HasForeignKey("PlayerId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Match");
b.Navigation("Player");
});
modelBuilder.Entity("Entities.Models.Players.Player", b =>
{
b.HasOne("Entities.Models.Teams.Team", "Team")
.WithMany("Players")
.HasForeignKey("TeamId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Team");
});
modelBuilder.Entity("Entities.Models.Staffs.Staff", b =>
{
b.HasOne("Entities.Models.Teams.Team", "Team")
.WithMany("Staff")
.HasForeignKey("TeamId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Team");
});
modelBuilder.Entity("Entities.Models.Stages.Stage", b =>
{
b.HasOne("Entities.Models.Divisions.Division", "Division")
.WithMany("Stages")
.HasForeignKey("DivisionId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Division");
});
modelBuilder.Entity("Entities.Models.Teams.Team", b =>
{
b.HasOne("Entities.Models.Tournaments.Tournament", "Tournament")
.WithMany("Teams")
.HasForeignKey("TournamentId");
b.Navigation("Tournament");
});
modelBuilder.Entity("Entities.Models.Divisions.Division", b =>
{
b.Navigation("Stages");
});
modelBuilder.Entity("Entities.Models.Matches.Match", b =>
{
b.Navigation("PlayerStatistics");
});
modelBuilder.Entity("Entities.Models.Stages.Stage", b =>
{
b.Navigation("Matches");
});
modelBuilder.Entity("Entities.Models.Teams.Team", b =>
{
b.Navigation("Players");
b.Navigation("Staff");
});
modelBuilder.Entity("Entities.Models.Tournaments.Tournament", b =>
{
b.Navigation("Divisions");
b.Navigation("Teams");
});
#pragma warning restore 612, 618
}
}
}
@@ -0,0 +1,30 @@
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace Persistance.Migrations;
/// <inheritdoc />
public partial class addOrderColumnIntoStage : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.AddColumn<int>(
name: "Order",
schema: "Club12",
table: "Stages",
type: "integer",
nullable: false,
defaultValue: 0);
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropColumn(
name: "Order",
schema: "Club12",
table: "Stages");
}
}
@@ -0,0 +1,705 @@
// <auto-generated />
using System;
using Infrastructure.Persistance;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Migrations;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
#nullable disable
namespace Persistance.Migrations
{
[DbContext(typeof(ApplicationDBContext))]
[Migration("20260205004338_removeUnneccessaryProp")]
partial class removeUnneccessaryProp
{
/// <inheritdoc />
protected override void BuildTargetModel(ModelBuilder modelBuilder)
{
#pragma warning disable 612, 618
modelBuilder
.HasAnnotation("ProductVersion", "8.0.11")
.HasAnnotation("Relational:MaxIdentifierLength", 63);
NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder);
modelBuilder.Entity("Entities.Models.BlogPosts.BlogPost", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uuid");
b.Property<string>("Author")
.IsRequired()
.HasMaxLength(50)
.HasColumnType("character varying(50)");
b.Property<DateTime>("DateCreated")
.HasColumnType("timestamp without time zone")
.HasColumnName("DateCreated");
b.Property<DateTime?>("DateUpdated")
.HasColumnType("timestamp without time zone")
.HasColumnName("DateUpdated");
b.Property<string>("MarkdownText")
.IsRequired()
.HasColumnType("text");
b.Property<string>("PhotoUrl")
.HasMaxLength(2048)
.HasColumnType("character varying(2048)");
b.Property<string>("Title")
.IsRequired()
.HasColumnType("text");
b.Property<int>("Views")
.HasColumnType("integer");
b.HasKey("Id");
b.ToTable("BlogPosts", "Club12");
});
modelBuilder.Entity("Entities.Models.Divisions.Division", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uuid");
b.Property<DateTime>("DateCreated")
.HasColumnType("timestamp without time zone")
.HasColumnName("DateCreated");
b.Property<DateTime?>("DateUpdated")
.HasColumnType("timestamp without time zone")
.HasColumnName("DateUpdated");
b.Property<bool>("IsFinished")
.HasColumnType("boolean");
b.Property<string>("Name")
.IsRequired()
.HasMaxLength(30)
.HasColumnType("character varying(30)");
b.Property<Guid>("TournamentId")
.HasColumnType("uuid");
b.HasKey("Id");
b.HasIndex("TournamentId");
b.ToTable("Divisions", "Club12");
});
modelBuilder.Entity("Entities.Models.Matches.Match", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uuid");
b.Property<DateTime>("DateCreated")
.HasColumnType("timestamp without time zone")
.HasColumnName("DateCreated");
b.Property<DateTime?>("DateUpdated")
.HasColumnType("timestamp without time zone")
.HasColumnName("DateUpdated");
b.Property<int?>("HomeScore")
.HasColumnType("integer");
b.Property<Guid?>("HomeTeamId")
.HasColumnType("uuid");
b.Property<bool>("IsFinished")
.HasColumnType("boolean");
b.Property<DateTime>("MatchDate")
.HasColumnType("timestamp without time zone");
b.Property<Guid>("StageId")
.HasColumnType("uuid");
b.Property<string>("Type")
.IsRequired()
.HasColumnType("text");
b.Property<Guid?>("VenueId")
.HasColumnType("uuid");
b.Property<int?>("VisitorScore")
.HasColumnType("integer");
b.Property<Guid?>("VisitorTeamId")
.HasColumnType("uuid");
b.Property<Guid?>("WinningTeamId")
.HasColumnType("uuid");
b.HasKey("Id");
b.HasIndex("HomeTeamId");
b.HasIndex("StageId");
b.HasIndex("VenueId");
b.HasIndex("VisitorTeamId");
b.HasIndex("WinningTeamId");
b.ToTable("Matches", "Club12");
});
modelBuilder.Entity("Entities.Models.PlayerSanctions.PlayerSanction", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uuid");
b.Property<DateTime>("DateCreated")
.HasColumnType("timestamp without time zone")
.HasColumnName("DateCreated");
b.Property<DateTime?>("DateUpdated")
.HasColumnType("timestamp without time zone")
.HasColumnName("DateUpdated");
b.Property<string>("Description")
.IsRequired()
.HasMaxLength(255)
.HasColumnType("character varying(255)");
b.Property<int>("Duration")
.HasColumnType("integer");
b.Property<DateTime>("IssuedDate")
.HasColumnType("timestamp without time zone");
b.Property<Guid>("MatchId")
.HasColumnType("uuid");
b.Property<Guid>("PlayerId")
.HasColumnType("uuid");
b.HasKey("Id");
b.HasIndex("MatchId");
b.HasIndex("PlayerId");
b.ToTable("PlayerSanctions", "Club12");
});
modelBuilder.Entity("Entities.Models.PlayerStatistics.PlayerStatistic", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uuid");
b.Property<DateTime>("DateCreated")
.HasColumnType("timestamp without time zone")
.HasColumnName("DateCreated");
b.Property<DateTime?>("DateUpdated")
.HasColumnType("timestamp without time zone")
.HasColumnName("DateUpdated");
b.Property<Guid>("MatchId")
.HasColumnType("uuid");
b.Property<Guid>("PlayerId")
.HasColumnType("uuid");
b.Property<int>("Value")
.HasColumnType("integer");
b.HasKey("Id");
b.HasIndex("MatchId");
b.HasIndex("PlayerId");
b.ToTable("PlayersStatistics", "Club12");
});
modelBuilder.Entity("Entities.Models.Players.Player", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uuid");
b.Property<DateTime>("BirthDate")
.HasColumnType("timestamp without time zone");
b.Property<DateTime>("DateCreated")
.HasColumnType("timestamp without time zone")
.HasColumnName("DateCreated");
b.Property<DateTime?>("DateUpdated")
.HasColumnType("timestamp without time zone")
.HasColumnName("DateUpdated");
b.Property<string>("DocumentNumber")
.IsRequired()
.HasMaxLength(15)
.HasColumnType("character varying(15)");
b.Property<string>("FirstName")
.IsRequired()
.HasMaxLength(70)
.HasColumnType("character varying(70)");
b.Property<bool>("IsSanctioned")
.HasColumnType("boolean");
b.Property<string>("LastName")
.IsRequired()
.HasMaxLength(70)
.HasColumnType("character varying(70)");
b.Property<string>("PhoneNumber")
.HasColumnType("text");
b.Property<string>("SecondName")
.HasMaxLength(70)
.HasColumnType("character varying(70)");
b.Property<string>("SocialSecurity")
.IsRequired()
.HasMaxLength(100)
.HasColumnType("character varying(100)");
b.Property<Guid>("TeamId")
.HasColumnType("uuid");
b.HasKey("Id");
b.HasIndex("DocumentNumber")
.IsUnique();
b.HasIndex("TeamId");
b.ToTable("Players", "Club12");
});
modelBuilder.Entity("Entities.Models.Staffs.Staff", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uuid");
b.Property<DateTime>("DateCreated")
.HasColumnType("timestamp without time zone")
.HasColumnName("DateCreated");
b.Property<DateTime?>("DateUpdated")
.HasColumnType("timestamp without time zone")
.HasColumnName("DateUpdated");
b.Property<string>("LastName")
.IsRequired()
.HasMaxLength(50)
.HasColumnType("character varying(50)");
b.Property<string>("Names")
.IsRequired()
.HasMaxLength(50)
.HasColumnType("character varying(50)");
b.Property<string>("PhoneNumber")
.IsRequired()
.HasMaxLength(15)
.HasColumnType("character varying(15)");
b.Property<Guid>("TeamId")
.HasColumnType("uuid");
b.Property<string>("Type")
.IsRequired()
.HasColumnType("text");
b.HasKey("Id");
b.HasIndex("TeamId");
b.ToTable("Staffs", "Club12");
});
modelBuilder.Entity("Entities.Models.Stages.Stage", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uuid");
b.Property<DateTime>("DateCreated")
.HasColumnType("timestamp without time zone")
.HasColumnName("DateCreated");
b.Property<DateTime?>("DateUpdated")
.HasColumnType("timestamp without time zone")
.HasColumnName("DateUpdated");
b.Property<string>("Description")
.HasMaxLength(1000)
.HasColumnType("character varying(1000)");
b.Property<Guid>("DivisionId")
.HasColumnType("uuid");
b.Property<DateTime>("EndDate")
.HasColumnType("timestamp without time zone");
b.Property<bool>("IsActive")
.HasColumnType("boolean");
b.Property<bool>("IsElimination")
.HasColumnType("boolean");
b.Property<string>("Name")
.IsRequired()
.HasMaxLength(100)
.HasColumnType("character varying(100)");
b.Property<int>("Order")
.HasColumnType("integer");
b.Property<string>("StageType")
.IsRequired()
.HasColumnType("text");
b.Property<DateTime>("StartDate")
.HasColumnType("timestamp without time zone");
b.HasKey("Id");
b.HasIndex("DivisionId");
b.HasIndex("Name", "DivisionId")
.IsUnique()
.HasDatabaseName("CONSTRAINT_UNIQUE_STAGE_NAME_AND_DIVISIONID");
b.ToTable("Stages", "Club12");
});
modelBuilder.Entity("Entities.Models.Teams.Team", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uuid");
b.Property<DateTime>("DateCreated")
.HasColumnType("timestamp without time zone")
.HasColumnName("DateCreated");
b.Property<DateTime?>("DateUpdated")
.HasColumnType("timestamp without time zone")
.HasColumnName("DateUpdated");
b.Property<string>("LogoUrl")
.IsRequired()
.HasColumnType("text");
b.Property<string>("Name")
.IsRequired()
.HasColumnType("text");
b.Property<string>("ShirtColor")
.IsRequired()
.HasColumnType("text");
b.Property<string>("ThreeLetterCode")
.IsRequired()
.HasColumnType("text");
b.Property<Guid?>("TournamentId")
.HasColumnType("uuid");
b.HasKey("Id");
b.HasIndex("TournamentId");
b.ToTable("Teams", "Club12");
});
modelBuilder.Entity("Entities.Models.Tournaments.Tournament", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uuid");
b.Property<DateTime>("DateCreated")
.HasColumnType("timestamp without time zone")
.HasColumnName("DateCreated");
b.Property<DateTime?>("DateUpdated")
.HasColumnType("timestamp without time zone")
.HasColumnName("DateUpdated");
b.Property<string>("Description")
.IsRequired()
.HasColumnType("text");
b.Property<bool>("IsFinished")
.HasColumnType("boolean");
b.Property<int>("MaxTeams")
.HasColumnType("integer");
b.Property<int>("MinTeams")
.HasColumnType("integer");
b.Property<string>("Name")
.IsRequired()
.HasColumnType("text");
b.Property<DateTime>("StartDate")
.HasColumnType("timestamp without time zone");
b.Property<DateTime>("TeamRegistrationDeadline")
.HasColumnType("timestamp without time zone");
b.HasKey("Id");
b.ToTable("Tournaments", "Club12", t =>
{
t.HasCheckConstraint("CK_Tournament_DeadlineBeforeStart", "\"TeamRegistrationDeadline\" < \"StartDate\"");
});
});
modelBuilder.Entity("Entities.Models.Users.User", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uuid");
b.Property<DateTime>("DateCreated")
.HasColumnType("timestamp without time zone")
.HasColumnName("DateCreated");
b.Property<DateTime?>("DateUpdated")
.HasColumnType("timestamp without time zone")
.HasColumnName("DateUpdated");
b.Property<string>("Password")
.IsRequired()
.HasMaxLength(64)
.HasColumnType("character varying(64)");
b.Property<string>("RefreshToken")
.HasMaxLength(256)
.HasColumnType("character varying(256)");
b.Property<DateTime?>("RefreshTokenExpiryTime")
.HasColumnType("timestamp without time zone");
b.Property<string>("Role")
.IsRequired()
.HasMaxLength(10)
.HasColumnType("character varying(10)");
b.Property<string>("Username")
.IsRequired()
.HasMaxLength(25)
.HasColumnType("character varying(25)");
b.HasKey("Id");
b.ToTable("Users", "Club12");
});
modelBuilder.Entity("Entities.Models.Venues.Venue", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uuid");
b.Property<string>("Address")
.IsRequired()
.HasMaxLength(200)
.HasColumnType("character varying(200)");
b.Property<DateTime>("DateCreated")
.HasColumnType("timestamp without time zone")
.HasColumnName("DateCreated");
b.Property<DateTime?>("DateUpdated")
.HasColumnType("timestamp without time zone")
.HasColumnName("DateUpdated");
b.Property<string>("Name")
.IsRequired()
.HasMaxLength(50)
.HasColumnType("character varying(50)");
b.Property<string>("PhotoUrl")
.HasColumnType("text");
b.HasKey("Id");
b.ToTable("Venues", "Club12");
});
modelBuilder.Entity("Entities.Models.Divisions.Division", b =>
{
b.HasOne("Entities.Models.Tournaments.Tournament", "Tournament")
.WithMany("Divisions")
.HasForeignKey("TournamentId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Tournament");
});
modelBuilder.Entity("Entities.Models.Matches.Match", b =>
{
b.HasOne("Entities.Models.Teams.Team", "HomeTeam")
.WithMany()
.HasForeignKey("HomeTeamId");
b.HasOne("Entities.Models.Stages.Stage", "Stage")
.WithMany("Matches")
.HasForeignKey("StageId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("Entities.Models.Venues.Venue", "Venue")
.WithMany()
.HasForeignKey("VenueId");
b.HasOne("Entities.Models.Teams.Team", "VisitorTeam")
.WithMany()
.HasForeignKey("VisitorTeamId");
b.HasOne("Entities.Models.Teams.Team", "WinningTeam")
.WithMany()
.HasForeignKey("WinningTeamId");
b.Navigation("HomeTeam");
b.Navigation("Stage");
b.Navigation("Venue");
b.Navigation("VisitorTeam");
b.Navigation("WinningTeam");
});
modelBuilder.Entity("Entities.Models.PlayerSanctions.PlayerSanction", b =>
{
b.HasOne("Entities.Models.Matches.Match", "Match")
.WithMany()
.HasForeignKey("MatchId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("Entities.Models.Players.Player", "Player")
.WithMany()
.HasForeignKey("PlayerId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Match");
b.Navigation("Player");
});
modelBuilder.Entity("Entities.Models.PlayerStatistics.PlayerStatistic", b =>
{
b.HasOne("Entities.Models.Matches.Match", "Match")
.WithMany("PlayerStatistics")
.HasForeignKey("MatchId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("Entities.Models.Players.Player", "Player")
.WithMany()
.HasForeignKey("PlayerId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Match");
b.Navigation("Player");
});
modelBuilder.Entity("Entities.Models.Players.Player", b =>
{
b.HasOne("Entities.Models.Teams.Team", "Team")
.WithMany("Players")
.HasForeignKey("TeamId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Team");
});
modelBuilder.Entity("Entities.Models.Staffs.Staff", b =>
{
b.HasOne("Entities.Models.Teams.Team", "Team")
.WithMany("Staff")
.HasForeignKey("TeamId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Team");
});
modelBuilder.Entity("Entities.Models.Stages.Stage", b =>
{
b.HasOne("Entities.Models.Divisions.Division", "Division")
.WithMany("Stages")
.HasForeignKey("DivisionId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Division");
});
modelBuilder.Entity("Entities.Models.Teams.Team", b =>
{
b.HasOne("Entities.Models.Tournaments.Tournament", "Tournament")
.WithMany("Teams")
.HasForeignKey("TournamentId");
b.Navigation("Tournament");
});
modelBuilder.Entity("Entities.Models.Divisions.Division", b =>
{
b.Navigation("Stages");
});
modelBuilder.Entity("Entities.Models.Matches.Match", b =>
{
b.Navigation("PlayerStatistics");
});
modelBuilder.Entity("Entities.Models.Stages.Stage", b =>
{
b.Navigation("Matches");
});
modelBuilder.Entity("Entities.Models.Teams.Team", b =>
{
b.Navigation("Players");
b.Navigation("Staff");
});
modelBuilder.Entity("Entities.Models.Tournaments.Tournament", b =>
{
b.Navigation("Divisions");
b.Navigation("Teams");
});
#pragma warning restore 612, 618
}
}
}
@@ -0,0 +1,81 @@
using Microsoft.EntityFrameworkCore.Migrations;
using System;
#nullable disable
namespace Persistance.Migrations;
/// <inheritdoc />
public partial class removeUnneccessaryProp : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropForeignKey(
name: "FK_Matches_Teams_VisitorTeamId",
schema: "Club12",
table: "Matches");
migrationBuilder.DropColumn(
name: "CanGenerateStageAutomated",
schema: "Club12",
table: "Divisions");
migrationBuilder.AlterColumn<Guid>(
name: "VisitorTeamId",
schema: "Club12",
table: "Matches",
type: "uuid",
nullable: true,
oldClrType: typeof(Guid),
oldType: "uuid");
migrationBuilder.AddForeignKey(
name: "FK_Matches_Teams_VisitorTeamId",
schema: "Club12",
table: "Matches",
column: "VisitorTeamId",
principalSchema: "Club12",
principalTable: "Teams",
principalColumn: "Id");
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropForeignKey(
name: "FK_Matches_Teams_VisitorTeamId",
schema: "Club12",
table: "Matches");
migrationBuilder.AlterColumn<Guid>(
name: "VisitorTeamId",
schema: "Club12",
table: "Matches",
type: "uuid",
nullable: false,
defaultValue: Guid.Empty,
oldClrType: typeof(Guid),
oldType: "uuid",
oldNullable: true);
migrationBuilder.AddColumn<bool>(
name: "CanGenerateStageAutomated",
schema: "Club12",
table: "Divisions",
type: "boolean",
nullable: false,
defaultValue: false);
migrationBuilder.AddForeignKey(
name: "FK_Matches_Teams_VisitorTeamId",
schema: "Club12",
table: "Matches",
column: "VisitorTeamId",
principalSchema: "Club12",
principalTable: "Teams",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
}
}
@@ -0,0 +1,757 @@
// <auto-generated />
using System;
using Infrastructure.Persistance;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Migrations;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
#nullable disable
namespace Persistance.Migrations
{
[DbContext(typeof(ApplicationDBContext))]
[Migration("20260218023223_AddStageTeamMatchTable")]
partial class AddStageTeamMatchTable
{
/// <inheritdoc />
protected override void BuildTargetModel(ModelBuilder modelBuilder)
{
#pragma warning disable 612, 618
modelBuilder
.HasAnnotation("ProductVersion", "8.0.11")
.HasAnnotation("Relational:MaxIdentifierLength", 63);
NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder);
modelBuilder.Entity("Entities.Models.BlogPosts.BlogPost", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uuid");
b.Property<string>("Author")
.IsRequired()
.HasMaxLength(50)
.HasColumnType("character varying(50)");
b.Property<DateTime>("DateCreated")
.HasColumnType("timestamp without time zone")
.HasColumnName("DateCreated");
b.Property<DateTime?>("DateUpdated")
.HasColumnType("timestamp without time zone")
.HasColumnName("DateUpdated");
b.Property<string>("MarkdownText")
.IsRequired()
.HasColumnType("text");
b.Property<string>("PhotoUrl")
.HasMaxLength(2048)
.HasColumnType("character varying(2048)");
b.Property<string>("Title")
.IsRequired()
.HasColumnType("text");
b.Property<int>("Views")
.HasColumnType("integer");
b.HasKey("Id");
b.ToTable("BlogPosts", "Club12");
});
modelBuilder.Entity("Entities.Models.Divisions.Division", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uuid");
b.Property<DateTime>("DateCreated")
.HasColumnType("timestamp without time zone")
.HasColumnName("DateCreated");
b.Property<DateTime?>("DateUpdated")
.HasColumnType("timestamp without time zone")
.HasColumnName("DateUpdated");
b.Property<bool>("IsFinished")
.HasColumnType("boolean");
b.Property<string>("Name")
.IsRequired()
.HasMaxLength(30)
.HasColumnType("character varying(30)");
b.Property<Guid>("TournamentId")
.HasColumnType("uuid");
b.HasKey("Id");
b.HasIndex("TournamentId");
b.ToTable("Divisions", "Club12");
});
modelBuilder.Entity("Entities.Models.Matches.Match", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uuid");
b.Property<DateTime>("DateCreated")
.HasColumnType("timestamp without time zone")
.HasColumnName("DateCreated");
b.Property<DateTime?>("DateUpdated")
.HasColumnType("timestamp without time zone")
.HasColumnName("DateUpdated");
b.Property<int?>("HomeScore")
.HasColumnType("integer");
b.Property<Guid?>("HomeTeamId")
.HasColumnType("uuid");
b.Property<bool>("IsFinished")
.HasColumnType("boolean");
b.Property<DateTime>("MatchDate")
.HasColumnType("timestamp without time zone");
b.Property<Guid>("StageId")
.HasColumnType("uuid");
b.Property<string>("Type")
.IsRequired()
.HasColumnType("text");
b.Property<Guid?>("VenueId")
.HasColumnType("uuid");
b.Property<int?>("VisitorScore")
.HasColumnType("integer");
b.Property<Guid?>("VisitorTeamId")
.HasColumnType("uuid");
b.Property<Guid?>("WinningTeamId")
.HasColumnType("uuid");
b.HasKey("Id");
b.HasIndex("HomeTeamId");
b.HasIndex("StageId");
b.HasIndex("VenueId");
b.HasIndex("VisitorTeamId");
b.HasIndex("WinningTeamId");
b.ToTable("Matches", "Club12");
});
modelBuilder.Entity("Entities.Models.PlayerSanctions.PlayerSanction", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uuid");
b.Property<DateTime>("DateCreated")
.HasColumnType("timestamp without time zone")
.HasColumnName("DateCreated");
b.Property<DateTime?>("DateUpdated")
.HasColumnType("timestamp without time zone")
.HasColumnName("DateUpdated");
b.Property<string>("Description")
.IsRequired()
.HasMaxLength(255)
.HasColumnType("character varying(255)");
b.Property<int>("Duration")
.HasColumnType("integer");
b.Property<DateTime>("IssuedDate")
.HasColumnType("timestamp without time zone");
b.Property<Guid>("MatchId")
.HasColumnType("uuid");
b.Property<Guid>("PlayerId")
.HasColumnType("uuid");
b.HasKey("Id");
b.HasIndex("MatchId");
b.HasIndex("PlayerId");
b.ToTable("PlayerSanctions", "Club12");
});
modelBuilder.Entity("Entities.Models.PlayerStatistics.PlayerStatistic", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uuid");
b.Property<DateTime>("DateCreated")
.HasColumnType("timestamp without time zone")
.HasColumnName("DateCreated");
b.Property<DateTime?>("DateUpdated")
.HasColumnType("timestamp without time zone")
.HasColumnName("DateUpdated");
b.Property<Guid>("MatchId")
.HasColumnType("uuid");
b.Property<Guid>("PlayerId")
.HasColumnType("uuid");
b.Property<int>("Value")
.HasColumnType("integer");
b.HasKey("Id");
b.HasIndex("MatchId");
b.HasIndex("PlayerId");
b.ToTable("PlayersStatistics", "Club12");
});
modelBuilder.Entity("Entities.Models.Players.Player", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uuid");
b.Property<DateTime>("BirthDate")
.HasColumnType("timestamp without time zone");
b.Property<DateTime>("DateCreated")
.HasColumnType("timestamp without time zone")
.HasColumnName("DateCreated");
b.Property<DateTime?>("DateUpdated")
.HasColumnType("timestamp without time zone")
.HasColumnName("DateUpdated");
b.Property<string>("DocumentNumber")
.IsRequired()
.HasMaxLength(15)
.HasColumnType("character varying(15)");
b.Property<string>("FirstName")
.IsRequired()
.HasMaxLength(70)
.HasColumnType("character varying(70)");
b.Property<bool>("IsSanctioned")
.HasColumnType("boolean");
b.Property<string>("LastName")
.IsRequired()
.HasMaxLength(70)
.HasColumnType("character varying(70)");
b.Property<string>("PhoneNumber")
.HasColumnType("text");
b.Property<string>("SecondName")
.HasMaxLength(70)
.HasColumnType("character varying(70)");
b.Property<string>("SocialSecurity")
.IsRequired()
.HasMaxLength(100)
.HasColumnType("character varying(100)");
b.Property<Guid>("TeamId")
.HasColumnType("uuid");
b.HasKey("Id");
b.HasIndex("DocumentNumber")
.IsUnique();
b.HasIndex("TeamId");
b.ToTable("Players", "Club12");
});
modelBuilder.Entity("Entities.Models.Staffs.Staff", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uuid");
b.Property<DateTime>("DateCreated")
.HasColumnType("timestamp without time zone")
.HasColumnName("DateCreated");
b.Property<DateTime?>("DateUpdated")
.HasColumnType("timestamp without time zone")
.HasColumnName("DateUpdated");
b.Property<string>("LastName")
.IsRequired()
.HasMaxLength(50)
.HasColumnType("character varying(50)");
b.Property<string>("Names")
.IsRequired()
.HasMaxLength(50)
.HasColumnType("character varying(50)");
b.Property<string>("PhoneNumber")
.IsRequired()
.HasMaxLength(15)
.HasColumnType("character varying(15)");
b.Property<Guid>("TeamId")
.HasColumnType("uuid");
b.Property<string>("Type")
.IsRequired()
.HasColumnType("text");
b.HasKey("Id");
b.HasIndex("TeamId");
b.ToTable("Staffs", "Club12");
});
modelBuilder.Entity("Entities.Models.StageTeamMatches.StageTeamMatch", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uuid");
b.Property<DateTime>("DateCreated")
.HasColumnType("timestamp without time zone")
.HasColumnName("DateCreated");
b.Property<DateTime?>("DateUpdated")
.HasColumnType("timestamp without time zone")
.HasColumnName("DateUpdated");
b.Property<Guid>("StageId")
.HasColumnType("uuid");
b.Property<Guid>("TeamId")
.HasColumnType("uuid");
b.HasKey("Id");
b.HasIndex("StageId");
b.HasIndex("TeamId");
b.ToTable("StageTeamMatches", "Club12");
});
modelBuilder.Entity("Entities.Models.Stages.Stage", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uuid");
b.Property<DateTime>("DateCreated")
.HasColumnType("timestamp without time zone")
.HasColumnName("DateCreated");
b.Property<DateTime?>("DateUpdated")
.HasColumnType("timestamp without time zone")
.HasColumnName("DateUpdated");
b.Property<string>("Description")
.HasMaxLength(1000)
.HasColumnType("character varying(1000)");
b.Property<Guid>("DivisionId")
.HasColumnType("uuid");
b.Property<DateTime>("EndDate")
.HasColumnType("timestamp without time zone");
b.Property<bool>("IsActive")
.HasColumnType("boolean");
b.Property<bool>("IsElimination")
.HasColumnType("boolean");
b.Property<string>("Name")
.IsRequired()
.HasMaxLength(100)
.HasColumnType("character varying(100)");
b.Property<int>("Order")
.HasColumnType("integer");
b.Property<string>("StageType")
.IsRequired()
.HasColumnType("text");
b.Property<DateTime>("StartDate")
.HasColumnType("timestamp without time zone");
b.HasKey("Id");
b.HasIndex("DivisionId");
b.HasIndex("Name", "DivisionId")
.IsUnique()
.HasDatabaseName("CONSTRAINT_UNIQUE_STAGE_NAME_AND_DIVISIONID");
b.ToTable("Stages", "Club12");
});
modelBuilder.Entity("Entities.Models.Teams.Team", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uuid");
b.Property<DateTime>("DateCreated")
.HasColumnType("timestamp without time zone")
.HasColumnName("DateCreated");
b.Property<DateTime?>("DateUpdated")
.HasColumnType("timestamp without time zone")
.HasColumnName("DateUpdated");
b.Property<string>("LogoUrl")
.IsRequired()
.HasColumnType("text");
b.Property<string>("Name")
.IsRequired()
.HasColumnType("text");
b.Property<string>("ShirtColor")
.IsRequired()
.HasColumnType("text");
b.Property<string>("ThreeLetterCode")
.IsRequired()
.HasColumnType("text");
b.Property<Guid?>("TournamentId")
.HasColumnType("uuid");
b.HasKey("Id");
b.HasIndex("TournamentId");
b.ToTable("Teams", "Club12");
});
modelBuilder.Entity("Entities.Models.Tournaments.Tournament", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uuid");
b.Property<DateTime>("DateCreated")
.HasColumnType("timestamp without time zone")
.HasColumnName("DateCreated");
b.Property<DateTime?>("DateUpdated")
.HasColumnType("timestamp without time zone")
.HasColumnName("DateUpdated");
b.Property<string>("Description")
.IsRequired()
.HasColumnType("text");
b.Property<bool>("IsFinished")
.HasColumnType("boolean");
b.Property<int>("MaxTeams")
.HasColumnType("integer");
b.Property<int>("MinTeams")
.HasColumnType("integer");
b.Property<string>("Name")
.IsRequired()
.HasColumnType("text");
b.Property<DateTime>("StartDate")
.HasColumnType("timestamp without time zone");
b.Property<DateTime>("TeamRegistrationDeadline")
.HasColumnType("timestamp without time zone");
b.HasKey("Id");
b.ToTable("Tournaments", "Club12", t =>
{
t.HasCheckConstraint("CK_Tournament_DeadlineBeforeStart", "\"TeamRegistrationDeadline\" < \"StartDate\"");
});
});
modelBuilder.Entity("Entities.Models.Users.User", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uuid");
b.Property<DateTime>("DateCreated")
.HasColumnType("timestamp without time zone")
.HasColumnName("DateCreated");
b.Property<DateTime?>("DateUpdated")
.HasColumnType("timestamp without time zone")
.HasColumnName("DateUpdated");
b.Property<string>("Password")
.IsRequired()
.HasMaxLength(64)
.HasColumnType("character varying(64)");
b.Property<string>("RefreshToken")
.HasMaxLength(256)
.HasColumnType("character varying(256)");
b.Property<DateTime?>("RefreshTokenExpiryTime")
.HasColumnType("timestamp without time zone");
b.Property<string>("Role")
.IsRequired()
.HasMaxLength(10)
.HasColumnType("character varying(10)");
b.Property<string>("Username")
.IsRequired()
.HasMaxLength(25)
.HasColumnType("character varying(25)");
b.HasKey("Id");
b.ToTable("Users", "Club12");
});
modelBuilder.Entity("Entities.Models.Venues.Venue", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uuid");
b.Property<string>("Address")
.IsRequired()
.HasMaxLength(200)
.HasColumnType("character varying(200)");
b.Property<DateTime>("DateCreated")
.HasColumnType("timestamp without time zone")
.HasColumnName("DateCreated");
b.Property<DateTime?>("DateUpdated")
.HasColumnType("timestamp without time zone")
.HasColumnName("DateUpdated");
b.Property<string>("Name")
.IsRequired()
.HasMaxLength(50)
.HasColumnType("character varying(50)");
b.Property<string>("PhotoUrl")
.HasColumnType("text");
b.HasKey("Id");
b.ToTable("Venues", "Club12");
});
modelBuilder.Entity("Entities.Models.Divisions.Division", b =>
{
b.HasOne("Entities.Models.Tournaments.Tournament", "Tournament")
.WithMany("Divisions")
.HasForeignKey("TournamentId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Tournament");
});
modelBuilder.Entity("Entities.Models.Matches.Match", b =>
{
b.HasOne("Entities.Models.Teams.Team", "HomeTeam")
.WithMany()
.HasForeignKey("HomeTeamId");
b.HasOne("Entities.Models.Stages.Stage", "Stage")
.WithMany("Matches")
.HasForeignKey("StageId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("Entities.Models.Venues.Venue", "Venue")
.WithMany()
.HasForeignKey("VenueId");
b.HasOne("Entities.Models.Teams.Team", "VisitorTeam")
.WithMany()
.HasForeignKey("VisitorTeamId");
b.HasOne("Entities.Models.Teams.Team", "WinningTeam")
.WithMany()
.HasForeignKey("WinningTeamId");
b.Navigation("HomeTeam");
b.Navigation("Stage");
b.Navigation("Venue");
b.Navigation("VisitorTeam");
b.Navigation("WinningTeam");
});
modelBuilder.Entity("Entities.Models.PlayerSanctions.PlayerSanction", b =>
{
b.HasOne("Entities.Models.Matches.Match", "Match")
.WithMany()
.HasForeignKey("MatchId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("Entities.Models.Players.Player", "Player")
.WithMany()
.HasForeignKey("PlayerId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Match");
b.Navigation("Player");
});
modelBuilder.Entity("Entities.Models.PlayerStatistics.PlayerStatistic", b =>
{
b.HasOne("Entities.Models.Matches.Match", "Match")
.WithMany("PlayerStatistics")
.HasForeignKey("MatchId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("Entities.Models.Players.Player", "Player")
.WithMany()
.HasForeignKey("PlayerId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Match");
b.Navigation("Player");
});
modelBuilder.Entity("Entities.Models.Players.Player", b =>
{
b.HasOne("Entities.Models.Teams.Team", "Team")
.WithMany("Players")
.HasForeignKey("TeamId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Team");
});
modelBuilder.Entity("Entities.Models.Staffs.Staff", b =>
{
b.HasOne("Entities.Models.Teams.Team", "Team")
.WithMany("Staff")
.HasForeignKey("TeamId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Team");
});
modelBuilder.Entity("Entities.Models.StageTeamMatches.StageTeamMatch", b =>
{
b.HasOne("Entities.Models.Stages.Stage", "Stage")
.WithMany("StageTeamMatches")
.HasForeignKey("StageId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("Entities.Models.Teams.Team", "Team")
.WithMany("StageTeamMatches")
.HasForeignKey("TeamId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Stage");
b.Navigation("Team");
});
modelBuilder.Entity("Entities.Models.Stages.Stage", b =>
{
b.HasOne("Entities.Models.Divisions.Division", "Division")
.WithMany("Stages")
.HasForeignKey("DivisionId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Division");
});
modelBuilder.Entity("Entities.Models.Teams.Team", b =>
{
b.HasOne("Entities.Models.Tournaments.Tournament", "Tournament")
.WithMany("Teams")
.HasForeignKey("TournamentId");
b.Navigation("Tournament");
});
modelBuilder.Entity("Entities.Models.Divisions.Division", b =>
{
b.Navigation("Stages");
});
modelBuilder.Entity("Entities.Models.Matches.Match", b =>
{
b.Navigation("PlayerStatistics");
});
modelBuilder.Entity("Entities.Models.Stages.Stage", b =>
{
b.Navigation("Matches");
b.Navigation("StageTeamMatches");
});
modelBuilder.Entity("Entities.Models.Teams.Team", b =>
{
b.Navigation("Players");
b.Navigation("Staff");
b.Navigation("StageTeamMatches");
});
modelBuilder.Entity("Entities.Models.Tournaments.Tournament", b =>
{
b.Navigation("Divisions");
b.Navigation("Teams");
});
#pragma warning restore 612, 618
}
}
}
@@ -0,0 +1,65 @@
using Microsoft.EntityFrameworkCore.Migrations;
using System;
#nullable disable
namespace Persistance.Migrations;
/// <inheritdoc />
public partial class AddStageTeamMatchTable : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.CreateTable(
name: "StageTeamMatches",
schema: "Club12",
columns: table => new
{
Id = table.Column<Guid>(type: "uuid", nullable: false),
StageId = table.Column<Guid>(type: "uuid", nullable: false),
TeamId = table.Column<Guid>(type: "uuid", nullable: false),
DateCreated = table.Column<DateTime>(type: "timestamp without time zone", nullable: false),
DateUpdated = table.Column<DateTime>(type: "timestamp without time zone", nullable: true)
},
constraints: table =>
{
table.PrimaryKey("PK_StageTeamMatches", x => x.Id);
table.ForeignKey(
name: "FK_StageTeamMatches_Stages_StageId",
column: x => x.StageId,
principalSchema: "Club12",
principalTable: "Stages",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
table.ForeignKey(
name: "FK_StageTeamMatches_Teams_TeamId",
column: x => x.TeamId,
principalSchema: "Club12",
principalTable: "Teams",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateIndex(
name: "IX_StageTeamMatches_StageId",
schema: "Club12",
table: "StageTeamMatches",
column: "StageId");
migrationBuilder.CreateIndex(
name: "IX_StageTeamMatches_TeamId",
schema: "Club12",
table: "StageTeamMatches",
column: "TeamId");
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropTable(
name: "StageTeamMatches",
schema: "Club12");
}
}
@@ -0,0 +1,748 @@
// <auto-generated />
using System;
using Infrastructure.Persistance;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Migrations;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
#nullable disable
namespace Persistance.Migrations
{
[DbContext(typeof(ApplicationDBContext))]
[Migration("20260315232746_cleanDB")]
partial class cleanDB
{
/// <inheritdoc />
protected override void BuildTargetModel(ModelBuilder modelBuilder)
{
#pragma warning disable 612, 618
modelBuilder
.HasAnnotation("ProductVersion", "8.0.11")
.HasAnnotation("Relational:MaxIdentifierLength", 63);
NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder);
modelBuilder.Entity("Domain.Entities.Models.BlogPost", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uuid");
b.Property<string>("Author")
.IsRequired()
.HasMaxLength(50)
.HasColumnType("character varying(50)");
b.Property<string>("CreatedBy")
.IsRequired()
.HasColumnType("text");
b.Property<DateTime>("DateCreated")
.HasColumnType("timestamp without time zone");
b.Property<DateTime?>("DateUpdated")
.HasColumnType("timestamp without time zone");
b.Property<string>("MarkdownText")
.IsRequired()
.HasColumnType("text");
b.Property<string>("PhotoUrl")
.HasMaxLength(2048)
.HasColumnType("character varying(2048)");
b.Property<string>("Title")
.IsRequired()
.HasColumnType("text");
b.Property<string>("UpdatedBy")
.HasColumnType("text");
b.Property<int>("Views")
.HasColumnType("integer");
b.HasKey("Id");
b.HasIndex("DateCreated")
.HasDatabaseName("IX_BlogPost_CreatedAt");
b.ToTable("BlogPosts", "Club12");
});
modelBuilder.Entity("Domain.Entities.Models.Division", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uuid");
b.Property<string>("CreatedBy")
.IsRequired()
.HasColumnType("text");
b.Property<DateTime>("DateCreated")
.HasColumnType("timestamp without time zone");
b.Property<DateTime?>("DateUpdated")
.HasColumnType("timestamp without time zone");
b.Property<bool>("IsFinished")
.HasColumnType("boolean");
b.Property<string>("Name")
.IsRequired()
.HasMaxLength(30)
.HasColumnType("character varying(30)");
b.Property<Guid>("TournamentId")
.HasColumnType("uuid");
b.Property<string>("UpdatedBy")
.HasColumnType("text");
b.HasKey("Id");
b.HasIndex("DateCreated")
.HasDatabaseName("IX_Division_CreatedAt");
b.HasIndex("TournamentId");
b.ToTable("Divisions", "Club12");
});
modelBuilder.Entity("Domain.Entities.Models.Match", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uuid");
b.Property<string>("CreatedBy")
.IsRequired()
.HasColumnType("text");
b.Property<DateTime>("DateCreated")
.HasColumnType("timestamp without time zone");
b.Property<DateTime?>("DateUpdated")
.HasColumnType("timestamp without time zone");
b.Property<int?>("HomeScore")
.HasColumnType("integer");
b.Property<Guid?>("HomeTeamId")
.HasColumnType("uuid");
b.Property<bool>("IsFinished")
.HasColumnType("boolean");
b.Property<DateTime>("MatchDate")
.HasColumnType("timestamp without time zone");
b.Property<Guid>("StageId")
.HasColumnType("uuid");
b.Property<string>("Type")
.IsRequired()
.HasColumnType("text");
b.Property<string>("UpdatedBy")
.HasColumnType("text");
b.Property<Guid?>("VenueId")
.HasColumnType("uuid");
b.Property<int?>("VisitorScore")
.HasColumnType("integer");
b.Property<Guid?>("VisitorTeamId")
.HasColumnType("uuid");
b.Property<Guid?>("WinningTeamId")
.HasColumnType("uuid");
b.HasKey("Id");
b.HasIndex("DateCreated")
.HasDatabaseName("IX_Match_CreatedAt");
b.HasIndex("HomeTeamId");
b.HasIndex("StageId");
b.HasIndex("VenueId");
b.HasIndex("VisitorTeamId");
b.HasIndex("WinningTeamId");
b.ToTable("Matches", "Club12");
});
modelBuilder.Entity("Domain.Entities.Models.Player", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uuid");
b.Property<DateTime>("BirthDate")
.HasColumnType("timestamp without time zone");
b.Property<string>("CreatedBy")
.IsRequired()
.HasColumnType("text");
b.Property<DateTime>("DateCreated")
.HasColumnType("timestamp without time zone");
b.Property<DateTime?>("DateUpdated")
.HasColumnType("timestamp without time zone");
b.Property<string>("DocumentNumber")
.IsRequired()
.HasMaxLength(15)
.HasColumnType("character varying(15)");
b.Property<string>("FirstName")
.IsRequired()
.HasMaxLength(70)
.HasColumnType("character varying(70)");
b.Property<bool>("IsSanctioned")
.HasColumnType("boolean");
b.Property<string>("LastName")
.IsRequired()
.HasMaxLength(70)
.HasColumnType("character varying(70)");
b.Property<string>("PhoneNumber")
.HasColumnType("text");
b.Property<string>("SecondName")
.HasMaxLength(70)
.HasColumnType("character varying(70)");
b.Property<string>("SocialSecurity")
.IsRequired()
.HasMaxLength(100)
.HasColumnType("character varying(100)");
b.Property<Guid>("TeamId")
.HasColumnType("uuid");
b.Property<string>("UpdatedBy")
.HasColumnType("text");
b.HasKey("Id");
b.HasIndex("DateCreated")
.HasDatabaseName("IX_Player_CreatedAt");
b.HasIndex("DocumentNumber")
.IsUnique();
b.HasIndex("TeamId");
b.ToTable("Players", "Club12");
});
modelBuilder.Entity("Domain.Entities.Models.PlayerSanction", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uuid");
b.Property<string>("CreatedBy")
.IsRequired()
.HasColumnType("text");
b.Property<DateTime>("DateCreated")
.HasColumnType("timestamp without time zone");
b.Property<DateTime?>("DateUpdated")
.HasColumnType("timestamp without time zone");
b.Property<string>("Description")
.IsRequired()
.HasMaxLength(255)
.HasColumnType("character varying(255)");
b.Property<int>("Duration")
.HasColumnType("integer");
b.Property<DateTime>("IssuedDate")
.HasColumnType("timestamp without time zone");
b.Property<Guid>("MatchId")
.HasColumnType("uuid");
b.Property<Guid>("PlayerId")
.HasColumnType("uuid");
b.Property<string>("UpdatedBy")
.HasColumnType("text");
b.HasKey("Id");
b.HasIndex("DateCreated")
.HasDatabaseName("IX_PlayerSanction_CreatedAt");
b.HasIndex("MatchId");
b.HasIndex("PlayerId");
b.ToTable("PlayerSanctions", "Club12");
});
modelBuilder.Entity("Domain.Entities.Models.PlayerStatistic", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uuid");
b.Property<string>("CreatedBy")
.IsRequired()
.HasColumnType("text");
b.Property<DateTime>("DateCreated")
.HasColumnType("timestamp without time zone");
b.Property<DateTime?>("DateUpdated")
.HasColumnType("timestamp without time zone");
b.Property<Guid>("MatchId")
.HasColumnType("uuid");
b.Property<Guid>("PlayerId")
.HasColumnType("uuid");
b.Property<string>("UpdatedBy")
.HasColumnType("text");
b.Property<int>("Value")
.HasColumnType("integer");
b.HasKey("Id");
b.HasIndex("DateCreated")
.HasDatabaseName("IX_PlayerStatistic_CreatedAt");
b.HasIndex("MatchId");
b.HasIndex("PlayerId");
b.ToTable("PlayersStatistics", "Club12");
});
modelBuilder.Entity("Domain.Entities.Models.Stage", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uuid");
b.Property<string>("CreatedBy")
.IsRequired()
.HasColumnType("text");
b.Property<DateTime>("DateCreated")
.HasColumnType("timestamp without time zone");
b.Property<DateTime?>("DateUpdated")
.HasColumnType("timestamp without time zone");
b.Property<string>("Description")
.HasMaxLength(1000)
.HasColumnType("character varying(1000)");
b.Property<Guid>("DivisionId")
.HasColumnType("uuid");
b.Property<DateTime>("EndDate")
.HasColumnType("timestamp without time zone");
b.Property<bool>("IsActive")
.HasColumnType("boolean");
b.Property<bool>("IsElimination")
.HasColumnType("boolean");
b.Property<string>("Name")
.IsRequired()
.HasMaxLength(100)
.HasColumnType("character varying(100)");
b.Property<int>("Order")
.HasColumnType("integer");
b.Property<string>("StageType")
.IsRequired()
.HasColumnType("text");
b.Property<DateTime>("StartDate")
.HasColumnType("timestamp without time zone");
b.Property<string>("UpdatedBy")
.HasColumnType("text");
b.HasKey("Id");
b.HasIndex("DateCreated")
.HasDatabaseName("IX_Stage_CreatedAt");
b.HasIndex("DivisionId");
b.HasIndex("Name", "DivisionId")
.IsUnique()
.HasDatabaseName("CONSTRAINT_UNIQUE_STAGE_NAME_AND_DIVISIONID");
b.ToTable("Stages", "Club12");
});
modelBuilder.Entity("Domain.Entities.Models.StageTeamMatch", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uuid");
b.Property<string>("CreatedBy")
.IsRequired()
.HasColumnType("text");
b.Property<DateTime>("DateCreated")
.HasColumnType("timestamp without time zone");
b.Property<DateTime?>("DateUpdated")
.HasColumnType("timestamp without time zone");
b.Property<Guid>("StageId")
.HasColumnType("uuid");
b.Property<Guid>("TeamId")
.HasColumnType("uuid");
b.Property<string>("UpdatedBy")
.HasColumnType("text");
b.HasKey("Id");
b.HasIndex("DateCreated")
.HasDatabaseName("IX_StageTeamMatch_CreatedAt");
b.HasIndex("StageId");
b.HasIndex("TeamId");
b.ToTable("StageTeamMatches", "Club12");
});
modelBuilder.Entity("Domain.Entities.Models.Team", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uuid");
b.Property<string>("CreatedBy")
.IsRequired()
.HasColumnType("text");
b.Property<DateTime>("DateCreated")
.HasColumnType("timestamp without time zone");
b.Property<DateTime?>("DateUpdated")
.HasColumnType("timestamp without time zone");
b.Property<string>("LogoUrl")
.IsRequired()
.HasColumnType("text");
b.Property<string>("Name")
.IsRequired()
.HasColumnType("text");
b.Property<string>("ShirtColor")
.IsRequired()
.HasColumnType("text");
b.Property<string>("ThreeLetterCode")
.IsRequired()
.HasColumnType("text");
b.Property<Guid?>("TournamentId")
.HasColumnType("uuid");
b.Property<string>("UpdatedBy")
.HasColumnType("text");
b.HasKey("Id");
b.HasIndex("DateCreated")
.HasDatabaseName("IX_Team_CreatedAt");
b.HasIndex("TournamentId");
b.ToTable("Teams", "Club12");
});
modelBuilder.Entity("Domain.Entities.Models.Tournament", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uuid");
b.Property<string>("CreatedBy")
.IsRequired()
.HasColumnType("text");
b.Property<DateTime>("DateCreated")
.HasColumnType("timestamp without time zone");
b.Property<DateTime?>("DateUpdated")
.HasColumnType("timestamp without time zone");
b.Property<string>("Description")
.IsRequired()
.HasColumnType("text");
b.Property<bool>("IsFinished")
.HasColumnType("boolean");
b.Property<int>("MaxTeams")
.HasColumnType("integer");
b.Property<int>("MinTeams")
.HasColumnType("integer");
b.Property<string>("Name")
.IsRequired()
.HasColumnType("text");
b.Property<DateTime>("StartDate")
.HasColumnType("timestamp without time zone");
b.Property<DateTime>("TeamRegistrationDeadline")
.HasColumnType("timestamp without time zone");
b.Property<string>("UpdatedBy")
.HasColumnType("text");
b.HasKey("Id");
b.HasIndex("DateCreated")
.HasDatabaseName("IX_Tournament_CreatedAt");
b.ToTable("Tournaments", "Club12", t =>
{
t.HasCheckConstraint("CK_Tournament_DeadlineBeforeStart", "\"TeamRegistrationDeadline\" < \"StartDate\"");
});
});
modelBuilder.Entity("Domain.Entities.Models.Venue", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uuid");
b.Property<string>("Address")
.IsRequired()
.HasMaxLength(200)
.HasColumnType("character varying(200)");
b.Property<string>("CreatedBy")
.IsRequired()
.HasColumnType("text");
b.Property<DateTime>("DateCreated")
.HasColumnType("timestamp without time zone");
b.Property<DateTime?>("DateUpdated")
.HasColumnType("timestamp without time zone");
b.Property<string>("Name")
.IsRequired()
.HasMaxLength(50)
.HasColumnType("character varying(50)");
b.Property<string>("PhotoUrl")
.HasColumnType("text");
b.Property<string>("UpdatedBy")
.HasColumnType("text");
b.HasKey("Id");
b.HasIndex("DateCreated")
.HasDatabaseName("IX_Venue_CreatedAt");
b.ToTable("Venues", "Club12");
});
modelBuilder.Entity("Domain.Entities.Models.Division", b =>
{
b.HasOne("Domain.Entities.Models.Tournament", "Tournament")
.WithMany("Divisions")
.HasForeignKey("TournamentId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Tournament");
});
modelBuilder.Entity("Domain.Entities.Models.Match", b =>
{
b.HasOne("Domain.Entities.Models.Team", "HomeTeam")
.WithMany()
.HasForeignKey("HomeTeamId");
b.HasOne("Domain.Entities.Models.Stage", "Stage")
.WithMany("Matches")
.HasForeignKey("StageId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("Domain.Entities.Models.Venue", "Venue")
.WithMany()
.HasForeignKey("VenueId");
b.HasOne("Domain.Entities.Models.Team", "VisitorTeam")
.WithMany()
.HasForeignKey("VisitorTeamId");
b.HasOne("Domain.Entities.Models.Team", "WinningTeam")
.WithMany()
.HasForeignKey("WinningTeamId");
b.Navigation("HomeTeam");
b.Navigation("Stage");
b.Navigation("Venue");
b.Navigation("VisitorTeam");
b.Navigation("WinningTeam");
});
modelBuilder.Entity("Domain.Entities.Models.Player", b =>
{
b.HasOne("Domain.Entities.Models.Team", "Team")
.WithMany("Players")
.HasForeignKey("TeamId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Team");
});
modelBuilder.Entity("Domain.Entities.Models.PlayerSanction", b =>
{
b.HasOne("Domain.Entities.Models.Match", "Match")
.WithMany()
.HasForeignKey("MatchId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("Domain.Entities.Models.Player", "Player")
.WithMany()
.HasForeignKey("PlayerId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Match");
b.Navigation("Player");
});
modelBuilder.Entity("Domain.Entities.Models.PlayerStatistic", b =>
{
b.HasOne("Domain.Entities.Models.Match", "Match")
.WithMany("PlayerStatistics")
.HasForeignKey("MatchId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("Domain.Entities.Models.Player", "Player")
.WithMany()
.HasForeignKey("PlayerId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Match");
b.Navigation("Player");
});
modelBuilder.Entity("Domain.Entities.Models.Stage", b =>
{
b.HasOne("Domain.Entities.Models.Division", "Division")
.WithMany("Stages")
.HasForeignKey("DivisionId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Division");
});
modelBuilder.Entity("Domain.Entities.Models.StageTeamMatch", b =>
{
b.HasOne("Domain.Entities.Models.Stage", "Stage")
.WithMany("StageTeamMatches")
.HasForeignKey("StageId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("Domain.Entities.Models.Team", "Team")
.WithMany("StageTeamMatches")
.HasForeignKey("TeamId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Stage");
b.Navigation("Team");
});
modelBuilder.Entity("Domain.Entities.Models.Team", b =>
{
b.HasOne("Domain.Entities.Models.Tournament", "Tournament")
.WithMany("Teams")
.HasForeignKey("TournamentId");
b.Navigation("Tournament");
});
modelBuilder.Entity("Domain.Entities.Models.Division", b =>
{
b.Navigation("Stages");
});
modelBuilder.Entity("Domain.Entities.Models.Match", b =>
{
b.Navigation("PlayerStatistics");
});
modelBuilder.Entity("Domain.Entities.Models.Stage", b =>
{
b.Navigation("Matches");
b.Navigation("StageTeamMatches");
});
modelBuilder.Entity("Domain.Entities.Models.Team", b =>
{
b.Navigation("Players");
b.Navigation("StageTeamMatches");
});
modelBuilder.Entity("Domain.Entities.Models.Tournament", b =>
{
b.Navigation("Divisions");
b.Navigation("Teams");
});
#pragma warning restore 612, 618
}
}
}
@@ -0,0 +1,474 @@
using Microsoft.EntityFrameworkCore.Migrations;
using System;
#nullable disable
namespace Persistance.Migrations;
/// <inheritdoc />
public partial class cleanDB : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropTable(
name: "Staffs",
schema: "Club12");
migrationBuilder.DropTable(
name: "Users",
schema: "Club12");
migrationBuilder.AddColumn<string>(
name: "CreatedBy",
schema: "Club12",
table: "Venues",
type: "text",
nullable: false,
defaultValue: "");
migrationBuilder.AddColumn<string>(
name: "UpdatedBy",
schema: "Club12",
table: "Venues",
type: "text",
nullable: true);
migrationBuilder.AddColumn<string>(
name: "CreatedBy",
schema: "Club12",
table: "Tournaments",
type: "text",
nullable: false,
defaultValue: "");
migrationBuilder.AddColumn<string>(
name: "UpdatedBy",
schema: "Club12",
table: "Tournaments",
type: "text",
nullable: true);
migrationBuilder.AddColumn<string>(
name: "CreatedBy",
schema: "Club12",
table: "Teams",
type: "text",
nullable: false,
defaultValue: "");
migrationBuilder.AddColumn<string>(
name: "UpdatedBy",
schema: "Club12",
table: "Teams",
type: "text",
nullable: true);
migrationBuilder.AddColumn<string>(
name: "CreatedBy",
schema: "Club12",
table: "StageTeamMatches",
type: "text",
nullable: false,
defaultValue: "");
migrationBuilder.AddColumn<string>(
name: "UpdatedBy",
schema: "Club12",
table: "StageTeamMatches",
type: "text",
nullable: true);
migrationBuilder.AddColumn<string>(
name: "CreatedBy",
schema: "Club12",
table: "Stages",
type: "text",
nullable: false,
defaultValue: "");
migrationBuilder.AddColumn<string>(
name: "UpdatedBy",
schema: "Club12",
table: "Stages",
type: "text",
nullable: true);
migrationBuilder.AddColumn<string>(
name: "CreatedBy",
schema: "Club12",
table: "PlayersStatistics",
type: "text",
nullable: false,
defaultValue: "");
migrationBuilder.AddColumn<string>(
name: "UpdatedBy",
schema: "Club12",
table: "PlayersStatistics",
type: "text",
nullable: true);
migrationBuilder.AddColumn<string>(
name: "CreatedBy",
schema: "Club12",
table: "PlayerSanctions",
type: "text",
nullable: false,
defaultValue: "");
migrationBuilder.AddColumn<string>(
name: "UpdatedBy",
schema: "Club12",
table: "PlayerSanctions",
type: "text",
nullable: true);
migrationBuilder.AddColumn<string>(
name: "CreatedBy",
schema: "Club12",
table: "Players",
type: "text",
nullable: false,
defaultValue: "");
migrationBuilder.AddColumn<string>(
name: "UpdatedBy",
schema: "Club12",
table: "Players",
type: "text",
nullable: true);
migrationBuilder.AddColumn<string>(
name: "CreatedBy",
schema: "Club12",
table: "Matches",
type: "text",
nullable: false,
defaultValue: "");
migrationBuilder.AddColumn<string>(
name: "UpdatedBy",
schema: "Club12",
table: "Matches",
type: "text",
nullable: true);
migrationBuilder.AddColumn<string>(
name: "CreatedBy",
schema: "Club12",
table: "Divisions",
type: "text",
nullable: false,
defaultValue: "");
migrationBuilder.AddColumn<string>(
name: "UpdatedBy",
schema: "Club12",
table: "Divisions",
type: "text",
nullable: true);
migrationBuilder.AddColumn<string>(
name: "CreatedBy",
schema: "Club12",
table: "BlogPosts",
type: "text",
nullable: false,
defaultValue: "");
migrationBuilder.AddColumn<string>(
name: "UpdatedBy",
schema: "Club12",
table: "BlogPosts",
type: "text",
nullable: true);
migrationBuilder.CreateIndex(
name: "IX_Venue_CreatedAt",
schema: "Club12",
table: "Venues",
column: "DateCreated");
migrationBuilder.CreateIndex(
name: "IX_Tournament_CreatedAt",
schema: "Club12",
table: "Tournaments",
column: "DateCreated");
migrationBuilder.CreateIndex(
name: "IX_Team_CreatedAt",
schema: "Club12",
table: "Teams",
column: "DateCreated");
migrationBuilder.CreateIndex(
name: "IX_StageTeamMatch_CreatedAt",
schema: "Club12",
table: "StageTeamMatches",
column: "DateCreated");
migrationBuilder.CreateIndex(
name: "IX_Stage_CreatedAt",
schema: "Club12",
table: "Stages",
column: "DateCreated");
migrationBuilder.CreateIndex(
name: "IX_PlayerStatistic_CreatedAt",
schema: "Club12",
table: "PlayersStatistics",
column: "DateCreated");
migrationBuilder.CreateIndex(
name: "IX_PlayerSanction_CreatedAt",
schema: "Club12",
table: "PlayerSanctions",
column: "DateCreated");
migrationBuilder.CreateIndex(
name: "IX_Player_CreatedAt",
schema: "Club12",
table: "Players",
column: "DateCreated");
migrationBuilder.CreateIndex(
name: "IX_Match_CreatedAt",
schema: "Club12",
table: "Matches",
column: "DateCreated");
migrationBuilder.CreateIndex(
name: "IX_Division_CreatedAt",
schema: "Club12",
table: "Divisions",
column: "DateCreated");
migrationBuilder.CreateIndex(
name: "IX_BlogPost_CreatedAt",
schema: "Club12",
table: "BlogPosts",
column: "DateCreated");
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropIndex(
name: "IX_Venue_CreatedAt",
schema: "Club12",
table: "Venues");
migrationBuilder.DropIndex(
name: "IX_Tournament_CreatedAt",
schema: "Club12",
table: "Tournaments");
migrationBuilder.DropIndex(
name: "IX_Team_CreatedAt",
schema: "Club12",
table: "Teams");
migrationBuilder.DropIndex(
name: "IX_StageTeamMatch_CreatedAt",
schema: "Club12",
table: "StageTeamMatches");
migrationBuilder.DropIndex(
name: "IX_Stage_CreatedAt",
schema: "Club12",
table: "Stages");
migrationBuilder.DropIndex(
name: "IX_PlayerStatistic_CreatedAt",
schema: "Club12",
table: "PlayersStatistics");
migrationBuilder.DropIndex(
name: "IX_PlayerSanction_CreatedAt",
schema: "Club12",
table: "PlayerSanctions");
migrationBuilder.DropIndex(
name: "IX_Player_CreatedAt",
schema: "Club12",
table: "Players");
migrationBuilder.DropIndex(
name: "IX_Match_CreatedAt",
schema: "Club12",
table: "Matches");
migrationBuilder.DropIndex(
name: "IX_Division_CreatedAt",
schema: "Club12",
table: "Divisions");
migrationBuilder.DropIndex(
name: "IX_BlogPost_CreatedAt",
schema: "Club12",
table: "BlogPosts");
migrationBuilder.DropColumn(
name: "CreatedBy",
schema: "Club12",
table: "Venues");
migrationBuilder.DropColumn(
name: "UpdatedBy",
schema: "Club12",
table: "Venues");
migrationBuilder.DropColumn(
name: "CreatedBy",
schema: "Club12",
table: "Tournaments");
migrationBuilder.DropColumn(
name: "UpdatedBy",
schema: "Club12",
table: "Tournaments");
migrationBuilder.DropColumn(
name: "CreatedBy",
schema: "Club12",
table: "Teams");
migrationBuilder.DropColumn(
name: "UpdatedBy",
schema: "Club12",
table: "Teams");
migrationBuilder.DropColumn(
name: "CreatedBy",
schema: "Club12",
table: "StageTeamMatches");
migrationBuilder.DropColumn(
name: "UpdatedBy",
schema: "Club12",
table: "StageTeamMatches");
migrationBuilder.DropColumn(
name: "CreatedBy",
schema: "Club12",
table: "Stages");
migrationBuilder.DropColumn(
name: "UpdatedBy",
schema: "Club12",
table: "Stages");
migrationBuilder.DropColumn(
name: "CreatedBy",
schema: "Club12",
table: "PlayersStatistics");
migrationBuilder.DropColumn(
name: "UpdatedBy",
schema: "Club12",
table: "PlayersStatistics");
migrationBuilder.DropColumn(
name: "CreatedBy",
schema: "Club12",
table: "PlayerSanctions");
migrationBuilder.DropColumn(
name: "UpdatedBy",
schema: "Club12",
table: "PlayerSanctions");
migrationBuilder.DropColumn(
name: "CreatedBy",
schema: "Club12",
table: "Players");
migrationBuilder.DropColumn(
name: "UpdatedBy",
schema: "Club12",
table: "Players");
migrationBuilder.DropColumn(
name: "CreatedBy",
schema: "Club12",
table: "Matches");
migrationBuilder.DropColumn(
name: "UpdatedBy",
schema: "Club12",
table: "Matches");
migrationBuilder.DropColumn(
name: "CreatedBy",
schema: "Club12",
table: "Divisions");
migrationBuilder.DropColumn(
name: "UpdatedBy",
schema: "Club12",
table: "Divisions");
migrationBuilder.DropColumn(
name: "CreatedBy",
schema: "Club12",
table: "BlogPosts");
migrationBuilder.DropColumn(
name: "UpdatedBy",
schema: "Club12",
table: "BlogPosts");
migrationBuilder.CreateTable(
name: "Staffs",
schema: "Club12",
columns: table => new
{
Id = table.Column<Guid>(type: "uuid", nullable: false),
TeamId = table.Column<Guid>(type: "uuid", nullable: false),
DateCreated = table.Column<DateTime>(type: "timestamp without time zone", nullable: false),
DateUpdated = table.Column<DateTime>(type: "timestamp without time zone", nullable: true),
LastName = table.Column<string>(type: "character varying(50)", maxLength: 50, nullable: false),
Names = table.Column<string>(type: "character varying(50)", maxLength: 50, nullable: false),
PhoneNumber = table.Column<string>(type: "character varying(15)", maxLength: 15, nullable: false),
Type = table.Column<string>(type: "text", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_Staffs", x => x.Id);
table.ForeignKey(
name: "FK_Staffs_Teams_TeamId",
column: x => x.TeamId,
principalSchema: "Club12",
principalTable: "Teams",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateTable(
name: "Users",
schema: "Club12",
columns: table => new
{
Id = table.Column<Guid>(type: "uuid", nullable: false),
DateCreated = table.Column<DateTime>(type: "timestamp without time zone", nullable: false),
DateUpdated = table.Column<DateTime>(type: "timestamp without time zone", nullable: true),
Password = table.Column<string>(type: "character varying(64)", maxLength: 64, nullable: false),
RefreshToken = table.Column<string>(type: "character varying(256)", maxLength: 256, nullable: true),
RefreshTokenExpiryTime = table.Column<DateTime>(type: "timestamp without time zone", nullable: true),
Role = table.Column<string>(type: "character varying(10)", maxLength: 10, nullable: false),
Username = table.Column<string>(type: "character varying(25)", maxLength: 25, nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_Users", x => x.Id);
});
migrationBuilder.CreateIndex(
name: "IX_Staffs_TeamId",
schema: "Club12",
table: "Staffs",
column: "TeamId");
}
}
@@ -0,0 +1,750 @@
// <auto-generated />
using System;
using Infrastructure.Persistance;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Migrations;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
#nullable disable
namespace Persistance.Migrations
{
[DbContext(typeof(ApplicationDBContext))]
[Migration("20260326234428_changeTournamentEntity")]
partial class changeTournamentEntity
{
/// <inheritdoc />
protected override void BuildTargetModel(ModelBuilder modelBuilder)
{
#pragma warning disable 612, 618
modelBuilder
.HasAnnotation("ProductVersion", "8.0.11")
.HasAnnotation("Relational:MaxIdentifierLength", 63);
NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder);
modelBuilder.Entity("Domain.Entities.Models.BlogPost", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uuid");
b.Property<string>("Author")
.IsRequired()
.HasMaxLength(50)
.HasColumnType("character varying(50)");
b.Property<string>("CreatedBy")
.IsRequired()
.HasColumnType("text");
b.Property<DateTime>("DateCreated")
.HasColumnType("timestamp without time zone");
b.Property<DateTime?>("DateUpdated")
.HasColumnType("timestamp without time zone");
b.Property<string>("MarkdownText")
.IsRequired()
.HasColumnType("text");
b.Property<string>("PhotoUrl")
.HasMaxLength(2048)
.HasColumnType("character varying(2048)");
b.Property<string>("Title")
.IsRequired()
.HasColumnType("text");
b.Property<string>("UpdatedBy")
.HasColumnType("text");
b.Property<int>("Views")
.HasColumnType("integer");
b.HasKey("Id");
b.HasIndex("DateCreated")
.HasDatabaseName("IX_BlogPost_CreatedAt");
b.ToTable("BlogPosts", "Club12");
});
modelBuilder.Entity("Domain.Entities.Models.Division", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uuid");
b.Property<string>("CreatedBy")
.IsRequired()
.HasColumnType("text");
b.Property<DateTime>("DateCreated")
.HasColumnType("timestamp without time zone");
b.Property<DateTime?>("DateUpdated")
.HasColumnType("timestamp without time zone");
b.Property<bool>("IsFinished")
.HasColumnType("boolean");
b.Property<string>("Name")
.IsRequired()
.HasMaxLength(30)
.HasColumnType("character varying(30)");
b.Property<Guid>("TournamentId")
.HasColumnType("uuid");
b.Property<string>("UpdatedBy")
.HasColumnType("text");
b.HasKey("Id");
b.HasIndex("DateCreated")
.HasDatabaseName("IX_Division_CreatedAt");
b.HasIndex("TournamentId");
b.ToTable("Divisions", "Club12");
});
modelBuilder.Entity("Domain.Entities.Models.Match", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uuid");
b.Property<string>("CreatedBy")
.IsRequired()
.HasColumnType("text");
b.Property<DateTime>("DateCreated")
.HasColumnType("timestamp without time zone");
b.Property<DateTime?>("DateUpdated")
.HasColumnType("timestamp without time zone");
b.Property<int?>("HomeScore")
.HasColumnType("integer");
b.Property<Guid?>("HomeTeamId")
.HasColumnType("uuid");
b.Property<bool>("IsFinished")
.HasColumnType("boolean");
b.Property<DateTime>("MatchDate")
.HasColumnType("timestamp without time zone");
b.Property<Guid>("StageId")
.HasColumnType("uuid");
b.Property<string>("Type")
.IsRequired()
.HasColumnType("text");
b.Property<string>("UpdatedBy")
.HasColumnType("text");
b.Property<Guid?>("VenueId")
.HasColumnType("uuid");
b.Property<int?>("VisitorScore")
.HasColumnType("integer");
b.Property<Guid?>("VisitorTeamId")
.HasColumnType("uuid");
b.Property<Guid?>("WinningTeamId")
.HasColumnType("uuid");
b.HasKey("Id");
b.HasIndex("DateCreated")
.HasDatabaseName("IX_Match_CreatedAt");
b.HasIndex("HomeTeamId");
b.HasIndex("StageId");
b.HasIndex("VenueId");
b.HasIndex("VisitorTeamId");
b.HasIndex("WinningTeamId");
b.ToTable("Matches", "Club12");
});
modelBuilder.Entity("Domain.Entities.Models.Player", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uuid");
b.Property<DateTime>("BirthDate")
.HasColumnType("timestamp without time zone");
b.Property<string>("CreatedBy")
.IsRequired()
.HasColumnType("text");
b.Property<DateTime>("DateCreated")
.HasColumnType("timestamp without time zone");
b.Property<DateTime?>("DateUpdated")
.HasColumnType("timestamp without time zone");
b.Property<string>("DocumentNumber")
.IsRequired()
.HasMaxLength(15)
.HasColumnType("character varying(15)");
b.Property<string>("FirstName")
.IsRequired()
.HasMaxLength(70)
.HasColumnType("character varying(70)");
b.Property<bool>("IsSanctioned")
.HasColumnType("boolean");
b.Property<string>("LastName")
.IsRequired()
.HasMaxLength(70)
.HasColumnType("character varying(70)");
b.Property<string>("PhoneNumber")
.HasColumnType("text");
b.Property<string>("SecondName")
.HasMaxLength(70)
.HasColumnType("character varying(70)");
b.Property<string>("SocialSecurity")
.IsRequired()
.HasMaxLength(100)
.HasColumnType("character varying(100)");
b.Property<Guid>("TeamId")
.HasColumnType("uuid");
b.Property<string>("UpdatedBy")
.HasColumnType("text");
b.HasKey("Id");
b.HasIndex("DateCreated")
.HasDatabaseName("IX_Player_CreatedAt");
b.HasIndex("DocumentNumber")
.IsUnique();
b.HasIndex("TeamId");
b.ToTable("Players", "Club12");
});
modelBuilder.Entity("Domain.Entities.Models.PlayerSanction", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uuid");
b.Property<string>("CreatedBy")
.IsRequired()
.HasColumnType("text");
b.Property<DateTime>("DateCreated")
.HasColumnType("timestamp without time zone");
b.Property<DateTime?>("DateUpdated")
.HasColumnType("timestamp without time zone");
b.Property<string>("Description")
.IsRequired()
.HasMaxLength(255)
.HasColumnType("character varying(255)");
b.Property<int>("Duration")
.HasColumnType("integer");
b.Property<DateTime>("IssuedDate")
.HasColumnType("timestamp without time zone");
b.Property<Guid>("MatchId")
.HasColumnType("uuid");
b.Property<Guid>("PlayerId")
.HasColumnType("uuid");
b.Property<string>("UpdatedBy")
.HasColumnType("text");
b.HasKey("Id");
b.HasIndex("DateCreated")
.HasDatabaseName("IX_PlayerSanction_CreatedAt");
b.HasIndex("MatchId");
b.HasIndex("PlayerId");
b.ToTable("PlayerSanctions", "Club12");
});
modelBuilder.Entity("Domain.Entities.Models.PlayerStatistic", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uuid");
b.Property<string>("CreatedBy")
.IsRequired()
.HasColumnType("text");
b.Property<DateTime>("DateCreated")
.HasColumnType("timestamp without time zone");
b.Property<DateTime?>("DateUpdated")
.HasColumnType("timestamp without time zone");
b.Property<Guid>("MatchId")
.HasColumnType("uuid");
b.Property<Guid>("PlayerId")
.HasColumnType("uuid");
b.Property<string>("UpdatedBy")
.HasColumnType("text");
b.Property<int>("Value")
.HasColumnType("integer");
b.HasKey("Id");
b.HasIndex("DateCreated")
.HasDatabaseName("IX_PlayerStatistic_CreatedAt");
b.HasIndex("MatchId");
b.HasIndex("PlayerId");
b.ToTable("PlayersStatistics", "Club12");
});
modelBuilder.Entity("Domain.Entities.Models.Stage", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uuid");
b.Property<string>("CreatedBy")
.IsRequired()
.HasColumnType("text");
b.Property<DateTime>("DateCreated")
.HasColumnType("timestamp without time zone");
b.Property<DateTime?>("DateUpdated")
.HasColumnType("timestamp without time zone");
b.Property<string>("Description")
.HasMaxLength(1000)
.HasColumnType("character varying(1000)");
b.Property<Guid>("DivisionId")
.HasColumnType("uuid");
b.Property<DateTime>("EndDate")
.HasColumnType("timestamp without time zone");
b.Property<bool>("IsActive")
.HasColumnType("boolean");
b.Property<bool>("IsElimination")
.HasColumnType("boolean");
b.Property<string>("Name")
.IsRequired()
.HasMaxLength(100)
.HasColumnType("character varying(100)");
b.Property<int>("Order")
.HasColumnType("integer");
b.Property<string>("StageType")
.IsRequired()
.HasColumnType("text");
b.Property<DateTime>("StartDate")
.HasColumnType("timestamp without time zone");
b.Property<string>("UpdatedBy")
.HasColumnType("text");
b.HasKey("Id");
b.HasIndex("DateCreated")
.HasDatabaseName("IX_Stage_CreatedAt");
b.HasIndex("DivisionId");
b.HasIndex("Name", "DivisionId")
.IsUnique()
.HasDatabaseName("CONSTRAINT_UNIQUE_STAGE_NAME_AND_DIVISIONID");
b.ToTable("Stages", "Club12");
});
modelBuilder.Entity("Domain.Entities.Models.StageTeamMatch", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uuid");
b.Property<string>("CreatedBy")
.IsRequired()
.HasColumnType("text");
b.Property<DateTime>("DateCreated")
.HasColumnType("timestamp without time zone");
b.Property<DateTime?>("DateUpdated")
.HasColumnType("timestamp without time zone");
b.Property<Guid>("StageId")
.HasColumnType("uuid");
b.Property<Guid>("TeamId")
.HasColumnType("uuid");
b.Property<string>("UpdatedBy")
.HasColumnType("text");
b.HasKey("Id");
b.HasIndex("DateCreated")
.HasDatabaseName("IX_StageTeamMatch_CreatedAt");
b.HasIndex("StageId");
b.HasIndex("TeamId");
b.ToTable("StageTeamMatches", "Club12");
});
modelBuilder.Entity("Domain.Entities.Models.Team", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uuid");
b.Property<string>("CreatedBy")
.IsRequired()
.HasColumnType("text");
b.Property<DateTime>("DateCreated")
.HasColumnType("timestamp without time zone");
b.Property<DateTime?>("DateUpdated")
.HasColumnType("timestamp without time zone");
b.Property<string>("LogoUrl")
.IsRequired()
.HasColumnType("text");
b.Property<string>("Name")
.IsRequired()
.HasColumnType("text");
b.Property<string>("ShirtColor")
.IsRequired()
.HasColumnType("text");
b.Property<string>("ThreeLetterCode")
.IsRequired()
.HasColumnType("text");
b.Property<Guid?>("TournamentId")
.HasColumnType("uuid");
b.Property<string>("UpdatedBy")
.HasColumnType("text");
b.HasKey("Id");
b.HasIndex("DateCreated")
.HasDatabaseName("IX_Team_CreatedAt");
b.HasIndex("TournamentId");
b.ToTable("Teams", "Club12");
});
modelBuilder.Entity("Domain.Entities.Models.Tournament", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uuid");
b.Property<string>("CreatedBy")
.IsRequired()
.HasColumnType("text");
b.Property<DateTime>("DateCreated")
.HasColumnType("timestamp without time zone");
b.Property<DateTime?>("DateUpdated")
.HasColumnType("timestamp without time zone");
b.Property<string>("Description")
.IsRequired()
.HasColumnType("text");
b.Property<int>("MaxTeams")
.HasColumnType("integer");
b.Property<int>("MinTeams")
.HasColumnType("integer");
b.Property<string>("Name")
.IsRequired()
.HasColumnType("text");
b.Property<DateTime>("StartDate")
.HasColumnType("timestamp without time zone");
b.Property<int>("Status")
.ValueGeneratedOnAdd()
.HasColumnType("integer")
.HasDefaultValue(0);
b.Property<DateTime>("TeamRegistrationDeadline")
.HasColumnType("timestamp without time zone");
b.Property<string>("UpdatedBy")
.HasColumnType("text");
b.HasKey("Id");
b.HasIndex("DateCreated")
.HasDatabaseName("IX_Tournament_CreatedAt");
b.ToTable("Tournaments", "Club12", t =>
{
t.HasCheckConstraint("CK_Tournament_DeadlineBeforeStart", "\"TeamRegistrationDeadline\" < \"StartDate\"");
});
});
modelBuilder.Entity("Domain.Entities.Models.Venue", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uuid");
b.Property<string>("Address")
.IsRequired()
.HasMaxLength(200)
.HasColumnType("character varying(200)");
b.Property<string>("CreatedBy")
.IsRequired()
.HasColumnType("text");
b.Property<DateTime>("DateCreated")
.HasColumnType("timestamp without time zone");
b.Property<DateTime?>("DateUpdated")
.HasColumnType("timestamp without time zone");
b.Property<string>("Name")
.IsRequired()
.HasMaxLength(50)
.HasColumnType("character varying(50)");
b.Property<string>("PhotoUrl")
.HasColumnType("text");
b.Property<string>("UpdatedBy")
.HasColumnType("text");
b.HasKey("Id");
b.HasIndex("DateCreated")
.HasDatabaseName("IX_Venue_CreatedAt");
b.ToTable("Venues", "Club12");
});
modelBuilder.Entity("Domain.Entities.Models.Division", b =>
{
b.HasOne("Domain.Entities.Models.Tournament", "Tournament")
.WithMany("Divisions")
.HasForeignKey("TournamentId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Tournament");
});
modelBuilder.Entity("Domain.Entities.Models.Match", b =>
{
b.HasOne("Domain.Entities.Models.Team", "HomeTeam")
.WithMany()
.HasForeignKey("HomeTeamId");
b.HasOne("Domain.Entities.Models.Stage", "Stage")
.WithMany("Matches")
.HasForeignKey("StageId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("Domain.Entities.Models.Venue", "Venue")
.WithMany()
.HasForeignKey("VenueId");
b.HasOne("Domain.Entities.Models.Team", "VisitorTeam")
.WithMany()
.HasForeignKey("VisitorTeamId");
b.HasOne("Domain.Entities.Models.Team", "WinningTeam")
.WithMany()
.HasForeignKey("WinningTeamId");
b.Navigation("HomeTeam");
b.Navigation("Stage");
b.Navigation("Venue");
b.Navigation("VisitorTeam");
b.Navigation("WinningTeam");
});
modelBuilder.Entity("Domain.Entities.Models.Player", b =>
{
b.HasOne("Domain.Entities.Models.Team", "Team")
.WithMany("Players")
.HasForeignKey("TeamId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Team");
});
modelBuilder.Entity("Domain.Entities.Models.PlayerSanction", b =>
{
b.HasOne("Domain.Entities.Models.Match", "Match")
.WithMany()
.HasForeignKey("MatchId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("Domain.Entities.Models.Player", "Player")
.WithMany()
.HasForeignKey("PlayerId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Match");
b.Navigation("Player");
});
modelBuilder.Entity("Domain.Entities.Models.PlayerStatistic", b =>
{
b.HasOne("Domain.Entities.Models.Match", "Match")
.WithMany("PlayerStatistics")
.HasForeignKey("MatchId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("Domain.Entities.Models.Player", "Player")
.WithMany()
.HasForeignKey("PlayerId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Match");
b.Navigation("Player");
});
modelBuilder.Entity("Domain.Entities.Models.Stage", b =>
{
b.HasOne("Domain.Entities.Models.Division", "Division")
.WithMany("Stages")
.HasForeignKey("DivisionId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Division");
});
modelBuilder.Entity("Domain.Entities.Models.StageTeamMatch", b =>
{
b.HasOne("Domain.Entities.Models.Stage", "Stage")
.WithMany("StageTeamMatches")
.HasForeignKey("StageId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("Domain.Entities.Models.Team", "Team")
.WithMany("StageTeamMatches")
.HasForeignKey("TeamId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Stage");
b.Navigation("Team");
});
modelBuilder.Entity("Domain.Entities.Models.Team", b =>
{
b.HasOne("Domain.Entities.Models.Tournament", "Tournament")
.WithMany("Teams")
.HasForeignKey("TournamentId");
b.Navigation("Tournament");
});
modelBuilder.Entity("Domain.Entities.Models.Division", b =>
{
b.Navigation("Stages");
});
modelBuilder.Entity("Domain.Entities.Models.Match", b =>
{
b.Navigation("PlayerStatistics");
});
modelBuilder.Entity("Domain.Entities.Models.Stage", b =>
{
b.Navigation("Matches");
b.Navigation("StageTeamMatches");
});
modelBuilder.Entity("Domain.Entities.Models.Team", b =>
{
b.Navigation("Players");
b.Navigation("StageTeamMatches");
});
modelBuilder.Entity("Domain.Entities.Models.Tournament", b =>
{
b.Navigation("Divisions");
b.Navigation("Teams");
});
#pragma warning restore 612, 618
}
}
}
@@ -0,0 +1,43 @@
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace Persistance.Migrations;
/// <inheritdoc />
public partial class changeTournamentEntity : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropColumn(
name: "IsFinished",
schema: "Club12",
table: "Tournaments");
migrationBuilder.AddColumn<int>(
name: "Status",
schema: "Club12",
table: "Tournaments",
type: "integer",
nullable: false,
defaultValue: 0);
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropColumn(
name: "Status",
schema: "Club12",
table: "Tournaments");
migrationBuilder.AddColumn<bool>(
name: "IsFinished",
schema: "Club12",
table: "Tournaments",
type: "boolean",
nullable: false,
defaultValue: false);
}
}
@@ -0,0 +1,816 @@
// <auto-generated />
using System;
using Infrastructure.Persistance;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Migrations;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
#nullable disable
namespace Persistance.Migrations
{
[DbContext(typeof(ApplicationDBContext))]
[Migration("20260403194406_AddScorerTable")]
partial class AddScorerTable
{
/// <inheritdoc />
protected override void BuildTargetModel(ModelBuilder modelBuilder)
{
#pragma warning disable 612, 618
modelBuilder
.HasAnnotation("ProductVersion", "10.0.5")
.HasAnnotation("Relational:MaxIdentifierLength", 63);
NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder);
modelBuilder.Entity("Domain.Entities.Models.BlogPost", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uuid");
b.Property<string>("Author")
.IsRequired()
.HasMaxLength(50)
.HasColumnType("character varying(50)");
b.Property<string>("CreatedBy")
.IsRequired()
.HasColumnType("text");
b.Property<DateTime>("DateCreated")
.HasColumnType("timestamp without time zone");
b.Property<DateTime?>("DateUpdated")
.HasColumnType("timestamp without time zone");
b.Property<string>("MarkdownText")
.IsRequired()
.HasColumnType("text");
b.Property<string>("PhotoUrl")
.HasMaxLength(2048)
.HasColumnType("character varying(2048)");
b.Property<string>("Title")
.IsRequired()
.HasColumnType("text");
b.Property<string>("UpdatedBy")
.HasColumnType("text");
b.Property<int>("Views")
.HasColumnType("integer");
b.HasKey("Id");
b.HasIndex("DateCreated")
.HasDatabaseName("IX_BlogPost_CreatedAt");
b.ToTable("BlogPosts", "Club12");
});
modelBuilder.Entity("Domain.Entities.Models.Division", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uuid");
b.Property<string>("CreatedBy")
.IsRequired()
.HasColumnType("text");
b.Property<DateTime>("DateCreated")
.HasColumnType("timestamp without time zone");
b.Property<DateTime?>("DateUpdated")
.HasColumnType("timestamp without time zone");
b.Property<bool>("IsFinished")
.HasColumnType("boolean");
b.Property<string>("Name")
.IsRequired()
.HasMaxLength(30)
.HasColumnType("character varying(30)");
b.Property<Guid>("TournamentId")
.HasColumnType("uuid");
b.Property<string>("UpdatedBy")
.HasColumnType("text");
b.HasKey("Id");
b.HasIndex("DateCreated")
.HasDatabaseName("IX_Division_CreatedAt");
b.HasIndex("TournamentId");
b.ToTable("Divisions", "Club12");
});
modelBuilder.Entity("Domain.Entities.Models.Match", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uuid");
b.Property<string>("CreatedBy")
.IsRequired()
.HasColumnType("text");
b.Property<DateTime>("DateCreated")
.HasColumnType("timestamp without time zone");
b.Property<DateTime?>("DateUpdated")
.HasColumnType("timestamp without time zone");
b.Property<int?>("HomeScore")
.HasColumnType("integer");
b.Property<Guid?>("HomeTeamId")
.HasColumnType("uuid");
b.Property<bool>("IsFinished")
.HasColumnType("boolean");
b.Property<DateTime>("MatchDate")
.HasColumnType("timestamp without time zone");
b.Property<Guid>("StageId")
.HasColumnType("uuid");
b.Property<string>("Type")
.IsRequired()
.HasColumnType("text");
b.Property<string>("UpdatedBy")
.HasColumnType("text");
b.Property<Guid?>("VenueId")
.HasColumnType("uuid");
b.Property<int?>("VisitorScore")
.HasColumnType("integer");
b.Property<Guid?>("VisitorTeamId")
.HasColumnType("uuid");
b.Property<Guid?>("WinningTeamId")
.HasColumnType("uuid");
b.HasKey("Id");
b.HasIndex("DateCreated")
.HasDatabaseName("IX_Match_CreatedAt");
b.HasIndex("HomeTeamId");
b.HasIndex("StageId");
b.HasIndex("VenueId");
b.HasIndex("VisitorTeamId");
b.HasIndex("WinningTeamId");
b.ToTable("Matches", "Club12");
});
modelBuilder.Entity("Domain.Entities.Models.Player", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uuid");
b.Property<DateTime>("BirthDate")
.HasColumnType("timestamp without time zone");
b.Property<string>("CreatedBy")
.IsRequired()
.HasColumnType("text");
b.Property<DateTime>("DateCreated")
.HasColumnType("timestamp without time zone");
b.Property<DateTime?>("DateUpdated")
.HasColumnType("timestamp without time zone");
b.Property<string>("DocumentNumber")
.IsRequired()
.HasMaxLength(15)
.HasColumnType("character varying(15)");
b.Property<string>("FirstName")
.IsRequired()
.HasMaxLength(70)
.HasColumnType("character varying(70)");
b.Property<bool>("IsSanctioned")
.HasColumnType("boolean");
b.Property<string>("LastName")
.IsRequired()
.HasMaxLength(70)
.HasColumnType("character varying(70)");
b.Property<string>("PhoneNumber")
.HasColumnType("text");
b.Property<string>("SecondName")
.HasMaxLength(70)
.HasColumnType("character varying(70)");
b.Property<string>("SocialSecurity")
.IsRequired()
.HasMaxLength(100)
.HasColumnType("character varying(100)");
b.Property<Guid>("TeamId")
.HasColumnType("uuid");
b.Property<string>("UpdatedBy")
.HasColumnType("text");
b.HasKey("Id");
b.HasIndex("DateCreated")
.HasDatabaseName("IX_Player_CreatedAt");
b.HasIndex("DocumentNumber")
.IsUnique();
b.HasIndex("TeamId");
b.ToTable("Players", "Club12");
});
modelBuilder.Entity("Domain.Entities.Models.PlayerSanction", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uuid");
b.Property<string>("CreatedBy")
.IsRequired()
.HasColumnType("text");
b.Property<DateTime>("DateCreated")
.HasColumnType("timestamp without time zone");
b.Property<DateTime?>("DateUpdated")
.HasColumnType("timestamp without time zone");
b.Property<string>("Description")
.IsRequired()
.HasMaxLength(255)
.HasColumnType("character varying(255)");
b.Property<int>("Duration")
.HasColumnType("integer");
b.Property<DateTime>("IssuedDate")
.HasColumnType("timestamp without time zone");
b.Property<Guid>("MatchId")
.HasColumnType("uuid");
b.Property<Guid>("PlayerId")
.HasColumnType("uuid");
b.Property<string>("UpdatedBy")
.HasColumnType("text");
b.HasKey("Id");
b.HasIndex("DateCreated")
.HasDatabaseName("IX_PlayerSanction_CreatedAt");
b.HasIndex("MatchId");
b.HasIndex("PlayerId");
b.ToTable("PlayerSanctions", "Club12");
});
modelBuilder.Entity("Domain.Entities.Models.PlayerStatistic", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uuid");
b.Property<string>("CreatedBy")
.IsRequired()
.HasColumnType("text");
b.Property<DateTime>("DateCreated")
.HasColumnType("timestamp without time zone");
b.Property<DateTime?>("DateUpdated")
.HasColumnType("timestamp without time zone");
b.Property<Guid>("MatchId")
.HasColumnType("uuid");
b.Property<Guid>("PlayerId")
.HasColumnType("uuid");
b.Property<string>("UpdatedBy")
.HasColumnType("text");
b.Property<int>("Value")
.HasColumnType("integer");
b.HasKey("Id");
b.HasIndex("DateCreated")
.HasDatabaseName("IX_PlayerStatistic_CreatedAt");
b.HasIndex("MatchId");
b.HasIndex("PlayerId");
b.ToTable("PlayersStatistics", "Club12");
});
modelBuilder.Entity("Domain.Entities.Models.Scorer", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uuid");
b.Property<string>("CreatedBy")
.IsRequired()
.HasColumnType("text");
b.Property<DateTime>("DateCreated")
.HasColumnType("timestamp without time zone");
b.Property<DateTime?>("DateUpdated")
.HasColumnType("timestamp without time zone");
b.Property<Guid>("MatchId")
.HasColumnType("uuid");
b.Property<Guid>("PlayerId")
.HasColumnType("uuid");
b.Property<int>("Points")
.HasColumnType("integer");
b.Property<string>("UpdatedBy")
.HasColumnType("text");
b.HasKey("Id");
b.HasIndex("DateCreated")
.HasDatabaseName("IX_Scorer_CreatedAt");
b.HasIndex("MatchId");
b.HasIndex("PlayerId");
b.ToTable("Scorers", "Club12");
});
modelBuilder.Entity("Domain.Entities.Models.Stage", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uuid");
b.Property<string>("CreatedBy")
.IsRequired()
.HasColumnType("text");
b.Property<DateTime>("DateCreated")
.HasColumnType("timestamp without time zone");
b.Property<DateTime?>("DateUpdated")
.HasColumnType("timestamp without time zone");
b.Property<string>("Description")
.HasMaxLength(1000)
.HasColumnType("character varying(1000)");
b.Property<Guid>("DivisionId")
.HasColumnType("uuid");
b.Property<DateTime>("EndDate")
.HasColumnType("timestamp without time zone");
b.Property<bool>("IsActive")
.HasColumnType("boolean");
b.Property<bool>("IsElimination")
.HasColumnType("boolean");
b.Property<string>("Name")
.IsRequired()
.HasMaxLength(100)
.HasColumnType("character varying(100)");
b.Property<int>("Order")
.HasColumnType("integer");
b.Property<string>("StageType")
.IsRequired()
.HasColumnType("text");
b.Property<DateTime>("StartDate")
.HasColumnType("timestamp without time zone");
b.Property<string>("UpdatedBy")
.HasColumnType("text");
b.HasKey("Id");
b.HasIndex("DateCreated")
.HasDatabaseName("IX_Stage_CreatedAt");
b.HasIndex("DivisionId");
b.HasIndex("Name", "DivisionId")
.IsUnique()
.HasDatabaseName("CONSTRAINT_UNIQUE_STAGE_NAME_AND_DIVISIONID");
b.ToTable("Stages", "Club12");
});
modelBuilder.Entity("Domain.Entities.Models.StageTeamMatch", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uuid");
b.Property<string>("CreatedBy")
.IsRequired()
.HasColumnType("text");
b.Property<DateTime>("DateCreated")
.HasColumnType("timestamp without time zone");
b.Property<DateTime?>("DateUpdated")
.HasColumnType("timestamp without time zone");
b.Property<Guid>("StageId")
.HasColumnType("uuid");
b.Property<Guid>("TeamId")
.HasColumnType("uuid");
b.Property<string>("UpdatedBy")
.HasColumnType("text");
b.HasKey("Id");
b.HasIndex("DateCreated")
.HasDatabaseName("IX_StageTeamMatch_CreatedAt");
b.HasIndex("StageId");
b.HasIndex("TeamId");
b.ToTable("StageTeamMatches", "Club12");
});
modelBuilder.Entity("Domain.Entities.Models.Team", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uuid");
b.Property<string>("CreatedBy")
.IsRequired()
.HasColumnType("text");
b.Property<DateTime>("DateCreated")
.HasColumnType("timestamp without time zone");
b.Property<DateTime?>("DateUpdated")
.HasColumnType("timestamp without time zone");
b.Property<string>("LogoUrl")
.IsRequired()
.HasColumnType("text");
b.Property<string>("Name")
.IsRequired()
.HasColumnType("text");
b.Property<string>("ShirtColor")
.IsRequired()
.HasColumnType("text");
b.Property<string>("ThreeLetterCode")
.IsRequired()
.HasColumnType("text");
b.Property<Guid?>("TournamentId")
.HasColumnType("uuid");
b.Property<string>("UpdatedBy")
.HasColumnType("text");
b.HasKey("Id");
b.HasIndex("DateCreated")
.HasDatabaseName("IX_Team_CreatedAt");
b.HasIndex("TournamentId");
b.ToTable("Teams", "Club12");
});
modelBuilder.Entity("Domain.Entities.Models.Tournament", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uuid");
b.Property<string>("CreatedBy")
.IsRequired()
.HasColumnType("text");
b.Property<DateTime>("DateCreated")
.HasColumnType("timestamp without time zone");
b.Property<DateTime?>("DateUpdated")
.HasColumnType("timestamp without time zone");
b.Property<string>("Description")
.IsRequired()
.HasColumnType("text");
b.Property<int>("MaxTeams")
.HasColumnType("integer");
b.Property<int>("MinTeams")
.HasColumnType("integer");
b.Property<string>("Name")
.IsRequired()
.HasColumnType("text");
b.Property<DateTime>("StartDate")
.HasColumnType("timestamp without time zone");
b.Property<int>("Status")
.ValueGeneratedOnAdd()
.HasColumnType("integer")
.HasDefaultValue(0);
b.Property<DateTime>("TeamRegistrationDeadline")
.HasColumnType("timestamp without time zone");
b.Property<string>("UpdatedBy")
.HasColumnType("text");
b.HasKey("Id");
b.HasIndex("DateCreated")
.HasDatabaseName("IX_Tournament_CreatedAt");
b.ToTable("Tournaments", "Club12", t =>
{
t.HasCheckConstraint("CK_Tournament_DeadlineBeforeStart", "\"TeamRegistrationDeadline\" < \"StartDate\"");
});
});
modelBuilder.Entity("Domain.Entities.Models.Venue", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uuid");
b.Property<string>("Address")
.IsRequired()
.HasMaxLength(200)
.HasColumnType("character varying(200)");
b.Property<string>("CreatedBy")
.IsRequired()
.HasColumnType("text");
b.Property<DateTime>("DateCreated")
.HasColumnType("timestamp without time zone");
b.Property<DateTime?>("DateUpdated")
.HasColumnType("timestamp without time zone");
b.Property<string>("Name")
.IsRequired()
.HasMaxLength(50)
.HasColumnType("character varying(50)");
b.Property<string>("PhotoUrl")
.HasColumnType("text");
b.Property<string>("UpdatedBy")
.HasColumnType("text");
b.HasKey("Id");
b.HasIndex("DateCreated")
.HasDatabaseName("IX_Venue_CreatedAt");
b.ToTable("Venues", "Club12");
});
modelBuilder.Entity("Domain.Entities.Models.Division", b =>
{
b.HasOne("Domain.Entities.Models.Tournament", "Tournament")
.WithMany("Divisions")
.HasForeignKey("TournamentId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Tournament");
});
modelBuilder.Entity("Domain.Entities.Models.Match", b =>
{
b.HasOne("Domain.Entities.Models.Team", "HomeTeam")
.WithMany()
.HasForeignKey("HomeTeamId");
b.HasOne("Domain.Entities.Models.Stage", "Stage")
.WithMany("Matches")
.HasForeignKey("StageId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("Domain.Entities.Models.Venue", "Venue")
.WithMany()
.HasForeignKey("VenueId");
b.HasOne("Domain.Entities.Models.Team", "VisitorTeam")
.WithMany()
.HasForeignKey("VisitorTeamId");
b.HasOne("Domain.Entities.Models.Team", "WinningTeam")
.WithMany()
.HasForeignKey("WinningTeamId");
b.Navigation("HomeTeam");
b.Navigation("Stage");
b.Navigation("Venue");
b.Navigation("VisitorTeam");
b.Navigation("WinningTeam");
});
modelBuilder.Entity("Domain.Entities.Models.Player", b =>
{
b.HasOne("Domain.Entities.Models.Team", "Team")
.WithMany("Players")
.HasForeignKey("TeamId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Team");
});
modelBuilder.Entity("Domain.Entities.Models.PlayerSanction", b =>
{
b.HasOne("Domain.Entities.Models.Match", "Match")
.WithMany()
.HasForeignKey("MatchId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("Domain.Entities.Models.Player", "Player")
.WithMany()
.HasForeignKey("PlayerId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Match");
b.Navigation("Player");
});
modelBuilder.Entity("Domain.Entities.Models.PlayerStatistic", b =>
{
b.HasOne("Domain.Entities.Models.Match", "Match")
.WithMany("PlayerStatistics")
.HasForeignKey("MatchId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("Domain.Entities.Models.Player", "Player")
.WithMany()
.HasForeignKey("PlayerId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Match");
b.Navigation("Player");
});
modelBuilder.Entity("Domain.Entities.Models.Scorer", b =>
{
b.HasOne("Domain.Entities.Models.Match", "Match")
.WithMany("Scorers")
.HasForeignKey("MatchId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("Domain.Entities.Models.Player", "Player")
.WithMany("Scorers")
.HasForeignKey("PlayerId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Match");
b.Navigation("Player");
});
modelBuilder.Entity("Domain.Entities.Models.Stage", b =>
{
b.HasOne("Domain.Entities.Models.Division", "Division")
.WithMany("Stages")
.HasForeignKey("DivisionId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Division");
});
modelBuilder.Entity("Domain.Entities.Models.StageTeamMatch", b =>
{
b.HasOne("Domain.Entities.Models.Stage", "Stage")
.WithMany("StageTeamMatches")
.HasForeignKey("StageId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("Domain.Entities.Models.Team", "Team")
.WithMany("StageTeamMatches")
.HasForeignKey("TeamId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Stage");
b.Navigation("Team");
});
modelBuilder.Entity("Domain.Entities.Models.Team", b =>
{
b.HasOne("Domain.Entities.Models.Tournament", "Tournament")
.WithMany("Teams")
.HasForeignKey("TournamentId");
b.Navigation("Tournament");
});
modelBuilder.Entity("Domain.Entities.Models.Division", b =>
{
b.Navigation("Stages");
});
modelBuilder.Entity("Domain.Entities.Models.Match", b =>
{
b.Navigation("PlayerStatistics");
b.Navigation("Scorers");
});
modelBuilder.Entity("Domain.Entities.Models.Player", b =>
{
b.Navigation("Scorers");
});
modelBuilder.Entity("Domain.Entities.Models.Stage", b =>
{
b.Navigation("Matches");
b.Navigation("StageTeamMatches");
});
modelBuilder.Entity("Domain.Entities.Models.Team", b =>
{
b.Navigation("Players");
b.Navigation("StageTeamMatches");
});
modelBuilder.Entity("Domain.Entities.Models.Tournament", b =>
{
b.Navigation("Divisions");
b.Navigation("Teams");
});
#pragma warning restore 612, 618
}
}
}
@@ -0,0 +1,74 @@
using Microsoft.EntityFrameworkCore.Migrations;
using System;
#nullable disable
namespace Persistance.Migrations;
/// <inheritdoc />
public partial class AddScorerTable : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.CreateTable(
name: "Scorers",
schema: "Club12",
columns: table => new
{
Id = table.Column<Guid>(type: "uuid", nullable: false),
PlayerId = table.Column<Guid>(type: "uuid", nullable: false),
Points = table.Column<int>(type: "integer", nullable: false),
MatchId = table.Column<Guid>(type: "uuid", nullable: false),
DateCreated = table.Column<DateTime>(type: "timestamp without time zone", nullable: false),
DateUpdated = table.Column<DateTime>(type: "timestamp without time zone", nullable: true),
CreatedBy = table.Column<string>(type: "text", nullable: false),
UpdatedBy = table.Column<string>(type: "text", nullable: true)
},
constraints: table =>
{
table.PrimaryKey("PK_Scorers", x => x.Id);
table.ForeignKey(
name: "FK_Scorers_Matches_MatchId",
column: x => x.MatchId,
principalSchema: "Club12",
principalTable: "Matches",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
table.ForeignKey(
name: "FK_Scorers_Players_PlayerId",
column: x => x.PlayerId,
principalSchema: "Club12",
principalTable: "Players",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateIndex(
name: "IX_Scorer_CreatedAt",
schema: "Club12",
table: "Scorers",
column: "DateCreated");
migrationBuilder.CreateIndex(
name: "IX_Scorers_MatchId",
schema: "Club12",
table: "Scorers",
column: "MatchId");
migrationBuilder.CreateIndex(
name: "IX_Scorers_PlayerId",
schema: "Club12",
table: "Scorers",
column: "PlayerId");
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropTable(
name: "Scorers",
schema: "Club12");
}
}
@@ -0,0 +1,820 @@
// <auto-generated />
using System;
using Infrastructure.Persistance;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Migrations;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
#nullable disable
namespace Infrastructure.Migrations
{
[DbContext(typeof(ApplicationDBContext))]
[Migration("20260629150628_AddPlayerStatisticType")]
partial class AddPlayerStatisticType
{
/// <inheritdoc />
protected override void BuildTargetModel(ModelBuilder modelBuilder)
{
#pragma warning disable 612, 618
modelBuilder
.HasAnnotation("ProductVersion", "8.0.25")
.HasAnnotation("Relational:MaxIdentifierLength", 63);
NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder);
modelBuilder.Entity("Domain.Entities.Models.BlogPost", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uuid");
b.Property<string>("Author")
.IsRequired()
.HasMaxLength(50)
.HasColumnType("character varying(50)");
b.Property<string>("CreatedBy")
.IsRequired()
.HasColumnType("text");
b.Property<DateTime>("DateCreated")
.HasColumnType("timestamp without time zone");
b.Property<DateTime?>("DateUpdated")
.HasColumnType("timestamp without time zone");
b.Property<string>("MarkdownText")
.IsRequired()
.HasColumnType("text");
b.Property<string>("PhotoUrl")
.HasMaxLength(2048)
.HasColumnType("character varying(2048)");
b.Property<string>("Title")
.IsRequired()
.HasColumnType("text");
b.Property<string>("UpdatedBy")
.HasColumnType("text");
b.Property<int>("Views")
.HasColumnType("integer");
b.HasKey("Id");
b.HasIndex("DateCreated")
.HasDatabaseName("IX_BlogPost_CreatedAt");
b.ToTable("BlogPosts", "Club12");
});
modelBuilder.Entity("Domain.Entities.Models.Division", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uuid");
b.Property<string>("CreatedBy")
.IsRequired()
.HasColumnType("text");
b.Property<DateTime>("DateCreated")
.HasColumnType("timestamp without time zone");
b.Property<DateTime?>("DateUpdated")
.HasColumnType("timestamp without time zone");
b.Property<bool>("IsFinished")
.HasColumnType("boolean");
b.Property<string>("Name")
.IsRequired()
.HasMaxLength(30)
.HasColumnType("character varying(30)");
b.Property<Guid>("TournamentId")
.HasColumnType("uuid");
b.Property<string>("UpdatedBy")
.HasColumnType("text");
b.HasKey("Id");
b.HasIndex("DateCreated")
.HasDatabaseName("IX_Division_CreatedAt");
b.HasIndex("TournamentId");
b.ToTable("Divisions", "Club12");
});
modelBuilder.Entity("Domain.Entities.Models.Match", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uuid");
b.Property<string>("CreatedBy")
.IsRequired()
.HasColumnType("text");
b.Property<DateTime>("DateCreated")
.HasColumnType("timestamp without time zone");
b.Property<DateTime?>("DateUpdated")
.HasColumnType("timestamp without time zone");
b.Property<int?>("HomeScore")
.HasColumnType("integer");
b.Property<Guid?>("HomeTeamId")
.HasColumnType("uuid");
b.Property<bool>("IsFinished")
.HasColumnType("boolean");
b.Property<DateTime>("MatchDate")
.HasColumnType("timestamp without time zone");
b.Property<Guid>("StageId")
.HasColumnType("uuid");
b.Property<string>("Type")
.IsRequired()
.HasColumnType("text");
b.Property<string>("UpdatedBy")
.HasColumnType("text");
b.Property<Guid?>("VenueId")
.HasColumnType("uuid");
b.Property<int?>("VisitorScore")
.HasColumnType("integer");
b.Property<Guid?>("VisitorTeamId")
.HasColumnType("uuid");
b.Property<Guid?>("WinningTeamId")
.HasColumnType("uuid");
b.HasKey("Id");
b.HasIndex("DateCreated")
.HasDatabaseName("IX_Match_CreatedAt");
b.HasIndex("HomeTeamId");
b.HasIndex("StageId");
b.HasIndex("VenueId");
b.HasIndex("VisitorTeamId");
b.HasIndex("WinningTeamId");
b.ToTable("Matches", "Club12");
});
modelBuilder.Entity("Domain.Entities.Models.Player", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uuid");
b.Property<DateTime>("BirthDate")
.HasColumnType("timestamp without time zone");
b.Property<string>("CreatedBy")
.IsRequired()
.HasColumnType("text");
b.Property<DateTime>("DateCreated")
.HasColumnType("timestamp without time zone");
b.Property<DateTime?>("DateUpdated")
.HasColumnType("timestamp without time zone");
b.Property<string>("DocumentNumber")
.IsRequired()
.HasMaxLength(15)
.HasColumnType("character varying(15)");
b.Property<string>("FirstName")
.IsRequired()
.HasMaxLength(70)
.HasColumnType("character varying(70)");
b.Property<bool>("IsSanctioned")
.HasColumnType("boolean");
b.Property<string>("LastName")
.IsRequired()
.HasMaxLength(70)
.HasColumnType("character varying(70)");
b.Property<string>("PhoneNumber")
.HasColumnType("text");
b.Property<string>("SecondName")
.HasMaxLength(70)
.HasColumnType("character varying(70)");
b.Property<string>("SocialSecurity")
.IsRequired()
.HasMaxLength(100)
.HasColumnType("character varying(100)");
b.Property<Guid>("TeamId")
.HasColumnType("uuid");
b.Property<string>("UpdatedBy")
.HasColumnType("text");
b.HasKey("Id");
b.HasIndex("DateCreated")
.HasDatabaseName("IX_Player_CreatedAt");
b.HasIndex("DocumentNumber")
.IsUnique();
b.HasIndex("TeamId");
b.ToTable("Players", "Club12");
});
modelBuilder.Entity("Domain.Entities.Models.PlayerSanction", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uuid");
b.Property<string>("CreatedBy")
.IsRequired()
.HasColumnType("text");
b.Property<DateTime>("DateCreated")
.HasColumnType("timestamp without time zone");
b.Property<DateTime?>("DateUpdated")
.HasColumnType("timestamp without time zone");
b.Property<string>("Description")
.IsRequired()
.HasMaxLength(255)
.HasColumnType("character varying(255)");
b.Property<int>("Duration")
.HasColumnType("integer");
b.Property<DateTime>("IssuedDate")
.HasColumnType("timestamp without time zone");
b.Property<Guid>("MatchId")
.HasColumnType("uuid");
b.Property<Guid>("PlayerId")
.HasColumnType("uuid");
b.Property<string>("UpdatedBy")
.HasColumnType("text");
b.HasKey("Id");
b.HasIndex("DateCreated")
.HasDatabaseName("IX_PlayerSanction_CreatedAt");
b.HasIndex("MatchId");
b.HasIndex("PlayerId");
b.ToTable("PlayerSanctions", "Club12");
});
modelBuilder.Entity("Domain.Entities.Models.PlayerStatistic", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uuid");
b.Property<string>("CreatedBy")
.IsRequired()
.HasColumnType("text");
b.Property<DateTime>("DateCreated")
.HasColumnType("timestamp without time zone");
b.Property<DateTime?>("DateUpdated")
.HasColumnType("timestamp without time zone");
b.Property<Guid>("MatchId")
.HasColumnType("uuid");
b.Property<Guid>("PlayerId")
.HasColumnType("uuid");
b.Property<string>("Type")
.IsRequired()
.HasColumnType("text");
b.Property<string>("UpdatedBy")
.HasColumnType("text");
b.Property<int>("Value")
.HasColumnType("integer");
b.HasKey("Id");
b.HasIndex("DateCreated")
.HasDatabaseName("IX_PlayerStatistic_CreatedAt");
b.HasIndex("MatchId");
b.HasIndex("PlayerId");
b.ToTable("PlayersStatistics", "Club12");
});
modelBuilder.Entity("Domain.Entities.Models.Scorer", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uuid");
b.Property<string>("CreatedBy")
.IsRequired()
.HasColumnType("text");
b.Property<DateTime>("DateCreated")
.HasColumnType("timestamp without time zone");
b.Property<DateTime?>("DateUpdated")
.HasColumnType("timestamp without time zone");
b.Property<Guid>("MatchId")
.HasColumnType("uuid");
b.Property<Guid>("PlayerId")
.HasColumnType("uuid");
b.Property<int>("Points")
.HasColumnType("integer");
b.Property<string>("UpdatedBy")
.HasColumnType("text");
b.HasKey("Id");
b.HasIndex("DateCreated")
.HasDatabaseName("IX_Scorer_CreatedAt");
b.HasIndex("MatchId");
b.HasIndex("PlayerId");
b.ToTable("Scorers", "Club12");
});
modelBuilder.Entity("Domain.Entities.Models.Stage", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uuid");
b.Property<string>("CreatedBy")
.IsRequired()
.HasColumnType("text");
b.Property<DateTime>("DateCreated")
.HasColumnType("timestamp without time zone");
b.Property<DateTime?>("DateUpdated")
.HasColumnType("timestamp without time zone");
b.Property<string>("Description")
.HasMaxLength(1000)
.HasColumnType("character varying(1000)");
b.Property<Guid>("DivisionId")
.HasColumnType("uuid");
b.Property<DateTime>("EndDate")
.HasColumnType("timestamp without time zone");
b.Property<bool>("IsActive")
.HasColumnType("boolean");
b.Property<bool>("IsElimination")
.HasColumnType("boolean");
b.Property<string>("Name")
.IsRequired()
.HasMaxLength(100)
.HasColumnType("character varying(100)");
b.Property<int>("Order")
.HasColumnType("integer");
b.Property<string>("StageType")
.IsRequired()
.HasColumnType("text");
b.Property<DateTime>("StartDate")
.HasColumnType("timestamp without time zone");
b.Property<string>("UpdatedBy")
.HasColumnType("text");
b.HasKey("Id");
b.HasIndex("DateCreated")
.HasDatabaseName("IX_Stage_CreatedAt");
b.HasIndex("DivisionId");
b.HasIndex("Name", "DivisionId")
.IsUnique()
.HasDatabaseName("CONSTRAINT_UNIQUE_STAGE_NAME_AND_DIVISIONID");
b.ToTable("Stages", "Club12");
});
modelBuilder.Entity("Domain.Entities.Models.StageTeamMatch", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uuid");
b.Property<string>("CreatedBy")
.IsRequired()
.HasColumnType("text");
b.Property<DateTime>("DateCreated")
.HasColumnType("timestamp without time zone");
b.Property<DateTime?>("DateUpdated")
.HasColumnType("timestamp without time zone");
b.Property<Guid>("StageId")
.HasColumnType("uuid");
b.Property<Guid>("TeamId")
.HasColumnType("uuid");
b.Property<string>("UpdatedBy")
.HasColumnType("text");
b.HasKey("Id");
b.HasIndex("DateCreated")
.HasDatabaseName("IX_StageTeamMatch_CreatedAt");
b.HasIndex("StageId");
b.HasIndex("TeamId");
b.ToTable("StageTeamMatches", "Club12");
});
modelBuilder.Entity("Domain.Entities.Models.Team", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uuid");
b.Property<string>("CreatedBy")
.IsRequired()
.HasColumnType("text");
b.Property<DateTime>("DateCreated")
.HasColumnType("timestamp without time zone");
b.Property<DateTime?>("DateUpdated")
.HasColumnType("timestamp without time zone");
b.Property<string>("LogoUrl")
.IsRequired()
.HasColumnType("text");
b.Property<string>("Name")
.IsRequired()
.HasColumnType("text");
b.Property<string>("ShirtColor")
.IsRequired()
.HasColumnType("text");
b.Property<string>("ThreeLetterCode")
.IsRequired()
.HasColumnType("text");
b.Property<Guid?>("TournamentId")
.HasColumnType("uuid");
b.Property<string>("UpdatedBy")
.HasColumnType("text");
b.HasKey("Id");
b.HasIndex("DateCreated")
.HasDatabaseName("IX_Team_CreatedAt");
b.HasIndex("TournamentId");
b.ToTable("Teams", "Club12");
});
modelBuilder.Entity("Domain.Entities.Models.Tournament", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uuid");
b.Property<string>("CreatedBy")
.IsRequired()
.HasColumnType("text");
b.Property<DateTime>("DateCreated")
.HasColumnType("timestamp without time zone");
b.Property<DateTime?>("DateUpdated")
.HasColumnType("timestamp without time zone");
b.Property<string>("Description")
.IsRequired()
.HasColumnType("text");
b.Property<int>("MaxTeams")
.HasColumnType("integer");
b.Property<int>("MinTeams")
.HasColumnType("integer");
b.Property<string>("Name")
.IsRequired()
.HasColumnType("text");
b.Property<DateTime>("StartDate")
.HasColumnType("timestamp without time zone");
b.Property<int>("Status")
.ValueGeneratedOnAdd()
.HasColumnType("integer")
.HasDefaultValue(0);
b.Property<DateTime>("TeamRegistrationDeadline")
.HasColumnType("timestamp without time zone");
b.Property<string>("UpdatedBy")
.HasColumnType("text");
b.HasKey("Id");
b.HasIndex("DateCreated")
.HasDatabaseName("IX_Tournament_CreatedAt");
b.ToTable("Tournaments", "Club12", t =>
{
t.HasCheckConstraint("CK_Tournament_DeadlineBeforeStart", "\"TeamRegistrationDeadline\" < \"StartDate\"");
});
});
modelBuilder.Entity("Domain.Entities.Models.Venue", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uuid");
b.Property<string>("Address")
.IsRequired()
.HasMaxLength(200)
.HasColumnType("character varying(200)");
b.Property<string>("CreatedBy")
.IsRequired()
.HasColumnType("text");
b.Property<DateTime>("DateCreated")
.HasColumnType("timestamp without time zone");
b.Property<DateTime?>("DateUpdated")
.HasColumnType("timestamp without time zone");
b.Property<string>("Name")
.IsRequired()
.HasMaxLength(50)
.HasColumnType("character varying(50)");
b.Property<string>("PhotoUrl")
.HasColumnType("text");
b.Property<string>("UpdatedBy")
.HasColumnType("text");
b.HasKey("Id");
b.HasIndex("DateCreated")
.HasDatabaseName("IX_Venue_CreatedAt");
b.ToTable("Venues", "Club12");
});
modelBuilder.Entity("Domain.Entities.Models.Division", b =>
{
b.HasOne("Domain.Entities.Models.Tournament", "Tournament")
.WithMany("Divisions")
.HasForeignKey("TournamentId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Tournament");
});
modelBuilder.Entity("Domain.Entities.Models.Match", b =>
{
b.HasOne("Domain.Entities.Models.Team", "HomeTeam")
.WithMany()
.HasForeignKey("HomeTeamId");
b.HasOne("Domain.Entities.Models.Stage", "Stage")
.WithMany("Matches")
.HasForeignKey("StageId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("Domain.Entities.Models.Venue", "Venue")
.WithMany()
.HasForeignKey("VenueId");
b.HasOne("Domain.Entities.Models.Team", "VisitorTeam")
.WithMany()
.HasForeignKey("VisitorTeamId");
b.HasOne("Domain.Entities.Models.Team", "WinningTeam")
.WithMany()
.HasForeignKey("WinningTeamId");
b.Navigation("HomeTeam");
b.Navigation("Stage");
b.Navigation("Venue");
b.Navigation("VisitorTeam");
b.Navigation("WinningTeam");
});
modelBuilder.Entity("Domain.Entities.Models.Player", b =>
{
b.HasOne("Domain.Entities.Models.Team", "Team")
.WithMany("Players")
.HasForeignKey("TeamId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Team");
});
modelBuilder.Entity("Domain.Entities.Models.PlayerSanction", b =>
{
b.HasOne("Domain.Entities.Models.Match", "Match")
.WithMany()
.HasForeignKey("MatchId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("Domain.Entities.Models.Player", "Player")
.WithMany()
.HasForeignKey("PlayerId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Match");
b.Navigation("Player");
});
modelBuilder.Entity("Domain.Entities.Models.PlayerStatistic", b =>
{
b.HasOne("Domain.Entities.Models.Match", "Match")
.WithMany("PlayerStatistics")
.HasForeignKey("MatchId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("Domain.Entities.Models.Player", "Player")
.WithMany()
.HasForeignKey("PlayerId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Match");
b.Navigation("Player");
});
modelBuilder.Entity("Domain.Entities.Models.Scorer", b =>
{
b.HasOne("Domain.Entities.Models.Match", "Match")
.WithMany("Scorers")
.HasForeignKey("MatchId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("Domain.Entities.Models.Player", "Player")
.WithMany("Scorers")
.HasForeignKey("PlayerId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Match");
b.Navigation("Player");
});
modelBuilder.Entity("Domain.Entities.Models.Stage", b =>
{
b.HasOne("Domain.Entities.Models.Division", "Division")
.WithMany("Stages")
.HasForeignKey("DivisionId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Division");
});
modelBuilder.Entity("Domain.Entities.Models.StageTeamMatch", b =>
{
b.HasOne("Domain.Entities.Models.Stage", "Stage")
.WithMany("StageTeamMatches")
.HasForeignKey("StageId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("Domain.Entities.Models.Team", "Team")
.WithMany("StageTeamMatches")
.HasForeignKey("TeamId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Stage");
b.Navigation("Team");
});
modelBuilder.Entity("Domain.Entities.Models.Team", b =>
{
b.HasOne("Domain.Entities.Models.Tournament", "Tournament")
.WithMany("Teams")
.HasForeignKey("TournamentId");
b.Navigation("Tournament");
});
modelBuilder.Entity("Domain.Entities.Models.Division", b =>
{
b.Navigation("Stages");
});
modelBuilder.Entity("Domain.Entities.Models.Match", b =>
{
b.Navigation("PlayerStatistics");
b.Navigation("Scorers");
});
modelBuilder.Entity("Domain.Entities.Models.Player", b =>
{
b.Navigation("Scorers");
});
modelBuilder.Entity("Domain.Entities.Models.Stage", b =>
{
b.Navigation("Matches");
b.Navigation("StageTeamMatches");
});
modelBuilder.Entity("Domain.Entities.Models.Team", b =>
{
b.Navigation("Players");
b.Navigation("StageTeamMatches");
});
modelBuilder.Entity("Domain.Entities.Models.Tournament", b =>
{
b.Navigation("Divisions");
b.Navigation("Teams");
});
#pragma warning restore 612, 618
}
}
}
@@ -0,0 +1,30 @@
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace Infrastructure.Migrations;
/// <inheritdoc />
public partial class AddPlayerStatisticType : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.AddColumn<string>(
name: "Type",
schema: "Club12",
table: "PlayersStatistics",
type: "text",
nullable: false,
defaultValue: "Points");
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropColumn(
name: "Type",
schema: "Club12",
table: "PlayersStatistics");
}
}
@@ -0,0 +1,838 @@
// <auto-generated />
using System;
using Infrastructure.Persistance;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Migrations;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
#nullable disable
namespace Infrastructure.Migrations
{
[DbContext(typeof(ApplicationDBContext))]
[Migration("20260629151546_AddSanctionAppeal")]
partial class AddSanctionAppeal
{
/// <inheritdoc />
protected override void BuildTargetModel(ModelBuilder modelBuilder)
{
#pragma warning disable 612, 618
modelBuilder
.HasAnnotation("ProductVersion", "8.0.25")
.HasAnnotation("Relational:MaxIdentifierLength", 63);
NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder);
modelBuilder.Entity("Domain.Entities.Models.BlogPost", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uuid");
b.Property<string>("Author")
.IsRequired()
.HasMaxLength(50)
.HasColumnType("character varying(50)");
b.Property<string>("CreatedBy")
.IsRequired()
.HasColumnType("text");
b.Property<DateTime>("DateCreated")
.HasColumnType("timestamp without time zone");
b.Property<DateTime?>("DateUpdated")
.HasColumnType("timestamp without time zone");
b.Property<string>("MarkdownText")
.IsRequired()
.HasColumnType("text");
b.Property<string>("PhotoUrl")
.HasMaxLength(2048)
.HasColumnType("character varying(2048)");
b.Property<string>("Title")
.IsRequired()
.HasColumnType("text");
b.Property<string>("UpdatedBy")
.HasColumnType("text");
b.Property<int>("Views")
.HasColumnType("integer");
b.HasKey("Id");
b.HasIndex("DateCreated")
.HasDatabaseName("IX_BlogPost_CreatedAt");
b.ToTable("BlogPosts", "Club12");
});
modelBuilder.Entity("Domain.Entities.Models.Division", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uuid");
b.Property<string>("CreatedBy")
.IsRequired()
.HasColumnType("text");
b.Property<DateTime>("DateCreated")
.HasColumnType("timestamp without time zone");
b.Property<DateTime?>("DateUpdated")
.HasColumnType("timestamp without time zone");
b.Property<bool>("IsFinished")
.HasColumnType("boolean");
b.Property<string>("Name")
.IsRequired()
.HasMaxLength(30)
.HasColumnType("character varying(30)");
b.Property<Guid>("TournamentId")
.HasColumnType("uuid");
b.Property<string>("UpdatedBy")
.HasColumnType("text");
b.HasKey("Id");
b.HasIndex("DateCreated")
.HasDatabaseName("IX_Division_CreatedAt");
b.HasIndex("TournamentId");
b.ToTable("Divisions", "Club12");
});
modelBuilder.Entity("Domain.Entities.Models.Match", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uuid");
b.Property<string>("CreatedBy")
.IsRequired()
.HasColumnType("text");
b.Property<DateTime>("DateCreated")
.HasColumnType("timestamp without time zone");
b.Property<DateTime?>("DateUpdated")
.HasColumnType("timestamp without time zone");
b.Property<int?>("HomeScore")
.HasColumnType("integer");
b.Property<Guid?>("HomeTeamId")
.HasColumnType("uuid");
b.Property<bool>("IsFinished")
.HasColumnType("boolean");
b.Property<DateTime>("MatchDate")
.HasColumnType("timestamp without time zone");
b.Property<Guid>("StageId")
.HasColumnType("uuid");
b.Property<string>("Type")
.IsRequired()
.HasColumnType("text");
b.Property<string>("UpdatedBy")
.HasColumnType("text");
b.Property<Guid?>("VenueId")
.HasColumnType("uuid");
b.Property<int?>("VisitorScore")
.HasColumnType("integer");
b.Property<Guid?>("VisitorTeamId")
.HasColumnType("uuid");
b.Property<Guid?>("WinningTeamId")
.HasColumnType("uuid");
b.HasKey("Id");
b.HasIndex("DateCreated")
.HasDatabaseName("IX_Match_CreatedAt");
b.HasIndex("HomeTeamId");
b.HasIndex("StageId");
b.HasIndex("VenueId");
b.HasIndex("VisitorTeamId");
b.HasIndex("WinningTeamId");
b.ToTable("Matches", "Club12");
});
modelBuilder.Entity("Domain.Entities.Models.Player", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uuid");
b.Property<DateTime>("BirthDate")
.HasColumnType("timestamp without time zone");
b.Property<string>("CreatedBy")
.IsRequired()
.HasColumnType("text");
b.Property<DateTime>("DateCreated")
.HasColumnType("timestamp without time zone");
b.Property<DateTime?>("DateUpdated")
.HasColumnType("timestamp without time zone");
b.Property<string>("DocumentNumber")
.IsRequired()
.HasMaxLength(15)
.HasColumnType("character varying(15)");
b.Property<string>("FirstName")
.IsRequired()
.HasMaxLength(70)
.HasColumnType("character varying(70)");
b.Property<bool>("IsSanctioned")
.HasColumnType("boolean");
b.Property<string>("LastName")
.IsRequired()
.HasMaxLength(70)
.HasColumnType("character varying(70)");
b.Property<string>("PhoneNumber")
.HasColumnType("text");
b.Property<string>("SecondName")
.HasMaxLength(70)
.HasColumnType("character varying(70)");
b.Property<string>("SocialSecurity")
.IsRequired()
.HasMaxLength(100)
.HasColumnType("character varying(100)");
b.Property<Guid>("TeamId")
.HasColumnType("uuid");
b.Property<string>("UpdatedBy")
.HasColumnType("text");
b.HasKey("Id");
b.HasIndex("DateCreated")
.HasDatabaseName("IX_Player_CreatedAt");
b.HasIndex("DocumentNumber")
.IsUnique();
b.HasIndex("TeamId");
b.ToTable("Players", "Club12");
});
modelBuilder.Entity("Domain.Entities.Models.PlayerSanction", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uuid");
b.Property<DateTime?>("AppealDate")
.HasColumnType("timestamp without time zone");
b.Property<string>("AppealReason")
.HasMaxLength(1000)
.HasColumnType("character varying(1000)");
b.Property<string>("AppealResolution")
.HasMaxLength(1000)
.HasColumnType("character varying(1000)");
b.Property<DateTime?>("AppealResolvedDate")
.HasColumnType("timestamp without time zone");
b.Property<string>("AppealStatus")
.IsRequired()
.HasColumnType("text");
b.Property<string>("CreatedBy")
.IsRequired()
.HasColumnType("text");
b.Property<DateTime>("DateCreated")
.HasColumnType("timestamp without time zone");
b.Property<DateTime?>("DateUpdated")
.HasColumnType("timestamp without time zone");
b.Property<string>("Description")
.IsRequired()
.HasMaxLength(255)
.HasColumnType("character varying(255)");
b.Property<int>("Duration")
.HasColumnType("integer");
b.Property<DateTime>("IssuedDate")
.HasColumnType("timestamp without time zone");
b.Property<Guid>("MatchId")
.HasColumnType("uuid");
b.Property<Guid>("PlayerId")
.HasColumnType("uuid");
b.Property<string>("UpdatedBy")
.HasColumnType("text");
b.HasKey("Id");
b.HasIndex("DateCreated")
.HasDatabaseName("IX_PlayerSanction_CreatedAt");
b.HasIndex("MatchId");
b.HasIndex("PlayerId");
b.ToTable("PlayerSanctions", "Club12");
});
modelBuilder.Entity("Domain.Entities.Models.PlayerStatistic", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uuid");
b.Property<string>("CreatedBy")
.IsRequired()
.HasColumnType("text");
b.Property<DateTime>("DateCreated")
.HasColumnType("timestamp without time zone");
b.Property<DateTime?>("DateUpdated")
.HasColumnType("timestamp without time zone");
b.Property<Guid>("MatchId")
.HasColumnType("uuid");
b.Property<Guid>("PlayerId")
.HasColumnType("uuid");
b.Property<string>("Type")
.IsRequired()
.HasColumnType("text");
b.Property<string>("UpdatedBy")
.HasColumnType("text");
b.Property<int>("Value")
.HasColumnType("integer");
b.HasKey("Id");
b.HasIndex("DateCreated")
.HasDatabaseName("IX_PlayerStatistic_CreatedAt");
b.HasIndex("MatchId");
b.HasIndex("PlayerId");
b.ToTable("PlayersStatistics", "Club12");
});
modelBuilder.Entity("Domain.Entities.Models.Scorer", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uuid");
b.Property<string>("CreatedBy")
.IsRequired()
.HasColumnType("text");
b.Property<DateTime>("DateCreated")
.HasColumnType("timestamp without time zone");
b.Property<DateTime?>("DateUpdated")
.HasColumnType("timestamp without time zone");
b.Property<Guid>("MatchId")
.HasColumnType("uuid");
b.Property<Guid>("PlayerId")
.HasColumnType("uuid");
b.Property<int>("Points")
.HasColumnType("integer");
b.Property<string>("UpdatedBy")
.HasColumnType("text");
b.HasKey("Id");
b.HasIndex("DateCreated")
.HasDatabaseName("IX_Scorer_CreatedAt");
b.HasIndex("MatchId");
b.HasIndex("PlayerId");
b.ToTable("Scorers", "Club12");
});
modelBuilder.Entity("Domain.Entities.Models.Stage", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uuid");
b.Property<string>("CreatedBy")
.IsRequired()
.HasColumnType("text");
b.Property<DateTime>("DateCreated")
.HasColumnType("timestamp without time zone");
b.Property<DateTime?>("DateUpdated")
.HasColumnType("timestamp without time zone");
b.Property<string>("Description")
.HasMaxLength(1000)
.HasColumnType("character varying(1000)");
b.Property<Guid>("DivisionId")
.HasColumnType("uuid");
b.Property<DateTime>("EndDate")
.HasColumnType("timestamp without time zone");
b.Property<bool>("IsActive")
.HasColumnType("boolean");
b.Property<bool>("IsElimination")
.HasColumnType("boolean");
b.Property<string>("Name")
.IsRequired()
.HasMaxLength(100)
.HasColumnType("character varying(100)");
b.Property<int>("Order")
.HasColumnType("integer");
b.Property<string>("StageType")
.IsRequired()
.HasColumnType("text");
b.Property<DateTime>("StartDate")
.HasColumnType("timestamp without time zone");
b.Property<string>("UpdatedBy")
.HasColumnType("text");
b.HasKey("Id");
b.HasIndex("DateCreated")
.HasDatabaseName("IX_Stage_CreatedAt");
b.HasIndex("DivisionId");
b.HasIndex("Name", "DivisionId")
.IsUnique()
.HasDatabaseName("CONSTRAINT_UNIQUE_STAGE_NAME_AND_DIVISIONID");
b.ToTable("Stages", "Club12");
});
modelBuilder.Entity("Domain.Entities.Models.StageTeamMatch", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uuid");
b.Property<string>("CreatedBy")
.IsRequired()
.HasColumnType("text");
b.Property<DateTime>("DateCreated")
.HasColumnType("timestamp without time zone");
b.Property<DateTime?>("DateUpdated")
.HasColumnType("timestamp without time zone");
b.Property<Guid>("StageId")
.HasColumnType("uuid");
b.Property<Guid>("TeamId")
.HasColumnType("uuid");
b.Property<string>("UpdatedBy")
.HasColumnType("text");
b.HasKey("Id");
b.HasIndex("DateCreated")
.HasDatabaseName("IX_StageTeamMatch_CreatedAt");
b.HasIndex("StageId");
b.HasIndex("TeamId");
b.ToTable("StageTeamMatches", "Club12");
});
modelBuilder.Entity("Domain.Entities.Models.Team", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uuid");
b.Property<string>("CreatedBy")
.IsRequired()
.HasColumnType("text");
b.Property<DateTime>("DateCreated")
.HasColumnType("timestamp without time zone");
b.Property<DateTime?>("DateUpdated")
.HasColumnType("timestamp without time zone");
b.Property<string>("LogoUrl")
.IsRequired()
.HasColumnType("text");
b.Property<string>("Name")
.IsRequired()
.HasColumnType("text");
b.Property<string>("ShirtColor")
.IsRequired()
.HasColumnType("text");
b.Property<string>("ThreeLetterCode")
.IsRequired()
.HasColumnType("text");
b.Property<Guid?>("TournamentId")
.HasColumnType("uuid");
b.Property<string>("UpdatedBy")
.HasColumnType("text");
b.HasKey("Id");
b.HasIndex("DateCreated")
.HasDatabaseName("IX_Team_CreatedAt");
b.HasIndex("TournamentId");
b.ToTable("Teams", "Club12");
});
modelBuilder.Entity("Domain.Entities.Models.Tournament", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uuid");
b.Property<string>("CreatedBy")
.IsRequired()
.HasColumnType("text");
b.Property<DateTime>("DateCreated")
.HasColumnType("timestamp without time zone");
b.Property<DateTime?>("DateUpdated")
.HasColumnType("timestamp without time zone");
b.Property<string>("Description")
.IsRequired()
.HasColumnType("text");
b.Property<int>("MaxTeams")
.HasColumnType("integer");
b.Property<int>("MinTeams")
.HasColumnType("integer");
b.Property<string>("Name")
.IsRequired()
.HasColumnType("text");
b.Property<DateTime>("StartDate")
.HasColumnType("timestamp without time zone");
b.Property<int>("Status")
.ValueGeneratedOnAdd()
.HasColumnType("integer")
.HasDefaultValue(0);
b.Property<DateTime>("TeamRegistrationDeadline")
.HasColumnType("timestamp without time zone");
b.Property<string>("UpdatedBy")
.HasColumnType("text");
b.HasKey("Id");
b.HasIndex("DateCreated")
.HasDatabaseName("IX_Tournament_CreatedAt");
b.ToTable("Tournaments", "Club12", t =>
{
t.HasCheckConstraint("CK_Tournament_DeadlineBeforeStart", "\"TeamRegistrationDeadline\" < \"StartDate\"");
});
});
modelBuilder.Entity("Domain.Entities.Models.Venue", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uuid");
b.Property<string>("Address")
.IsRequired()
.HasMaxLength(200)
.HasColumnType("character varying(200)");
b.Property<string>("CreatedBy")
.IsRequired()
.HasColumnType("text");
b.Property<DateTime>("DateCreated")
.HasColumnType("timestamp without time zone");
b.Property<DateTime?>("DateUpdated")
.HasColumnType("timestamp without time zone");
b.Property<string>("Name")
.IsRequired()
.HasMaxLength(50)
.HasColumnType("character varying(50)");
b.Property<string>("PhotoUrl")
.HasColumnType("text");
b.Property<string>("UpdatedBy")
.HasColumnType("text");
b.HasKey("Id");
b.HasIndex("DateCreated")
.HasDatabaseName("IX_Venue_CreatedAt");
b.ToTable("Venues", "Club12");
});
modelBuilder.Entity("Domain.Entities.Models.Division", b =>
{
b.HasOne("Domain.Entities.Models.Tournament", "Tournament")
.WithMany("Divisions")
.HasForeignKey("TournamentId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Tournament");
});
modelBuilder.Entity("Domain.Entities.Models.Match", b =>
{
b.HasOne("Domain.Entities.Models.Team", "HomeTeam")
.WithMany()
.HasForeignKey("HomeTeamId");
b.HasOne("Domain.Entities.Models.Stage", "Stage")
.WithMany("Matches")
.HasForeignKey("StageId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("Domain.Entities.Models.Venue", "Venue")
.WithMany()
.HasForeignKey("VenueId");
b.HasOne("Domain.Entities.Models.Team", "VisitorTeam")
.WithMany()
.HasForeignKey("VisitorTeamId");
b.HasOne("Domain.Entities.Models.Team", "WinningTeam")
.WithMany()
.HasForeignKey("WinningTeamId");
b.Navigation("HomeTeam");
b.Navigation("Stage");
b.Navigation("Venue");
b.Navigation("VisitorTeam");
b.Navigation("WinningTeam");
});
modelBuilder.Entity("Domain.Entities.Models.Player", b =>
{
b.HasOne("Domain.Entities.Models.Team", "Team")
.WithMany("Players")
.HasForeignKey("TeamId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Team");
});
modelBuilder.Entity("Domain.Entities.Models.PlayerSanction", b =>
{
b.HasOne("Domain.Entities.Models.Match", "Match")
.WithMany()
.HasForeignKey("MatchId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("Domain.Entities.Models.Player", "Player")
.WithMany()
.HasForeignKey("PlayerId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Match");
b.Navigation("Player");
});
modelBuilder.Entity("Domain.Entities.Models.PlayerStatistic", b =>
{
b.HasOne("Domain.Entities.Models.Match", "Match")
.WithMany("PlayerStatistics")
.HasForeignKey("MatchId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("Domain.Entities.Models.Player", "Player")
.WithMany()
.HasForeignKey("PlayerId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Match");
b.Navigation("Player");
});
modelBuilder.Entity("Domain.Entities.Models.Scorer", b =>
{
b.HasOne("Domain.Entities.Models.Match", "Match")
.WithMany("Scorers")
.HasForeignKey("MatchId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("Domain.Entities.Models.Player", "Player")
.WithMany("Scorers")
.HasForeignKey("PlayerId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Match");
b.Navigation("Player");
});
modelBuilder.Entity("Domain.Entities.Models.Stage", b =>
{
b.HasOne("Domain.Entities.Models.Division", "Division")
.WithMany("Stages")
.HasForeignKey("DivisionId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Division");
});
modelBuilder.Entity("Domain.Entities.Models.StageTeamMatch", b =>
{
b.HasOne("Domain.Entities.Models.Stage", "Stage")
.WithMany("StageTeamMatches")
.HasForeignKey("StageId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("Domain.Entities.Models.Team", "Team")
.WithMany("StageTeamMatches")
.HasForeignKey("TeamId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Stage");
b.Navigation("Team");
});
modelBuilder.Entity("Domain.Entities.Models.Team", b =>
{
b.HasOne("Domain.Entities.Models.Tournament", "Tournament")
.WithMany("Teams")
.HasForeignKey("TournamentId");
b.Navigation("Tournament");
});
modelBuilder.Entity("Domain.Entities.Models.Division", b =>
{
b.Navigation("Stages");
});
modelBuilder.Entity("Domain.Entities.Models.Match", b =>
{
b.Navigation("PlayerStatistics");
b.Navigation("Scorers");
});
modelBuilder.Entity("Domain.Entities.Models.Player", b =>
{
b.Navigation("Scorers");
});
modelBuilder.Entity("Domain.Entities.Models.Stage", b =>
{
b.Navigation("Matches");
b.Navigation("StageTeamMatches");
});
modelBuilder.Entity("Domain.Entities.Models.Team", b =>
{
b.Navigation("Players");
b.Navigation("StageTeamMatches");
});
modelBuilder.Entity("Domain.Entities.Models.Tournament", b =>
{
b.Navigation("Divisions");
b.Navigation("Teams");
});
#pragma warning restore 612, 618
}
}
}
@@ -0,0 +1,82 @@
using Microsoft.EntityFrameworkCore.Migrations;
using System;
#nullable disable
namespace Infrastructure.Migrations;
/// <inheritdoc />
public partial class AddSanctionAppeal : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.AddColumn<DateTime>(
name: "AppealDate",
schema: "Club12",
table: "PlayerSanctions",
type: "timestamp without time zone",
nullable: true);
migrationBuilder.AddColumn<string>(
name: "AppealReason",
schema: "Club12",
table: "PlayerSanctions",
type: "character varying(1000)",
maxLength: 1000,
nullable: true);
migrationBuilder.AddColumn<string>(
name: "AppealResolution",
schema: "Club12",
table: "PlayerSanctions",
type: "character varying(1000)",
maxLength: 1000,
nullable: true);
migrationBuilder.AddColumn<DateTime>(
name: "AppealResolvedDate",
schema: "Club12",
table: "PlayerSanctions",
type: "timestamp without time zone",
nullable: true);
migrationBuilder.AddColumn<string>(
name: "AppealStatus",
schema: "Club12",
table: "PlayerSanctions",
type: "text",
nullable: false,
defaultValue: "None");
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropColumn(
name: "AppealDate",
schema: "Club12",
table: "PlayerSanctions");
migrationBuilder.DropColumn(
name: "AppealReason",
schema: "Club12",
table: "PlayerSanctions");
migrationBuilder.DropColumn(
name: "AppealResolution",
schema: "Club12",
table: "PlayerSanctions");
migrationBuilder.DropColumn(
name: "AppealResolvedDate",
schema: "Club12",
table: "PlayerSanctions");
migrationBuilder.DropColumn(
name: "AppealStatus",
schema: "Club12",
table: "PlayerSanctions");
}
}
@@ -0,0 +1,959 @@
// <auto-generated />
using System;
using Infrastructure.Persistance;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Migrations;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
#nullable disable
namespace Infrastructure.Migrations
{
[DbContext(typeof(ApplicationDBContext))]
[Migration("20260816030250_AddPlayoffSeriesAndBracketName")]
partial class AddPlayoffSeriesAndBracketName
{
/// <inheritdoc />
protected override void BuildTargetModel(ModelBuilder modelBuilder)
{
#pragma warning disable 612, 618
modelBuilder
.HasAnnotation("ProductVersion", "8.0.30")
.HasAnnotation("Relational:MaxIdentifierLength", 63);
NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder);
modelBuilder.Entity("Domain.Entities.Models.BlogPost", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uuid");
b.Property<string>("Author")
.IsRequired()
.HasMaxLength(50)
.HasColumnType("character varying(50)");
b.Property<string>("CreatedBy")
.IsRequired()
.HasColumnType("text");
b.Property<DateTime>("DateCreated")
.HasColumnType("timestamp without time zone");
b.Property<DateTime?>("DateUpdated")
.HasColumnType("timestamp without time zone");
b.Property<string>("MarkdownText")
.IsRequired()
.HasColumnType("text");
b.Property<string>("PhotoUrl")
.HasMaxLength(2048)
.HasColumnType("character varying(2048)");
b.Property<string>("Title")
.IsRequired()
.HasColumnType("text");
b.Property<string>("UpdatedBy")
.HasColumnType("text");
b.Property<int>("Views")
.HasColumnType("integer");
b.HasKey("Id");
b.HasIndex("DateCreated")
.HasDatabaseName("IX_BlogPost_CreatedAt");
b.ToTable("BlogPosts", "Club12");
});
modelBuilder.Entity("Domain.Entities.Models.Division", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uuid");
b.Property<string>("CreatedBy")
.IsRequired()
.HasColumnType("text");
b.Property<DateTime>("DateCreated")
.HasColumnType("timestamp without time zone");
b.Property<DateTime?>("DateUpdated")
.HasColumnType("timestamp without time zone");
b.Property<bool>("IsCrossDivisionCup")
.HasColumnType("boolean");
b.Property<bool>("IsFinished")
.HasColumnType("boolean");
b.Property<string>("Name")
.IsRequired()
.HasMaxLength(30)
.HasColumnType("character varying(30)");
b.Property<Guid>("TournamentId")
.HasColumnType("uuid");
b.Property<string>("UpdatedBy")
.HasColumnType("text");
b.HasKey("Id");
b.HasIndex("DateCreated")
.HasDatabaseName("IX_Division_CreatedAt");
b.HasIndex("TournamentId");
b.ToTable("Divisions", "Club12");
});
modelBuilder.Entity("Domain.Entities.Models.Match", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uuid");
b.Property<string>("CreatedBy")
.IsRequired()
.HasColumnType("text");
b.Property<DateTime>("DateCreated")
.HasColumnType("timestamp without time zone");
b.Property<DateTime?>("DateUpdated")
.HasColumnType("timestamp without time zone");
b.Property<int?>("GameNumber")
.HasColumnType("integer");
b.Property<int?>("HomeScore")
.HasColumnType("integer");
b.Property<Guid?>("HomeTeamId")
.HasColumnType("uuid");
b.Property<bool>("IsFinished")
.HasColumnType("boolean");
b.Property<DateTime>("MatchDate")
.HasColumnType("timestamp without time zone");
b.Property<Guid?>("SeriesId")
.HasColumnType("uuid");
b.Property<Guid>("StageId")
.HasColumnType("uuid");
b.Property<string>("Type")
.IsRequired()
.HasColumnType("text");
b.Property<string>("UpdatedBy")
.HasColumnType("text");
b.Property<Guid?>("VenueId")
.HasColumnType("uuid");
b.Property<int?>("VisitorScore")
.HasColumnType("integer");
b.Property<Guid?>("VisitorTeamId")
.HasColumnType("uuid");
b.Property<Guid?>("WinningTeamId")
.HasColumnType("uuid");
b.HasKey("Id");
b.HasIndex("DateCreated")
.HasDatabaseName("IX_Match_CreatedAt");
b.HasIndex("HomeTeamId");
b.HasIndex("SeriesId");
b.HasIndex("StageId");
b.HasIndex("VenueId");
b.HasIndex("VisitorTeamId");
b.HasIndex("WinningTeamId");
b.ToTable("Matches", "Club12");
});
modelBuilder.Entity("Domain.Entities.Models.MatchSeries", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uuid");
b.Property<int>("BestOf")
.HasColumnType("integer");
b.Property<string>("CreatedBy")
.IsRequired()
.HasColumnType("text");
b.Property<DateTime>("DateCreated")
.HasColumnType("timestamp without time zone");
b.Property<DateTime?>("DateUpdated")
.HasColumnType("timestamp without time zone");
b.Property<Guid>("HomeTeamId")
.HasColumnType("uuid");
b.Property<Guid>("StageId")
.HasColumnType("uuid");
b.Property<string>("UpdatedBy")
.HasColumnType("text");
b.Property<Guid>("VisitorTeamId")
.HasColumnType("uuid");
b.Property<Guid?>("WinningTeamId")
.HasColumnType("uuid");
b.HasKey("Id");
b.HasIndex("DateCreated")
.HasDatabaseName("IX_MatchSeries_CreatedAt");
b.HasIndex("HomeTeamId");
b.HasIndex("StageId");
b.HasIndex("VisitorTeamId");
b.HasIndex("WinningTeamId");
b.ToTable("MatchSeries", "Club12");
});
modelBuilder.Entity("Domain.Entities.Models.Player", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uuid");
b.Property<DateTime>("BirthDate")
.HasColumnType("timestamp without time zone");
b.Property<string>("CreatedBy")
.IsRequired()
.HasColumnType("text");
b.Property<DateTime>("DateCreated")
.HasColumnType("timestamp without time zone");
b.Property<DateTime?>("DateUpdated")
.HasColumnType("timestamp without time zone");
b.Property<string>("DocumentNumber")
.IsRequired()
.HasMaxLength(15)
.HasColumnType("character varying(15)");
b.Property<string>("FirstName")
.IsRequired()
.HasMaxLength(70)
.HasColumnType("character varying(70)");
b.Property<bool>("IsSanctioned")
.HasColumnType("boolean");
b.Property<string>("LastName")
.IsRequired()
.HasMaxLength(70)
.HasColumnType("character varying(70)");
b.Property<string>("PhoneNumber")
.HasColumnType("text");
b.Property<string>("SecondName")
.HasMaxLength(70)
.HasColumnType("character varying(70)");
b.Property<string>("SocialSecurity")
.IsRequired()
.HasMaxLength(100)
.HasColumnType("character varying(100)");
b.Property<Guid>("TeamId")
.HasColumnType("uuid");
b.Property<string>("UpdatedBy")
.HasColumnType("text");
b.HasKey("Id");
b.HasIndex("DateCreated")
.HasDatabaseName("IX_Player_CreatedAt");
b.HasIndex("DocumentNumber")
.IsUnique();
b.HasIndex("TeamId");
b.ToTable("Players", "Club12");
});
modelBuilder.Entity("Domain.Entities.Models.PlayerSanction", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uuid");
b.Property<DateTime?>("AppealDate")
.HasColumnType("timestamp without time zone");
b.Property<string>("AppealReason")
.HasMaxLength(1000)
.HasColumnType("character varying(1000)");
b.Property<string>("AppealResolution")
.HasMaxLength(1000)
.HasColumnType("character varying(1000)");
b.Property<DateTime?>("AppealResolvedDate")
.HasColumnType("timestamp without time zone");
b.Property<string>("AppealStatus")
.IsRequired()
.HasColumnType("text");
b.Property<string>("CreatedBy")
.IsRequired()
.HasColumnType("text");
b.Property<DateTime>("DateCreated")
.HasColumnType("timestamp without time zone");
b.Property<DateTime?>("DateUpdated")
.HasColumnType("timestamp without time zone");
b.Property<string>("Description")
.IsRequired()
.HasMaxLength(255)
.HasColumnType("character varying(255)");
b.Property<int>("Duration")
.HasColumnType("integer");
b.Property<DateTime>("IssuedDate")
.HasColumnType("timestamp without time zone");
b.Property<Guid>("MatchId")
.HasColumnType("uuid");
b.Property<Guid>("PlayerId")
.HasColumnType("uuid");
b.Property<string>("UpdatedBy")
.HasColumnType("text");
b.HasKey("Id");
b.HasIndex("DateCreated")
.HasDatabaseName("IX_PlayerSanction_CreatedAt");
b.HasIndex("MatchId");
b.HasIndex("PlayerId");
b.ToTable("PlayerSanctions", "Club12");
});
modelBuilder.Entity("Domain.Entities.Models.PlayerStatistic", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uuid");
b.Property<string>("CreatedBy")
.IsRequired()
.HasColumnType("text");
b.Property<DateTime>("DateCreated")
.HasColumnType("timestamp without time zone");
b.Property<DateTime?>("DateUpdated")
.HasColumnType("timestamp without time zone");
b.Property<Guid>("MatchId")
.HasColumnType("uuid");
b.Property<Guid>("PlayerId")
.HasColumnType("uuid");
b.Property<string>("Type")
.IsRequired()
.HasColumnType("text");
b.Property<string>("UpdatedBy")
.HasColumnType("text");
b.Property<int>("Value")
.HasColumnType("integer");
b.HasKey("Id");
b.HasIndex("DateCreated")
.HasDatabaseName("IX_PlayerStatistic_CreatedAt");
b.HasIndex("MatchId");
b.HasIndex("PlayerId");
b.ToTable("PlayersStatistics", "Club12");
});
modelBuilder.Entity("Domain.Entities.Models.Scorer", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uuid");
b.Property<string>("CreatedBy")
.IsRequired()
.HasColumnType("text");
b.Property<DateTime>("DateCreated")
.HasColumnType("timestamp without time zone");
b.Property<DateTime?>("DateUpdated")
.HasColumnType("timestamp without time zone");
b.Property<Guid>("MatchId")
.HasColumnType("uuid");
b.Property<Guid>("PlayerId")
.HasColumnType("uuid");
b.Property<int>("Points")
.HasColumnType("integer");
b.Property<string>("UpdatedBy")
.HasColumnType("text");
b.HasKey("Id");
b.HasIndex("DateCreated")
.HasDatabaseName("IX_Scorer_CreatedAt");
b.HasIndex("MatchId");
b.HasIndex("PlayerId");
b.ToTable("Scorers", "Club12");
});
modelBuilder.Entity("Domain.Entities.Models.Stage", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uuid");
b.Property<int>("BestOf")
.ValueGeneratedOnAdd()
.HasColumnType("integer")
.HasDefaultValue(1);
b.Property<string>("BracketName")
.HasMaxLength(100)
.HasColumnType("character varying(100)");
b.Property<string>("CreatedBy")
.IsRequired()
.HasColumnType("text");
b.Property<DateTime>("DateCreated")
.HasColumnType("timestamp without time zone");
b.Property<DateTime?>("DateUpdated")
.HasColumnType("timestamp without time zone");
b.Property<string>("Description")
.HasMaxLength(1000)
.HasColumnType("character varying(1000)");
b.Property<Guid>("DivisionId")
.HasColumnType("uuid");
b.Property<DateTime>("EndDate")
.HasColumnType("timestamp without time zone");
b.Property<bool>("IsActive")
.HasColumnType("boolean");
b.Property<bool>("IsElimination")
.HasColumnType("boolean");
b.Property<string>("Name")
.IsRequired()
.HasMaxLength(100)
.HasColumnType("character varying(100)");
b.Property<int>("Order")
.HasColumnType("integer");
b.Property<int>("RoundRobinLegs")
.ValueGeneratedOnAdd()
.HasColumnType("integer")
.HasDefaultValue(1);
b.Property<string>("StageType")
.IsRequired()
.HasColumnType("text");
b.Property<DateTime>("StartDate")
.HasColumnType("timestamp without time zone");
b.Property<string>("UpdatedBy")
.HasColumnType("text");
b.HasKey("Id");
b.HasIndex("DateCreated")
.HasDatabaseName("IX_Stage_CreatedAt");
b.HasIndex("DivisionId");
b.HasIndex("Name", "DivisionId")
.IsUnique()
.HasDatabaseName("CONSTRAINT_UNIQUE_STAGE_NAME_AND_DIVISIONID");
b.ToTable("Stages", "Club12");
});
modelBuilder.Entity("Domain.Entities.Models.StageTeamMatch", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uuid");
b.Property<string>("CreatedBy")
.IsRequired()
.HasColumnType("text");
b.Property<DateTime>("DateCreated")
.HasColumnType("timestamp without time zone");
b.Property<DateTime?>("DateUpdated")
.HasColumnType("timestamp without time zone");
b.Property<Guid>("StageId")
.HasColumnType("uuid");
b.Property<Guid>("TeamId")
.HasColumnType("uuid");
b.Property<string>("UpdatedBy")
.HasColumnType("text");
b.HasKey("Id");
b.HasIndex("DateCreated")
.HasDatabaseName("IX_StageTeamMatch_CreatedAt");
b.HasIndex("StageId");
b.HasIndex("TeamId");
b.ToTable("StageTeamMatches", "Club12");
});
modelBuilder.Entity("Domain.Entities.Models.Team", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uuid");
b.Property<string>("CreatedBy")
.IsRequired()
.HasColumnType("text");
b.Property<DateTime>("DateCreated")
.HasColumnType("timestamp without time zone");
b.Property<DateTime?>("DateUpdated")
.HasColumnType("timestamp without time zone");
b.Property<string>("LogoUrl")
.IsRequired()
.HasColumnType("text");
b.Property<string>("Name")
.IsRequired()
.HasColumnType("text");
b.Property<string>("ShirtColor")
.IsRequired()
.HasColumnType("text");
b.Property<string>("ThreeLetterCode")
.IsRequired()
.HasColumnType("text");
b.Property<Guid?>("TournamentId")
.HasColumnType("uuid");
b.Property<string>("UpdatedBy")
.HasColumnType("text");
b.HasKey("Id");
b.HasIndex("DateCreated")
.HasDatabaseName("IX_Team_CreatedAt");
b.HasIndex("TournamentId");
b.ToTable("Teams", "Club12");
});
modelBuilder.Entity("Domain.Entities.Models.Tournament", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uuid");
b.Property<string>("CreatedBy")
.IsRequired()
.HasColumnType("text");
b.Property<DateTime>("DateCreated")
.HasColumnType("timestamp without time zone");
b.Property<DateTime?>("DateUpdated")
.HasColumnType("timestamp without time zone");
b.Property<string>("Description")
.IsRequired()
.HasColumnType("text");
b.Property<int>("MaxTeams")
.HasColumnType("integer");
b.Property<int>("MinTeams")
.HasColumnType("integer");
b.Property<string>("Name")
.IsRequired()
.HasColumnType("text");
b.Property<DateTime>("StartDate")
.HasColumnType("timestamp without time zone");
b.Property<int>("Status")
.ValueGeneratedOnAdd()
.HasColumnType("integer")
.HasDefaultValue(0);
b.Property<DateTime>("TeamRegistrationDeadline")
.HasColumnType("timestamp without time zone");
b.Property<string>("UpdatedBy")
.HasColumnType("text");
b.HasKey("Id");
b.HasIndex("DateCreated")
.HasDatabaseName("IX_Tournament_CreatedAt");
b.ToTable("Tournaments", "Club12", t =>
{
t.HasCheckConstraint("CK_Tournament_DeadlineBeforeStart", "\"TeamRegistrationDeadline\" < \"StartDate\"");
});
});
modelBuilder.Entity("Domain.Entities.Models.Venue", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uuid");
b.Property<string>("Address")
.IsRequired()
.HasMaxLength(200)
.HasColumnType("character varying(200)");
b.Property<string>("CreatedBy")
.IsRequired()
.HasColumnType("text");
b.Property<DateTime>("DateCreated")
.HasColumnType("timestamp without time zone");
b.Property<DateTime?>("DateUpdated")
.HasColumnType("timestamp without time zone");
b.Property<string>("Name")
.IsRequired()
.HasMaxLength(50)
.HasColumnType("character varying(50)");
b.Property<string>("PhotoUrl")
.HasColumnType("text");
b.Property<string>("UpdatedBy")
.HasColumnType("text");
b.HasKey("Id");
b.HasIndex("DateCreated")
.HasDatabaseName("IX_Venue_CreatedAt");
b.ToTable("Venues", "Club12");
});
modelBuilder.Entity("Domain.Entities.Models.Division", b =>
{
b.HasOne("Domain.Entities.Models.Tournament", "Tournament")
.WithMany("Divisions")
.HasForeignKey("TournamentId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Tournament");
});
modelBuilder.Entity("Domain.Entities.Models.Match", b =>
{
b.HasOne("Domain.Entities.Models.Team", "HomeTeam")
.WithMany()
.HasForeignKey("HomeTeamId");
b.HasOne("Domain.Entities.Models.MatchSeries", "Series")
.WithMany("Matches")
.HasForeignKey("SeriesId");
b.HasOne("Domain.Entities.Models.Stage", "Stage")
.WithMany("Matches")
.HasForeignKey("StageId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("Domain.Entities.Models.Venue", "Venue")
.WithMany()
.HasForeignKey("VenueId");
b.HasOne("Domain.Entities.Models.Team", "VisitorTeam")
.WithMany()
.HasForeignKey("VisitorTeamId");
b.HasOne("Domain.Entities.Models.Team", "WinningTeam")
.WithMany()
.HasForeignKey("WinningTeamId");
b.Navigation("HomeTeam");
b.Navigation("Series");
b.Navigation("Stage");
b.Navigation("Venue");
b.Navigation("VisitorTeam");
b.Navigation("WinningTeam");
});
modelBuilder.Entity("Domain.Entities.Models.MatchSeries", b =>
{
b.HasOne("Domain.Entities.Models.Team", "HomeTeam")
.WithMany()
.HasForeignKey("HomeTeamId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("Domain.Entities.Models.Stage", "Stage")
.WithMany("MatchSeries")
.HasForeignKey("StageId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("Domain.Entities.Models.Team", "VisitorTeam")
.WithMany()
.HasForeignKey("VisitorTeamId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("Domain.Entities.Models.Team", "WinningTeam")
.WithMany()
.HasForeignKey("WinningTeamId");
b.Navigation("HomeTeam");
b.Navigation("Stage");
b.Navigation("VisitorTeam");
b.Navigation("WinningTeam");
});
modelBuilder.Entity("Domain.Entities.Models.Player", b =>
{
b.HasOne("Domain.Entities.Models.Team", "Team")
.WithMany("Players")
.HasForeignKey("TeamId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Team");
});
modelBuilder.Entity("Domain.Entities.Models.PlayerSanction", b =>
{
b.HasOne("Domain.Entities.Models.Match", "Match")
.WithMany()
.HasForeignKey("MatchId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("Domain.Entities.Models.Player", "Player")
.WithMany()
.HasForeignKey("PlayerId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Match");
b.Navigation("Player");
});
modelBuilder.Entity("Domain.Entities.Models.PlayerStatistic", b =>
{
b.HasOne("Domain.Entities.Models.Match", "Match")
.WithMany("PlayerStatistics")
.HasForeignKey("MatchId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("Domain.Entities.Models.Player", "Player")
.WithMany()
.HasForeignKey("PlayerId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Match");
b.Navigation("Player");
});
modelBuilder.Entity("Domain.Entities.Models.Scorer", b =>
{
b.HasOne("Domain.Entities.Models.Match", "Match")
.WithMany("Scorers")
.HasForeignKey("MatchId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("Domain.Entities.Models.Player", "Player")
.WithMany("Scorers")
.HasForeignKey("PlayerId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Match");
b.Navigation("Player");
});
modelBuilder.Entity("Domain.Entities.Models.Stage", b =>
{
b.HasOne("Domain.Entities.Models.Division", "Division")
.WithMany("Stages")
.HasForeignKey("DivisionId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Division");
});
modelBuilder.Entity("Domain.Entities.Models.StageTeamMatch", b =>
{
b.HasOne("Domain.Entities.Models.Stage", "Stage")
.WithMany("StageTeamMatches")
.HasForeignKey("StageId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("Domain.Entities.Models.Team", "Team")
.WithMany("StageTeamMatches")
.HasForeignKey("TeamId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Stage");
b.Navigation("Team");
});
modelBuilder.Entity("Domain.Entities.Models.Team", b =>
{
b.HasOne("Domain.Entities.Models.Tournament", "Tournament")
.WithMany("Teams")
.HasForeignKey("TournamentId");
b.Navigation("Tournament");
});
modelBuilder.Entity("Domain.Entities.Models.Division", b =>
{
b.Navigation("Stages");
});
modelBuilder.Entity("Domain.Entities.Models.Match", b =>
{
b.Navigation("PlayerStatistics");
b.Navigation("Scorers");
});
modelBuilder.Entity("Domain.Entities.Models.MatchSeries", b =>
{
b.Navigation("Matches");
});
modelBuilder.Entity("Domain.Entities.Models.Player", b =>
{
b.Navigation("Scorers");
});
modelBuilder.Entity("Domain.Entities.Models.Stage", b =>
{
b.Navigation("MatchSeries");
b.Navigation("Matches");
b.Navigation("StageTeamMatches");
});
modelBuilder.Entity("Domain.Entities.Models.Team", b =>
{
b.Navigation("Players");
b.Navigation("StageTeamMatches");
});
modelBuilder.Entity("Domain.Entities.Models.Tournament", b =>
{
b.Navigation("Divisions");
b.Navigation("Teams");
});
#pragma warning restore 612, 618
}
}
}
@@ -0,0 +1,202 @@
using Microsoft.EntityFrameworkCore.Migrations;
using System;
#nullable disable
namespace Infrastructure.Migrations;
/// <inheritdoc />
public partial class AddPlayoffSeriesAndBracketName : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.AddColumn<int>(
name: "BestOf",
schema: "Club12",
table: "Stages",
type: "integer",
nullable: false,
defaultValue: 1);
migrationBuilder.AddColumn<string>(
name: "BracketName",
schema: "Club12",
table: "Stages",
type: "character varying(100)",
maxLength: 100,
nullable: true);
migrationBuilder.AddColumn<int>(
name: "RoundRobinLegs",
schema: "Club12",
table: "Stages",
type: "integer",
nullable: false,
defaultValue: 1);
migrationBuilder.AddColumn<int>(
name: "GameNumber",
schema: "Club12",
table: "Matches",
type: "integer",
nullable: true);
migrationBuilder.AddColumn<Guid>(
name: "SeriesId",
schema: "Club12",
table: "Matches",
type: "uuid",
nullable: true);
migrationBuilder.AddColumn<bool>(
name: "IsCrossDivisionCup",
schema: "Club12",
table: "Divisions",
type: "boolean",
nullable: false,
defaultValue: false);
migrationBuilder.CreateTable(
name: "MatchSeries",
schema: "Club12",
columns: table => new
{
Id = table.Column<Guid>(type: "uuid", nullable: false),
StageId = table.Column<Guid>(type: "uuid", nullable: false),
HomeTeamId = table.Column<Guid>(type: "uuid", nullable: false),
VisitorTeamId = table.Column<Guid>(type: "uuid", nullable: false),
BestOf = table.Column<int>(type: "integer", nullable: false),
WinningTeamId = table.Column<Guid>(type: "uuid", nullable: true),
DateCreated = table.Column<DateTime>(type: "timestamp without time zone", nullable: false),
DateUpdated = table.Column<DateTime>(type: "timestamp without time zone", nullable: true),
CreatedBy = table.Column<string>(type: "text", nullable: false),
UpdatedBy = table.Column<string>(type: "text", nullable: true)
},
constraints: table =>
{
table.PrimaryKey("PK_MatchSeries", x => x.Id);
table.ForeignKey(
name: "FK_MatchSeries_Stages_StageId",
column: x => x.StageId,
principalSchema: "Club12",
principalTable: "Stages",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
table.ForeignKey(
name: "FK_MatchSeries_Teams_HomeTeamId",
column: x => x.HomeTeamId,
principalSchema: "Club12",
principalTable: "Teams",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
table.ForeignKey(
name: "FK_MatchSeries_Teams_VisitorTeamId",
column: x => x.VisitorTeamId,
principalSchema: "Club12",
principalTable: "Teams",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
table.ForeignKey(
name: "FK_MatchSeries_Teams_WinningTeamId",
column: x => x.WinningTeamId,
principalSchema: "Club12",
principalTable: "Teams",
principalColumn: "Id");
});
migrationBuilder.CreateIndex(
name: "IX_Matches_SeriesId",
schema: "Club12",
table: "Matches",
column: "SeriesId");
migrationBuilder.CreateIndex(
name: "IX_MatchSeries_CreatedAt",
schema: "Club12",
table: "MatchSeries",
column: "DateCreated");
migrationBuilder.CreateIndex(
name: "IX_MatchSeries_HomeTeamId",
schema: "Club12",
table: "MatchSeries",
column: "HomeTeamId");
migrationBuilder.CreateIndex(
name: "IX_MatchSeries_StageId",
schema: "Club12",
table: "MatchSeries",
column: "StageId");
migrationBuilder.CreateIndex(
name: "IX_MatchSeries_VisitorTeamId",
schema: "Club12",
table: "MatchSeries",
column: "VisitorTeamId");
migrationBuilder.CreateIndex(
name: "IX_MatchSeries_WinningTeamId",
schema: "Club12",
table: "MatchSeries",
column: "WinningTeamId");
migrationBuilder.AddForeignKey(
name: "FK_Matches_MatchSeries_SeriesId",
schema: "Club12",
table: "Matches",
column: "SeriesId",
principalSchema: "Club12",
principalTable: "MatchSeries",
principalColumn: "Id");
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropForeignKey(
name: "FK_Matches_MatchSeries_SeriesId",
schema: "Club12",
table: "Matches");
migrationBuilder.DropTable(
name: "MatchSeries",
schema: "Club12");
migrationBuilder.DropIndex(
name: "IX_Matches_SeriesId",
schema: "Club12",
table: "Matches");
migrationBuilder.DropColumn(
name: "BestOf",
schema: "Club12",
table: "Stages");
migrationBuilder.DropColumn(
name: "BracketName",
schema: "Club12",
table: "Stages");
migrationBuilder.DropColumn(
name: "RoundRobinLegs",
schema: "Club12",
table: "Stages");
migrationBuilder.DropColumn(
name: "GameNumber",
schema: "Club12",
table: "Matches");
migrationBuilder.DropColumn(
name: "SeriesId",
schema: "Club12",
table: "Matches");
migrationBuilder.DropColumn(
name: "IsCrossDivisionCup",
schema: "Club12",
table: "Divisions");
}
}
@@ -0,0 +1,975 @@
// <auto-generated />
using System;
using Infrastructure.Persistance;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Migrations;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
#nullable disable
namespace Infrastructure.Migrations
{
[DbContext(typeof(ApplicationDBContext))]
[Migration("20260817044123_AddSlugToTournamentAndTeam")]
partial class AddSlugToTournamentAndTeam
{
/// <inheritdoc />
protected override void BuildTargetModel(ModelBuilder modelBuilder)
{
#pragma warning disable 612, 618
modelBuilder
.HasAnnotation("ProductVersion", "8.0.30")
.HasAnnotation("Relational:MaxIdentifierLength", 63);
NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder);
modelBuilder.Entity("Domain.Entities.Models.BlogPost", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uuid");
b.Property<string>("Author")
.IsRequired()
.HasMaxLength(50)
.HasColumnType("character varying(50)");
b.Property<string>("CreatedBy")
.IsRequired()
.HasColumnType("text");
b.Property<DateTime>("DateCreated")
.HasColumnType("timestamp without time zone");
b.Property<DateTime?>("DateUpdated")
.HasColumnType("timestamp without time zone");
b.Property<string>("MarkdownText")
.IsRequired()
.HasColumnType("text");
b.Property<string>("PhotoUrl")
.HasMaxLength(2048)
.HasColumnType("character varying(2048)");
b.Property<string>("Title")
.IsRequired()
.HasColumnType("text");
b.Property<string>("UpdatedBy")
.HasColumnType("text");
b.Property<int>("Views")
.HasColumnType("integer");
b.HasKey("Id");
b.HasIndex("DateCreated")
.HasDatabaseName("IX_BlogPost_CreatedAt");
b.ToTable("BlogPosts", "Club12");
});
modelBuilder.Entity("Domain.Entities.Models.Division", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uuid");
b.Property<string>("CreatedBy")
.IsRequired()
.HasColumnType("text");
b.Property<DateTime>("DateCreated")
.HasColumnType("timestamp without time zone");
b.Property<DateTime?>("DateUpdated")
.HasColumnType("timestamp without time zone");
b.Property<bool>("IsCrossDivisionCup")
.HasColumnType("boolean");
b.Property<bool>("IsFinished")
.HasColumnType("boolean");
b.Property<string>("Name")
.IsRequired()
.HasMaxLength(30)
.HasColumnType("character varying(30)");
b.Property<Guid>("TournamentId")
.HasColumnType("uuid");
b.Property<string>("UpdatedBy")
.HasColumnType("text");
b.HasKey("Id");
b.HasIndex("DateCreated")
.HasDatabaseName("IX_Division_CreatedAt");
b.HasIndex("TournamentId");
b.ToTable("Divisions", "Club12");
});
modelBuilder.Entity("Domain.Entities.Models.Match", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uuid");
b.Property<string>("CreatedBy")
.IsRequired()
.HasColumnType("text");
b.Property<DateTime>("DateCreated")
.HasColumnType("timestamp without time zone");
b.Property<DateTime?>("DateUpdated")
.HasColumnType("timestamp without time zone");
b.Property<int?>("GameNumber")
.HasColumnType("integer");
b.Property<int?>("HomeScore")
.HasColumnType("integer");
b.Property<Guid?>("HomeTeamId")
.HasColumnType("uuid");
b.Property<bool>("IsFinished")
.HasColumnType("boolean");
b.Property<DateTime>("MatchDate")
.HasColumnType("timestamp without time zone");
b.Property<Guid?>("SeriesId")
.HasColumnType("uuid");
b.Property<Guid>("StageId")
.HasColumnType("uuid");
b.Property<string>("Type")
.IsRequired()
.HasColumnType("text");
b.Property<string>("UpdatedBy")
.HasColumnType("text");
b.Property<Guid?>("VenueId")
.HasColumnType("uuid");
b.Property<int?>("VisitorScore")
.HasColumnType("integer");
b.Property<Guid?>("VisitorTeamId")
.HasColumnType("uuid");
b.Property<Guid?>("WinningTeamId")
.HasColumnType("uuid");
b.HasKey("Id");
b.HasIndex("DateCreated")
.HasDatabaseName("IX_Match_CreatedAt");
b.HasIndex("HomeTeamId");
b.HasIndex("SeriesId");
b.HasIndex("StageId");
b.HasIndex("VenueId");
b.HasIndex("VisitorTeamId");
b.HasIndex("WinningTeamId");
b.ToTable("Matches", "Club12");
});
modelBuilder.Entity("Domain.Entities.Models.MatchSeries", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uuid");
b.Property<int>("BestOf")
.HasColumnType("integer");
b.Property<string>("CreatedBy")
.IsRequired()
.HasColumnType("text");
b.Property<DateTime>("DateCreated")
.HasColumnType("timestamp without time zone");
b.Property<DateTime?>("DateUpdated")
.HasColumnType("timestamp without time zone");
b.Property<Guid>("HomeTeamId")
.HasColumnType("uuid");
b.Property<Guid>("StageId")
.HasColumnType("uuid");
b.Property<string>("UpdatedBy")
.HasColumnType("text");
b.Property<Guid>("VisitorTeamId")
.HasColumnType("uuid");
b.Property<Guid?>("WinningTeamId")
.HasColumnType("uuid");
b.HasKey("Id");
b.HasIndex("DateCreated")
.HasDatabaseName("IX_MatchSeries_CreatedAt");
b.HasIndex("HomeTeamId");
b.HasIndex("StageId");
b.HasIndex("VisitorTeamId");
b.HasIndex("WinningTeamId");
b.ToTable("MatchSeries", "Club12");
});
modelBuilder.Entity("Domain.Entities.Models.Player", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uuid");
b.Property<DateTime>("BirthDate")
.HasColumnType("timestamp without time zone");
b.Property<string>("CreatedBy")
.IsRequired()
.HasColumnType("text");
b.Property<DateTime>("DateCreated")
.HasColumnType("timestamp without time zone");
b.Property<DateTime?>("DateUpdated")
.HasColumnType("timestamp without time zone");
b.Property<string>("DocumentNumber")
.IsRequired()
.HasMaxLength(15)
.HasColumnType("character varying(15)");
b.Property<string>("FirstName")
.IsRequired()
.HasMaxLength(70)
.HasColumnType("character varying(70)");
b.Property<bool>("IsSanctioned")
.HasColumnType("boolean");
b.Property<string>("LastName")
.IsRequired()
.HasMaxLength(70)
.HasColumnType("character varying(70)");
b.Property<string>("PhoneNumber")
.HasColumnType("text");
b.Property<string>("SecondName")
.HasMaxLength(70)
.HasColumnType("character varying(70)");
b.Property<string>("SocialSecurity")
.IsRequired()
.HasMaxLength(100)
.HasColumnType("character varying(100)");
b.Property<Guid>("TeamId")
.HasColumnType("uuid");
b.Property<string>("UpdatedBy")
.HasColumnType("text");
b.HasKey("Id");
b.HasIndex("DateCreated")
.HasDatabaseName("IX_Player_CreatedAt");
b.HasIndex("DocumentNumber")
.IsUnique();
b.HasIndex("TeamId");
b.ToTable("Players", "Club12");
});
modelBuilder.Entity("Domain.Entities.Models.PlayerSanction", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uuid");
b.Property<DateTime?>("AppealDate")
.HasColumnType("timestamp without time zone");
b.Property<string>("AppealReason")
.HasMaxLength(1000)
.HasColumnType("character varying(1000)");
b.Property<string>("AppealResolution")
.HasMaxLength(1000)
.HasColumnType("character varying(1000)");
b.Property<DateTime?>("AppealResolvedDate")
.HasColumnType("timestamp without time zone");
b.Property<string>("AppealStatus")
.IsRequired()
.HasColumnType("text");
b.Property<string>("CreatedBy")
.IsRequired()
.HasColumnType("text");
b.Property<DateTime>("DateCreated")
.HasColumnType("timestamp without time zone");
b.Property<DateTime?>("DateUpdated")
.HasColumnType("timestamp without time zone");
b.Property<string>("Description")
.IsRequired()
.HasMaxLength(255)
.HasColumnType("character varying(255)");
b.Property<int>("Duration")
.HasColumnType("integer");
b.Property<DateTime>("IssuedDate")
.HasColumnType("timestamp without time zone");
b.Property<Guid>("MatchId")
.HasColumnType("uuid");
b.Property<Guid>("PlayerId")
.HasColumnType("uuid");
b.Property<string>("UpdatedBy")
.HasColumnType("text");
b.HasKey("Id");
b.HasIndex("DateCreated")
.HasDatabaseName("IX_PlayerSanction_CreatedAt");
b.HasIndex("MatchId");
b.HasIndex("PlayerId");
b.ToTable("PlayerSanctions", "Club12");
});
modelBuilder.Entity("Domain.Entities.Models.PlayerStatistic", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uuid");
b.Property<string>("CreatedBy")
.IsRequired()
.HasColumnType("text");
b.Property<DateTime>("DateCreated")
.HasColumnType("timestamp without time zone");
b.Property<DateTime?>("DateUpdated")
.HasColumnType("timestamp without time zone");
b.Property<Guid>("MatchId")
.HasColumnType("uuid");
b.Property<Guid>("PlayerId")
.HasColumnType("uuid");
b.Property<string>("Type")
.IsRequired()
.HasColumnType("text");
b.Property<string>("UpdatedBy")
.HasColumnType("text");
b.Property<int>("Value")
.HasColumnType("integer");
b.HasKey("Id");
b.HasIndex("DateCreated")
.HasDatabaseName("IX_PlayerStatistic_CreatedAt");
b.HasIndex("MatchId");
b.HasIndex("PlayerId");
b.ToTable("PlayersStatistics", "Club12");
});
modelBuilder.Entity("Domain.Entities.Models.Scorer", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uuid");
b.Property<string>("CreatedBy")
.IsRequired()
.HasColumnType("text");
b.Property<DateTime>("DateCreated")
.HasColumnType("timestamp without time zone");
b.Property<DateTime?>("DateUpdated")
.HasColumnType("timestamp without time zone");
b.Property<Guid>("MatchId")
.HasColumnType("uuid");
b.Property<Guid>("PlayerId")
.HasColumnType("uuid");
b.Property<int>("Points")
.HasColumnType("integer");
b.Property<string>("UpdatedBy")
.HasColumnType("text");
b.HasKey("Id");
b.HasIndex("DateCreated")
.HasDatabaseName("IX_Scorer_CreatedAt");
b.HasIndex("MatchId");
b.HasIndex("PlayerId");
b.ToTable("Scorers", "Club12");
});
modelBuilder.Entity("Domain.Entities.Models.Stage", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uuid");
b.Property<int>("BestOf")
.ValueGeneratedOnAdd()
.HasColumnType("integer")
.HasDefaultValue(1);
b.Property<string>("BracketName")
.HasMaxLength(100)
.HasColumnType("character varying(100)");
b.Property<string>("CreatedBy")
.IsRequired()
.HasColumnType("text");
b.Property<DateTime>("DateCreated")
.HasColumnType("timestamp without time zone");
b.Property<DateTime?>("DateUpdated")
.HasColumnType("timestamp without time zone");
b.Property<string>("Description")
.HasMaxLength(1000)
.HasColumnType("character varying(1000)");
b.Property<Guid>("DivisionId")
.HasColumnType("uuid");
b.Property<DateTime>("EndDate")
.HasColumnType("timestamp without time zone");
b.Property<bool>("IsActive")
.HasColumnType("boolean");
b.Property<bool>("IsElimination")
.HasColumnType("boolean");
b.Property<string>("Name")
.IsRequired()
.HasMaxLength(100)
.HasColumnType("character varying(100)");
b.Property<int>("Order")
.HasColumnType("integer");
b.Property<int>("RoundRobinLegs")
.ValueGeneratedOnAdd()
.HasColumnType("integer")
.HasDefaultValue(1);
b.Property<string>("StageType")
.IsRequired()
.HasColumnType("text");
b.Property<DateTime>("StartDate")
.HasColumnType("timestamp without time zone");
b.Property<string>("UpdatedBy")
.HasColumnType("text");
b.HasKey("Id");
b.HasIndex("DateCreated")
.HasDatabaseName("IX_Stage_CreatedAt");
b.HasIndex("DivisionId");
b.HasIndex("Name", "DivisionId")
.IsUnique()
.HasDatabaseName("CONSTRAINT_UNIQUE_STAGE_NAME_AND_DIVISIONID");
b.ToTable("Stages", "Club12");
});
modelBuilder.Entity("Domain.Entities.Models.StageTeamMatch", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uuid");
b.Property<string>("CreatedBy")
.IsRequired()
.HasColumnType("text");
b.Property<DateTime>("DateCreated")
.HasColumnType("timestamp without time zone");
b.Property<DateTime?>("DateUpdated")
.HasColumnType("timestamp without time zone");
b.Property<Guid>("StageId")
.HasColumnType("uuid");
b.Property<Guid>("TeamId")
.HasColumnType("uuid");
b.Property<string>("UpdatedBy")
.HasColumnType("text");
b.HasKey("Id");
b.HasIndex("DateCreated")
.HasDatabaseName("IX_StageTeamMatch_CreatedAt");
b.HasIndex("StageId");
b.HasIndex("TeamId");
b.ToTable("StageTeamMatches", "Club12");
});
modelBuilder.Entity("Domain.Entities.Models.Team", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uuid");
b.Property<string>("CreatedBy")
.IsRequired()
.HasColumnType("text");
b.Property<DateTime>("DateCreated")
.HasColumnType("timestamp without time zone");
b.Property<DateTime?>("DateUpdated")
.HasColumnType("timestamp without time zone");
b.Property<string>("LogoUrl")
.IsRequired()
.HasColumnType("text");
b.Property<string>("Name")
.IsRequired()
.HasColumnType("text");
b.Property<string>("ShirtColor")
.IsRequired()
.HasColumnType("text");
b.Property<string>("Slug")
.IsRequired()
.HasMaxLength(220)
.HasColumnType("character varying(220)");
b.Property<string>("ThreeLetterCode")
.IsRequired()
.HasColumnType("text");
b.Property<Guid?>("TournamentId")
.HasColumnType("uuid");
b.Property<string>("UpdatedBy")
.HasColumnType("text");
b.HasKey("Id");
b.HasIndex("DateCreated")
.HasDatabaseName("IX_Team_CreatedAt");
b.HasIndex("Slug")
.IsUnique();
b.HasIndex("TournamentId");
b.ToTable("Teams", "Club12");
});
modelBuilder.Entity("Domain.Entities.Models.Tournament", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uuid");
b.Property<string>("CreatedBy")
.IsRequired()
.HasColumnType("text");
b.Property<DateTime>("DateCreated")
.HasColumnType("timestamp without time zone");
b.Property<DateTime?>("DateUpdated")
.HasColumnType("timestamp without time zone");
b.Property<string>("Description")
.IsRequired()
.HasColumnType("text");
b.Property<int>("MaxTeams")
.HasColumnType("integer");
b.Property<int>("MinTeams")
.HasColumnType("integer");
b.Property<string>("Name")
.IsRequired()
.HasColumnType("text");
b.Property<string>("Slug")
.IsRequired()
.HasMaxLength(220)
.HasColumnType("character varying(220)");
b.Property<DateTime>("StartDate")
.HasColumnType("timestamp without time zone");
b.Property<int>("Status")
.ValueGeneratedOnAdd()
.HasColumnType("integer")
.HasDefaultValue(0);
b.Property<DateTime>("TeamRegistrationDeadline")
.HasColumnType("timestamp without time zone");
b.Property<string>("UpdatedBy")
.HasColumnType("text");
b.HasKey("Id");
b.HasIndex("DateCreated")
.HasDatabaseName("IX_Tournament_CreatedAt");
b.HasIndex("Slug")
.IsUnique();
b.ToTable("Tournaments", "Club12", t =>
{
t.HasCheckConstraint("CK_Tournament_DeadlineBeforeStart", "\"TeamRegistrationDeadline\" < \"StartDate\"");
});
});
modelBuilder.Entity("Domain.Entities.Models.Venue", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uuid");
b.Property<string>("Address")
.IsRequired()
.HasMaxLength(200)
.HasColumnType("character varying(200)");
b.Property<string>("CreatedBy")
.IsRequired()
.HasColumnType("text");
b.Property<DateTime>("DateCreated")
.HasColumnType("timestamp without time zone");
b.Property<DateTime?>("DateUpdated")
.HasColumnType("timestamp without time zone");
b.Property<string>("Name")
.IsRequired()
.HasMaxLength(50)
.HasColumnType("character varying(50)");
b.Property<string>("PhotoUrl")
.HasColumnType("text");
b.Property<string>("UpdatedBy")
.HasColumnType("text");
b.HasKey("Id");
b.HasIndex("DateCreated")
.HasDatabaseName("IX_Venue_CreatedAt");
b.ToTable("Venues", "Club12");
});
modelBuilder.Entity("Domain.Entities.Models.Division", b =>
{
b.HasOne("Domain.Entities.Models.Tournament", "Tournament")
.WithMany("Divisions")
.HasForeignKey("TournamentId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Tournament");
});
modelBuilder.Entity("Domain.Entities.Models.Match", b =>
{
b.HasOne("Domain.Entities.Models.Team", "HomeTeam")
.WithMany()
.HasForeignKey("HomeTeamId");
b.HasOne("Domain.Entities.Models.MatchSeries", "Series")
.WithMany("Matches")
.HasForeignKey("SeriesId");
b.HasOne("Domain.Entities.Models.Stage", "Stage")
.WithMany("Matches")
.HasForeignKey("StageId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("Domain.Entities.Models.Venue", "Venue")
.WithMany()
.HasForeignKey("VenueId");
b.HasOne("Domain.Entities.Models.Team", "VisitorTeam")
.WithMany()
.HasForeignKey("VisitorTeamId");
b.HasOne("Domain.Entities.Models.Team", "WinningTeam")
.WithMany()
.HasForeignKey("WinningTeamId");
b.Navigation("HomeTeam");
b.Navigation("Series");
b.Navigation("Stage");
b.Navigation("Venue");
b.Navigation("VisitorTeam");
b.Navigation("WinningTeam");
});
modelBuilder.Entity("Domain.Entities.Models.MatchSeries", b =>
{
b.HasOne("Domain.Entities.Models.Team", "HomeTeam")
.WithMany()
.HasForeignKey("HomeTeamId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("Domain.Entities.Models.Stage", "Stage")
.WithMany("MatchSeries")
.HasForeignKey("StageId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("Domain.Entities.Models.Team", "VisitorTeam")
.WithMany()
.HasForeignKey("VisitorTeamId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("Domain.Entities.Models.Team", "WinningTeam")
.WithMany()
.HasForeignKey("WinningTeamId");
b.Navigation("HomeTeam");
b.Navigation("Stage");
b.Navigation("VisitorTeam");
b.Navigation("WinningTeam");
});
modelBuilder.Entity("Domain.Entities.Models.Player", b =>
{
b.HasOne("Domain.Entities.Models.Team", "Team")
.WithMany("Players")
.HasForeignKey("TeamId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Team");
});
modelBuilder.Entity("Domain.Entities.Models.PlayerSanction", b =>
{
b.HasOne("Domain.Entities.Models.Match", "Match")
.WithMany()
.HasForeignKey("MatchId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("Domain.Entities.Models.Player", "Player")
.WithMany()
.HasForeignKey("PlayerId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Match");
b.Navigation("Player");
});
modelBuilder.Entity("Domain.Entities.Models.PlayerStatistic", b =>
{
b.HasOne("Domain.Entities.Models.Match", "Match")
.WithMany("PlayerStatistics")
.HasForeignKey("MatchId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("Domain.Entities.Models.Player", "Player")
.WithMany()
.HasForeignKey("PlayerId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Match");
b.Navigation("Player");
});
modelBuilder.Entity("Domain.Entities.Models.Scorer", b =>
{
b.HasOne("Domain.Entities.Models.Match", "Match")
.WithMany("Scorers")
.HasForeignKey("MatchId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("Domain.Entities.Models.Player", "Player")
.WithMany("Scorers")
.HasForeignKey("PlayerId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Match");
b.Navigation("Player");
});
modelBuilder.Entity("Domain.Entities.Models.Stage", b =>
{
b.HasOne("Domain.Entities.Models.Division", "Division")
.WithMany("Stages")
.HasForeignKey("DivisionId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Division");
});
modelBuilder.Entity("Domain.Entities.Models.StageTeamMatch", b =>
{
b.HasOne("Domain.Entities.Models.Stage", "Stage")
.WithMany("StageTeamMatches")
.HasForeignKey("StageId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("Domain.Entities.Models.Team", "Team")
.WithMany("StageTeamMatches")
.HasForeignKey("TeamId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Stage");
b.Navigation("Team");
});
modelBuilder.Entity("Domain.Entities.Models.Team", b =>
{
b.HasOne("Domain.Entities.Models.Tournament", "Tournament")
.WithMany("Teams")
.HasForeignKey("TournamentId");
b.Navigation("Tournament");
});
modelBuilder.Entity("Domain.Entities.Models.Division", b =>
{
b.Navigation("Stages");
});
modelBuilder.Entity("Domain.Entities.Models.Match", b =>
{
b.Navigation("PlayerStatistics");
b.Navigation("Scorers");
});
modelBuilder.Entity("Domain.Entities.Models.MatchSeries", b =>
{
b.Navigation("Matches");
});
modelBuilder.Entity("Domain.Entities.Models.Player", b =>
{
b.Navigation("Scorers");
});
modelBuilder.Entity("Domain.Entities.Models.Stage", b =>
{
b.Navigation("MatchSeries");
b.Navigation("Matches");
b.Navigation("StageTeamMatches");
});
modelBuilder.Entity("Domain.Entities.Models.Team", b =>
{
b.Navigation("Players");
b.Navigation("StageTeamMatches");
});
modelBuilder.Entity("Domain.Entities.Models.Tournament", b =>
{
b.Navigation("Divisions");
b.Navigation("Teams");
});
#pragma warning restore 612, 618
}
}
}
@@ -0,0 +1,146 @@
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace Infrastructure.Migrations;
/// <inheritdoc />
public partial class AddSlugToTournamentAndTeam : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.AddColumn<string>(
name: "Slug",
schema: "Club12",
table: "Tournaments",
type: "character varying(220)",
maxLength: 220,
nullable: true);
migrationBuilder.AddColumn<string>(
name: "Slug",
schema: "Club12",
table: "Teams",
type: "character varying(220)",
maxLength: 220,
nullable: true);
// Backfills every existing row's Slug from its current Name, mirroring
// SlugGenerator.GenerateSlug (lowercase, accented characters
// transliterated to their base letter, non-alphanumeric runs collapsed
// to a single hyphen, leading/trailing hyphens trimmed). Rows whose
// computed base slug collides get a numeric suffix (-2, -3, ...)
// ordered by Id, the same disambiguation strategy SlugGenerator uses
// for newly created rows.
migrationBuilder.Sql(
@"
WITH base AS (
SELECT ""Id"",
trim(both '-' from
regexp_replace(
translate(lower(""Name""), 'áéíóúüñ', 'aeiouun'),
'[^a-z0-9]+', '-', 'g'
)
) AS slug_base
FROM ""Club12"".""Tournaments""
),
numbered AS (
SELECT ""Id"", slug_base,
ROW_NUMBER() OVER (PARTITION BY slug_base ORDER BY ""Id"") AS rn
FROM base
)
UPDATE ""Club12"".""Tournaments"" t
SET ""Slug"" = CASE WHEN n.rn = 1 THEN n.slug_base ELSE n.slug_base || '-' || n.rn::text END
FROM numbered n
WHERE t.""Id"" = n.""Id"";
"
);
migrationBuilder.Sql(
@"
WITH base AS (
SELECT ""Id"",
trim(both '-' from
regexp_replace(
translate(lower(""Name""), 'áéíóúüñ', 'aeiouun'),
'[^a-z0-9]+', '-', 'g'
)
) AS slug_base
FROM ""Club12"".""Teams""
),
numbered AS (
SELECT ""Id"", slug_base,
ROW_NUMBER() OVER (PARTITION BY slug_base ORDER BY ""Id"") AS rn
FROM base
)
UPDATE ""Club12"".""Teams"" t
SET ""Slug"" = CASE WHEN n.rn = 1 THEN n.slug_base ELSE n.slug_base || '-' || n.rn::text END
FROM numbered n
WHERE t.""Id"" = n.""Id"";
"
);
migrationBuilder.AlterColumn<string>(
name: "Slug",
schema: "Club12",
table: "Tournaments",
type: "character varying(220)",
maxLength: 220,
nullable: false,
oldClrType: typeof(string),
oldType: "character varying(220)",
oldMaxLength: 220,
oldNullable: true);
migrationBuilder.AlterColumn<string>(
name: "Slug",
schema: "Club12",
table: "Teams",
type: "character varying(220)",
maxLength: 220,
nullable: false,
oldClrType: typeof(string),
oldType: "character varying(220)",
oldMaxLength: 220,
oldNullable: true);
migrationBuilder.CreateIndex(
name: "IX_Tournaments_Slug",
schema: "Club12",
table: "Tournaments",
column: "Slug",
unique: true);
migrationBuilder.CreateIndex(
name: "IX_Teams_Slug",
schema: "Club12",
table: "Teams",
column: "Slug",
unique: true);
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropIndex(
name: "IX_Tournaments_Slug",
schema: "Club12",
table: "Tournaments");
migrationBuilder.DropIndex(
name: "IX_Teams_Slug",
schema: "Club12",
table: "Teams");
migrationBuilder.DropColumn(
name: "Slug",
schema: "Club12",
table: "Tournaments");
migrationBuilder.DropColumn(
name: "Slug",
schema: "Club12",
table: "Teams");
}
}
@@ -0,0 +1,983 @@
// <auto-generated />
using System;
using Infrastructure.Persistance;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Migrations;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
#nullable disable
namespace Infrastructure.Migrations
{
[DbContext(typeof(ApplicationDBContext))]
[Migration("20260817064644_AddSlugToMatch")]
partial class AddSlugToMatch
{
/// <inheritdoc />
protected override void BuildTargetModel(ModelBuilder modelBuilder)
{
#pragma warning disable 612, 618
modelBuilder
.HasAnnotation("ProductVersion", "8.0.30")
.HasAnnotation("Relational:MaxIdentifierLength", 63);
NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder);
modelBuilder.Entity("Domain.Entities.Models.BlogPost", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uuid");
b.Property<string>("Author")
.IsRequired()
.HasMaxLength(50)
.HasColumnType("character varying(50)");
b.Property<string>("CreatedBy")
.IsRequired()
.HasColumnType("text");
b.Property<DateTime>("DateCreated")
.HasColumnType("timestamp without time zone");
b.Property<DateTime?>("DateUpdated")
.HasColumnType("timestamp without time zone");
b.Property<string>("MarkdownText")
.IsRequired()
.HasColumnType("text");
b.Property<string>("PhotoUrl")
.HasMaxLength(2048)
.HasColumnType("character varying(2048)");
b.Property<string>("Title")
.IsRequired()
.HasColumnType("text");
b.Property<string>("UpdatedBy")
.HasColumnType("text");
b.Property<int>("Views")
.HasColumnType("integer");
b.HasKey("Id");
b.HasIndex("DateCreated")
.HasDatabaseName("IX_BlogPost_CreatedAt");
b.ToTable("BlogPosts", "Club12");
});
modelBuilder.Entity("Domain.Entities.Models.Division", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uuid");
b.Property<string>("CreatedBy")
.IsRequired()
.HasColumnType("text");
b.Property<DateTime>("DateCreated")
.HasColumnType("timestamp without time zone");
b.Property<DateTime?>("DateUpdated")
.HasColumnType("timestamp without time zone");
b.Property<bool>("IsCrossDivisionCup")
.HasColumnType("boolean");
b.Property<bool>("IsFinished")
.HasColumnType("boolean");
b.Property<string>("Name")
.IsRequired()
.HasMaxLength(30)
.HasColumnType("character varying(30)");
b.Property<Guid>("TournamentId")
.HasColumnType("uuid");
b.Property<string>("UpdatedBy")
.HasColumnType("text");
b.HasKey("Id");
b.HasIndex("DateCreated")
.HasDatabaseName("IX_Division_CreatedAt");
b.HasIndex("TournamentId");
b.ToTable("Divisions", "Club12");
});
modelBuilder.Entity("Domain.Entities.Models.Match", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uuid");
b.Property<string>("CreatedBy")
.IsRequired()
.HasColumnType("text");
b.Property<DateTime>("DateCreated")
.HasColumnType("timestamp without time zone");
b.Property<DateTime?>("DateUpdated")
.HasColumnType("timestamp without time zone");
b.Property<int?>("GameNumber")
.HasColumnType("integer");
b.Property<int?>("HomeScore")
.HasColumnType("integer");
b.Property<Guid?>("HomeTeamId")
.HasColumnType("uuid");
b.Property<bool>("IsFinished")
.HasColumnType("boolean");
b.Property<DateTime>("MatchDate")
.HasColumnType("timestamp without time zone");
b.Property<Guid?>("SeriesId")
.HasColumnType("uuid");
b.Property<string>("Slug")
.IsRequired()
.HasMaxLength(220)
.HasColumnType("character varying(220)");
b.Property<Guid>("StageId")
.HasColumnType("uuid");
b.Property<string>("Type")
.IsRequired()
.HasColumnType("text");
b.Property<string>("UpdatedBy")
.HasColumnType("text");
b.Property<Guid?>("VenueId")
.HasColumnType("uuid");
b.Property<int?>("VisitorScore")
.HasColumnType("integer");
b.Property<Guid?>("VisitorTeamId")
.HasColumnType("uuid");
b.Property<Guid?>("WinningTeamId")
.HasColumnType("uuid");
b.HasKey("Id");
b.HasIndex("DateCreated")
.HasDatabaseName("IX_Match_CreatedAt");
b.HasIndex("HomeTeamId");
b.HasIndex("SeriesId");
b.HasIndex("Slug")
.IsUnique();
b.HasIndex("StageId");
b.HasIndex("VenueId");
b.HasIndex("VisitorTeamId");
b.HasIndex("WinningTeamId");
b.ToTable("Matches", "Club12");
});
modelBuilder.Entity("Domain.Entities.Models.MatchSeries", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uuid");
b.Property<int>("BestOf")
.HasColumnType("integer");
b.Property<string>("CreatedBy")
.IsRequired()
.HasColumnType("text");
b.Property<DateTime>("DateCreated")
.HasColumnType("timestamp without time zone");
b.Property<DateTime?>("DateUpdated")
.HasColumnType("timestamp without time zone");
b.Property<Guid>("HomeTeamId")
.HasColumnType("uuid");
b.Property<Guid>("StageId")
.HasColumnType("uuid");
b.Property<string>("UpdatedBy")
.HasColumnType("text");
b.Property<Guid>("VisitorTeamId")
.HasColumnType("uuid");
b.Property<Guid?>("WinningTeamId")
.HasColumnType("uuid");
b.HasKey("Id");
b.HasIndex("DateCreated")
.HasDatabaseName("IX_MatchSeries_CreatedAt");
b.HasIndex("HomeTeamId");
b.HasIndex("StageId");
b.HasIndex("VisitorTeamId");
b.HasIndex("WinningTeamId");
b.ToTable("MatchSeries", "Club12");
});
modelBuilder.Entity("Domain.Entities.Models.Player", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uuid");
b.Property<DateTime>("BirthDate")
.HasColumnType("timestamp without time zone");
b.Property<string>("CreatedBy")
.IsRequired()
.HasColumnType("text");
b.Property<DateTime>("DateCreated")
.HasColumnType("timestamp without time zone");
b.Property<DateTime?>("DateUpdated")
.HasColumnType("timestamp without time zone");
b.Property<string>("DocumentNumber")
.IsRequired()
.HasMaxLength(15)
.HasColumnType("character varying(15)");
b.Property<string>("FirstName")
.IsRequired()
.HasMaxLength(70)
.HasColumnType("character varying(70)");
b.Property<bool>("IsSanctioned")
.HasColumnType("boolean");
b.Property<string>("LastName")
.IsRequired()
.HasMaxLength(70)
.HasColumnType("character varying(70)");
b.Property<string>("PhoneNumber")
.HasColumnType("text");
b.Property<string>("SecondName")
.HasMaxLength(70)
.HasColumnType("character varying(70)");
b.Property<string>("SocialSecurity")
.IsRequired()
.HasMaxLength(100)
.HasColumnType("character varying(100)");
b.Property<Guid>("TeamId")
.HasColumnType("uuid");
b.Property<string>("UpdatedBy")
.HasColumnType("text");
b.HasKey("Id");
b.HasIndex("DateCreated")
.HasDatabaseName("IX_Player_CreatedAt");
b.HasIndex("DocumentNumber")
.IsUnique();
b.HasIndex("TeamId");
b.ToTable("Players", "Club12");
});
modelBuilder.Entity("Domain.Entities.Models.PlayerSanction", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uuid");
b.Property<DateTime?>("AppealDate")
.HasColumnType("timestamp without time zone");
b.Property<string>("AppealReason")
.HasMaxLength(1000)
.HasColumnType("character varying(1000)");
b.Property<string>("AppealResolution")
.HasMaxLength(1000)
.HasColumnType("character varying(1000)");
b.Property<DateTime?>("AppealResolvedDate")
.HasColumnType("timestamp without time zone");
b.Property<string>("AppealStatus")
.IsRequired()
.HasColumnType("text");
b.Property<string>("CreatedBy")
.IsRequired()
.HasColumnType("text");
b.Property<DateTime>("DateCreated")
.HasColumnType("timestamp without time zone");
b.Property<DateTime?>("DateUpdated")
.HasColumnType("timestamp without time zone");
b.Property<string>("Description")
.IsRequired()
.HasMaxLength(255)
.HasColumnType("character varying(255)");
b.Property<int>("Duration")
.HasColumnType("integer");
b.Property<DateTime>("IssuedDate")
.HasColumnType("timestamp without time zone");
b.Property<Guid>("MatchId")
.HasColumnType("uuid");
b.Property<Guid>("PlayerId")
.HasColumnType("uuid");
b.Property<string>("UpdatedBy")
.HasColumnType("text");
b.HasKey("Id");
b.HasIndex("DateCreated")
.HasDatabaseName("IX_PlayerSanction_CreatedAt");
b.HasIndex("MatchId");
b.HasIndex("PlayerId");
b.ToTable("PlayerSanctions", "Club12");
});
modelBuilder.Entity("Domain.Entities.Models.PlayerStatistic", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uuid");
b.Property<string>("CreatedBy")
.IsRequired()
.HasColumnType("text");
b.Property<DateTime>("DateCreated")
.HasColumnType("timestamp without time zone");
b.Property<DateTime?>("DateUpdated")
.HasColumnType("timestamp without time zone");
b.Property<Guid>("MatchId")
.HasColumnType("uuid");
b.Property<Guid>("PlayerId")
.HasColumnType("uuid");
b.Property<string>("Type")
.IsRequired()
.HasColumnType("text");
b.Property<string>("UpdatedBy")
.HasColumnType("text");
b.Property<int>("Value")
.HasColumnType("integer");
b.HasKey("Id");
b.HasIndex("DateCreated")
.HasDatabaseName("IX_PlayerStatistic_CreatedAt");
b.HasIndex("MatchId");
b.HasIndex("PlayerId");
b.ToTable("PlayersStatistics", "Club12");
});
modelBuilder.Entity("Domain.Entities.Models.Scorer", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uuid");
b.Property<string>("CreatedBy")
.IsRequired()
.HasColumnType("text");
b.Property<DateTime>("DateCreated")
.HasColumnType("timestamp without time zone");
b.Property<DateTime?>("DateUpdated")
.HasColumnType("timestamp without time zone");
b.Property<Guid>("MatchId")
.HasColumnType("uuid");
b.Property<Guid>("PlayerId")
.HasColumnType("uuid");
b.Property<int>("Points")
.HasColumnType("integer");
b.Property<string>("UpdatedBy")
.HasColumnType("text");
b.HasKey("Id");
b.HasIndex("DateCreated")
.HasDatabaseName("IX_Scorer_CreatedAt");
b.HasIndex("MatchId");
b.HasIndex("PlayerId");
b.ToTable("Scorers", "Club12");
});
modelBuilder.Entity("Domain.Entities.Models.Stage", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uuid");
b.Property<int>("BestOf")
.ValueGeneratedOnAdd()
.HasColumnType("integer")
.HasDefaultValue(1);
b.Property<string>("BracketName")
.HasMaxLength(100)
.HasColumnType("character varying(100)");
b.Property<string>("CreatedBy")
.IsRequired()
.HasColumnType("text");
b.Property<DateTime>("DateCreated")
.HasColumnType("timestamp without time zone");
b.Property<DateTime?>("DateUpdated")
.HasColumnType("timestamp without time zone");
b.Property<string>("Description")
.HasMaxLength(1000)
.HasColumnType("character varying(1000)");
b.Property<Guid>("DivisionId")
.HasColumnType("uuid");
b.Property<DateTime>("EndDate")
.HasColumnType("timestamp without time zone");
b.Property<bool>("IsActive")
.HasColumnType("boolean");
b.Property<bool>("IsElimination")
.HasColumnType("boolean");
b.Property<string>("Name")
.IsRequired()
.HasMaxLength(100)
.HasColumnType("character varying(100)");
b.Property<int>("Order")
.HasColumnType("integer");
b.Property<int>("RoundRobinLegs")
.ValueGeneratedOnAdd()
.HasColumnType("integer")
.HasDefaultValue(1);
b.Property<string>("StageType")
.IsRequired()
.HasColumnType("text");
b.Property<DateTime>("StartDate")
.HasColumnType("timestamp without time zone");
b.Property<string>("UpdatedBy")
.HasColumnType("text");
b.HasKey("Id");
b.HasIndex("DateCreated")
.HasDatabaseName("IX_Stage_CreatedAt");
b.HasIndex("DivisionId");
b.HasIndex("Name", "DivisionId")
.IsUnique()
.HasDatabaseName("CONSTRAINT_UNIQUE_STAGE_NAME_AND_DIVISIONID");
b.ToTable("Stages", "Club12");
});
modelBuilder.Entity("Domain.Entities.Models.StageTeamMatch", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uuid");
b.Property<string>("CreatedBy")
.IsRequired()
.HasColumnType("text");
b.Property<DateTime>("DateCreated")
.HasColumnType("timestamp without time zone");
b.Property<DateTime?>("DateUpdated")
.HasColumnType("timestamp without time zone");
b.Property<Guid>("StageId")
.HasColumnType("uuid");
b.Property<Guid>("TeamId")
.HasColumnType("uuid");
b.Property<string>("UpdatedBy")
.HasColumnType("text");
b.HasKey("Id");
b.HasIndex("DateCreated")
.HasDatabaseName("IX_StageTeamMatch_CreatedAt");
b.HasIndex("StageId");
b.HasIndex("TeamId");
b.ToTable("StageTeamMatches", "Club12");
});
modelBuilder.Entity("Domain.Entities.Models.Team", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uuid");
b.Property<string>("CreatedBy")
.IsRequired()
.HasColumnType("text");
b.Property<DateTime>("DateCreated")
.HasColumnType("timestamp without time zone");
b.Property<DateTime?>("DateUpdated")
.HasColumnType("timestamp without time zone");
b.Property<string>("LogoUrl")
.IsRequired()
.HasColumnType("text");
b.Property<string>("Name")
.IsRequired()
.HasColumnType("text");
b.Property<string>("ShirtColor")
.IsRequired()
.HasColumnType("text");
b.Property<string>("Slug")
.IsRequired()
.HasMaxLength(220)
.HasColumnType("character varying(220)");
b.Property<string>("ThreeLetterCode")
.IsRequired()
.HasColumnType("text");
b.Property<Guid?>("TournamentId")
.HasColumnType("uuid");
b.Property<string>("UpdatedBy")
.HasColumnType("text");
b.HasKey("Id");
b.HasIndex("DateCreated")
.HasDatabaseName("IX_Team_CreatedAt");
b.HasIndex("Slug")
.IsUnique();
b.HasIndex("TournamentId");
b.ToTable("Teams", "Club12");
});
modelBuilder.Entity("Domain.Entities.Models.Tournament", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uuid");
b.Property<string>("CreatedBy")
.IsRequired()
.HasColumnType("text");
b.Property<DateTime>("DateCreated")
.HasColumnType("timestamp without time zone");
b.Property<DateTime?>("DateUpdated")
.HasColumnType("timestamp without time zone");
b.Property<string>("Description")
.IsRequired()
.HasColumnType("text");
b.Property<int>("MaxTeams")
.HasColumnType("integer");
b.Property<int>("MinTeams")
.HasColumnType("integer");
b.Property<string>("Name")
.IsRequired()
.HasColumnType("text");
b.Property<string>("Slug")
.IsRequired()
.HasMaxLength(220)
.HasColumnType("character varying(220)");
b.Property<DateTime>("StartDate")
.HasColumnType("timestamp without time zone");
b.Property<int>("Status")
.ValueGeneratedOnAdd()
.HasColumnType("integer")
.HasDefaultValue(0);
b.Property<DateTime>("TeamRegistrationDeadline")
.HasColumnType("timestamp without time zone");
b.Property<string>("UpdatedBy")
.HasColumnType("text");
b.HasKey("Id");
b.HasIndex("DateCreated")
.HasDatabaseName("IX_Tournament_CreatedAt");
b.HasIndex("Slug")
.IsUnique();
b.ToTable("Tournaments", "Club12", t =>
{
t.HasCheckConstraint("CK_Tournament_DeadlineBeforeStart", "\"TeamRegistrationDeadline\" < \"StartDate\"");
});
});
modelBuilder.Entity("Domain.Entities.Models.Venue", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uuid");
b.Property<string>("Address")
.IsRequired()
.HasMaxLength(200)
.HasColumnType("character varying(200)");
b.Property<string>("CreatedBy")
.IsRequired()
.HasColumnType("text");
b.Property<DateTime>("DateCreated")
.HasColumnType("timestamp without time zone");
b.Property<DateTime?>("DateUpdated")
.HasColumnType("timestamp without time zone");
b.Property<string>("Name")
.IsRequired()
.HasMaxLength(50)
.HasColumnType("character varying(50)");
b.Property<string>("PhotoUrl")
.HasColumnType("text");
b.Property<string>("UpdatedBy")
.HasColumnType("text");
b.HasKey("Id");
b.HasIndex("DateCreated")
.HasDatabaseName("IX_Venue_CreatedAt");
b.ToTable("Venues", "Club12");
});
modelBuilder.Entity("Domain.Entities.Models.Division", b =>
{
b.HasOne("Domain.Entities.Models.Tournament", "Tournament")
.WithMany("Divisions")
.HasForeignKey("TournamentId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Tournament");
});
modelBuilder.Entity("Domain.Entities.Models.Match", b =>
{
b.HasOne("Domain.Entities.Models.Team", "HomeTeam")
.WithMany()
.HasForeignKey("HomeTeamId");
b.HasOne("Domain.Entities.Models.MatchSeries", "Series")
.WithMany("Matches")
.HasForeignKey("SeriesId");
b.HasOne("Domain.Entities.Models.Stage", "Stage")
.WithMany("Matches")
.HasForeignKey("StageId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("Domain.Entities.Models.Venue", "Venue")
.WithMany()
.HasForeignKey("VenueId");
b.HasOne("Domain.Entities.Models.Team", "VisitorTeam")
.WithMany()
.HasForeignKey("VisitorTeamId");
b.HasOne("Domain.Entities.Models.Team", "WinningTeam")
.WithMany()
.HasForeignKey("WinningTeamId");
b.Navigation("HomeTeam");
b.Navigation("Series");
b.Navigation("Stage");
b.Navigation("Venue");
b.Navigation("VisitorTeam");
b.Navigation("WinningTeam");
});
modelBuilder.Entity("Domain.Entities.Models.MatchSeries", b =>
{
b.HasOne("Domain.Entities.Models.Team", "HomeTeam")
.WithMany()
.HasForeignKey("HomeTeamId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("Domain.Entities.Models.Stage", "Stage")
.WithMany("MatchSeries")
.HasForeignKey("StageId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("Domain.Entities.Models.Team", "VisitorTeam")
.WithMany()
.HasForeignKey("VisitorTeamId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("Domain.Entities.Models.Team", "WinningTeam")
.WithMany()
.HasForeignKey("WinningTeamId");
b.Navigation("HomeTeam");
b.Navigation("Stage");
b.Navigation("VisitorTeam");
b.Navigation("WinningTeam");
});
modelBuilder.Entity("Domain.Entities.Models.Player", b =>
{
b.HasOne("Domain.Entities.Models.Team", "Team")
.WithMany("Players")
.HasForeignKey("TeamId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Team");
});
modelBuilder.Entity("Domain.Entities.Models.PlayerSanction", b =>
{
b.HasOne("Domain.Entities.Models.Match", "Match")
.WithMany()
.HasForeignKey("MatchId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("Domain.Entities.Models.Player", "Player")
.WithMany()
.HasForeignKey("PlayerId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Match");
b.Navigation("Player");
});
modelBuilder.Entity("Domain.Entities.Models.PlayerStatistic", b =>
{
b.HasOne("Domain.Entities.Models.Match", "Match")
.WithMany("PlayerStatistics")
.HasForeignKey("MatchId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("Domain.Entities.Models.Player", "Player")
.WithMany()
.HasForeignKey("PlayerId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Match");
b.Navigation("Player");
});
modelBuilder.Entity("Domain.Entities.Models.Scorer", b =>
{
b.HasOne("Domain.Entities.Models.Match", "Match")
.WithMany("Scorers")
.HasForeignKey("MatchId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("Domain.Entities.Models.Player", "Player")
.WithMany("Scorers")
.HasForeignKey("PlayerId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Match");
b.Navigation("Player");
});
modelBuilder.Entity("Domain.Entities.Models.Stage", b =>
{
b.HasOne("Domain.Entities.Models.Division", "Division")
.WithMany("Stages")
.HasForeignKey("DivisionId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Division");
});
modelBuilder.Entity("Domain.Entities.Models.StageTeamMatch", b =>
{
b.HasOne("Domain.Entities.Models.Stage", "Stage")
.WithMany("StageTeamMatches")
.HasForeignKey("StageId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("Domain.Entities.Models.Team", "Team")
.WithMany("StageTeamMatches")
.HasForeignKey("TeamId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Stage");
b.Navigation("Team");
});
modelBuilder.Entity("Domain.Entities.Models.Team", b =>
{
b.HasOne("Domain.Entities.Models.Tournament", "Tournament")
.WithMany("Teams")
.HasForeignKey("TournamentId");
b.Navigation("Tournament");
});
modelBuilder.Entity("Domain.Entities.Models.Division", b =>
{
b.Navigation("Stages");
});
modelBuilder.Entity("Domain.Entities.Models.Match", b =>
{
b.Navigation("PlayerStatistics");
b.Navigation("Scorers");
});
modelBuilder.Entity("Domain.Entities.Models.MatchSeries", b =>
{
b.Navigation("Matches");
});
modelBuilder.Entity("Domain.Entities.Models.Player", b =>
{
b.Navigation("Scorers");
});
modelBuilder.Entity("Domain.Entities.Models.Stage", b =>
{
b.Navigation("MatchSeries");
b.Navigation("Matches");
b.Navigation("StageTeamMatches");
});
modelBuilder.Entity("Domain.Entities.Models.Team", b =>
{
b.Navigation("Players");
b.Navigation("StageTeamMatches");
});
modelBuilder.Entity("Domain.Entities.Models.Tournament", b =>
{
b.Navigation("Divisions");
b.Navigation("Teams");
});
#pragma warning restore 612, 618
}
}
}
@@ -0,0 +1,98 @@
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace Infrastructure.Migrations;
/// <inheritdoc />
public partial class AddSlugToMatch : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.AddColumn<string>(
name: "Slug",
schema: "Club12",
table: "Matches",
type: "character varying(220)",
maxLength: 220,
nullable: true);
// Backfills every existing match's Slug from its home/visitor team names
// and match date, mirroring MatchSlugSourceBuilder.Build + SlugGenerator.GenerateSlug
// ("{homeTeamName} vs {visitorTeamName} {yyyy-MM-dd}", lowercased, accented
// characters transliterated to their base letter, non-alphanumeric runs
// collapsed to a single hyphen, leading/trailing hyphens trimmed). A team
// missing from either side (unseeded match) falls back to the same "TBD"
// placeholder the application uses. Rows whose computed base slug collides
// (e.g. two legs between the same pairing on the same day, or several
// unseeded matches) get a numeric suffix (-2, -3, ...) ordered by Id, the
// same disambiguation strategy SlugGenerator uses for newly created rows.
migrationBuilder.Sql(
@"
WITH base AS (
SELECT m.""Id"",
trim(both '-' from
regexp_replace(
translate(
lower(
concat(
COALESCE(ht.""Name"", 'TBD'), ' vs ', COALESCE(vt.""Name"", 'TBD'),
' ', to_char(m.""MatchDate"", 'YYYY-MM-DD')
)
),
'áéíóúüñ', 'aeiouun'
),
'[^a-z0-9]+', '-', 'g'
)
) AS slug_base
FROM ""Club12"".""Matches"" m
LEFT JOIN ""Club12"".""Teams"" ht ON ht.""Id"" = m.""HomeTeamId""
LEFT JOIN ""Club12"".""Teams"" vt ON vt.""Id"" = m.""VisitorTeamId""
),
numbered AS (
SELECT ""Id"", slug_base,
ROW_NUMBER() OVER (PARTITION BY slug_base ORDER BY ""Id"") AS rn
FROM base
)
UPDATE ""Club12"".""Matches"" m
SET ""Slug"" = CASE WHEN n.rn = 1 THEN n.slug_base ELSE n.slug_base || '-' || n.rn::text END
FROM numbered n
WHERE m.""Id"" = n.""Id"";
"
);
migrationBuilder.AlterColumn<string>(
name: "Slug",
schema: "Club12",
table: "Matches",
type: "character varying(220)",
maxLength: 220,
nullable: false,
oldClrType: typeof(string),
oldType: "character varying(220)",
oldMaxLength: 220,
oldNullable: true);
migrationBuilder.CreateIndex(
name: "IX_Matches_Slug",
schema: "Club12",
table: "Matches",
column: "Slug",
unique: true);
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropIndex(
name: "IX_Matches_Slug",
schema: "Club12",
table: "Matches");
migrationBuilder.DropColumn(
name: "Slug",
schema: "Club12",
table: "Matches");
}
}
@@ -0,0 +1,115 @@
using Microsoft.EntityFrameworkCore.Migrations;
using System;
#nullable disable
namespace Infrastructure.Migrations;
/// <inheritdoc />
public partial class AddPlayerTeamRegistrationTable : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.CreateTable(
name: "PlayerTeamRegistrations",
schema: "Club12",
columns: table => new
{
Id = table.Column<Guid>(type: "uuid", nullable: false),
PlayerId = table.Column<Guid>(type: "uuid", nullable: false),
TeamId = table.Column<Guid>(type: "uuid", nullable: false),
TournamentId = table.Column<Guid>(type: "uuid", nullable: false),
DateCreated = table.Column<DateTime>(type: "timestamp without time zone", nullable: false),
DateUpdated = table.Column<DateTime>(type: "timestamp without time zone", nullable: true),
CreatedBy = table.Column<string>(type: "text", nullable: false),
UpdatedBy = table.Column<string>(type: "text", nullable: true)
},
constraints: table =>
{
table.PrimaryKey("PK_PlayerTeamRegistrations", x => x.Id);
table.ForeignKey(
name: "FK_PlayerTeamRegistrations_Players_PlayerId",
column: x => x.PlayerId,
principalSchema: "Club12",
principalTable: "Players",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
table.ForeignKey(
name: "FK_PlayerTeamRegistrations_Teams_TeamId",
column: x => x.TeamId,
principalSchema: "Club12",
principalTable: "Teams",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
table.ForeignKey(
name: "FK_PlayerTeamRegistrations_Tournaments_TournamentId",
column: x => x.TournamentId,
principalSchema: "Club12",
principalTable: "Tournaments",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateIndex(
name: "IX_PlayerTeamRegistration_CreatedAt",
schema: "Club12",
table: "PlayerTeamRegistrations",
column: "DateCreated");
migrationBuilder.CreateIndex(
name: "IX_PlayerTeamRegistrations_PlayerId_TournamentId",
schema: "Club12",
table: "PlayerTeamRegistrations",
columns: new[] { "PlayerId", "TournamentId" },
unique: true);
migrationBuilder.CreateIndex(
name: "IX_PlayerTeamRegistrations_TeamId",
schema: "Club12",
table: "PlayerTeamRegistrations",
column: "TeamId");
migrationBuilder.CreateIndex(
name: "IX_PlayerTeamRegistrations_TournamentId",
schema: "Club12",
table: "PlayerTeamRegistrations",
column: "TournamentId");
// Data backfill: every existing player's CURRENT team assignment
// (Players.TeamId) becomes a season-scoped registration for
// whatever tournament that team is CURRENTLY assigned to
// (Teams.TournamentId at the time this migration runs). This
// preserves today's roster attribution exactly as-is — e.g. a
// player on a team currently pointed at "Apertura Club 12 2026"
// gets a registration for that same tournament, a player on a
// team currently pointed at "Femenino Club12 La Vuelta" gets a
// registration for that one. Players whose team has no current
// tournament (Teams.TournamentId IS NULL) are skipped: there is
// no season to attribute them to.
migrationBuilder.Sql(
"""
INSERT INTO "Club12"."PlayerTeamRegistrations"
("Id", "PlayerId", "TeamId", "TournamentId", "DateCreated", "CreatedBy")
SELECT
gen_random_uuid(),
p."Id",
p."TeamId",
t."TournamentId",
p."DateCreated",
'System'
FROM "Club12"."Players" p
JOIN "Club12"."Teams" t ON t."Id" = p."TeamId"
WHERE t."TournamentId" IS NOT NULL;
""");
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropTable(
name: "PlayerTeamRegistrations",
schema: "Club12");
}
}
File diff suppressed because it is too large Load Diff
@@ -0,0 +1,85 @@
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace Infrastructure.Migrations;
/// <inheritdoc />
public partial class AddSlugToBlogPost : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.AddColumn<string>(
name: "Slug",
schema: "Club12",
table: "BlogPosts",
type: "character varying(220)",
maxLength: 220,
nullable: true);
// Backfills every existing post's Slug from its current Title, mirroring
// SlugGenerator.GenerateSlug (lowercase, accented characters
// transliterated to their base letter, non-alphanumeric runs collapsed
// to a single hyphen, leading/trailing hyphens trimmed). Rows whose
// computed base slug collides get a numeric suffix (-2, -3, ...)
// ordered by Id, the same disambiguation strategy SlugGenerator uses
// for newly created rows.
migrationBuilder.Sql(
@"
WITH base AS (
SELECT ""Id"",
trim(both '-' from
regexp_replace(
translate(lower(""Title""), 'áéíóúüñ', 'aeiouun'),
'[^a-z0-9]+', '-', 'g'
)
) AS slug_base
FROM ""Club12"".""BlogPosts""
),
numbered AS (
SELECT ""Id"", slug_base,
ROW_NUMBER() OVER (PARTITION BY slug_base ORDER BY ""Id"") AS rn
FROM base
)
UPDATE ""Club12"".""BlogPosts"" bp
SET ""Slug"" = CASE WHEN n.rn = 1 THEN n.slug_base ELSE n.slug_base || '-' || n.rn::text END
FROM numbered n
WHERE bp.""Id"" = n.""Id"";
"
);
migrationBuilder.AlterColumn<string>(
name: "Slug",
schema: "Club12",
table: "BlogPosts",
type: "character varying(220)",
maxLength: 220,
nullable: false,
oldClrType: typeof(string),
oldType: "character varying(220)",
oldMaxLength: 220,
oldNullable: true);
migrationBuilder.CreateIndex(
name: "IX_BlogPosts_Slug",
schema: "Club12",
table: "BlogPosts",
column: "Slug",
unique: true);
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropIndex(
name: "IX_BlogPosts_Slug",
schema: "Club12",
table: "BlogPosts");
migrationBuilder.DropColumn(
name: "Slug",
schema: "Club12",
table: "BlogPosts");
}
}
File diff suppressed because it is too large Load Diff
@@ -0,0 +1,101 @@
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace Infrastructure.Migrations;
/// <inheritdoc />
public partial class AddSlugToPlayerSanction : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.AddColumn<string>(
name: "Slug",
schema: "Club12",
table: "PlayerSanctions",
type: "character varying(220)",
maxLength: 220,
nullable: true);
// Backfills every existing sanction's Slug from its sanctioned player's
// name and the sanction's issued date, mirroring PlayerSanctionService's
// "{playerFullName} {issuedDate:yyyy-MM-dd}" source string fed through
// SlugGenerator.GenerateSlug (lowercase, accented characters
// transliterated to their base letter, non-alphanumeric runs collapsed
// to a single hyphen, leading/trailing hyphens trimmed). The player's
// last/first/second name are concatenated the same way as the
// application's Player.FullName computed property (case does not
// matter here since the whole string is lowercased regardless). Rows
// whose computed base slug collides (e.g. the same player sanctioned
// twice on the same day) get a numeric suffix (-2, -3, ...) ordered by
// Id, the same disambiguation strategy SlugGenerator uses for newly
// created rows.
migrationBuilder.Sql(
@"
WITH base AS (
SELECT ps.""Id"",
trim(both '-' from
regexp_replace(
translate(
lower(
concat(
p.""LastName"", ' ', p.""FirstName"",
CASE WHEN p.""SecondName"" IS NULL OR trim(p.""SecondName"") = '' THEN '' ELSE ' ' || p.""SecondName"" END,
' ', to_char(ps.""IssuedDate"", 'YYYY-MM-DD')
)
),
'áéíóúüñ', 'aeiouun'
),
'[^a-z0-9]+', '-', 'g'
)
) AS slug_base
FROM ""Club12"".""PlayerSanctions"" ps
JOIN ""Club12"".""Players"" p ON p.""Id"" = ps.""PlayerId""
),
numbered AS (
SELECT ""Id"", slug_base,
ROW_NUMBER() OVER (PARTITION BY slug_base ORDER BY ""Id"") AS rn
FROM base
)
UPDATE ""Club12"".""PlayerSanctions"" ps
SET ""Slug"" = CASE WHEN n.rn = 1 THEN n.slug_base ELSE n.slug_base || '-' || n.rn::text END
FROM numbered n
WHERE ps.""Id"" = n.""Id"";
"
);
migrationBuilder.AlterColumn<string>(
name: "Slug",
schema: "Club12",
table: "PlayerSanctions",
type: "character varying(220)",
maxLength: 220,
nullable: false,
oldClrType: typeof(string),
oldType: "character varying(220)",
oldMaxLength: 220,
oldNullable: true);
migrationBuilder.CreateIndex(
name: "IX_PlayerSanctions_Slug",
schema: "Club12",
table: "PlayerSanctions",
column: "Slug",
unique: true);
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropIndex(
name: "IX_PlayerSanctions_Slug",
schema: "Club12",
table: "PlayerSanctions");
migrationBuilder.DropColumn(
name: "Slug",
schema: "Club12",
table: "PlayerSanctions");
}
}
File diff suppressed because it is too large Load Diff
@@ -0,0 +1,47 @@
using System;
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace Infrastructure.Migrations;
/// <inheritdoc />
public partial class AddBackupRecordTable : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.CreateTable(
name: "BackupRecords",
schema: "Club12",
columns: table => new
{
Id = table.Column<Guid>(type: "uuid", nullable: false),
StoragePath = table.Column<string>(type: "character varying(500)", maxLength: 500, nullable: false),
SizeBytes = table.Column<long>(type: "bigint", nullable: false),
Origin = table.Column<string>(type: "text", nullable: false),
DateCreated = table.Column<DateTime>(type: "timestamp without time zone", nullable: false),
DateUpdated = table.Column<DateTime>(type: "timestamp without time zone", nullable: true),
CreatedBy = table.Column<string>(type: "text", nullable: false),
UpdatedBy = table.Column<string>(type: "text", nullable: true)
},
constraints: table =>
{
table.PrimaryKey("PK_BackupRecords", x => x.Id);
});
migrationBuilder.CreateIndex(
name: "IX_BackupRecord_CreatedAt",
schema: "Club12",
table: "BackupRecords",
column: "DateCreated");
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropTable(
name: "BackupRecords",
schema: "Club12");
}
}
@@ -0,0 +1,74 @@
using System;
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace Infrastructure.Migrations
{
/// <inheritdoc />
public partial class AddTeamTournamentRegistrationTable : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.CreateTable(
name: "TeamTournamentRegistrations",
schema: "Club12",
columns: table => new
{
Id = table.Column<Guid>(type: "uuid", nullable: false),
TeamId = table.Column<Guid>(type: "uuid", nullable: false),
TournamentId = table.Column<Guid>(type: "uuid", nullable: false),
DateCreated = table.Column<DateTime>(type: "timestamp without time zone", nullable: false),
DateUpdated = table.Column<DateTime>(type: "timestamp without time zone", nullable: true),
CreatedBy = table.Column<string>(type: "text", nullable: false),
UpdatedBy = table.Column<string>(type: "text", nullable: true)
},
constraints: table =>
{
table.PrimaryKey("PK_TeamTournamentRegistrations", x => x.Id);
table.ForeignKey(
name: "FK_TeamTournamentRegistrations_Teams_TeamId",
column: x => x.TeamId,
principalSchema: "Club12",
principalTable: "Teams",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
table.ForeignKey(
name: "FK_TeamTournamentRegistrations_Tournaments_TournamentId",
column: x => x.TournamentId,
principalSchema: "Club12",
principalTable: "Tournaments",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateIndex(
name: "IX_TeamTournamentRegistration_CreatedAt",
schema: "Club12",
table: "TeamTournamentRegistrations",
column: "DateCreated");
migrationBuilder.CreateIndex(
name: "IX_TeamTournamentRegistrations_TeamId_TournamentId",
schema: "Club12",
table: "TeamTournamentRegistrations",
columns: new[] { "TeamId", "TournamentId" },
unique: true);
migrationBuilder.CreateIndex(
name: "IX_TeamTournamentRegistrations_TournamentId",
schema: "Club12",
table: "TeamTournamentRegistrations",
column: "TournamentId");
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropTable(
name: "TeamTournamentRegistrations",
schema: "Club12");
}
}
}
@@ -0,0 +1,286 @@
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace Infrastructure.Migrations
{
/// <inheritdoc />
public partial class AddSlugToDivisionStageVenuePlayer : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.AddColumn<string>(
name: "Slug",
schema: "Club12",
table: "Divisions",
type: "character varying(220)",
maxLength: 220,
nullable: true);
migrationBuilder.AddColumn<string>(
name: "Slug",
schema: "Club12",
table: "Stages",
type: "character varying(220)",
maxLength: 220,
nullable: true);
migrationBuilder.AddColumn<string>(
name: "Slug",
schema: "Club12",
table: "Venues",
type: "character varying(220)",
maxLength: 220,
nullable: true);
migrationBuilder.AddColumn<string>(
name: "Slug",
schema: "Club12",
table: "Players",
type: "character varying(220)",
maxLength: 220,
nullable: true);
// Backfills every existing Division/Stage/Venue row's Slug from its
// current Name, mirroring SlugGenerator.GenerateSlug (lowercase,
// accented characters transliterated to their base letter,
// non-alphanumeric runs collapsed to a single hyphen,
// leading/trailing hyphens trimmed). Rows whose computed base slug
// collides get a numeric suffix (-2, -3, ...) ordered by Id, the
// same disambiguation strategy SlugGenerator uses for newly created
// rows.
migrationBuilder.Sql(
@"
WITH base AS (
SELECT ""Id"",
trim(both '-' from
regexp_replace(
translate(lower(""Name""), 'áéíóúüñ', 'aeiouun'),
'[^a-z0-9]+', '-', 'g'
)
) AS slug_base
FROM ""Club12"".""Divisions""
),
numbered AS (
SELECT ""Id"", slug_base,
ROW_NUMBER() OVER (PARTITION BY slug_base ORDER BY ""Id"") AS rn
FROM base
)
UPDATE ""Club12"".""Divisions"" t
SET ""Slug"" = CASE WHEN n.rn = 1 THEN n.slug_base ELSE n.slug_base || '-' || n.rn::text END
FROM numbered n
WHERE t.""Id"" = n.""Id"";
"
);
migrationBuilder.Sql(
@"
WITH base AS (
SELECT ""Id"",
trim(both '-' from
regexp_replace(
translate(lower(""Name""), 'áéíóúüñ', 'aeiouun'),
'[^a-z0-9]+', '-', 'g'
)
) AS slug_base
FROM ""Club12"".""Stages""
),
numbered AS (
SELECT ""Id"", slug_base,
ROW_NUMBER() OVER (PARTITION BY slug_base ORDER BY ""Id"") AS rn
FROM base
)
UPDATE ""Club12"".""Stages"" t
SET ""Slug"" = CASE WHEN n.rn = 1 THEN n.slug_base ELSE n.slug_base || '-' || n.rn::text END
FROM numbered n
WHERE t.""Id"" = n.""Id"";
"
);
migrationBuilder.Sql(
@"
WITH base AS (
SELECT ""Id"",
trim(both '-' from
regexp_replace(
translate(lower(""Name""), 'áéíóúüñ', 'aeiouun'),
'[^a-z0-9]+', '-', 'g'
)
) AS slug_base
FROM ""Club12"".""Venues""
),
numbered AS (
SELECT ""Id"", slug_base,
ROW_NUMBER() OVER (PARTITION BY slug_base ORDER BY ""Id"") AS rn
FROM base
)
UPDATE ""Club12"".""Venues"" t
SET ""Slug"" = CASE WHEN n.rn = 1 THEN n.slug_base ELSE n.slug_base || '-' || n.rn::text END
FROM numbered n
WHERE t.""Id"" = n.""Id"";
"
);
// Backfills every existing player's Slug from their full name,
// mirroring PlayerService's use of Player.FullName fed through
// SlugGenerator.GenerateSlug. The last/first/second name are
// concatenated the same way as the application's Player.FullName
// computed property (case does not matter here since the whole
// string is lowercased regardless). Duplicate names get a numeric
// suffix (-2, -3, ...) ordered by Id, matching SlugGenerator's
// disambiguation for newly created rows.
migrationBuilder.Sql(
@"
WITH base AS (
SELECT ""Id"",
trim(both '-' from
regexp_replace(
translate(
lower(
concat(
""LastName"", ' ', ""FirstName"",
CASE WHEN ""SecondName"" IS NULL OR trim(""SecondName"") = '' THEN '' ELSE ' ' || ""SecondName"" END
)
),
'áéíóúüñ', 'aeiouun'
),
'[^a-z0-9]+', '-', 'g'
)
) AS slug_base
FROM ""Club12"".""Players""
),
numbered AS (
SELECT ""Id"", slug_base,
ROW_NUMBER() OVER (PARTITION BY slug_base ORDER BY ""Id"") AS rn
FROM base
)
UPDATE ""Club12"".""Players"" t
SET ""Slug"" = CASE WHEN n.rn = 1 THEN n.slug_base ELSE n.slug_base || '-' || n.rn::text END
FROM numbered n
WHERE t.""Id"" = n.""Id"";
"
);
migrationBuilder.AlterColumn<string>(
name: "Slug",
schema: "Club12",
table: "Divisions",
type: "character varying(220)",
maxLength: 220,
nullable: false,
oldClrType: typeof(string),
oldType: "character varying(220)",
oldMaxLength: 220,
oldNullable: true);
migrationBuilder.AlterColumn<string>(
name: "Slug",
schema: "Club12",
table: "Stages",
type: "character varying(220)",
maxLength: 220,
nullable: false,
oldClrType: typeof(string),
oldType: "character varying(220)",
oldMaxLength: 220,
oldNullable: true);
migrationBuilder.AlterColumn<string>(
name: "Slug",
schema: "Club12",
table: "Venues",
type: "character varying(220)",
maxLength: 220,
nullable: false,
oldClrType: typeof(string),
oldType: "character varying(220)",
oldMaxLength: 220,
oldNullable: true);
migrationBuilder.AlterColumn<string>(
name: "Slug",
schema: "Club12",
table: "Players",
type: "character varying(220)",
maxLength: 220,
nullable: false,
oldClrType: typeof(string),
oldType: "character varying(220)",
oldMaxLength: 220,
oldNullable: true);
migrationBuilder.CreateIndex(
name: "IX_Divisions_Slug",
schema: "Club12",
table: "Divisions",
column: "Slug",
unique: true);
migrationBuilder.CreateIndex(
name: "IX_Stages_Slug",
schema: "Club12",
table: "Stages",
column: "Slug",
unique: true);
migrationBuilder.CreateIndex(
name: "IX_Venues_Slug",
schema: "Club12",
table: "Venues",
column: "Slug",
unique: true);
migrationBuilder.CreateIndex(
name: "IX_Players_Slug",
schema: "Club12",
table: "Players",
column: "Slug",
unique: true);
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropIndex(
name: "IX_Venues_Slug",
schema: "Club12",
table: "Venues");
migrationBuilder.DropIndex(
name: "IX_Stages_Slug",
schema: "Club12",
table: "Stages");
migrationBuilder.DropIndex(
name: "IX_Players_Slug",
schema: "Club12",
table: "Players");
migrationBuilder.DropIndex(
name: "IX_Divisions_Slug",
schema: "Club12",
table: "Divisions");
migrationBuilder.DropColumn(
name: "Slug",
schema: "Club12",
table: "Venues");
migrationBuilder.DropColumn(
name: "Slug",
schema: "Club12",
table: "Stages");
migrationBuilder.DropColumn(
name: "Slug",
schema: "Club12",
table: "Players");
migrationBuilder.DropColumn(
name: "Slug",
schema: "Club12",
table: "Divisions");
}
}
}
@@ -0,0 +1,66 @@
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace Infrastructure.Migrations
{
/// <inheritdoc />
public partial class DropTournamentTeamCountLimits : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
// HU-34: MinTeams / MaxTeams are no longer part of the tournament model.
migrationBuilder.DropColumn(
name: "MaxTeams",
schema: "Club12",
table: "Tournaments");
migrationBuilder.DropColumn(
name: "MinTeams",
schema: "Club12",
table: "Tournaments");
// HU-35: the new RegistrationClosed status is inserted BETWEEN
// OpenForRegistration (1) and Ongoing in the TournamentStatus enum,
// which is persisted as its integer ordinal. Inserting a value in
// the middle shifts every following member up by one, so existing
// rows must be remapped: Ongoing 2->3, Finished 3->4, Canceled 4->5.
// Updated in descending order so an already-shifted value is never
// re-matched by a later statement. Scheduled (0) and
// OpenForRegistration (1) are unchanged; no existing row can hold
// the newly freed value 2 (RegistrationClosed).
migrationBuilder.Sql(@"UPDATE ""Club12"".""Tournaments"" SET ""Status"" = 5 WHERE ""Status"" = 4;");
migrationBuilder.Sql(@"UPDATE ""Club12"".""Tournaments"" SET ""Status"" = 4 WHERE ""Status"" = 3;");
migrationBuilder.Sql(@"UPDATE ""Club12"".""Tournaments"" SET ""Status"" = 3 WHERE ""Status"" = 2;");
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
// Reverse the status remap (ascending, mirror of Up): Canceled
// 5->4, Finished 4->3, Ongoing 3->2. Any row left on 2 after this
// (a RegistrationClosed tournament) collapses back onto Ongoing (2),
// the closest pre-RegistrationClosed state.
migrationBuilder.Sql(@"UPDATE ""Club12"".""Tournaments"" SET ""Status"" = 2 WHERE ""Status"" = 3;");
migrationBuilder.Sql(@"UPDATE ""Club12"".""Tournaments"" SET ""Status"" = 3 WHERE ""Status"" = 4;");
migrationBuilder.Sql(@"UPDATE ""Club12"".""Tournaments"" SET ""Status"" = 4 WHERE ""Status"" = 5;");
migrationBuilder.AddColumn<int>(
name: "MaxTeams",
schema: "Club12",
table: "Tournaments",
type: "integer",
nullable: false,
defaultValue: 0);
migrationBuilder.AddColumn<int>(
name: "MinTeams",
schema: "Club12",
table: "Tournaments",
type: "integer",
nullable: false,
defaultValue: 0);
}
}
}
File diff suppressed because it is too large Load Diff
@@ -0,0 +1,38 @@
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace Infrastructure.Migrations
{
/// <inheritdoc />
public partial class AddMatchStatus : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
// HU-69: new result-lifecycle column. New rows default to
// "Scheduled"; the column is persisted as the enum name (string).
migrationBuilder.AddColumn<string>(
name: "Status",
schema: "Club12",
table: "Matches",
type: "text",
nullable: false,
defaultValue: "Scheduled");
// Backfill existing rows: any already-finished match is a normally
// played result (walkovers did not exist before this column).
migrationBuilder.Sql(
@"UPDATE ""Club12"".""Matches"" SET ""Status"" = 'Played' WHERE ""IsFinished"" = true;");
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropColumn(
name: "Status",
schema: "Club12",
table: "Matches");
}
}
}
@@ -0,0 +1,88 @@
using System;
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace Infrastructure.Migrations
{
/// <inheritdoc />
public partial class AddDivisionPointsAndPlayoffMapping : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.AddColumn<int>(
name: "PointsForLoss",
schema: "Club12",
table: "Divisions",
type: "integer",
nullable: false,
defaultValue: 1);
migrationBuilder.AddColumn<int>(
name: "PointsForWin",
schema: "Club12",
table: "Divisions",
type: "integer",
nullable: false,
defaultValue: 2);
migrationBuilder.CreateTable(
name: "DivisionPlayoffMappings",
schema: "Club12",
columns: table => new
{
Id = table.Column<Guid>(type: "uuid", nullable: false),
DivisionId = table.Column<Guid>(type: "uuid", nullable: false),
FromPosition = table.Column<int>(type: "integer", nullable: false),
ToPosition = table.Column<int>(type: "integer", nullable: false),
Destination = table.Column<string>(type: "character varying(100)", maxLength: 100, nullable: false),
DateCreated = table.Column<DateTime>(type: "timestamp without time zone", nullable: false),
DateUpdated = table.Column<DateTime>(type: "timestamp without time zone", nullable: true),
CreatedBy = table.Column<string>(type: "text", nullable: false),
UpdatedBy = table.Column<string>(type: "text", nullable: true)
},
constraints: table =>
{
table.PrimaryKey("PK_DivisionPlayoffMappings", x => x.Id);
table.ForeignKey(
name: "FK_DivisionPlayoffMappings_Divisions_DivisionId",
column: x => x.DivisionId,
principalSchema: "Club12",
principalTable: "Divisions",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateIndex(
name: "IX_DivisionPlayoffMapping_CreatedAt",
schema: "Club12",
table: "DivisionPlayoffMappings",
column: "DateCreated");
migrationBuilder.CreateIndex(
name: "IX_DivisionPlayoffMappings_DivisionId",
schema: "Club12",
table: "DivisionPlayoffMappings",
column: "DivisionId");
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropTable(
name: "DivisionPlayoffMappings",
schema: "Club12");
migrationBuilder.DropColumn(
name: "PointsForLoss",
schema: "Club12",
table: "Divisions");
migrationBuilder.DropColumn(
name: "PointsForWin",
schema: "Club12",
table: "Divisions");
}
}
}
@@ -0,0 +1,88 @@
using Microsoft.EntityFrameworkCore.Migrations;
using System;
#nullable disable
namespace Infrastructure.Migrations;
/// <summary>
/// Adds the medical-record / eligibility fields to PlayerTeamRegistration
/// (HU-55/57/58/59). Because the record lives on the season registration, it is
/// inherently per season: every existing row starts (and every new row
/// defaults to) 'Pending', so no prior approval is ever inherited (HU-59).
/// </summary>
public partial class AddMedicalRecordToPlayerTeamRegistration : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
// Status persisted as the enum name (string), mirroring the other enum
// columns in this DB. Existing rows default to 'Pending' — no season
// ever inherits another season's approval (HU-59).
migrationBuilder.AddColumn<string>(
name: "MedicalRecordStatus",
schema: "Club12",
table: "PlayerTeamRegistrations",
type: "text",
nullable: false,
defaultValue: "Pending");
migrationBuilder.AddColumn<string>(
name: "MedicalRecordFileUrl",
schema: "Club12",
table: "PlayerTeamRegistrations",
type: "text",
nullable: true);
migrationBuilder.AddColumn<string>(
name: "MedicalRecordFileName",
schema: "Club12",
table: "PlayerTeamRegistrations",
type: "text",
nullable: true);
migrationBuilder.AddColumn<string>(
name: "MedicalRecordReviewReason",
schema: "Club12",
table: "PlayerTeamRegistrations",
type: "text",
nullable: true);
migrationBuilder.AddColumn<DateTime>(
name: "MedicalRecordReviewedAt",
schema: "Club12",
table: "PlayerTeamRegistrations",
type: "timestamp without time zone",
nullable: true);
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropColumn(
name: "MedicalRecordStatus",
schema: "Club12",
table: "PlayerTeamRegistrations");
migrationBuilder.DropColumn(
name: "MedicalRecordFileUrl",
schema: "Club12",
table: "PlayerTeamRegistrations");
migrationBuilder.DropColumn(
name: "MedicalRecordFileName",
schema: "Club12",
table: "PlayerTeamRegistrations");
migrationBuilder.DropColumn(
name: "MedicalRecordReviewReason",
schema: "Club12",
table: "PlayerTeamRegistrations");
migrationBuilder.DropColumn(
name: "MedicalRecordReviewedAt",
schema: "Club12",
table: "PlayerTeamRegistrations");
}
}
File diff suppressed because it is too large Load Diff
@@ -0,0 +1,33 @@
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace Infrastructure.Migrations
{
/// <inheritdoc />
public partial class AddRoundToMatch : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
// HU-63/HU-65: the matchday (jornada) a match belongs to, 1-based.
// Nullable: existing rows and non-round-robin matches (e.g. knockout
// stages) have no round. New round-robin fixtures set it explicitly.
migrationBuilder.AddColumn<int>(
name: "Round",
schema: "Club12",
table: "Matches",
type: "integer",
nullable: true);
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropColumn(
name: "Round",
schema: "Club12",
table: "Matches");
}
}
}

Some files were not shown because too many files have changed in this diff Show More