From c6a777c245dd95d4a8eeed69e91b753bb0bca1ef Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Zieli=C5=84ski?= Date: Tue, 18 Nov 2025 20:38:35 +0100 Subject: [PATCH] New lines fixes --- .../DiunaBI.API/Controllers/AuthController.cs | 100 ++-- .../Controllers/DataInboxController.cs | 260 +++++----- .../Controllers/TestsController.cs | 98 ++-- src/Backend/DiunaBI.API/DiunaBI.API.csproj | 88 ++-- .../Properties/launchSettings.json | 46 +- .../DiunaBI.API/appsettings.Production.json | 92 ++-- .../DiunaBI.Domain/Entities/DataInbox.cs | 28 +- src/Backend/DiunaBI.Domain/Entities/Layer.cs | 66 +-- .../DiunaBI.Domain/Entities/ProcessSource.cs | 24 +- src/Backend/DiunaBI.Domain/Entities/User.cs | 26 +- .../Data/AppDbContext.cs | 364 +++++++------- .../20221205190148_Initial.Designer.cs | 104 ++-- .../Migrations/20221205190148_Initial.cs | 72 +-- ...1211210507_DataSetsAndDataRows.Designer.cs | 386 +++++++-------- .../20221211210507_DataSetsAndDataRows.cs | 242 +++++----- .../20221219163620_RenameFields.Designer.cs | 396 +++++++-------- .../Migrations/20221219163620_RenameFields.cs | 146 +++--- ...21221165749_DataSetIdOnDataRow.Designer.cs | 400 +++++++-------- .../20221221165749_DataSetIdOnDataRow.cs | 158 +++--- .../20230106095427_RenameModels.Designer.cs | 400 +++++++-------- .../Migrations/20230106095427_RenameModels.cs | 454 +++++++++--------- .../Services/GoogleDriveHelper.cs | 74 +-- .../Services/GoogleSheetsHelper.cs | 74 +-- .../DiunaBI.UI.Shared.csproj | 60 +-- src/Backend/DiunaBI.UI.Shared/_Imports.razor | 22 +- .../DiunaBI.UI.Web/DiunaBI.UI.Web.csproj | 34 +- src/Backend/DiunaBI.UI.Web/Program.cs | 72 +-- .../Properties/launchSettings.json | 24 +- src/Backend/DiunaBI.UI.Web/wwwroot/app.css | 102 ++-- tools/http-tests/AutoImport.http | 2 +- 30 files changed, 2207 insertions(+), 2207 deletions(-) diff --git a/src/Backend/DiunaBI.API/Controllers/AuthController.cs b/src/Backend/DiunaBI.API/Controllers/AuthController.cs index 5c91b6c..ea3035b 100644 --- a/src/Backend/DiunaBI.API/Controllers/AuthController.cs +++ b/src/Backend/DiunaBI.API/Controllers/AuthController.cs @@ -1,51 +1,51 @@ -using DiunaBI.API.Services; -using DiunaBI.Domain.Entities; -using Microsoft.AspNetCore.Mvc; - -namespace DiunaBI.API.Controllers; - -[ApiController] -[Route("[controller]")] -public class AuthController( - GoogleAuthService googleAuthService, - JwtTokenService jwtTokenService, - ILogger logger) - : ControllerBase -{ - [HttpPost("apiToken")] - public async Task ApiToken([FromBody] string idToken) - { - try - { - if (string.IsNullOrEmpty(idToken)) - { - logger.LogWarning("Empty idToken received"); - return BadRequest("IdToken is required"); - } - - var (isValid, user, error) = await googleAuthService.ValidateGoogleTokenAsync(idToken); - - if (!isValid || user == null) - { - logger.LogWarning("Google token validation failed: {Error}", error); - return Unauthorized(); - } - - var jwt = jwtTokenService.GenerateToken(user); - - logger.LogInformation("User authenticated successfully: {Email}", user.Email); - - return Ok(new - { - token = jwt, - id = user.Id, - expirationTime = DateTime.UtcNow.AddDays(7) // z JwtSettings - }); - } - catch (Exception ex) - { - logger.LogError(ex, "Error during authentication"); - return StatusCode(500, "Internal server error"); - } - } +using DiunaBI.API.Services; +using DiunaBI.Domain.Entities; +using Microsoft.AspNetCore.Mvc; + +namespace DiunaBI.API.Controllers; + +[ApiController] +[Route("[controller]")] +public class AuthController( + GoogleAuthService googleAuthService, + JwtTokenService jwtTokenService, + ILogger logger) + : ControllerBase +{ + [HttpPost("apiToken")] + public async Task ApiToken([FromBody] string idToken) + { + try + { + if (string.IsNullOrEmpty(idToken)) + { + logger.LogWarning("Empty idToken received"); + return BadRequest("IdToken is required"); + } + + var (isValid, user, error) = await googleAuthService.ValidateGoogleTokenAsync(idToken); + + if (!isValid || user == null) + { + logger.LogWarning("Google token validation failed: {Error}", error); + return Unauthorized(); + } + + var jwt = jwtTokenService.GenerateToken(user); + + logger.LogInformation("User authenticated successfully: {Email}", user.Email); + + return Ok(new + { + token = jwt, + id = user.Id, + expirationTime = DateTime.UtcNow.AddDays(7) // z JwtSettings + }); + } + catch (Exception ex) + { + logger.LogError(ex, "Error during authentication"); + return StatusCode(500, "Internal server error"); + } + } } \ No newline at end of file diff --git a/src/Backend/DiunaBI.API/Controllers/DataInboxController.cs b/src/Backend/DiunaBI.API/Controllers/DataInboxController.cs index c2d2260..d35e00e 100644 --- a/src/Backend/DiunaBI.API/Controllers/DataInboxController.cs +++ b/src/Backend/DiunaBI.API/Controllers/DataInboxController.cs @@ -1,131 +1,131 @@ -using System.Text; -using Microsoft.AspNetCore.Authorization; -using Microsoft.AspNetCore.Mvc; -using Microsoft.EntityFrameworkCore; -using DiunaBI.Infrastructure.Data; -using DiunaBI.Domain.Entities; - -namespace DiunaBI.API.Controllers; - -[ApiController] -[Route("[controller]")] -public class DataInboxController : Controller -{ - private readonly AppDbContext _db; - private readonly IConfiguration _configuration; - private readonly ILogger _logger; - - public DataInboxController( - AppDbContext db, - IConfiguration configuration, - ILogger logger) - { - _db = db; - _configuration = configuration; - _logger = logger; - } - - [HttpPut] - [Route("Add/{apiKey}")] - [AllowAnonymous] - public IActionResult Add(string apiKey, [FromBody] DataInbox dataInbox) - { - if (apiKey != _configuration["apiKey"]) - { - _logger.LogWarning("DataInbox: Unauthorized request - wrong apiKey for source {Source}", dataInbox.Source); - return Unauthorized(); - } - - try - { - if (!Request.Headers.TryGetValue("Authorization", out var authHeader)) - { - _logger.LogWarning("DataInbox: Unauthorized request - no authorization header for source {Source}", dataInbox.Source); - return Unauthorized(); - } - - var credentialsArr = authHeader.ToString().Split(" "); - if (credentialsArr.Length != 2) - { - _logger.LogWarning("DataInbox: Unauthorized request - wrong auth header format for source {Source}", dataInbox.Source); - return Unauthorized(); - } - - var authValue = Encoding.UTF8.GetString(Convert.FromBase64String(credentialsArr[1])); - var username = authValue.Split(':')[0]; - var password = authValue.Split(':')[1]; - if (username != _configuration["morska-user"] || password != _configuration["morska-pass"]) - { - _logger.LogWarning("DataInbox: Unauthorized request - bad credentials for source {Source}", dataInbox.Source); - return Unauthorized(); - } - - // check if datainbox.data is base64 encoded value - if (!string.IsNullOrEmpty(dataInbox.Data) && !IsBase64String(dataInbox.Data)) - { - _logger.LogWarning("DataInbox: Invalid data format - not base64 encoded for source {Source}", dataInbox.Source); - return BadRequest("Invalid data format - not base64 encoded"); - } - - dataInbox.Id = Guid.NewGuid(); - dataInbox.CreatedAt = DateTime.UtcNow; - _db.DataInbox.Add(dataInbox); - _db.SaveChanges(); - - _logger.LogInformation("DataInbox: Insert success for source {Source}, name {Name}", dataInbox.Source, dataInbox.Name); - - if (dataInbox.Name == "morska.d3.importer") - { - _logger.LogDebug("DataInbox: Detected morska.d3.importer - processing will be handled by AutoImport"); - // AutoImport będzie obsługiwać ten typ danych - } - - return Ok(); - } - catch (Exception e) - { - _logger.LogError(e, "DataInbox: Insert error for source {Source}, name {Name}", dataInbox.Source, dataInbox.Name); - return BadRequest(e.ToString()); - } - } - - [HttpGet] - public IActionResult GetAll() - { - try - { - var dataInbox = _db.DataInbox.AsNoTracking().ToList(); - _logger.LogDebug("DataInbox: Retrieved {Count} records", dataInbox.Count); - return Ok(dataInbox); - } - catch (Exception e) - { - _logger.LogError(e, "DataInbox: Error retrieving records"); - return BadRequest(e.ToString()); - } - } - - // helpers - private bool IsBase64String(string data) - { - if (string.IsNullOrEmpty(data)) - { - return false; - } - try - { - var base64Bytes = Convert.FromBase64String(data); - var utf8String = Encoding.UTF8.GetString(base64Bytes); - var reEncoded = Convert.ToBase64String(Encoding.UTF8.GetBytes(utf8String)); - return data.TrimEnd('=') == reEncoded.TrimEnd('='); - } - catch (FormatException) - { - return false; - } - catch (DecoderFallbackException) - { - return false; - } - } +using System.Text; +using Microsoft.AspNetCore.Authorization; +using Microsoft.AspNetCore.Mvc; +using Microsoft.EntityFrameworkCore; +using DiunaBI.Infrastructure.Data; +using DiunaBI.Domain.Entities; + +namespace DiunaBI.API.Controllers; + +[ApiController] +[Route("[controller]")] +public class DataInboxController : Controller +{ + private readonly AppDbContext _db; + private readonly IConfiguration _configuration; + private readonly ILogger _logger; + + public DataInboxController( + AppDbContext db, + IConfiguration configuration, + ILogger logger) + { + _db = db; + _configuration = configuration; + _logger = logger; + } + + [HttpPut] + [Route("Add/{apiKey}")] + [AllowAnonymous] + public IActionResult Add(string apiKey, [FromBody] DataInbox dataInbox) + { + if (apiKey != _configuration["apiKey"]) + { + _logger.LogWarning("DataInbox: Unauthorized request - wrong apiKey for source {Source}", dataInbox.Source); + return Unauthorized(); + } + + try + { + if (!Request.Headers.TryGetValue("Authorization", out var authHeader)) + { + _logger.LogWarning("DataInbox: Unauthorized request - no authorization header for source {Source}", dataInbox.Source); + return Unauthorized(); + } + + var credentialsArr = authHeader.ToString().Split(" "); + if (credentialsArr.Length != 2) + { + _logger.LogWarning("DataInbox: Unauthorized request - wrong auth header format for source {Source}", dataInbox.Source); + return Unauthorized(); + } + + var authValue = Encoding.UTF8.GetString(Convert.FromBase64String(credentialsArr[1])); + var username = authValue.Split(':')[0]; + var password = authValue.Split(':')[1]; + if (username != _configuration["morska-user"] || password != _configuration["morska-pass"]) + { + _logger.LogWarning("DataInbox: Unauthorized request - bad credentials for source {Source}", dataInbox.Source); + return Unauthorized(); + } + + // check if datainbox.data is base64 encoded value + if (!string.IsNullOrEmpty(dataInbox.Data) && !IsBase64String(dataInbox.Data)) + { + _logger.LogWarning("DataInbox: Invalid data format - not base64 encoded for source {Source}", dataInbox.Source); + return BadRequest("Invalid data format - not base64 encoded"); + } + + dataInbox.Id = Guid.NewGuid(); + dataInbox.CreatedAt = DateTime.UtcNow; + _db.DataInbox.Add(dataInbox); + _db.SaveChanges(); + + _logger.LogInformation("DataInbox: Insert success for source {Source}, name {Name}", dataInbox.Source, dataInbox.Name); + + if (dataInbox.Name == "morska.d3.importer") + { + _logger.LogDebug("DataInbox: Detected morska.d3.importer - processing will be handled by AutoImport"); + // AutoImport będzie obsługiwać ten typ danych + } + + return Ok(); + } + catch (Exception e) + { + _logger.LogError(e, "DataInbox: Insert error for source {Source}, name {Name}", dataInbox.Source, dataInbox.Name); + return BadRequest(e.ToString()); + } + } + + [HttpGet] + public IActionResult GetAll() + { + try + { + var dataInbox = _db.DataInbox.AsNoTracking().ToList(); + _logger.LogDebug("DataInbox: Retrieved {Count} records", dataInbox.Count); + return Ok(dataInbox); + } + catch (Exception e) + { + _logger.LogError(e, "DataInbox: Error retrieving records"); + return BadRequest(e.ToString()); + } + } + + // helpers + private bool IsBase64String(string data) + { + if (string.IsNullOrEmpty(data)) + { + return false; + } + try + { + var base64Bytes = Convert.FromBase64String(data); + var utf8String = Encoding.UTF8.GetString(base64Bytes); + var reEncoded = Convert.ToBase64String(Encoding.UTF8.GetBytes(utf8String)); + return data.TrimEnd('=') == reEncoded.TrimEnd('='); + } + catch (FormatException) + { + return false; + } + catch (DecoderFallbackException) + { + return false; + } + } } \ No newline at end of file diff --git a/src/Backend/DiunaBI.API/Controllers/TestsController.cs b/src/Backend/DiunaBI.API/Controllers/TestsController.cs index 779caed..a105aa6 100644 --- a/src/Backend/DiunaBI.API/Controllers/TestsController.cs +++ b/src/Backend/DiunaBI.API/Controllers/TestsController.cs @@ -1,50 +1,50 @@ -using DiunaBI.Infrastructure.Services; -using Microsoft.AspNetCore.Authorization; -using Microsoft.AspNetCore.Mvc; - -namespace DiunaBI.API.Controllers; - -[ApiController] -[Route("[controller]")] -[Authorize] -public class TestsController : Controller -{ - private readonly PluginManager _pluginManager; - private readonly ILogger _logger; - public TestsController( - PluginManager pluginManager, - ILogger logger) - { - _pluginManager = pluginManager; - _logger = logger; - - } - - [HttpGet] - [Route("Ping")] - [AllowAnonymous] - public IActionResult Ping() - { - var tmp = new - { - a = 2, - b = "test" - }; - var tmp2 = new - { - a = 2, - b = "test" - }; - var user = User.Identity; - _logger.LogInformation("LogTest: OldValue {tmp}, NewValue {tmp2}, ChangedBy: {user}", tmp, tmp2, user?.Name); - return Ok("Pong"); - } - [HttpGet] - [Route("Plugins")] - [AllowAnonymous] - public IActionResult GetPlugins() - { - var plugins = _pluginManager.GetPluginsCount(); - return Ok(plugins); - } +using DiunaBI.Infrastructure.Services; +using Microsoft.AspNetCore.Authorization; +using Microsoft.AspNetCore.Mvc; + +namespace DiunaBI.API.Controllers; + +[ApiController] +[Route("[controller]")] +[Authorize] +public class TestsController : Controller +{ + private readonly PluginManager _pluginManager; + private readonly ILogger _logger; + public TestsController( + PluginManager pluginManager, + ILogger logger) + { + _pluginManager = pluginManager; + _logger = logger; + + } + + [HttpGet] + [Route("Ping")] + [AllowAnonymous] + public IActionResult Ping() + { + var tmp = new + { + a = 2, + b = "test" + }; + var tmp2 = new + { + a = 2, + b = "test" + }; + var user = User.Identity; + _logger.LogInformation("LogTest: OldValue {tmp}, NewValue {tmp2}, ChangedBy: {user}", tmp, tmp2, user?.Name); + return Ok("Pong"); + } + [HttpGet] + [Route("Plugins")] + [AllowAnonymous] + public IActionResult GetPlugins() + { + var plugins = _pluginManager.GetPluginsCount(); + return Ok(plugins); + } } \ No newline at end of file diff --git a/src/Backend/DiunaBI.API/DiunaBI.API.csproj b/src/Backend/DiunaBI.API/DiunaBI.API.csproj index 6e591e9..7ea8e7b 100644 --- a/src/Backend/DiunaBI.API/DiunaBI.API.csproj +++ b/src/Backend/DiunaBI.API/DiunaBI.API.csproj @@ -1,45 +1,45 @@ - - - net8.0 - enable - enable - DiunaBI.WebAPI - - - - - - - - - - - - - - - - - - - - - - - - PreserveNewest - true - PreserveNewest - - - - - - - - - - - - + + + net8.0 + enable + enable + DiunaBI.WebAPI + + + + + + + + + + + + + + + + + + + + + + + + PreserveNewest + true + PreserveNewest + + + + + + + + + + + + \ No newline at end of file diff --git a/src/Backend/DiunaBI.API/Properties/launchSettings.json b/src/Backend/DiunaBI.API/Properties/launchSettings.json index 91252f2..c37a5a2 100644 --- a/src/Backend/DiunaBI.API/Properties/launchSettings.json +++ b/src/Backend/DiunaBI.API/Properties/launchSettings.json @@ -1,23 +1,23 @@ -{ - "$schema": "https://json.schemastore.org/launchsettings.json", - "profiles": { - "http": { - "commandName": "Project", - "dotnetRunMessages": true, - "launchBrowser": false, - "applicationUrl": "http://localhost:5163", - "environmentVariables": { - "ASPNETCORE_ENVIRONMENT": "Development" - } - }, - "https": { - "commandName": "Project", - "dotnetRunMessages": true, - "launchBrowser": false, - "applicationUrl": "https://localhost:7148;http://localhost:5163", - "environmentVariables": { - "ASPNETCORE_ENVIRONMENT": "Development" - } - } - } -} +{ + "$schema": "https://json.schemastore.org/launchsettings.json", + "profiles": { + "http": { + "commandName": "Project", + "dotnetRunMessages": true, + "launchBrowser": false, + "applicationUrl": "http://localhost:5163", + "environmentVariables": { + "ASPNETCORE_ENVIRONMENT": "Development" + } + }, + "https": { + "commandName": "Project", + "dotnetRunMessages": true, + "launchBrowser": false, + "applicationUrl": "https://localhost:7148;http://localhost:5163", + "environmentVariables": { + "ASPNETCORE_ENVIRONMENT": "Development" + } + } + } +} diff --git a/src/Backend/DiunaBI.API/appsettings.Production.json b/src/Backend/DiunaBI.API/appsettings.Production.json index e3b12d3..dced057 100644 --- a/src/Backend/DiunaBI.API/appsettings.Production.json +++ b/src/Backend/DiunaBI.API/appsettings.Production.json @@ -1,47 +1,47 @@ -{ - "Logging": { - "LogLevel": { - "Default": "Information", - "Microsoft.AspNetCore": "Warning" - } - }, - "Serilog": { - "MinimumLevel": { - "Default": "Information", - "Override": { - "Microsoft.AspNetCore": "Warning", - "Microsoft.EntityFrameworkCore.Database.Command": "Warning", - "Microsoft.EntityFrameworkCore.Infrastructure": "Warning", - "System.Net.Http.HttpClient": "Warning", - "Google.Apis": "Warning", - "DiunaBI.Core.Services.PluginManager": "Information" - } - }, - "WriteTo": [ - { - "Name": "Console", - "Args": { - "outputTemplate": "[{Timestamp:HH:mm:ss} {Level:u3}] {Message:lj}{NewLine}{Exception}" - } - }, - { - "Name": "File", - "Args": { - "path": "/var/log/diunabi/app-.log", - "rollingInterval": "Day", - "retainedFileCountLimit": 30, - "outputTemplate": "{Timestamp:yyyy-MM-dd HH:mm:ss.fff zzz} [{Level:u3}] {SourceContext} {Message:lj} {Properties:j}{NewLine}{Exception}" - } - } - ], - "Enrich": ["FromLogContext", "WithMachineName", "WithThreadId"] - }, - "AllowedHosts": "*", - "Kestrel": { - "Endpoints": { - "Http": { - "Url": "http://0.0.0.0:7142" - } - } - } +{ + "Logging": { + "LogLevel": { + "Default": "Information", + "Microsoft.AspNetCore": "Warning" + } + }, + "Serilog": { + "MinimumLevel": { + "Default": "Information", + "Override": { + "Microsoft.AspNetCore": "Warning", + "Microsoft.EntityFrameworkCore.Database.Command": "Warning", + "Microsoft.EntityFrameworkCore.Infrastructure": "Warning", + "System.Net.Http.HttpClient": "Warning", + "Google.Apis": "Warning", + "DiunaBI.Core.Services.PluginManager": "Information" + } + }, + "WriteTo": [ + { + "Name": "Console", + "Args": { + "outputTemplate": "[{Timestamp:HH:mm:ss} {Level:u3}] {Message:lj}{NewLine}{Exception}" + } + }, + { + "Name": "File", + "Args": { + "path": "/var/log/diunabi/app-.log", + "rollingInterval": "Day", + "retainedFileCountLimit": 30, + "outputTemplate": "{Timestamp:yyyy-MM-dd HH:mm:ss.fff zzz} [{Level:u3}] {SourceContext} {Message:lj} {Properties:j}{NewLine}{Exception}" + } + } + ], + "Enrich": ["FromLogContext", "WithMachineName", "WithThreadId"] + }, + "AllowedHosts": "*", + "Kestrel": { + "Endpoints": { + "Http": { + "Url": "http://0.0.0.0:7142" + } + } + } } \ No newline at end of file diff --git a/src/Backend/DiunaBI.Domain/Entities/DataInbox.cs b/src/Backend/DiunaBI.Domain/Entities/DataInbox.cs index 940c010..21cb2dd 100644 --- a/src/Backend/DiunaBI.Domain/Entities/DataInbox.cs +++ b/src/Backend/DiunaBI.Domain/Entities/DataInbox.cs @@ -1,15 +1,15 @@ -using System; -using System.ComponentModel.DataAnnotations; - -namespace DiunaBI.Domain.Entities; - -public class DataInbox -{ - #region Properties - public Guid Id { get; set; } - public required string Name { get; init; } - public required string Source { get; set; } - public required string Data { get; init; } - public DateTime CreatedAt { get; set; } - #endregion +using System; +using System.ComponentModel.DataAnnotations; + +namespace DiunaBI.Domain.Entities; + +public class DataInbox +{ + #region Properties + public Guid Id { get; set; } + public required string Name { get; init; } + public required string Source { get; set; } + public required string Data { get; init; } + public DateTime CreatedAt { get; set; } + #endregion } \ No newline at end of file diff --git a/src/Backend/DiunaBI.Domain/Entities/Layer.cs b/src/Backend/DiunaBI.Domain/Entities/Layer.cs index 8d98f2c..441a157 100644 --- a/src/Backend/DiunaBI.Domain/Entities/Layer.cs +++ b/src/Backend/DiunaBI.Domain/Entities/Layer.cs @@ -1,34 +1,34 @@ -using System; -using System.Collections.Generic; -using System.ComponentModel.DataAnnotations; - -namespace DiunaBI.Domain.Entities; - -public enum LayerType -{ - Import, - Processed, - Administration, - Dictionary, -} -public class Layer -{ - #region Properties - public Guid Id { get; init; } - public int Number { get; init; } - public string? Name { get; set; } - public LayerType Type { get; init; } - public DateTime CreatedAt { get; set; } - public DateTime ModifiedAt { get; set; } - public bool IsDeleted { get; init; } = false; - public bool IsCancelled { get; init; } = false; - #endregion - #region Relations - public ICollection? Records { get; init; } - public Guid CreatedById { get; set; } - public User? CreatedBy { get; init; } - public Guid ModifiedById { get; set; } - public User? ModifiedBy { get; init; } - public Guid? ParentId { get; init; } - #endregion +using System; +using System.Collections.Generic; +using System.ComponentModel.DataAnnotations; + +namespace DiunaBI.Domain.Entities; + +public enum LayerType +{ + Import, + Processed, + Administration, + Dictionary, +} +public class Layer +{ + #region Properties + public Guid Id { get; init; } + public int Number { get; init; } + public string? Name { get; set; } + public LayerType Type { get; init; } + public DateTime CreatedAt { get; set; } + public DateTime ModifiedAt { get; set; } + public bool IsDeleted { get; init; } = false; + public bool IsCancelled { get; init; } = false; + #endregion + #region Relations + public ICollection? Records { get; init; } + public Guid CreatedById { get; set; } + public User? CreatedBy { get; init; } + public Guid ModifiedById { get; set; } + public User? ModifiedBy { get; init; } + public Guid? ParentId { get; init; } + #endregion } \ No newline at end of file diff --git a/src/Backend/DiunaBI.Domain/Entities/ProcessSource.cs b/src/Backend/DiunaBI.Domain/Entities/ProcessSource.cs index e4dd73a..ec48a02 100644 --- a/src/Backend/DiunaBI.Domain/Entities/ProcessSource.cs +++ b/src/Backend/DiunaBI.Domain/Entities/ProcessSource.cs @@ -1,13 +1,13 @@ -using System; -using System.ComponentModel.DataAnnotations; - -namespace DiunaBI.Domain.Entities; - -public class ProcessSource -{ - #region Relations - public Guid LayerId { get; init; } - public Guid SourceId { get; init; } - public Layer? Source { get; init; } - #endregion +using System; +using System.ComponentModel.DataAnnotations; + +namespace DiunaBI.Domain.Entities; + +public class ProcessSource +{ + #region Relations + public Guid LayerId { get; init; } + public Guid SourceId { get; init; } + public Layer? Source { get; init; } + #endregion } \ No newline at end of file diff --git a/src/Backend/DiunaBI.Domain/Entities/User.cs b/src/Backend/DiunaBI.Domain/Entities/User.cs index fc24865..59a60cc 100644 --- a/src/Backend/DiunaBI.Domain/Entities/User.cs +++ b/src/Backend/DiunaBI.Domain/Entities/User.cs @@ -1,14 +1,14 @@ -using System; -using System.ComponentModel.DataAnnotations; - -namespace DiunaBI.Domain.Entities; - -public class User -{ - #region Properties - public Guid Id { get; init; } - public string? Email { get; init; } - public string? UserName { get; set; } - public DateTime CreatedAt { get; init; } - #endregion +using System; +using System.ComponentModel.DataAnnotations; + +namespace DiunaBI.Domain.Entities; + +public class User +{ + #region Properties + public Guid Id { get; init; } + public string? Email { get; init; } + public string? UserName { get; set; } + public DateTime CreatedAt { get; init; } + #endregion } \ No newline at end of file diff --git a/src/Backend/DiunaBI.Infrastructure/Data/AppDbContext.cs b/src/Backend/DiunaBI.Infrastructure/Data/AppDbContext.cs index 687bc72..bd44a33 100644 --- a/src/Backend/DiunaBI.Infrastructure/Data/AppDbContext.cs +++ b/src/Backend/DiunaBI.Infrastructure/Data/AppDbContext.cs @@ -1,183 +1,183 @@ -using Microsoft.EntityFrameworkCore; -using DiunaBI.Domain.Entities; - -namespace DiunaBI.Infrastructure.Data; - -public class AppDbContext(DbContextOptions options) : DbContext(options) -{ - public DbSet Users { get; init; } - public DbSet Layers { get; init; } - public DbSet Records { get; init; } - public DbSet ProcessSources { get; init; } - public DbSet DataInbox { get; init; } - public DbSet QueueJobs { get; init; } - - protected override void OnModelCreating(ModelBuilder modelBuilder) - { - modelBuilder.Entity().HasKey(x => x.Id); - modelBuilder.Entity().Property(x => x.Email).HasMaxLength(50); - modelBuilder.Entity().Property(x => x.UserName).HasMaxLength(50); - - modelBuilder.Entity().HasKey(x => x.Id); - modelBuilder.Entity().Property(x => x.Number).IsRequired(); - modelBuilder.Entity().Property(x => x.Name).IsRequired().HasMaxLength(50); - modelBuilder.Entity().Property(x => x.Type).IsRequired().HasConversion(); - modelBuilder.Entity().Property(x => x.CreatedAt).IsRequired(); - modelBuilder.Entity().Property(x => x.ModifiedAt).IsRequired(); - modelBuilder.Entity().Property(x => x.IsDeleted).IsRequired().HasDefaultValue(false); - modelBuilder.Entity().Property(x => x.IsCancelled).IsRequired(); - modelBuilder.Entity().Property(x => x.CreatedById).IsRequired(); - modelBuilder.Entity().Property(x => x.ModifiedById).IsRequired(); - - modelBuilder.Entity() - .HasOne(x => x.CreatedBy) - .WithMany() - .HasForeignKey(x => x.CreatedById) - .OnDelete(DeleteBehavior.Restrict); - - modelBuilder.Entity() - .HasOne(x => x.ModifiedBy) - .WithMany() - .HasForeignKey(x => x.ModifiedById) - .OnDelete(DeleteBehavior.Restrict); - - modelBuilder.Entity() - .HasMany(x => x.Records) - .WithOne() - .HasForeignKey(r => r.LayerId) - .OnDelete(DeleteBehavior.Cascade); - - modelBuilder.Entity().HasKey(x => x.Id); - modelBuilder.Entity().Property(x => x.Code).IsRequired().HasMaxLength(50); - modelBuilder.Entity().Property(x => x.Desc1).HasMaxLength(10000); - modelBuilder.Entity().Property(x => x.CreatedAt); - modelBuilder.Entity().Property(x => x.ModifiedAt); - modelBuilder.Entity().Property(x => x.IsDeleted); - modelBuilder.Entity().Property(x => x.CreatedById).IsRequired(); - modelBuilder.Entity().Property(x => x.ModifiedById).IsRequired(); - modelBuilder.Entity().Property(x => x.LayerId).IsRequired(); - - modelBuilder.Entity() - .HasOne(x => x.CreatedBy) - .WithMany() - .HasForeignKey(x => x.CreatedById) - .OnDelete(DeleteBehavior.Restrict); - - modelBuilder.Entity() - .HasOne(x => x.ModifiedBy) - .WithMany() - .HasForeignKey(x => x.ModifiedById) - .OnDelete(DeleteBehavior.Restrict); - - modelBuilder.Entity() - .HasOne() - .WithMany(l => l.Records!) - .HasForeignKey(x => x.LayerId) - .OnDelete(DeleteBehavior.Cascade); - - modelBuilder.Entity().HasKey(x => new { x.LayerId, x.SourceId }); - modelBuilder.Entity().Property(x => x.LayerId).IsRequired(); - modelBuilder.Entity().Property(x => x.SourceId).IsRequired(); - - modelBuilder.Entity() - .HasOne() - .WithMany() - .HasForeignKey(x => x.LayerId) - .OnDelete(DeleteBehavior.Cascade); - - modelBuilder.Entity() - .HasOne(x => x.Source) - .WithMany() - .HasForeignKey(x => x.SourceId) - .OnDelete(DeleteBehavior.Restrict); - - modelBuilder.Entity().HasKey(x => x.Id); - modelBuilder.Entity().Property(x => x.Name).IsRequired().HasMaxLength(50); - modelBuilder.Entity().Property(x => x.Source).IsRequired().HasMaxLength(50); - modelBuilder.Entity().Property(x => x.Data).IsRequired(); - modelBuilder.Entity().Property(x => x.CreatedAt); - - modelBuilder.Entity().HasKey(x => x.Id); - modelBuilder.Entity().Property(x => x.LayerId).IsRequired(); - modelBuilder.Entity().Property(x => x.LayerName).IsRequired().HasMaxLength(200); - modelBuilder.Entity().Property(x => x.PluginName).IsRequired().HasMaxLength(100); - modelBuilder.Entity().Property(x => x.JobType).IsRequired().HasConversion(); - modelBuilder.Entity().Property(x => x.Priority); - modelBuilder.Entity().Property(x => x.CreatedAt).IsRequired(); - modelBuilder.Entity().Property(x => x.RetryCount); - modelBuilder.Entity().Property(x => x.MaxRetries); - modelBuilder.Entity().Property(x => x.Status).IsRequired().HasConversion(); - modelBuilder.Entity().Property(x => x.LastError).HasMaxLength(1000); - modelBuilder.Entity().Property(x => x.LastAttemptAt); - modelBuilder.Entity().Property(x => x.CompletedAt); - modelBuilder.Entity().Property(x => x.CreatedById).IsRequired(); - modelBuilder.Entity().Property(x => x.CreatedAtUtc).IsRequired(); - modelBuilder.Entity().Property(x => x.ModifiedById).IsRequired(); - modelBuilder.Entity().Property(x => x.ModifiedAtUtc).IsRequired(); - - // Configure automatic timestamps for entities with CreatedAt/ModifiedAt - ConfigureTimestamps(modelBuilder); - } - - private void ConfigureTimestamps(ModelBuilder modelBuilder) - { - foreach (var entityType in modelBuilder.Model.GetEntityTypes()) - { - // Check if entity has CreatedAt property - var createdAtProperty = entityType.FindProperty("CreatedAt"); - if (createdAtProperty != null) - { - modelBuilder.Entity(entityType.ClrType) - .Property("CreatedAt") - .HasDefaultValueSql("NOW()"); - } - - // Check if entity has ModifiedAt property - var modifiedAtProperty = entityType.FindProperty("ModifiedAt"); - if (modifiedAtProperty != null) - { - modelBuilder.Entity(entityType.ClrType) - .Property("ModifiedAt") - .HasDefaultValueSql("NOW()"); - } - } - } - - public override int SaveChanges() - { - UpdateTimestamps(); - return base.SaveChanges(); - } - - public override Task SaveChangesAsync(CancellationToken cancellationToken = default) - { - UpdateTimestamps(); - return base.SaveChangesAsync(cancellationToken); - } - - private void UpdateTimestamps() - { - var entities = ChangeTracker.Entries() - .Where(e => e.State == EntityState.Added || e.State == EntityState.Modified); - - foreach (var entity in entities) - { - // Try to set CreatedAt for new entities - if (entity.State == EntityState.Added) - { - var createdAtProperty = entity.Properties.FirstOrDefault(p => p.Metadata.Name == "CreatedAt"); - if (createdAtProperty != null) - { - createdAtProperty.CurrentValue = DateTime.UtcNow; - } - } - - // Always update ModifiedAt - var modifiedAtProperty = entity.Properties.FirstOrDefault(p => p.Metadata.Name == "ModifiedAt"); - if (modifiedAtProperty != null) - { - modifiedAtProperty.CurrentValue = DateTime.UtcNow; - } - } - } +using Microsoft.EntityFrameworkCore; +using DiunaBI.Domain.Entities; + +namespace DiunaBI.Infrastructure.Data; + +public class AppDbContext(DbContextOptions options) : DbContext(options) +{ + public DbSet Users { get; init; } + public DbSet Layers { get; init; } + public DbSet Records { get; init; } + public DbSet ProcessSources { get; init; } + public DbSet DataInbox { get; init; } + public DbSet QueueJobs { get; init; } + + protected override void OnModelCreating(ModelBuilder modelBuilder) + { + modelBuilder.Entity().HasKey(x => x.Id); + modelBuilder.Entity().Property(x => x.Email).HasMaxLength(50); + modelBuilder.Entity().Property(x => x.UserName).HasMaxLength(50); + + modelBuilder.Entity().HasKey(x => x.Id); + modelBuilder.Entity().Property(x => x.Number).IsRequired(); + modelBuilder.Entity().Property(x => x.Name).IsRequired().HasMaxLength(50); + modelBuilder.Entity().Property(x => x.Type).IsRequired().HasConversion(); + modelBuilder.Entity().Property(x => x.CreatedAt).IsRequired(); + modelBuilder.Entity().Property(x => x.ModifiedAt).IsRequired(); + modelBuilder.Entity().Property(x => x.IsDeleted).IsRequired().HasDefaultValue(false); + modelBuilder.Entity().Property(x => x.IsCancelled).IsRequired(); + modelBuilder.Entity().Property(x => x.CreatedById).IsRequired(); + modelBuilder.Entity().Property(x => x.ModifiedById).IsRequired(); + + modelBuilder.Entity() + .HasOne(x => x.CreatedBy) + .WithMany() + .HasForeignKey(x => x.CreatedById) + .OnDelete(DeleteBehavior.Restrict); + + modelBuilder.Entity() + .HasOne(x => x.ModifiedBy) + .WithMany() + .HasForeignKey(x => x.ModifiedById) + .OnDelete(DeleteBehavior.Restrict); + + modelBuilder.Entity() + .HasMany(x => x.Records) + .WithOne() + .HasForeignKey(r => r.LayerId) + .OnDelete(DeleteBehavior.Cascade); + + modelBuilder.Entity().HasKey(x => x.Id); + modelBuilder.Entity().Property(x => x.Code).IsRequired().HasMaxLength(50); + modelBuilder.Entity().Property(x => x.Desc1).HasMaxLength(10000); + modelBuilder.Entity().Property(x => x.CreatedAt); + modelBuilder.Entity().Property(x => x.ModifiedAt); + modelBuilder.Entity().Property(x => x.IsDeleted); + modelBuilder.Entity().Property(x => x.CreatedById).IsRequired(); + modelBuilder.Entity().Property(x => x.ModifiedById).IsRequired(); + modelBuilder.Entity().Property(x => x.LayerId).IsRequired(); + + modelBuilder.Entity() + .HasOne(x => x.CreatedBy) + .WithMany() + .HasForeignKey(x => x.CreatedById) + .OnDelete(DeleteBehavior.Restrict); + + modelBuilder.Entity() + .HasOne(x => x.ModifiedBy) + .WithMany() + .HasForeignKey(x => x.ModifiedById) + .OnDelete(DeleteBehavior.Restrict); + + modelBuilder.Entity() + .HasOne() + .WithMany(l => l.Records!) + .HasForeignKey(x => x.LayerId) + .OnDelete(DeleteBehavior.Cascade); + + modelBuilder.Entity().HasKey(x => new { x.LayerId, x.SourceId }); + modelBuilder.Entity().Property(x => x.LayerId).IsRequired(); + modelBuilder.Entity().Property(x => x.SourceId).IsRequired(); + + modelBuilder.Entity() + .HasOne() + .WithMany() + .HasForeignKey(x => x.LayerId) + .OnDelete(DeleteBehavior.Cascade); + + modelBuilder.Entity() + .HasOne(x => x.Source) + .WithMany() + .HasForeignKey(x => x.SourceId) + .OnDelete(DeleteBehavior.Restrict); + + modelBuilder.Entity().HasKey(x => x.Id); + modelBuilder.Entity().Property(x => x.Name).IsRequired().HasMaxLength(50); + modelBuilder.Entity().Property(x => x.Source).IsRequired().HasMaxLength(50); + modelBuilder.Entity().Property(x => x.Data).IsRequired(); + modelBuilder.Entity().Property(x => x.CreatedAt); + + modelBuilder.Entity().HasKey(x => x.Id); + modelBuilder.Entity().Property(x => x.LayerId).IsRequired(); + modelBuilder.Entity().Property(x => x.LayerName).IsRequired().HasMaxLength(200); + modelBuilder.Entity().Property(x => x.PluginName).IsRequired().HasMaxLength(100); + modelBuilder.Entity().Property(x => x.JobType).IsRequired().HasConversion(); + modelBuilder.Entity().Property(x => x.Priority); + modelBuilder.Entity().Property(x => x.CreatedAt).IsRequired(); + modelBuilder.Entity().Property(x => x.RetryCount); + modelBuilder.Entity().Property(x => x.MaxRetries); + modelBuilder.Entity().Property(x => x.Status).IsRequired().HasConversion(); + modelBuilder.Entity().Property(x => x.LastError).HasMaxLength(1000); + modelBuilder.Entity().Property(x => x.LastAttemptAt); + modelBuilder.Entity().Property(x => x.CompletedAt); + modelBuilder.Entity().Property(x => x.CreatedById).IsRequired(); + modelBuilder.Entity().Property(x => x.CreatedAtUtc).IsRequired(); + modelBuilder.Entity().Property(x => x.ModifiedById).IsRequired(); + modelBuilder.Entity().Property(x => x.ModifiedAtUtc).IsRequired(); + + // Configure automatic timestamps for entities with CreatedAt/ModifiedAt + ConfigureTimestamps(modelBuilder); + } + + private void ConfigureTimestamps(ModelBuilder modelBuilder) + { + foreach (var entityType in modelBuilder.Model.GetEntityTypes()) + { + // Check if entity has CreatedAt property + var createdAtProperty = entityType.FindProperty("CreatedAt"); + if (createdAtProperty != null) + { + modelBuilder.Entity(entityType.ClrType) + .Property("CreatedAt") + .HasDefaultValueSql("NOW()"); + } + + // Check if entity has ModifiedAt property + var modifiedAtProperty = entityType.FindProperty("ModifiedAt"); + if (modifiedAtProperty != null) + { + modelBuilder.Entity(entityType.ClrType) + .Property("ModifiedAt") + .HasDefaultValueSql("NOW()"); + } + } + } + + public override int SaveChanges() + { + UpdateTimestamps(); + return base.SaveChanges(); + } + + public override Task SaveChangesAsync(CancellationToken cancellationToken = default) + { + UpdateTimestamps(); + return base.SaveChangesAsync(cancellationToken); + } + + private void UpdateTimestamps() + { + var entities = ChangeTracker.Entries() + .Where(e => e.State == EntityState.Added || e.State == EntityState.Modified); + + foreach (var entity in entities) + { + // Try to set CreatedAt for new entities + if (entity.State == EntityState.Added) + { + var createdAtProperty = entity.Properties.FirstOrDefault(p => p.Metadata.Name == "CreatedAt"); + if (createdAtProperty != null) + { + createdAtProperty.CurrentValue = DateTime.UtcNow; + } + } + + // Always update ModifiedAt + var modifiedAtProperty = entity.Properties.FirstOrDefault(p => p.Metadata.Name == "ModifiedAt"); + if (modifiedAtProperty != null) + { + modifiedAtProperty.CurrentValue = DateTime.UtcNow; + } + } + } } \ No newline at end of file diff --git a/src/Backend/DiunaBI.Infrastructure/Migrations/20221205190148_Initial.Designer.cs b/src/Backend/DiunaBI.Infrastructure/Migrations/20221205190148_Initial.Designer.cs index f3b0d43..b87c581 100644 --- a/src/Backend/DiunaBI.Infrastructure/Migrations/20221205190148_Initial.Designer.cs +++ b/src/Backend/DiunaBI.Infrastructure/Migrations/20221205190148_Initial.Designer.cs @@ -1,52 +1,52 @@ -// -using System; -using Microsoft.EntityFrameworkCore; -using Microsoft.EntityFrameworkCore.Infrastructure; -using Microsoft.EntityFrameworkCore.Metadata; -using Microsoft.EntityFrameworkCore.Migrations; -using Microsoft.EntityFrameworkCore.Storage.ValueConversion; -using DiunaBI.Domain.Entities; -using DiunaBI.Infrastructure.Data; - -#nullable disable - -namespace DiunaBI.Infrastructure.Migrations -{ - [DbContext(typeof(AppDbContext))] - [Migration("20221205190148_Initial")] - partial class Initial - { - /// - protected void BuildTargetModel(ModelBuilder modelBuilder) - { -#pragma warning disable 612, 618 - modelBuilder - .HasAnnotation("ProductVersion", "7.0.0") - .HasAnnotation("Relational:MaxIdentifierLength", 128); - - SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder); - - modelBuilder.Entity("WebAPI.Models.User", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("uniqueidentifier"); - - b.Property("CreatedAt") - .HasColumnType("datetime2"); - - b.Property("Email") - .HasColumnType("nvarchar(max)"); - - b.Property("UserName") - .HasMaxLength(50) - .HasColumnType("nvarchar(50)"); - - b.HasKey("Id"); - - b.ToTable("Users"); - }); -#pragma warning restore 612, 618 - } - } -} +// +using System; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Metadata; +using Microsoft.EntityFrameworkCore.Migrations; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; +using DiunaBI.Domain.Entities; +using DiunaBI.Infrastructure.Data; + +#nullable disable + +namespace DiunaBI.Infrastructure.Migrations +{ + [DbContext(typeof(AppDbContext))] + [Migration("20221205190148_Initial")] + partial class Initial + { + /// + protected void BuildTargetModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder + .HasAnnotation("ProductVersion", "7.0.0") + .HasAnnotation("Relational:MaxIdentifierLength", 128); + + SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder); + + modelBuilder.Entity("WebAPI.Models.User", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uniqueidentifier"); + + b.Property("CreatedAt") + .HasColumnType("datetime2"); + + b.Property("Email") + .HasColumnType("nvarchar(max)"); + + b.Property("UserName") + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.HasKey("Id"); + + b.ToTable("Users"); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/src/Backend/DiunaBI.Infrastructure/Migrations/20221205190148_Initial.cs b/src/Backend/DiunaBI.Infrastructure/Migrations/20221205190148_Initial.cs index 25c996b..1a2e662 100644 --- a/src/Backend/DiunaBI.Infrastructure/Migrations/20221205190148_Initial.cs +++ b/src/Backend/DiunaBI.Infrastructure/Migrations/20221205190148_Initial.cs @@ -1,36 +1,36 @@ -using System; -using Microsoft.EntityFrameworkCore.Migrations; - -#nullable disable - -namespace DiunaBI.Infrastructure.Migrations -{ - /// - public partial class Initial : Migration - { - /// - protected override void Up(MigrationBuilder migrationBuilder) - { - migrationBuilder.CreateTable( - name: "Users", - columns: table => new - { - Id = table.Column(type: "uniqueidentifier", nullable: false), - Email = table.Column(type: "nvarchar(max)", nullable: true), - UserName = table.Column(type: "nvarchar(50)", maxLength: 50, nullable: true), - CreatedAt = table.Column(type: "datetime2", nullable: false) - }, - constraints: table => - { - table.PrimaryKey("PK_Users", x => x.Id); - }); - } - - /// - protected override void Down(MigrationBuilder migrationBuilder) - { - migrationBuilder.DropTable( - name: "Users"); - } - } -} +using System; +using Microsoft.EntityFrameworkCore.Migrations; + +#nullable disable + +namespace DiunaBI.Infrastructure.Migrations +{ + /// + public partial class Initial : Migration + { + /// + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.CreateTable( + name: "Users", + columns: table => new + { + Id = table.Column(type: "uniqueidentifier", nullable: false), + Email = table.Column(type: "nvarchar(max)", nullable: true), + UserName = table.Column(type: "nvarchar(50)", maxLength: 50, nullable: true), + CreatedAt = table.Column(type: "datetime2", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_Users", x => x.Id); + }); + } + + /// + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropTable( + name: "Users"); + } + } +} diff --git a/src/Backend/DiunaBI.Infrastructure/Migrations/20221211210507_DataSetsAndDataRows.Designer.cs b/src/Backend/DiunaBI.Infrastructure/Migrations/20221211210507_DataSetsAndDataRows.Designer.cs index 21a773c..4597252 100644 --- a/src/Backend/DiunaBI.Infrastructure/Migrations/20221211210507_DataSetsAndDataRows.Designer.cs +++ b/src/Backend/DiunaBI.Infrastructure/Migrations/20221211210507_DataSetsAndDataRows.Designer.cs @@ -1,193 +1,193 @@ -// -using System; -using Microsoft.EntityFrameworkCore; -using Microsoft.EntityFrameworkCore.Infrastructure; -using Microsoft.EntityFrameworkCore.Metadata; -using Microsoft.EntityFrameworkCore.Migrations; -using Microsoft.EntityFrameworkCore.Storage.ValueConversion; -using DiunaBI.Domain.Entities; -using DiunaBI.Infrastructure.Data; - -#nullable disable - -namespace DiunaBI.Infrastructure.Migrations -{ - [DbContext(typeof(AppDbContext))] - [Migration("20221211210507_DataSetsAndDataRows")] - partial class DataSetsAndDataRows - { - /// - protected void BuildTargetModel(ModelBuilder modelBuilder) - { -#pragma warning disable 612, 618 - modelBuilder - .HasAnnotation("ProductVersion", "7.0.0") - .HasAnnotation("Relational:MaxIdentifierLength", 128); - - SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder); - - modelBuilder.Entity("WebAPI.Models.DataRow", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("uniqueidentifier"); - - b.Property("CreatedAt") - .HasColumnType("datetime2"); - - b.Property("CreatedById") - .HasColumnType("uniqueidentifier"); - - b.Property("DataSetId") - .HasColumnType("uniqueidentifier"); - - b.Property("Desc1") - .HasColumnType("nvarchar(max)"); - - b.Property("Desc2") - .HasColumnType("nvarchar(max)"); - - b.Property("Desc3") - .HasColumnType("nvarchar(max)"); - - b.Property("Desc4") - .HasColumnType("nvarchar(max)"); - - b.Property("Desc5") - .HasColumnType("nvarchar(max)"); - - b.Property("IsDeleted") - .HasColumnType("bit"); - - b.Property("MPK") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b.Property("ModifiedAt") - .HasColumnType("datetime2"); - - b.Property("ModifiedById") - .HasColumnType("uniqueidentifier"); - - b.Property("Value") - .HasColumnType("real"); - - b.HasKey("Id"); - - b.HasIndex("CreatedById"); - - b.HasIndex("DataSetId"); - - b.HasIndex("ModifiedById"); - - b.ToTable("DataRows"); - }); - - modelBuilder.Entity("WebAPI.Models.DataSet", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("uniqueidentifier"); - - b.Property("CreatedAt") - .HasColumnType("datetime2"); - - b.Property("CreatedById") - .HasColumnType("uniqueidentifier"); - - b.Property("IsDeleted") - .HasColumnType("bit"); - - b.Property("ModifiedAt") - .HasColumnType("datetime2"); - - b.Property("ModifiedById") - .HasColumnType("uniqueidentifier"); - - b.Property("Name") - .HasColumnType("nvarchar(max)"); - - b.Property("Number") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b.HasKey("Id"); - - b.HasIndex("CreatedById"); - - b.HasIndex("ModifiedById"); - - b.ToTable("DataSets"); - }); - - modelBuilder.Entity("WebAPI.Models.User", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("uniqueidentifier"); - - b.Property("CreatedAt") - .HasColumnType("datetime2"); - - b.Property("Email") - .HasColumnType("nvarchar(max)"); - - b.Property("UserName") - .HasMaxLength(50) - .HasColumnType("nvarchar(50)"); - - b.HasKey("Id"); - - b.ToTable("Users"); - }); - - modelBuilder.Entity("WebAPI.Models.DataRow", b => - { - b.HasOne("WebAPI.Models.User", "CreatedBy") - .WithMany() - .HasForeignKey("CreatedById") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("WebAPI.Models.DataSet", null) - .WithMany("DataRows") - .HasForeignKey("DataSetId"); - - b.HasOne("WebAPI.Models.User", "ModifiedBy") - .WithMany() - .HasForeignKey("ModifiedById") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("CreatedBy"); - - b.Navigation("ModifiedBy"); - }); - - modelBuilder.Entity("WebAPI.Models.DataSet", b => - { - b.HasOne("WebAPI.Models.User", "CreatedBy") - .WithMany() - .HasForeignKey("CreatedById") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("WebAPI.Models.User", "ModifiedBy") - .WithMany() - .HasForeignKey("ModifiedById") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("CreatedBy"); - - b.Navigation("ModifiedBy"); - }); - - modelBuilder.Entity("WebAPI.Models.DataSet", b => - { - b.Navigation("DataRows"); - }); -#pragma warning restore 612, 618 - } - } -} +// +using System; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Metadata; +using Microsoft.EntityFrameworkCore.Migrations; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; +using DiunaBI.Domain.Entities; +using DiunaBI.Infrastructure.Data; + +#nullable disable + +namespace DiunaBI.Infrastructure.Migrations +{ + [DbContext(typeof(AppDbContext))] + [Migration("20221211210507_DataSetsAndDataRows")] + partial class DataSetsAndDataRows + { + /// + protected void BuildTargetModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder + .HasAnnotation("ProductVersion", "7.0.0") + .HasAnnotation("Relational:MaxIdentifierLength", 128); + + SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder); + + modelBuilder.Entity("WebAPI.Models.DataRow", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uniqueidentifier"); + + b.Property("CreatedAt") + .HasColumnType("datetime2"); + + b.Property("CreatedById") + .HasColumnType("uniqueidentifier"); + + b.Property("DataSetId") + .HasColumnType("uniqueidentifier"); + + b.Property("Desc1") + .HasColumnType("nvarchar(max)"); + + b.Property("Desc2") + .HasColumnType("nvarchar(max)"); + + b.Property("Desc3") + .HasColumnType("nvarchar(max)"); + + b.Property("Desc4") + .HasColumnType("nvarchar(max)"); + + b.Property("Desc5") + .HasColumnType("nvarchar(max)"); + + b.Property("IsDeleted") + .HasColumnType("bit"); + + b.Property("MPK") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("ModifiedAt") + .HasColumnType("datetime2"); + + b.Property("ModifiedById") + .HasColumnType("uniqueidentifier"); + + b.Property("Value") + .HasColumnType("real"); + + b.HasKey("Id"); + + b.HasIndex("CreatedById"); + + b.HasIndex("DataSetId"); + + b.HasIndex("ModifiedById"); + + b.ToTable("DataRows"); + }); + + modelBuilder.Entity("WebAPI.Models.DataSet", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uniqueidentifier"); + + b.Property("CreatedAt") + .HasColumnType("datetime2"); + + b.Property("CreatedById") + .HasColumnType("uniqueidentifier"); + + b.Property("IsDeleted") + .HasColumnType("bit"); + + b.Property("ModifiedAt") + .HasColumnType("datetime2"); + + b.Property("ModifiedById") + .HasColumnType("uniqueidentifier"); + + b.Property("Name") + .HasColumnType("nvarchar(max)"); + + b.Property("Number") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.HasKey("Id"); + + b.HasIndex("CreatedById"); + + b.HasIndex("ModifiedById"); + + b.ToTable("DataSets"); + }); + + modelBuilder.Entity("WebAPI.Models.User", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uniqueidentifier"); + + b.Property("CreatedAt") + .HasColumnType("datetime2"); + + b.Property("Email") + .HasColumnType("nvarchar(max)"); + + b.Property("UserName") + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.HasKey("Id"); + + b.ToTable("Users"); + }); + + modelBuilder.Entity("WebAPI.Models.DataRow", b => + { + b.HasOne("WebAPI.Models.User", "CreatedBy") + .WithMany() + .HasForeignKey("CreatedById") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("WebAPI.Models.DataSet", null) + .WithMany("DataRows") + .HasForeignKey("DataSetId"); + + b.HasOne("WebAPI.Models.User", "ModifiedBy") + .WithMany() + .HasForeignKey("ModifiedById") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("CreatedBy"); + + b.Navigation("ModifiedBy"); + }); + + modelBuilder.Entity("WebAPI.Models.DataSet", b => + { + b.HasOne("WebAPI.Models.User", "CreatedBy") + .WithMany() + .HasForeignKey("CreatedById") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("WebAPI.Models.User", "ModifiedBy") + .WithMany() + .HasForeignKey("ModifiedById") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("CreatedBy"); + + b.Navigation("ModifiedBy"); + }); + + modelBuilder.Entity("WebAPI.Models.DataSet", b => + { + b.Navigation("DataRows"); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/src/Backend/DiunaBI.Infrastructure/Migrations/20221211210507_DataSetsAndDataRows.cs b/src/Backend/DiunaBI.Infrastructure/Migrations/20221211210507_DataSetsAndDataRows.cs index 8b3b603..0f1bcb8 100644 --- a/src/Backend/DiunaBI.Infrastructure/Migrations/20221211210507_DataSetsAndDataRows.cs +++ b/src/Backend/DiunaBI.Infrastructure/Migrations/20221211210507_DataSetsAndDataRows.cs @@ -1,121 +1,121 @@ -using System; -using Microsoft.EntityFrameworkCore.Migrations; - -#nullable disable - -namespace DiunaBI.Infrastructure.Migrations -{ - /// - public partial class DataSetsAndDataRows : Migration - { - /// - protected override void Up(MigrationBuilder migrationBuilder) - { - migrationBuilder.CreateTable( - name: "DataSets", - columns: table => new - { - Id = table.Column(type: "uniqueidentifier", nullable: false), - Number = table.Column(type: "nvarchar(max)", nullable: false), - Name = table.Column(type: "nvarchar(max)", nullable: true), - CreatedAt = table.Column(type: "datetime2", nullable: false), - ModifiedAt = table.Column(type: "datetime2", nullable: false), - IsDeleted = table.Column(type: "bit", nullable: false), - CreatedById = table.Column(type: "uniqueidentifier", nullable: false), - ModifiedById = table.Column(type: "uniqueidentifier", nullable: false) - }, - constraints: table => - { - table.PrimaryKey("PK_DataSets", x => x.Id); - table.ForeignKey( - name: "FK_DataSets_Users_CreatedById", - column: x => x.CreatedById, - principalTable: "Users", - principalColumn: "Id", - onDelete: ReferentialAction.NoAction); - table.ForeignKey( - name: "FK_DataSets_Users_ModifiedById", - column: x => x.ModifiedById, - principalTable: "Users", - principalColumn: "Id", - onDelete: ReferentialAction.NoAction); - }); - - migrationBuilder.CreateTable( - name: "DataRows", - columns: table => new - { - Id = table.Column(type: "uniqueidentifier", nullable: false), - MPK = table.Column(type: "nvarchar(max)", nullable: false), - Value = table.Column(type: "real", nullable: false), - Desc1 = table.Column(type: "nvarchar(max)", nullable: true), - Desc2 = table.Column(type: "nvarchar(max)", nullable: true), - Desc3 = table.Column(type: "nvarchar(max)", nullable: true), - Desc4 = table.Column(type: "nvarchar(max)", nullable: true), - Desc5 = table.Column(type: "nvarchar(max)", nullable: true), - CreatedAt = table.Column(type: "datetime2", nullable: false), - ModifiedAt = table.Column(type: "datetime2", nullable: false), - IsDeleted = table.Column(type: "bit", nullable: false), - CreatedById = table.Column(type: "uniqueidentifier", nullable: false), - ModifiedById = table.Column(type: "uniqueidentifier", nullable: false), - DataSetId = table.Column(type: "uniqueidentifier", nullable: true) - }, - constraints: table => - { - table.PrimaryKey("PK_DataRows", x => x.Id); - table.ForeignKey( - name: "FK_DataRows_DataSets_DataSetId", - column: x => x.DataSetId, - principalTable: "DataSets", - principalColumn: "Id"); - table.ForeignKey( - name: "FK_DataRows_Users_CreatedById", - column: x => x.CreatedById, - principalTable: "Users", - principalColumn: "Id", - onDelete: ReferentialAction.NoAction); - table.ForeignKey( - name: "FK_DataRows_Users_ModifiedById", - column: x => x.ModifiedById, - principalTable: "Users", - principalColumn: "Id", - onDelete: ReferentialAction.NoAction); - }); - - migrationBuilder.CreateIndex( - name: "IX_DataRows_CreatedById", - table: "DataRows", - column: "CreatedById"); - - migrationBuilder.CreateIndex( - name: "IX_DataRows_DataSetId", - table: "DataRows", - column: "DataSetId"); - - migrationBuilder.CreateIndex( - name: "IX_DataRows_ModifiedById", - table: "DataRows", - column: "ModifiedById"); - - migrationBuilder.CreateIndex( - name: "IX_DataSets_CreatedById", - table: "DataSets", - column: "CreatedById"); - - migrationBuilder.CreateIndex( - name: "IX_DataSets_ModifiedById", - table: "DataSets", - column: "ModifiedById"); - } - - /// - protected override void Down(MigrationBuilder migrationBuilder) - { - migrationBuilder.DropTable( - name: "DataRows"); - - migrationBuilder.DropTable( - name: "DataSets"); - } - } -} +using System; +using Microsoft.EntityFrameworkCore.Migrations; + +#nullable disable + +namespace DiunaBI.Infrastructure.Migrations +{ + /// + public partial class DataSetsAndDataRows : Migration + { + /// + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.CreateTable( + name: "DataSets", + columns: table => new + { + Id = table.Column(type: "uniqueidentifier", nullable: false), + Number = table.Column(type: "nvarchar(max)", nullable: false), + Name = table.Column(type: "nvarchar(max)", nullable: true), + CreatedAt = table.Column(type: "datetime2", nullable: false), + ModifiedAt = table.Column(type: "datetime2", nullable: false), + IsDeleted = table.Column(type: "bit", nullable: false), + CreatedById = table.Column(type: "uniqueidentifier", nullable: false), + ModifiedById = table.Column(type: "uniqueidentifier", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_DataSets", x => x.Id); + table.ForeignKey( + name: "FK_DataSets_Users_CreatedById", + column: x => x.CreatedById, + principalTable: "Users", + principalColumn: "Id", + onDelete: ReferentialAction.NoAction); + table.ForeignKey( + name: "FK_DataSets_Users_ModifiedById", + column: x => x.ModifiedById, + principalTable: "Users", + principalColumn: "Id", + onDelete: ReferentialAction.NoAction); + }); + + migrationBuilder.CreateTable( + name: "DataRows", + columns: table => new + { + Id = table.Column(type: "uniqueidentifier", nullable: false), + MPK = table.Column(type: "nvarchar(max)", nullable: false), + Value = table.Column(type: "real", nullable: false), + Desc1 = table.Column(type: "nvarchar(max)", nullable: true), + Desc2 = table.Column(type: "nvarchar(max)", nullable: true), + Desc3 = table.Column(type: "nvarchar(max)", nullable: true), + Desc4 = table.Column(type: "nvarchar(max)", nullable: true), + Desc5 = table.Column(type: "nvarchar(max)", nullable: true), + CreatedAt = table.Column(type: "datetime2", nullable: false), + ModifiedAt = table.Column(type: "datetime2", nullable: false), + IsDeleted = table.Column(type: "bit", nullable: false), + CreatedById = table.Column(type: "uniqueidentifier", nullable: false), + ModifiedById = table.Column(type: "uniqueidentifier", nullable: false), + DataSetId = table.Column(type: "uniqueidentifier", nullable: true) + }, + constraints: table => + { + table.PrimaryKey("PK_DataRows", x => x.Id); + table.ForeignKey( + name: "FK_DataRows_DataSets_DataSetId", + column: x => x.DataSetId, + principalTable: "DataSets", + principalColumn: "Id"); + table.ForeignKey( + name: "FK_DataRows_Users_CreatedById", + column: x => x.CreatedById, + principalTable: "Users", + principalColumn: "Id", + onDelete: ReferentialAction.NoAction); + table.ForeignKey( + name: "FK_DataRows_Users_ModifiedById", + column: x => x.ModifiedById, + principalTable: "Users", + principalColumn: "Id", + onDelete: ReferentialAction.NoAction); + }); + + migrationBuilder.CreateIndex( + name: "IX_DataRows_CreatedById", + table: "DataRows", + column: "CreatedById"); + + migrationBuilder.CreateIndex( + name: "IX_DataRows_DataSetId", + table: "DataRows", + column: "DataSetId"); + + migrationBuilder.CreateIndex( + name: "IX_DataRows_ModifiedById", + table: "DataRows", + column: "ModifiedById"); + + migrationBuilder.CreateIndex( + name: "IX_DataSets_CreatedById", + table: "DataSets", + column: "CreatedById"); + + migrationBuilder.CreateIndex( + name: "IX_DataSets_ModifiedById", + table: "DataSets", + column: "ModifiedById"); + } + + /// + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropTable( + name: "DataRows"); + + migrationBuilder.DropTable( + name: "DataSets"); + } + } +} diff --git a/src/Backend/DiunaBI.Infrastructure/Migrations/20221219163620_RenameFields.Designer.cs b/src/Backend/DiunaBI.Infrastructure/Migrations/20221219163620_RenameFields.Designer.cs index 0c8b364..1ba9362 100644 --- a/src/Backend/DiunaBI.Infrastructure/Migrations/20221219163620_RenameFields.Designer.cs +++ b/src/Backend/DiunaBI.Infrastructure/Migrations/20221219163620_RenameFields.Designer.cs @@ -1,198 +1,198 @@ -// -using System; -using Microsoft.EntityFrameworkCore; -using Microsoft.EntityFrameworkCore.Infrastructure; -using Microsoft.EntityFrameworkCore.Metadata; -using Microsoft.EntityFrameworkCore.Migrations; -using Microsoft.EntityFrameworkCore.Storage.ValueConversion; -using DiunaBI.Domain.Entities; -using DiunaBI.Infrastructure.Data; - -#nullable disable - -namespace DiunaBI.Infrastructure.Migrations -{ - [DbContext(typeof(AppDbContext))] - [Migration("20221219163620_RenameFields")] - partial class RenameFields - { - /// - protected void BuildTargetModel(ModelBuilder modelBuilder) - { -#pragma warning disable 612, 618 - modelBuilder - .HasAnnotation("ProductVersion", "7.0.0") - .HasAnnotation("Relational:MaxIdentifierLength", 128); - - SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder); - - modelBuilder.Entity("WebAPI.Models.DataRow", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("uniqueidentifier"); - - b.Property("Code") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b.Property("CreatedAt") - .HasColumnType("datetime2"); - - b.Property("CreatedById") - .HasColumnType("uniqueidentifier"); - - b.Property("DataSetId") - .HasColumnType("uniqueidentifier"); - - b.Property("Desc1") - .HasColumnType("nvarchar(max)"); - - b.Property("Desc2") - .HasColumnType("nvarchar(max)"); - - b.Property("Desc3") - .HasColumnType("nvarchar(max)"); - - b.Property("Desc4") - .HasColumnType("nvarchar(max)"); - - b.Property("Desc5") - .HasColumnType("nvarchar(max)"); - - b.Property("IsDeleted") - .HasColumnType("bit"); - - b.Property("ModifiedAt") - .HasColumnType("datetime2"); - - b.Property("ModifiedById") - .HasColumnType("uniqueidentifier"); - - b.Property("Value") - .HasColumnType("real"); - - b.HasKey("Id"); - - b.HasIndex("CreatedById"); - - b.HasIndex("DataSetId"); - - b.HasIndex("ModifiedById"); - - b.ToTable("DataRows"); - }); - - modelBuilder.Entity("WebAPI.Models.DataSet", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("uniqueidentifier"); - - b.Property("CreatedAt") - .HasColumnType("datetime2"); - - b.Property("CreatedById") - .HasColumnType("uniqueidentifier"); - - b.Property("IsDeleted") - .HasColumnType("bit"); - - b.Property("ModifiedAt") - .HasColumnType("datetime2"); - - b.Property("ModifiedById") - .HasColumnType("uniqueidentifier"); - - b.Property("Name") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b.Property("Number") - .IsRequired() - .HasColumnType("int"); - - b.Property("Source") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b.HasKey("Id"); - - b.HasIndex("CreatedById"); - - b.HasIndex("ModifiedById"); - - b.ToTable("DataSets"); - }); - - modelBuilder.Entity("WebAPI.Models.User", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("uniqueidentifier"); - - b.Property("CreatedAt") - .HasColumnType("datetime2"); - - b.Property("Email") - .HasColumnType("nvarchar(max)"); - - b.Property("UserName") - .HasMaxLength(50) - .HasColumnType("nvarchar(50)"); - - b.HasKey("Id"); - - b.ToTable("Users"); - }); - - modelBuilder.Entity("WebAPI.Models.DataRow", b => - { - b.HasOne("WebAPI.Models.User", "CreatedBy") - .WithMany() - .HasForeignKey("CreatedById") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("WebAPI.Models.DataSet", null) - .WithMany("DataRows") - .HasForeignKey("DataSetId"); - - b.HasOne("WebAPI.Models.User", "ModifiedBy") - .WithMany() - .HasForeignKey("ModifiedById") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("CreatedBy"); - - b.Navigation("ModifiedBy"); - }); - - modelBuilder.Entity("WebAPI.Models.DataSet", b => - { - b.HasOne("WebAPI.Models.User", "CreatedBy") - .WithMany() - .HasForeignKey("CreatedById") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("WebAPI.Models.User", "ModifiedBy") - .WithMany() - .HasForeignKey("ModifiedById") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("CreatedBy"); - - b.Navigation("ModifiedBy"); - }); - - modelBuilder.Entity("WebAPI.Models.DataSet", b => - { - b.Navigation("DataRows"); - }); -#pragma warning restore 612, 618 - } - } -} +// +using System; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Metadata; +using Microsoft.EntityFrameworkCore.Migrations; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; +using DiunaBI.Domain.Entities; +using DiunaBI.Infrastructure.Data; + +#nullable disable + +namespace DiunaBI.Infrastructure.Migrations +{ + [DbContext(typeof(AppDbContext))] + [Migration("20221219163620_RenameFields")] + partial class RenameFields + { + /// + protected void BuildTargetModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder + .HasAnnotation("ProductVersion", "7.0.0") + .HasAnnotation("Relational:MaxIdentifierLength", 128); + + SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder); + + modelBuilder.Entity("WebAPI.Models.DataRow", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uniqueidentifier"); + + b.Property("Code") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("CreatedAt") + .HasColumnType("datetime2"); + + b.Property("CreatedById") + .HasColumnType("uniqueidentifier"); + + b.Property("DataSetId") + .HasColumnType("uniqueidentifier"); + + b.Property("Desc1") + .HasColumnType("nvarchar(max)"); + + b.Property("Desc2") + .HasColumnType("nvarchar(max)"); + + b.Property("Desc3") + .HasColumnType("nvarchar(max)"); + + b.Property("Desc4") + .HasColumnType("nvarchar(max)"); + + b.Property("Desc5") + .HasColumnType("nvarchar(max)"); + + b.Property("IsDeleted") + .HasColumnType("bit"); + + b.Property("ModifiedAt") + .HasColumnType("datetime2"); + + b.Property("ModifiedById") + .HasColumnType("uniqueidentifier"); + + b.Property("Value") + .HasColumnType("real"); + + b.HasKey("Id"); + + b.HasIndex("CreatedById"); + + b.HasIndex("DataSetId"); + + b.HasIndex("ModifiedById"); + + b.ToTable("DataRows"); + }); + + modelBuilder.Entity("WebAPI.Models.DataSet", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uniqueidentifier"); + + b.Property("CreatedAt") + .HasColumnType("datetime2"); + + b.Property("CreatedById") + .HasColumnType("uniqueidentifier"); + + b.Property("IsDeleted") + .HasColumnType("bit"); + + b.Property("ModifiedAt") + .HasColumnType("datetime2"); + + b.Property("ModifiedById") + .HasColumnType("uniqueidentifier"); + + b.Property("Name") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("Number") + .IsRequired() + .HasColumnType("int"); + + b.Property("Source") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.HasKey("Id"); + + b.HasIndex("CreatedById"); + + b.HasIndex("ModifiedById"); + + b.ToTable("DataSets"); + }); + + modelBuilder.Entity("WebAPI.Models.User", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uniqueidentifier"); + + b.Property("CreatedAt") + .HasColumnType("datetime2"); + + b.Property("Email") + .HasColumnType("nvarchar(max)"); + + b.Property("UserName") + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.HasKey("Id"); + + b.ToTable("Users"); + }); + + modelBuilder.Entity("WebAPI.Models.DataRow", b => + { + b.HasOne("WebAPI.Models.User", "CreatedBy") + .WithMany() + .HasForeignKey("CreatedById") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("WebAPI.Models.DataSet", null) + .WithMany("DataRows") + .HasForeignKey("DataSetId"); + + b.HasOne("WebAPI.Models.User", "ModifiedBy") + .WithMany() + .HasForeignKey("ModifiedById") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("CreatedBy"); + + b.Navigation("ModifiedBy"); + }); + + modelBuilder.Entity("WebAPI.Models.DataSet", b => + { + b.HasOne("WebAPI.Models.User", "CreatedBy") + .WithMany() + .HasForeignKey("CreatedById") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("WebAPI.Models.User", "ModifiedBy") + .WithMany() + .HasForeignKey("ModifiedById") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("CreatedBy"); + + b.Navigation("ModifiedBy"); + }); + + modelBuilder.Entity("WebAPI.Models.DataSet", b => + { + b.Navigation("DataRows"); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/src/Backend/DiunaBI.Infrastructure/Migrations/20221219163620_RenameFields.cs b/src/Backend/DiunaBI.Infrastructure/Migrations/20221219163620_RenameFields.cs index 4989f50..6b7f7a9 100644 --- a/src/Backend/DiunaBI.Infrastructure/Migrations/20221219163620_RenameFields.cs +++ b/src/Backend/DiunaBI.Infrastructure/Migrations/20221219163620_RenameFields.cs @@ -1,73 +1,73 @@ -using Microsoft.EntityFrameworkCore.Migrations; - -#nullable disable - -namespace DiunaBI.Infrastructure.Migrations -{ - /// - public partial class RenameFields : Migration - { - /// - protected override void Up(MigrationBuilder migrationBuilder) - { - migrationBuilder.RenameColumn( - name: "MPK", - table: "DataRows", - newName: "Code"); - - migrationBuilder.AlterColumn( - name: "Number", - table: "DataSets", - type: "int", - nullable: false, - oldClrType: typeof(string), - oldType: "nvarchar(max)"); - - migrationBuilder.AlterColumn( - name: "Name", - table: "DataSets", - type: "nvarchar(max)", - nullable: false, - defaultValue: "", - oldClrType: typeof(string), - oldType: "nvarchar(max)", - oldNullable: true); - - migrationBuilder.AddColumn( - name: "Source", - table: "DataSets", - type: "nvarchar(max)", - nullable: false, - defaultValue: ""); - } - - /// - protected override void Down(MigrationBuilder migrationBuilder) - { - migrationBuilder.DropColumn( - name: "Source", - table: "DataSets"); - - migrationBuilder.RenameColumn( - name: "Code", - table: "DataRows", - newName: "MPK"); - - migrationBuilder.AlterColumn( - name: "Number", - table: "DataSets", - type: "nvarchar(max)", - nullable: false, - oldClrType: typeof(int), - oldType: "int"); - - migrationBuilder.AlterColumn( - name: "Name", - table: "DataSets", - type: "nvarchar(max)", - nullable: true, - oldClrType: typeof(string), - oldType: "nvarchar(max)"); - } - } -} +using Microsoft.EntityFrameworkCore.Migrations; + +#nullable disable + +namespace DiunaBI.Infrastructure.Migrations +{ + /// + public partial class RenameFields : Migration + { + /// + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.RenameColumn( + name: "MPK", + table: "DataRows", + newName: "Code"); + + migrationBuilder.AlterColumn( + name: "Number", + table: "DataSets", + type: "int", + nullable: false, + oldClrType: typeof(string), + oldType: "nvarchar(max)"); + + migrationBuilder.AlterColumn( + name: "Name", + table: "DataSets", + type: "nvarchar(max)", + nullable: false, + defaultValue: "", + oldClrType: typeof(string), + oldType: "nvarchar(max)", + oldNullable: true); + + migrationBuilder.AddColumn( + name: "Source", + table: "DataSets", + type: "nvarchar(max)", + nullable: false, + defaultValue: ""); + } + + /// + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropColumn( + name: "Source", + table: "DataSets"); + + migrationBuilder.RenameColumn( + name: "Code", + table: "DataRows", + newName: "MPK"); + + migrationBuilder.AlterColumn( + name: "Number", + table: "DataSets", + type: "nvarchar(max)", + nullable: false, + oldClrType: typeof(int), + oldType: "int"); + + migrationBuilder.AlterColumn( + name: "Name", + table: "DataSets", + type: "nvarchar(max)", + nullable: true, + oldClrType: typeof(string), + oldType: "nvarchar(max)"); + } + } +} diff --git a/src/Backend/DiunaBI.Infrastructure/Migrations/20221221165749_DataSetIdOnDataRow.Designer.cs b/src/Backend/DiunaBI.Infrastructure/Migrations/20221221165749_DataSetIdOnDataRow.Designer.cs index 8a24b1c..3016814 100644 --- a/src/Backend/DiunaBI.Infrastructure/Migrations/20221221165749_DataSetIdOnDataRow.Designer.cs +++ b/src/Backend/DiunaBI.Infrastructure/Migrations/20221221165749_DataSetIdOnDataRow.Designer.cs @@ -1,200 +1,200 @@ -// -using System; -using Microsoft.EntityFrameworkCore; -using Microsoft.EntityFrameworkCore.Infrastructure; -using Microsoft.EntityFrameworkCore.Metadata; -using Microsoft.EntityFrameworkCore.Migrations; -using Microsoft.EntityFrameworkCore.Storage.ValueConversion; -using DiunaBI.Domain.Entities; -using DiunaBI.Infrastructure.Data; - -#nullable disable - -namespace DiunaBI.Infrastructure.Migrations -{ - [DbContext(typeof(AppDbContext))] - [Migration("20221221165749_DataSetIdOnDataRow")] - partial class DataSetIdOnDataRow - { - /// - protected void BuildTargetModel(ModelBuilder modelBuilder) - { -#pragma warning disable 612, 618 - modelBuilder - .HasAnnotation("ProductVersion", "7.0.0") - .HasAnnotation("Relational:MaxIdentifierLength", 128); - - SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder); - - modelBuilder.Entity("WebAPI.Models.DataRow", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("uniqueidentifier"); - - b.Property("Code") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b.Property("CreatedAt") - .HasColumnType("datetime2"); - - b.Property("CreatedById") - .HasColumnType("uniqueidentifier"); - - b.Property("DataSetId") - .HasColumnType("uniqueidentifier"); - - b.Property("Desc1") - .HasColumnType("nvarchar(max)"); - - b.Property("Desc2") - .HasColumnType("nvarchar(max)"); - - b.Property("Desc3") - .HasColumnType("nvarchar(max)"); - - b.Property("Desc4") - .HasColumnType("nvarchar(max)"); - - b.Property("Desc5") - .HasColumnType("nvarchar(max)"); - - b.Property("IsDeleted") - .HasColumnType("bit"); - - b.Property("ModifiedAt") - .HasColumnType("datetime2"); - - b.Property("ModifiedById") - .HasColumnType("uniqueidentifier"); - - b.Property("Value") - .HasColumnType("real"); - - b.HasKey("Id"); - - b.HasIndex("CreatedById"); - - b.HasIndex("DataSetId"); - - b.HasIndex("ModifiedById"); - - b.ToTable("DataRows"); - }); - - modelBuilder.Entity("WebAPI.Models.DataSet", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("uniqueidentifier"); - - b.Property("CreatedAt") - .HasColumnType("datetime2"); - - b.Property("CreatedById") - .HasColumnType("uniqueidentifier"); - - b.Property("IsDeleted") - .HasColumnType("bit"); - - b.Property("ModifiedAt") - .HasColumnType("datetime2"); - - b.Property("ModifiedById") - .HasColumnType("uniqueidentifier"); - - b.Property("Name") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b.Property("Number") - .IsRequired() - .HasColumnType("int"); - - b.Property("Source") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b.HasKey("Id"); - - b.HasIndex("CreatedById"); - - b.HasIndex("ModifiedById"); - - b.ToTable("DataSets"); - }); - - modelBuilder.Entity("WebAPI.Models.User", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("uniqueidentifier"); - - b.Property("CreatedAt") - .HasColumnType("datetime2"); - - b.Property("Email") - .HasColumnType("nvarchar(max)"); - - b.Property("UserName") - .HasMaxLength(50) - .HasColumnType("nvarchar(50)"); - - b.HasKey("Id"); - - b.ToTable("Users"); - }); - - modelBuilder.Entity("WebAPI.Models.DataRow", b => - { - b.HasOne("WebAPI.Models.User", "CreatedBy") - .WithMany() - .HasForeignKey("CreatedById") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("WebAPI.Models.DataSet", null) - .WithMany("DataRows") - .HasForeignKey("DataSetId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("WebAPI.Models.User", "ModifiedBy") - .WithMany() - .HasForeignKey("ModifiedById") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("CreatedBy"); - - b.Navigation("ModifiedBy"); - }); - - modelBuilder.Entity("WebAPI.Models.DataSet", b => - { - b.HasOne("WebAPI.Models.User", "CreatedBy") - .WithMany() - .HasForeignKey("CreatedById") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("WebAPI.Models.User", "ModifiedBy") - .WithMany() - .HasForeignKey("ModifiedById") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("CreatedBy"); - - b.Navigation("ModifiedBy"); - }); - - modelBuilder.Entity("WebAPI.Models.DataSet", b => - { - b.Navigation("DataRows"); - }); -#pragma warning restore 612, 618 - } - } -} +// +using System; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Metadata; +using Microsoft.EntityFrameworkCore.Migrations; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; +using DiunaBI.Domain.Entities; +using DiunaBI.Infrastructure.Data; + +#nullable disable + +namespace DiunaBI.Infrastructure.Migrations +{ + [DbContext(typeof(AppDbContext))] + [Migration("20221221165749_DataSetIdOnDataRow")] + partial class DataSetIdOnDataRow + { + /// + protected void BuildTargetModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder + .HasAnnotation("ProductVersion", "7.0.0") + .HasAnnotation("Relational:MaxIdentifierLength", 128); + + SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder); + + modelBuilder.Entity("WebAPI.Models.DataRow", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uniqueidentifier"); + + b.Property("Code") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("CreatedAt") + .HasColumnType("datetime2"); + + b.Property("CreatedById") + .HasColumnType("uniqueidentifier"); + + b.Property("DataSetId") + .HasColumnType("uniqueidentifier"); + + b.Property("Desc1") + .HasColumnType("nvarchar(max)"); + + b.Property("Desc2") + .HasColumnType("nvarchar(max)"); + + b.Property("Desc3") + .HasColumnType("nvarchar(max)"); + + b.Property("Desc4") + .HasColumnType("nvarchar(max)"); + + b.Property("Desc5") + .HasColumnType("nvarchar(max)"); + + b.Property("IsDeleted") + .HasColumnType("bit"); + + b.Property("ModifiedAt") + .HasColumnType("datetime2"); + + b.Property("ModifiedById") + .HasColumnType("uniqueidentifier"); + + b.Property("Value") + .HasColumnType("real"); + + b.HasKey("Id"); + + b.HasIndex("CreatedById"); + + b.HasIndex("DataSetId"); + + b.HasIndex("ModifiedById"); + + b.ToTable("DataRows"); + }); + + modelBuilder.Entity("WebAPI.Models.DataSet", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uniqueidentifier"); + + b.Property("CreatedAt") + .HasColumnType("datetime2"); + + b.Property("CreatedById") + .HasColumnType("uniqueidentifier"); + + b.Property("IsDeleted") + .HasColumnType("bit"); + + b.Property("ModifiedAt") + .HasColumnType("datetime2"); + + b.Property("ModifiedById") + .HasColumnType("uniqueidentifier"); + + b.Property("Name") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("Number") + .IsRequired() + .HasColumnType("int"); + + b.Property("Source") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.HasKey("Id"); + + b.HasIndex("CreatedById"); + + b.HasIndex("ModifiedById"); + + b.ToTable("DataSets"); + }); + + modelBuilder.Entity("WebAPI.Models.User", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uniqueidentifier"); + + b.Property("CreatedAt") + .HasColumnType("datetime2"); + + b.Property("Email") + .HasColumnType("nvarchar(max)"); + + b.Property("UserName") + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.HasKey("Id"); + + b.ToTable("Users"); + }); + + modelBuilder.Entity("WebAPI.Models.DataRow", b => + { + b.HasOne("WebAPI.Models.User", "CreatedBy") + .WithMany() + .HasForeignKey("CreatedById") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("WebAPI.Models.DataSet", null) + .WithMany("DataRows") + .HasForeignKey("DataSetId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("WebAPI.Models.User", "ModifiedBy") + .WithMany() + .HasForeignKey("ModifiedById") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("CreatedBy"); + + b.Navigation("ModifiedBy"); + }); + + modelBuilder.Entity("WebAPI.Models.DataSet", b => + { + b.HasOne("WebAPI.Models.User", "CreatedBy") + .WithMany() + .HasForeignKey("CreatedById") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("WebAPI.Models.User", "ModifiedBy") + .WithMany() + .HasForeignKey("ModifiedById") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("CreatedBy"); + + b.Navigation("ModifiedBy"); + }); + + modelBuilder.Entity("WebAPI.Models.DataSet", b => + { + b.Navigation("DataRows"); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/src/Backend/DiunaBI.Infrastructure/Migrations/20221221165749_DataSetIdOnDataRow.cs b/src/Backend/DiunaBI.Infrastructure/Migrations/20221221165749_DataSetIdOnDataRow.cs index 3c8a29e..6ad0bcc 100644 --- a/src/Backend/DiunaBI.Infrastructure/Migrations/20221221165749_DataSetIdOnDataRow.cs +++ b/src/Backend/DiunaBI.Infrastructure/Migrations/20221221165749_DataSetIdOnDataRow.cs @@ -1,80 +1,80 @@ -using System; -using Microsoft.EntityFrameworkCore.Migrations; - -#nullable disable - -namespace DiunaBI.Infrastructure.Migrations -{ - /// - public partial class DataSetIdOnDataRow : Migration - { - /// - protected override void Up(MigrationBuilder migrationBuilder) - { - migrationBuilder.DropForeignKey( - name: "FK_DataRows_DataSets_DataSetId", - table: "DataRows"); - - // DODAJ: Usuń index przed zmianą kolumny - migrationBuilder.DropIndex( - name: "IX_DataRows_DataSetId", - table: "DataRows"); - - migrationBuilder.AlterColumn( - name: "DataSetId", - table: "DataRows", - type: "uniqueidentifier", - nullable: false, - defaultValue: new Guid("00000000-0000-0000-0000-000000000000"), - oldClrType: typeof(Guid), - oldType: "uniqueidentifier", - oldNullable: true); - - // DODAJ: Odtwórz index po zmianie kolumny - migrationBuilder.CreateIndex( - name: "IX_DataRows_DataSetId", - table: "DataRows", - column: "DataSetId"); - - migrationBuilder.AddForeignKey( - name: "FK_DataRows_DataSets_DataSetId", - table: "DataRows", - column: "DataSetId", - principalTable: "DataSets", - principalColumn: "Id", - onDelete: ReferentialAction.Cascade); - } - - /// - protected override void Down(MigrationBuilder migrationBuilder) - { - migrationBuilder.DropForeignKey( - name: "FK_DataRows_DataSets_DataSetId", - table: "DataRows"); - - migrationBuilder.DropIndex( - name: "IX_DataRows_DataSetId", - table: "DataRows"); - - migrationBuilder.AlterColumn( - name: "DataSetId", - table: "DataRows", - type: "uniqueidentifier", - nullable: true, - oldClrType: typeof(Guid), - oldType: "uniqueidentifier"); - - migrationBuilder.CreateIndex( - name: "IX_DataRows_DataSetId", - table: "DataRows", - column: "DataSetId"); - - migrationBuilder.AddForeignKey( - name: "FK_DataRows_DataSets_DataSetId", - table: "DataRows", - column: "DataSetId", - principalTable: "DataSets", - principalColumn: "Id"); - } - } +using System; +using Microsoft.EntityFrameworkCore.Migrations; + +#nullable disable + +namespace DiunaBI.Infrastructure.Migrations +{ + /// + public partial class DataSetIdOnDataRow : Migration + { + /// + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropForeignKey( + name: "FK_DataRows_DataSets_DataSetId", + table: "DataRows"); + + // DODAJ: Usuń index przed zmianą kolumny + migrationBuilder.DropIndex( + name: "IX_DataRows_DataSetId", + table: "DataRows"); + + migrationBuilder.AlterColumn( + name: "DataSetId", + table: "DataRows", + type: "uniqueidentifier", + nullable: false, + defaultValue: new Guid("00000000-0000-0000-0000-000000000000"), + oldClrType: typeof(Guid), + oldType: "uniqueidentifier", + oldNullable: true); + + // DODAJ: Odtwórz index po zmianie kolumny + migrationBuilder.CreateIndex( + name: "IX_DataRows_DataSetId", + table: "DataRows", + column: "DataSetId"); + + migrationBuilder.AddForeignKey( + name: "FK_DataRows_DataSets_DataSetId", + table: "DataRows", + column: "DataSetId", + principalTable: "DataSets", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + } + + /// + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropForeignKey( + name: "FK_DataRows_DataSets_DataSetId", + table: "DataRows"); + + migrationBuilder.DropIndex( + name: "IX_DataRows_DataSetId", + table: "DataRows"); + + migrationBuilder.AlterColumn( + name: "DataSetId", + table: "DataRows", + type: "uniqueidentifier", + nullable: true, + oldClrType: typeof(Guid), + oldType: "uniqueidentifier"); + + migrationBuilder.CreateIndex( + name: "IX_DataRows_DataSetId", + table: "DataRows", + column: "DataSetId"); + + migrationBuilder.AddForeignKey( + name: "FK_DataRows_DataSets_DataSetId", + table: "DataRows", + column: "DataSetId", + principalTable: "DataSets", + principalColumn: "Id"); + } + } } \ No newline at end of file diff --git a/src/Backend/DiunaBI.Infrastructure/Migrations/20230106095427_RenameModels.Designer.cs b/src/Backend/DiunaBI.Infrastructure/Migrations/20230106095427_RenameModels.Designer.cs index 8cb5e5c..140327d 100644 --- a/src/Backend/DiunaBI.Infrastructure/Migrations/20230106095427_RenameModels.Designer.cs +++ b/src/Backend/DiunaBI.Infrastructure/Migrations/20230106095427_RenameModels.Designer.cs @@ -1,200 +1,200 @@ -// -using System; -using Microsoft.EntityFrameworkCore; -using Microsoft.EntityFrameworkCore.Infrastructure; -using Microsoft.EntityFrameworkCore.Metadata; -using Microsoft.EntityFrameworkCore.Migrations; -using Microsoft.EntityFrameworkCore.Storage.ValueConversion; -using DiunaBI.Domain.Entities; -using DiunaBI.Infrastructure.Data; - -#nullable disable - -namespace DiunaBI.Infrastructure.Migrations -{ - [DbContext(typeof(AppDbContext))] - [Migration("20230106095427_RenameModels")] - partial class RenameModels - { - /// - protected void BuildTargetModel(ModelBuilder modelBuilder) - { -#pragma warning disable 612, 618 - modelBuilder - .HasAnnotation("ProductVersion", "7.0.0") - .HasAnnotation("Relational:MaxIdentifierLength", 128); - - SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder); - - modelBuilder.Entity("WebAPI.Models.Layer", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("uniqueidentifier"); - - b.Property("CreatedAt") - .HasColumnType("datetime2"); - - b.Property("CreatedById") - .HasColumnType("uniqueidentifier"); - - b.Property("IsDeleted") - .HasColumnType("bit"); - - b.Property("ModifiedAt") - .HasColumnType("datetime2"); - - b.Property("ModifiedById") - .HasColumnType("uniqueidentifier"); - - b.Property("Name") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b.Property("Number") - .IsRequired() - .HasColumnType("int"); - - b.Property("Source") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b.HasKey("Id"); - - b.HasIndex("CreatedById"); - - b.HasIndex("ModifiedById"); - - b.ToTable("Layers"); - }); - - modelBuilder.Entity("WebAPI.Models.Record", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("uniqueidentifier"); - - b.Property("Code") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b.Property("CreatedAt") - .HasColumnType("datetime2"); - - b.Property("CreatedById") - .HasColumnType("uniqueidentifier"); - - b.Property("Desc1") - .HasColumnType("nvarchar(max)"); - - b.Property("Desc2") - .HasColumnType("nvarchar(max)"); - - b.Property("Desc3") - .HasColumnType("nvarchar(max)"); - - b.Property("Desc4") - .HasColumnType("nvarchar(max)"); - - b.Property("Desc5") - .HasColumnType("nvarchar(max)"); - - b.Property("IsDeleted") - .HasColumnType("bit"); - - b.Property("LayerId") - .HasColumnType("uniqueidentifier"); - - b.Property("ModifiedAt") - .HasColumnType("datetime2"); - - b.Property("ModifiedById") - .HasColumnType("uniqueidentifier"); - - b.Property("Value") - .HasColumnType("real"); - - b.HasKey("Id"); - - b.HasIndex("CreatedById"); - - b.HasIndex("LayerId"); - - b.HasIndex("ModifiedById"); - - b.ToTable("Records"); - }); - - modelBuilder.Entity("WebAPI.Models.User", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("uniqueidentifier"); - - b.Property("CreatedAt") - .HasColumnType("datetime2"); - - b.Property("Email") - .HasColumnType("nvarchar(max)"); - - b.Property("UserName") - .HasMaxLength(50) - .HasColumnType("nvarchar(50)"); - - b.HasKey("Id"); - - b.ToTable("Users"); - }); - - modelBuilder.Entity("WebAPI.Models.Layer", b => - { - b.HasOne("WebAPI.Models.User", "CreatedBy") - .WithMany() - .HasForeignKey("CreatedById") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("WebAPI.Models.User", "ModifiedBy") - .WithMany() - .HasForeignKey("ModifiedById") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("CreatedBy"); - - b.Navigation("ModifiedBy"); - }); - - modelBuilder.Entity("WebAPI.Models.Record", b => - { - b.HasOne("WebAPI.Models.User", "CreatedBy") - .WithMany() - .HasForeignKey("CreatedById") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("WebAPI.Models.Layer", null) - .WithMany("Records") - .HasForeignKey("LayerId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("WebAPI.Models.User", "ModifiedBy") - .WithMany() - .HasForeignKey("ModifiedById") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("CreatedBy"); - - b.Navigation("ModifiedBy"); - }); - - modelBuilder.Entity("WebAPI.Models.Layer", b => - { - b.Navigation("Records"); - }); -#pragma warning restore 612, 618 - } - } -} +// +using System; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Metadata; +using Microsoft.EntityFrameworkCore.Migrations; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; +using DiunaBI.Domain.Entities; +using DiunaBI.Infrastructure.Data; + +#nullable disable + +namespace DiunaBI.Infrastructure.Migrations +{ + [DbContext(typeof(AppDbContext))] + [Migration("20230106095427_RenameModels")] + partial class RenameModels + { + /// + protected void BuildTargetModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder + .HasAnnotation("ProductVersion", "7.0.0") + .HasAnnotation("Relational:MaxIdentifierLength", 128); + + SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder); + + modelBuilder.Entity("WebAPI.Models.Layer", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uniqueidentifier"); + + b.Property("CreatedAt") + .HasColumnType("datetime2"); + + b.Property("CreatedById") + .HasColumnType("uniqueidentifier"); + + b.Property("IsDeleted") + .HasColumnType("bit"); + + b.Property("ModifiedAt") + .HasColumnType("datetime2"); + + b.Property("ModifiedById") + .HasColumnType("uniqueidentifier"); + + b.Property("Name") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("Number") + .IsRequired() + .HasColumnType("int"); + + b.Property("Source") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.HasKey("Id"); + + b.HasIndex("CreatedById"); + + b.HasIndex("ModifiedById"); + + b.ToTable("Layers"); + }); + + modelBuilder.Entity("WebAPI.Models.Record", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uniqueidentifier"); + + b.Property("Code") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("CreatedAt") + .HasColumnType("datetime2"); + + b.Property("CreatedById") + .HasColumnType("uniqueidentifier"); + + b.Property("Desc1") + .HasColumnType("nvarchar(max)"); + + b.Property("Desc2") + .HasColumnType("nvarchar(max)"); + + b.Property("Desc3") + .HasColumnType("nvarchar(max)"); + + b.Property("Desc4") + .HasColumnType("nvarchar(max)"); + + b.Property("Desc5") + .HasColumnType("nvarchar(max)"); + + b.Property("IsDeleted") + .HasColumnType("bit"); + + b.Property("LayerId") + .HasColumnType("uniqueidentifier"); + + b.Property("ModifiedAt") + .HasColumnType("datetime2"); + + b.Property("ModifiedById") + .HasColumnType("uniqueidentifier"); + + b.Property("Value") + .HasColumnType("real"); + + b.HasKey("Id"); + + b.HasIndex("CreatedById"); + + b.HasIndex("LayerId"); + + b.HasIndex("ModifiedById"); + + b.ToTable("Records"); + }); + + modelBuilder.Entity("WebAPI.Models.User", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uniqueidentifier"); + + b.Property("CreatedAt") + .HasColumnType("datetime2"); + + b.Property("Email") + .HasColumnType("nvarchar(max)"); + + b.Property("UserName") + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.HasKey("Id"); + + b.ToTable("Users"); + }); + + modelBuilder.Entity("WebAPI.Models.Layer", b => + { + b.HasOne("WebAPI.Models.User", "CreatedBy") + .WithMany() + .HasForeignKey("CreatedById") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("WebAPI.Models.User", "ModifiedBy") + .WithMany() + .HasForeignKey("ModifiedById") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("CreatedBy"); + + b.Navigation("ModifiedBy"); + }); + + modelBuilder.Entity("WebAPI.Models.Record", b => + { + b.HasOne("WebAPI.Models.User", "CreatedBy") + .WithMany() + .HasForeignKey("CreatedById") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("WebAPI.Models.Layer", null) + .WithMany("Records") + .HasForeignKey("LayerId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("WebAPI.Models.User", "ModifiedBy") + .WithMany() + .HasForeignKey("ModifiedById") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("CreatedBy"); + + b.Navigation("ModifiedBy"); + }); + + modelBuilder.Entity("WebAPI.Models.Layer", b => + { + b.Navigation("Records"); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/src/Backend/DiunaBI.Infrastructure/Migrations/20230106095427_RenameModels.cs b/src/Backend/DiunaBI.Infrastructure/Migrations/20230106095427_RenameModels.cs index 0d003ef..f031c4e 100644 --- a/src/Backend/DiunaBI.Infrastructure/Migrations/20230106095427_RenameModels.cs +++ b/src/Backend/DiunaBI.Infrastructure/Migrations/20230106095427_RenameModels.cs @@ -1,227 +1,227 @@ -using System; -using Microsoft.EntityFrameworkCore.Migrations; - -#nullable disable - -namespace DiunaBI.Infrastructure.Migrations -{ - /// - public partial class RenameModels : Migration - { - /// - protected override void Up(MigrationBuilder migrationBuilder) - { - migrationBuilder.DropTable( - name: "DataRows"); - - migrationBuilder.DropTable( - name: "DataSets"); - - migrationBuilder.CreateTable( - name: "Layers", - columns: table => new - { - Id = table.Column(type: "uniqueidentifier", nullable: false), - Number = table.Column(type: "int", nullable: false), - Source = table.Column(type: "nvarchar(max)", nullable: false), - Name = table.Column(type: "nvarchar(max)", nullable: false), - CreatedAt = table.Column(type: "datetime2", nullable: false), - ModifiedAt = table.Column(type: "datetime2", nullable: false), - IsDeleted = table.Column(type: "bit", nullable: false), - CreatedById = table.Column(type: "uniqueidentifier", nullable: false), - ModifiedById = table.Column(type: "uniqueidentifier", nullable: false) - }, - constraints: table => - { - table.PrimaryKey("PK_Layers", x => x.Id); - table.ForeignKey( - name: "FK_Layers_Users_CreatedById", - column: x => x.CreatedById, - principalTable: "Users", - principalColumn: "Id", - onDelete: ReferentialAction.NoAction); - table.ForeignKey( - name: "FK_Layers_Users_ModifiedById", - column: x => x.ModifiedById, - principalTable: "Users", - principalColumn: "Id", - onDelete: ReferentialAction.NoAction); - }); - - migrationBuilder.CreateTable( - name: "Records", - columns: table => new - { - Id = table.Column(type: "uniqueidentifier", nullable: false), - Code = table.Column(type: "nvarchar(max)", nullable: false), - Value = table.Column(type: "real", nullable: false), - Desc1 = table.Column(type: "nvarchar(max)", nullable: true), - Desc2 = table.Column(type: "nvarchar(max)", nullable: true), - Desc3 = table.Column(type: "nvarchar(max)", nullable: true), - Desc4 = table.Column(type: "nvarchar(max)", nullable: true), - Desc5 = table.Column(type: "nvarchar(max)", nullable: true), - CreatedAt = table.Column(type: "datetime2", nullable: false), - ModifiedAt = table.Column(type: "datetime2", nullable: false), - IsDeleted = table.Column(type: "bit", nullable: false), - CreatedById = table.Column(type: "uniqueidentifier", nullable: false), - ModifiedById = table.Column(type: "uniqueidentifier", nullable: false), - LayerId = table.Column(type: "uniqueidentifier", nullable: false) - }, - constraints: table => - { - table.PrimaryKey("PK_Records", x => x.Id); - table.ForeignKey( - name: "FK_Records_Layers_LayerId", - column: x => x.LayerId, - principalTable: "Layers", - principalColumn: "Id", - onDelete: ReferentialAction.NoAction); - table.ForeignKey( - name: "FK_Records_Users_CreatedById", - column: x => x.CreatedById, - principalTable: "Users", - principalColumn: "Id", - onDelete: ReferentialAction.NoAction); - table.ForeignKey( - name: "FK_Records_Users_ModifiedById", - column: x => x.ModifiedById, - principalTable: "Users", - principalColumn: "Id", - onDelete: ReferentialAction.NoAction); - }); - - migrationBuilder.CreateIndex( - name: "IX_Layers_CreatedById", - table: "Layers", - column: "CreatedById"); - - migrationBuilder.CreateIndex( - name: "IX_Layers_ModifiedById", - table: "Layers", - column: "ModifiedById"); - - migrationBuilder.CreateIndex( - name: "IX_Records_CreatedById", - table: "Records", - column: "CreatedById"); - - migrationBuilder.CreateIndex( - name: "IX_Records_LayerId", - table: "Records", - column: "LayerId"); - - migrationBuilder.CreateIndex( - name: "IX_Records_ModifiedById", - table: "Records", - column: "ModifiedById"); - } - - /// - protected override void Down(MigrationBuilder migrationBuilder) - { - migrationBuilder.DropTable( - name: "Records"); - - migrationBuilder.DropTable( - name: "Layers"); - - migrationBuilder.CreateTable( - name: "DataSets", - columns: table => new - { - Id = table.Column(type: "uniqueidentifier", nullable: false), - CreatedById = table.Column(type: "uniqueidentifier", nullable: false), - ModifiedById = table.Column(type: "uniqueidentifier", nullable: false), - CreatedAt = table.Column(type: "datetime2", nullable: false), - IsDeleted = table.Column(type: "bit", nullable: false), - ModifiedAt = table.Column(type: "datetime2", nullable: false), - Name = table.Column(type: "nvarchar(max)", nullable: false), - Number = table.Column(type: "int", nullable: false), - Source = table.Column(type: "nvarchar(max)", nullable: false) - }, - constraints: table => - { - table.PrimaryKey("PK_DataSets", x => x.Id); - table.ForeignKey( - name: "FK_DataSets_Users_CreatedById", - column: x => x.CreatedById, - principalTable: "Users", - principalColumn: "Id", - onDelete: ReferentialAction.NoAction); - table.ForeignKey( - name: "FK_DataSets_Users_ModifiedById", - column: x => x.ModifiedById, - principalTable: "Users", - principalColumn: "Id", - onDelete: ReferentialAction.NoAction); - }); - - migrationBuilder.CreateTable( - name: "DataRows", - columns: table => new - { - Id = table.Column(type: "uniqueidentifier", nullable: false), - CreatedById = table.Column(type: "uniqueidentifier", nullable: false), - ModifiedById = table.Column(type: "uniqueidentifier", nullable: false), - Code = table.Column(type: "nvarchar(max)", nullable: false), - CreatedAt = table.Column(type: "datetime2", nullable: false), - DataSetId = table.Column(type: "uniqueidentifier", nullable: false), - Desc1 = table.Column(type: "nvarchar(max)", nullable: true), - Desc2 = table.Column(type: "nvarchar(max)", nullable: true), - Desc3 = table.Column(type: "nvarchar(max)", nullable: true), - Desc4 = table.Column(type: "nvarchar(max)", nullable: true), - Desc5 = table.Column(type: "nvarchar(max)", nullable: true), - IsDeleted = table.Column(type: "bit", nullable: false), - ModifiedAt = table.Column(type: "datetime2", nullable: false), - Value = table.Column(type: "real", nullable: false) - }, - constraints: table => - { - table.PrimaryKey("PK_DataRows", x => x.Id); - table.ForeignKey( - name: "FK_DataRows_DataSets_DataSetId", - column: x => x.DataSetId, - principalTable: "DataSets", - principalColumn: "Id", - onDelete: ReferentialAction.NoAction); - table.ForeignKey( - name: "FK_DataRows_Users_CreatedById", - column: x => x.CreatedById, - principalTable: "Users", - principalColumn: "Id", - onDelete: ReferentialAction.NoAction); - table.ForeignKey( - name: "FK_DataRows_Users_ModifiedById", - column: x => x.ModifiedById, - principalTable: "Users", - principalColumn: "Id", - onDelete: ReferentialAction.NoAction); - }); - - migrationBuilder.CreateIndex( - name: "IX_DataRows_CreatedById", - table: "DataRows", - column: "CreatedById"); - - migrationBuilder.CreateIndex( - name: "IX_DataRows_DataSetId", - table: "DataRows", - column: "DataSetId"); - - migrationBuilder.CreateIndex( - name: "IX_DataRows_ModifiedById", - table: "DataRows", - column: "ModifiedById"); - - migrationBuilder.CreateIndex( - name: "IX_DataSets_CreatedById", - table: "DataSets", - column: "CreatedById"); - - migrationBuilder.CreateIndex( - name: "IX_DataSets_ModifiedById", - table: "DataSets", - column: "ModifiedById"); - } - } -} +using System; +using Microsoft.EntityFrameworkCore.Migrations; + +#nullable disable + +namespace DiunaBI.Infrastructure.Migrations +{ + /// + public partial class RenameModels : Migration + { + /// + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropTable( + name: "DataRows"); + + migrationBuilder.DropTable( + name: "DataSets"); + + migrationBuilder.CreateTable( + name: "Layers", + columns: table => new + { + Id = table.Column(type: "uniqueidentifier", nullable: false), + Number = table.Column(type: "int", nullable: false), + Source = table.Column(type: "nvarchar(max)", nullable: false), + Name = table.Column(type: "nvarchar(max)", nullable: false), + CreatedAt = table.Column(type: "datetime2", nullable: false), + ModifiedAt = table.Column(type: "datetime2", nullable: false), + IsDeleted = table.Column(type: "bit", nullable: false), + CreatedById = table.Column(type: "uniqueidentifier", nullable: false), + ModifiedById = table.Column(type: "uniqueidentifier", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_Layers", x => x.Id); + table.ForeignKey( + name: "FK_Layers_Users_CreatedById", + column: x => x.CreatedById, + principalTable: "Users", + principalColumn: "Id", + onDelete: ReferentialAction.NoAction); + table.ForeignKey( + name: "FK_Layers_Users_ModifiedById", + column: x => x.ModifiedById, + principalTable: "Users", + principalColumn: "Id", + onDelete: ReferentialAction.NoAction); + }); + + migrationBuilder.CreateTable( + name: "Records", + columns: table => new + { + Id = table.Column(type: "uniqueidentifier", nullable: false), + Code = table.Column(type: "nvarchar(max)", nullable: false), + Value = table.Column(type: "real", nullable: false), + Desc1 = table.Column(type: "nvarchar(max)", nullable: true), + Desc2 = table.Column(type: "nvarchar(max)", nullable: true), + Desc3 = table.Column(type: "nvarchar(max)", nullable: true), + Desc4 = table.Column(type: "nvarchar(max)", nullable: true), + Desc5 = table.Column(type: "nvarchar(max)", nullable: true), + CreatedAt = table.Column(type: "datetime2", nullable: false), + ModifiedAt = table.Column(type: "datetime2", nullable: false), + IsDeleted = table.Column(type: "bit", nullable: false), + CreatedById = table.Column(type: "uniqueidentifier", nullable: false), + ModifiedById = table.Column(type: "uniqueidentifier", nullable: false), + LayerId = table.Column(type: "uniqueidentifier", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_Records", x => x.Id); + table.ForeignKey( + name: "FK_Records_Layers_LayerId", + column: x => x.LayerId, + principalTable: "Layers", + principalColumn: "Id", + onDelete: ReferentialAction.NoAction); + table.ForeignKey( + name: "FK_Records_Users_CreatedById", + column: x => x.CreatedById, + principalTable: "Users", + principalColumn: "Id", + onDelete: ReferentialAction.NoAction); + table.ForeignKey( + name: "FK_Records_Users_ModifiedById", + column: x => x.ModifiedById, + principalTable: "Users", + principalColumn: "Id", + onDelete: ReferentialAction.NoAction); + }); + + migrationBuilder.CreateIndex( + name: "IX_Layers_CreatedById", + table: "Layers", + column: "CreatedById"); + + migrationBuilder.CreateIndex( + name: "IX_Layers_ModifiedById", + table: "Layers", + column: "ModifiedById"); + + migrationBuilder.CreateIndex( + name: "IX_Records_CreatedById", + table: "Records", + column: "CreatedById"); + + migrationBuilder.CreateIndex( + name: "IX_Records_LayerId", + table: "Records", + column: "LayerId"); + + migrationBuilder.CreateIndex( + name: "IX_Records_ModifiedById", + table: "Records", + column: "ModifiedById"); + } + + /// + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropTable( + name: "Records"); + + migrationBuilder.DropTable( + name: "Layers"); + + migrationBuilder.CreateTable( + name: "DataSets", + columns: table => new + { + Id = table.Column(type: "uniqueidentifier", nullable: false), + CreatedById = table.Column(type: "uniqueidentifier", nullable: false), + ModifiedById = table.Column(type: "uniqueidentifier", nullable: false), + CreatedAt = table.Column(type: "datetime2", nullable: false), + IsDeleted = table.Column(type: "bit", nullable: false), + ModifiedAt = table.Column(type: "datetime2", nullable: false), + Name = table.Column(type: "nvarchar(max)", nullable: false), + Number = table.Column(type: "int", nullable: false), + Source = table.Column(type: "nvarchar(max)", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_DataSets", x => x.Id); + table.ForeignKey( + name: "FK_DataSets_Users_CreatedById", + column: x => x.CreatedById, + principalTable: "Users", + principalColumn: "Id", + onDelete: ReferentialAction.NoAction); + table.ForeignKey( + name: "FK_DataSets_Users_ModifiedById", + column: x => x.ModifiedById, + principalTable: "Users", + principalColumn: "Id", + onDelete: ReferentialAction.NoAction); + }); + + migrationBuilder.CreateTable( + name: "DataRows", + columns: table => new + { + Id = table.Column(type: "uniqueidentifier", nullable: false), + CreatedById = table.Column(type: "uniqueidentifier", nullable: false), + ModifiedById = table.Column(type: "uniqueidentifier", nullable: false), + Code = table.Column(type: "nvarchar(max)", nullable: false), + CreatedAt = table.Column(type: "datetime2", nullable: false), + DataSetId = table.Column(type: "uniqueidentifier", nullable: false), + Desc1 = table.Column(type: "nvarchar(max)", nullable: true), + Desc2 = table.Column(type: "nvarchar(max)", nullable: true), + Desc3 = table.Column(type: "nvarchar(max)", nullable: true), + Desc4 = table.Column(type: "nvarchar(max)", nullable: true), + Desc5 = table.Column(type: "nvarchar(max)", nullable: true), + IsDeleted = table.Column(type: "bit", nullable: false), + ModifiedAt = table.Column(type: "datetime2", nullable: false), + Value = table.Column(type: "real", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_DataRows", x => x.Id); + table.ForeignKey( + name: "FK_DataRows_DataSets_DataSetId", + column: x => x.DataSetId, + principalTable: "DataSets", + principalColumn: "Id", + onDelete: ReferentialAction.NoAction); + table.ForeignKey( + name: "FK_DataRows_Users_CreatedById", + column: x => x.CreatedById, + principalTable: "Users", + principalColumn: "Id", + onDelete: ReferentialAction.NoAction); + table.ForeignKey( + name: "FK_DataRows_Users_ModifiedById", + column: x => x.ModifiedById, + principalTable: "Users", + principalColumn: "Id", + onDelete: ReferentialAction.NoAction); + }); + + migrationBuilder.CreateIndex( + name: "IX_DataRows_CreatedById", + table: "DataRows", + column: "CreatedById"); + + migrationBuilder.CreateIndex( + name: "IX_DataRows_DataSetId", + table: "DataRows", + column: "DataSetId"); + + migrationBuilder.CreateIndex( + name: "IX_DataRows_ModifiedById", + table: "DataRows", + column: "ModifiedById"); + + migrationBuilder.CreateIndex( + name: "IX_DataSets_CreatedById", + table: "DataSets", + column: "CreatedById"); + + migrationBuilder.CreateIndex( + name: "IX_DataSets_ModifiedById", + table: "DataSets", + column: "ModifiedById"); + } + } +} diff --git a/src/Backend/DiunaBI.Infrastructure/Services/GoogleDriveHelper.cs b/src/Backend/DiunaBI.Infrastructure/Services/GoogleDriveHelper.cs index a550538..52f098a 100644 --- a/src/Backend/DiunaBI.Infrastructure/Services/GoogleDriveHelper.cs +++ b/src/Backend/DiunaBI.Infrastructure/Services/GoogleDriveHelper.cs @@ -1,38 +1,38 @@ -using Google.Apis.Auth.OAuth2; -using Google.Apis.Drive.v3; -using Google.Apis.Services; - -namespace DiunaBI.Infrastructure.Services; - -public class GoogleDriveHelper -{ - public DriveService? Service { get; private set; } - private const string ApplicationName = "Diuna"; - private static readonly string[] Scopes = [DriveService.Scope.Drive]; - public GoogleDriveHelper() - { - InitializeService(); - } - private void InitializeService() - { - var credential = GetCredentialsFromFile(); - Service = new DriveService(new BaseClientService.Initializer - { - HttpClientInitializer = credential, - ApplicationName = ApplicationName - }); - } - private static GoogleCredential GetCredentialsFromFile() - { -#if DEBUG - using var stream = new FileStream("client_secrets.Development.json", FileMode.Open, FileAccess.Read); - return GoogleCredential.FromStream(stream).CreateScoped(Scopes); -#else - var json = Environment.GetEnvironmentVariable("GOOGLE_SERVICE_ACCOUNT_JSON"); - if (string.IsNullOrWhiteSpace(json)) - throw new InvalidOperationException("GOOGLE_SERVICE_ACCOUNT_JSON environment variable is not set."); - json = json.Replace("\\n", "\n"); - return GoogleCredential.FromJson(json).CreateScoped(Scopes); -#endif - } +using Google.Apis.Auth.OAuth2; +using Google.Apis.Drive.v3; +using Google.Apis.Services; + +namespace DiunaBI.Infrastructure.Services; + +public class GoogleDriveHelper +{ + public DriveService? Service { get; private set; } + private const string ApplicationName = "Diuna"; + private static readonly string[] Scopes = [DriveService.Scope.Drive]; + public GoogleDriveHelper() + { + InitializeService(); + } + private void InitializeService() + { + var credential = GetCredentialsFromFile(); + Service = new DriveService(new BaseClientService.Initializer + { + HttpClientInitializer = credential, + ApplicationName = ApplicationName + }); + } + private static GoogleCredential GetCredentialsFromFile() + { +#if DEBUG + using var stream = new FileStream("client_secrets.Development.json", FileMode.Open, FileAccess.Read); + return GoogleCredential.FromStream(stream).CreateScoped(Scopes); +#else + var json = Environment.GetEnvironmentVariable("GOOGLE_SERVICE_ACCOUNT_JSON"); + if (string.IsNullOrWhiteSpace(json)) + throw new InvalidOperationException("GOOGLE_SERVICE_ACCOUNT_JSON environment variable is not set."); + json = json.Replace("\\n", "\n"); + return GoogleCredential.FromJson(json).CreateScoped(Scopes); +#endif + } } \ No newline at end of file diff --git a/src/Backend/DiunaBI.Infrastructure/Services/GoogleSheetsHelper.cs b/src/Backend/DiunaBI.Infrastructure/Services/GoogleSheetsHelper.cs index 935d5f9..9e28ff6 100644 --- a/src/Backend/DiunaBI.Infrastructure/Services/GoogleSheetsHelper.cs +++ b/src/Backend/DiunaBI.Infrastructure/Services/GoogleSheetsHelper.cs @@ -1,38 +1,38 @@ -using Google.Apis.Auth.OAuth2; -using Google.Apis.Services; -using Google.Apis.Sheets.v4; - -namespace DiunaBI.Infrastructure.Services; - -public class GoogleSheetsHelper -{ - public SheetsService? Service { get; private set; } - private const string ApplicationName = "Diuna"; - private static readonly string[] Scopes = [SheetsService.Scope.Spreadsheets]; - public GoogleSheetsHelper() - { - InitializeService(); - } - private void InitializeService() - { - var credential = GetCredentialsFromFile(); - Service = new SheetsService(new BaseClientService.Initializer - { - HttpClientInitializer = credential, - ApplicationName = ApplicationName - }); - } - private static GoogleCredential GetCredentialsFromFile() - { -#if DEBUG - using var stream = new FileStream("client_secrets.Development.json", FileMode.Open, FileAccess.Read); - return GoogleCredential.FromStream(stream).CreateScoped(Scopes); -#else - var json = Environment.GetEnvironmentVariable("GOOGLE_SERVICE_ACCOUNT_JSON"); - if (string.IsNullOrWhiteSpace(json)) - throw new InvalidOperationException("GOOGLE_SERVICE_ACCOUNT_JSON environment variable is not set."); - json = json.Replace("\\n", "\n"); - return GoogleCredential.FromJson(json).CreateScoped(Scopes); -#endif - } +using Google.Apis.Auth.OAuth2; +using Google.Apis.Services; +using Google.Apis.Sheets.v4; + +namespace DiunaBI.Infrastructure.Services; + +public class GoogleSheetsHelper +{ + public SheetsService? Service { get; private set; } + private const string ApplicationName = "Diuna"; + private static readonly string[] Scopes = [SheetsService.Scope.Spreadsheets]; + public GoogleSheetsHelper() + { + InitializeService(); + } + private void InitializeService() + { + var credential = GetCredentialsFromFile(); + Service = new SheetsService(new BaseClientService.Initializer + { + HttpClientInitializer = credential, + ApplicationName = ApplicationName + }); + } + private static GoogleCredential GetCredentialsFromFile() + { +#if DEBUG + using var stream = new FileStream("client_secrets.Development.json", FileMode.Open, FileAccess.Read); + return GoogleCredential.FromStream(stream).CreateScoped(Scopes); +#else + var json = Environment.GetEnvironmentVariable("GOOGLE_SERVICE_ACCOUNT_JSON"); + if (string.IsNullOrWhiteSpace(json)) + throw new InvalidOperationException("GOOGLE_SERVICE_ACCOUNT_JSON environment variable is not set."); + json = json.Replace("\\n", "\n"); + return GoogleCredential.FromJson(json).CreateScoped(Scopes); +#endif + } } \ No newline at end of file diff --git a/src/Backend/DiunaBI.UI.Shared/DiunaBI.UI.Shared.csproj b/src/Backend/DiunaBI.UI.Shared/DiunaBI.UI.Shared.csproj index 57d31f7..3cda54f 100644 --- a/src/Backend/DiunaBI.UI.Shared/DiunaBI.UI.Shared.csproj +++ b/src/Backend/DiunaBI.UI.Shared/DiunaBI.UI.Shared.csproj @@ -1,30 +1,30 @@ - - - - net8.0 - enable - enable - - - - - - - - - - - - - - - - - - - - - - - - + + + + net8.0 + enable + enable + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/Backend/DiunaBI.UI.Shared/_Imports.razor b/src/Backend/DiunaBI.UI.Shared/_Imports.razor index efa2542..69701a9 100644 --- a/src/Backend/DiunaBI.UI.Shared/_Imports.razor +++ b/src/Backend/DiunaBI.UI.Shared/_Imports.razor @@ -1,12 +1,12 @@ -@using System.Net.Http -@using System.Net.Http.Json -@using Microsoft.AspNetCore.Components.Forms -@using Microsoft.AspNetCore.Components.Routing -@using Microsoft.AspNetCore.Components.Web -@using static Microsoft.AspNetCore.Components.Web.RenderMode -@using Microsoft.AspNetCore.Components.Web.Virtualization -@using Microsoft.JSInterop -@using DiunaBI.UI.Shared -@using DiunaBI.UI.Shared.Components -@using DiunaBI.Application.DTOModels +@using System.Net.Http +@using System.Net.Http.Json +@using Microsoft.AspNetCore.Components.Forms +@using Microsoft.AspNetCore.Components.Routing +@using Microsoft.AspNetCore.Components.Web +@using static Microsoft.AspNetCore.Components.Web.RenderMode +@using Microsoft.AspNetCore.Components.Web.Virtualization +@using Microsoft.JSInterop +@using DiunaBI.UI.Shared +@using DiunaBI.UI.Shared.Components +@using DiunaBI.Application.DTOModels @using MudBlazor \ No newline at end of file diff --git a/src/Backend/DiunaBI.UI.Web/DiunaBI.UI.Web.csproj b/src/Backend/DiunaBI.UI.Web/DiunaBI.UI.Web.csproj index 53465b1..0224edb 100644 --- a/src/Backend/DiunaBI.UI.Web/DiunaBI.UI.Web.csproj +++ b/src/Backend/DiunaBI.UI.Web/DiunaBI.UI.Web.csproj @@ -1,17 +1,17 @@ - - - - net8.0 - enable - enable - - - - - - - - - - - + + + + net8.0 + enable + enable + + + + + + + + + + + diff --git a/src/Backend/DiunaBI.UI.Web/Program.cs b/src/Backend/DiunaBI.UI.Web/Program.cs index 41f0b93..284ca6a 100644 --- a/src/Backend/DiunaBI.UI.Web/Program.cs +++ b/src/Backend/DiunaBI.UI.Web/Program.cs @@ -1,37 +1,37 @@ -using DiunaBI.UI.Shared; -using DiunaBI.UI.Shared.Extensions; -using DiunaBI.UI.Shared.Services; -using DiunaBI.UI.Web.Components; -using MudBlazor.Services; - -var builder = WebApplication.CreateBuilder(args); - -builder.Services.AddRazorComponents() - .AddInteractiveServerComponents(); -builder.Services.AddMudServices(); - -var apiBaseUrl = builder.Configuration["ApiSettings:BaseUrl"] - ?? throw new InvalidOperationException("ApiSettings:BaseUrl is not configured"); -builder.Services.AddSharedServices(apiBaseUrl); - -builder.Services.AddScoped(); - -var app = builder.Build(); - -if (!app.Environment.IsDevelopment()) -{ - app.UseExceptionHandler("/Error", createScopeForErrors: true); - app.UseHsts(); -} - -app.UseHttpsRedirection(); -app.UseStaticFiles(); -app.UseAntiforgery(); - -app.MapGet("/health", () => Results.Ok(new { status = "OK", timestamp = DateTime.UtcNow })); - -app.MapRazorComponents() - .AddInteractiveServerRenderMode() - .AddAdditionalAssemblies(typeof(MainLayout).Assembly); - +using DiunaBI.UI.Shared; +using DiunaBI.UI.Shared.Extensions; +using DiunaBI.UI.Shared.Services; +using DiunaBI.UI.Web.Components; +using MudBlazor.Services; + +var builder = WebApplication.CreateBuilder(args); + +builder.Services.AddRazorComponents() + .AddInteractiveServerComponents(); +builder.Services.AddMudServices(); + +var apiBaseUrl = builder.Configuration["ApiSettings:BaseUrl"] + ?? throw new InvalidOperationException("ApiSettings:BaseUrl is not configured"); +builder.Services.AddSharedServices(apiBaseUrl); + +builder.Services.AddScoped(); + +var app = builder.Build(); + +if (!app.Environment.IsDevelopment()) +{ + app.UseExceptionHandler("/Error", createScopeForErrors: true); + app.UseHsts(); +} + +app.UseHttpsRedirection(); +app.UseStaticFiles(); +app.UseAntiforgery(); + +app.MapGet("/health", () => Results.Ok(new { status = "OK", timestamp = DateTime.UtcNow })); + +app.MapRazorComponents() + .AddInteractiveServerRenderMode() + .AddAdditionalAssemblies(typeof(MainLayout).Assembly); + app.Run(); \ No newline at end of file diff --git a/src/Backend/DiunaBI.UI.Web/Properties/launchSettings.json b/src/Backend/DiunaBI.UI.Web/Properties/launchSettings.json index 2e11377..1cc7277 100644 --- a/src/Backend/DiunaBI.UI.Web/Properties/launchSettings.json +++ b/src/Backend/DiunaBI.UI.Web/Properties/launchSettings.json @@ -1,13 +1,13 @@ -{ - "profiles": { - "dev": { - "commandName": "Project", - "dotnetRunMessages": true, - "launchBrowser": true, - "applicationUrl": "https://localhost:7246;http://localhost:5246", - "environmentVariables": { - "ASPNETCORE_ENVIRONMENT": "Development" - } - } - } +{ + "profiles": { + "dev": { + "commandName": "Project", + "dotnetRunMessages": true, + "launchBrowser": true, + "applicationUrl": "https://localhost:7246;http://localhost:5246", + "environmentVariables": { + "ASPNETCORE_ENVIRONMENT": "Development" + } + } + } } \ No newline at end of file diff --git a/src/Backend/DiunaBI.UI.Web/wwwroot/app.css b/src/Backend/DiunaBI.UI.Web/wwwroot/app.css index 2bd9b78..7ac30e2 100644 --- a/src/Backend/DiunaBI.UI.Web/wwwroot/app.css +++ b/src/Backend/DiunaBI.UI.Web/wwwroot/app.css @@ -1,51 +1,51 @@ -html, body { - font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif; -} - -a, .btn-link { - color: #006bb7; -} - -.btn-primary { - color: #fff; - background-color: #1b6ec2; - border-color: #1861ac; -} - -.btn:focus, .btn:active:focus, .btn-link.nav-link:focus, .form-control:focus, .form-check-input:focus { - box-shadow: 0 0 0 0.1rem white, 0 0 0 0.25rem #258cfb; -} - -.content { - padding-top: 1.1rem; -} - -h1:focus { - outline: none; -} - -.valid.modified:not([type=checkbox]) { - outline: 1px solid #26b050; -} - -.invalid { - outline: 1px solid #e50000; -} - -.validation-message { - color: #e50000; -} - -.blazor-error-boundary { - background: url(data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iNTYiIGhlaWdodD0iNDkiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIgeG1sbnM6eGxpbms9Imh0dHA6Ly93d3cudzMub3JnLzE5OTkveGxpbmsiIG92ZXJmbG93PSJoaWRkZW4iPjxkZWZzPjxjbGlwUGF0aCBpZD0iY2xpcDAiPjxyZWN0IHg9IjIzNSIgeT0iNTEiIHdpZHRoPSI1NiIgaGVpZ2h0PSI0OSIvPjwvY2xpcFBhdGg+PC9kZWZzPjxnIGNsaXAtcGF0aD0idXJsKCNjbGlwMCkiIHRyYW5zZm9ybT0idHJhbnNsYXRlKC0yMzUgLTUxKSI+PHBhdGggZD0iTTI2My41MDYgNTFDMjY0LjcxNyA1MSAyNjUuODEzIDUxLjQ4MzcgMjY2LjYwNiA1Mi4yNjU4TDI2Ny4wNTIgNTIuNzk4NyAyNjcuNTM5IDUzLjYyODMgMjkwLjE4NSA5Mi4xODMxIDI5MC41NDUgOTIuNzk1IDI5MC42NTYgOTIuOTk2QzI5MC44NzcgOTMuNTEzIDI5MSA5NC4wODE1IDI5MSA5NC42NzgyIDI5MSA5Ny4wNjUxIDI4OS4wMzggOTkgMjg2LjYxNyA5OUwyNDAuMzgzIDk5QzIzNy45NjMgOTkgMjM2IDk3LjA2NTEgMjM2IDk0LjY3ODIgMjM2IDk0LjM3OTkgMjM2LjAzMSA5NC4wODg2IDIzNi4wODkgOTMuODA3MkwyMzYuMzM4IDkzLjAxNjIgMjM2Ljg1OCA5Mi4xMzE0IDI1OS40NzMgNTMuNjI5NCAyNTkuOTYxIDUyLjc5ODUgMjYwLjQwNyA1Mi4yNjU4QzI2MS4yIDUxLjQ4MzcgMjYyLjI5NiA1MSAyNjMuNTA2IDUxWk0yNjMuNTg2IDY2LjAxODNDMjYwLjczNyA2Ni4wMTgzIDI1OS4zMTMgNjcuMTI0NSAyNTkuMzEzIDY5LjMzNyAyNTkuMzEzIDY5LjYxMDIgMjU5LjMzMiA2OS44NjA4IDI1OS4zNzEgNzAuMDg4N0wyNjEuNzk1IDg0LjAxNjEgMjY1LjM4IDg0LjAxNjEgMjY3LjgyMSA2OS43NDc1QzI2Ny44NiA2OS43MzA5IDI2Ny44NzkgNjkuNTg3NyAyNjcuODc5IDY5LjMxNzkgMjY3Ljg3OSA2Ny4xMTgyIDI2Ni40NDggNjYuMDE4MyAyNjMuNTg2IDY2LjAxODNaTTI2My41NzYgODYuMDU0N0MyNjEuMDQ5IDg2LjA1NDcgMjU5Ljc4NiA4Ny4zMDA1IDI1OS43ODYgODkuNzkyMSAyNTkuNzg2IDkyLjI4MzcgMjYxLjA0OSA5My41Mjk1IDI2My41NzYgOTMuNTI5NSAyNjYuMTE2IDkzLjUyOTUgMjY3LjM4NyA5Mi4yODM3IDI2Ny4zODcgODkuNzkyMSAyNjcuMzg3IDg3LjMwMDUgMjY2LjExNiA4Ni4wNTQ3IDI2My41NzYgODYuMDU0N1oiIGZpbGw9IiNGRkU1MDAiIGZpbGwtcnVsZT0iZXZlbm9kZCIvPjwvZz48L3N2Zz4=) no-repeat 1rem/1.8rem, #b32121; - padding: 1rem 1rem 1rem 3.7rem; - color: white; -} - - .blazor-error-boundary::after { - content: "An error has occurred." - } - -.darker-border-checkbox.form-check-input { - border-color: #929292; -} +html, body { + font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif; +} + +a, .btn-link { + color: #006bb7; +} + +.btn-primary { + color: #fff; + background-color: #1b6ec2; + border-color: #1861ac; +} + +.btn:focus, .btn:active:focus, .btn-link.nav-link:focus, .form-control:focus, .form-check-input:focus { + box-shadow: 0 0 0 0.1rem white, 0 0 0 0.25rem #258cfb; +} + +.content { + padding-top: 1.1rem; +} + +h1:focus { + outline: none; +} + +.valid.modified:not([type=checkbox]) { + outline: 1px solid #26b050; +} + +.invalid { + outline: 1px solid #e50000; +} + +.validation-message { + color: #e50000; +} + +.blazor-error-boundary { + background: url(data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iNTYiIGhlaWdodD0iNDkiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIgeG1sbnM6eGxpbms9Imh0dHA6Ly93d3cudzMub3JnLzE5OTkveGxpbmsiIG92ZXJmbG93PSJoaWRkZW4iPjxkZWZzPjxjbGlwUGF0aCBpZD0iY2xpcDAiPjxyZWN0IHg9IjIzNSIgeT0iNTEiIHdpZHRoPSI1NiIgaGVpZ2h0PSI0OSIvPjwvY2xpcFBhdGg+PC9kZWZzPjxnIGNsaXAtcGF0aD0idXJsKCNjbGlwMCkiIHRyYW5zZm9ybT0idHJhbnNsYXRlKC0yMzUgLTUxKSI+PHBhdGggZD0iTTI2My41MDYgNTFDMjY0LjcxNyA1MSAyNjUuODEzIDUxLjQ4MzcgMjY2LjYwNiA1Mi4yNjU4TDI2Ny4wNTIgNTIuNzk4NyAyNjcuNTM5IDUzLjYyODMgMjkwLjE4NSA5Mi4xODMxIDI5MC41NDUgOTIuNzk1IDI5MC42NTYgOTIuOTk2QzI5MC44NzcgOTMuNTEzIDI5MSA5NC4wODE1IDI5MSA5NC42NzgyIDI5MSA5Ny4wNjUxIDI4OS4wMzggOTkgMjg2LjYxNyA5OUwyNDAuMzgzIDk5QzIzNy45NjMgOTkgMjM2IDk3LjA2NTEgMjM2IDk0LjY3ODIgMjM2IDk0LjM3OTkgMjM2LjAzMSA5NC4wODg2IDIzNi4wODkgOTMuODA3MkwyMzYuMzM4IDkzLjAxNjIgMjM2Ljg1OCA5Mi4xMzE0IDI1OS40NzMgNTMuNjI5NCAyNTkuOTYxIDUyLjc5ODUgMjYwLjQwNyA1Mi4yNjU4QzI2MS4yIDUxLjQ4MzcgMjYyLjI5NiA1MSAyNjMuNTA2IDUxWk0yNjMuNTg2IDY2LjAxODNDMjYwLjczNyA2Ni4wMTgzIDI1OS4zMTMgNjcuMTI0NSAyNTkuMzEzIDY5LjMzNyAyNTkuMzEzIDY5LjYxMDIgMjU5LjMzMiA2OS44NjA4IDI1OS4zNzEgNzAuMDg4N0wyNjEuNzk1IDg0LjAxNjEgMjY1LjM4IDg0LjAxNjEgMjY3LjgyMSA2OS43NDc1QzI2Ny44NiA2OS43MzA5IDI2Ny44NzkgNjkuNTg3NyAyNjcuODc5IDY5LjMxNzkgMjY3Ljg3OSA2Ny4xMTgyIDI2Ni40NDggNjYuMDE4MyAyNjMuNTg2IDY2LjAxODNaTTI2My41NzYgODYuMDU0N0MyNjEuMDQ5IDg2LjA1NDcgMjU5Ljc4NiA4Ny4zMDA1IDI1OS43ODYgODkuNzkyMSAyNTkuNzg2IDkyLjI4MzcgMjYxLjA0OSA5My41Mjk1IDI2My41NzYgOTMuNTI5NSAyNjYuMTE2IDkzLjUyOTUgMjY3LjM4NyA5Mi4yODM3IDI2Ny4zODcgODkuNzkyMSAyNjcuMzg3IDg3LjMwMDUgMjY2LjExNiA4Ni4wNTQ3IDI2My41NzYgODYuMDU0N1oiIGZpbGw9IiNGRkU1MDAiIGZpbGwtcnVsZT0iZXZlbm9kZCIvPjwvZz48L3N2Zz4=) no-repeat 1rem/1.8rem, #b32121; + padding: 1rem 1rem 1rem 3.7rem; + color: white; +} + + .blazor-error-boundary::after { + content: "An error has occurred." + } + +.darker-border-checkbox.form-check-input { + border-color: #929292; +} diff --git a/tools/http-tests/AutoImport.http b/tools/http-tests/AutoImport.http index 90de1de..7e40991 100644 --- a/tools/http-tests/AutoImport.http +++ b/tools/http-tests/AutoImport.http @@ -1,3 +1,3 @@ ### -GET http://localhost:5400/api/Layers/AutoImport/10763478CB738D4ecb2h76g803478CB738D4e/D3- +GET http://localhost:5400/Layers/AutoImport/10763478CB738D4ecb2h76g803478CB738D4e/K5-