From e625890aa32d76f05f4d7164f03bcdca0fa2d992 Mon Sep 17 00:00:00 2001 From: Thomas Cheyney Date: Fri, 8 Nov 2024 15:38:28 +0000 Subject: [PATCH 1/9] Remove all calls to Migrate --- .../FamilyHubs.Idam.Api/StartupExtensions.cs | 5 +--- .../ApplicationDbContextInitialiser.cs | 23 ------------------- .../ApplicationDbContextInitialiser.cs | 4 +--- .../ApplicationDbContextInitialiser.cs | 6 +---- 4 files changed, 3 insertions(+), 35 deletions(-) diff --git a/src/service/idam-api/src/FamilyHubs.Idam.Api/StartupExtensions.cs b/src/service/idam-api/src/FamilyHubs.Idam.Api/StartupExtensions.cs index 00b5954ef..8d0dda7bf 100644 --- a/src/service/idam-api/src/FamilyHubs.Idam.Api/StartupExtensions.cs +++ b/src/service/idam-api/src/FamilyHubs.Idam.Api/StartupExtensions.cs @@ -162,13 +162,10 @@ private static async Task InitialiseDatabase(this WebApplication webApplication) if (!webApplication.Environment.IsProduction()) { - if (shouldRestDatabaseOnRestart) await dbContext.Database.EnsureDeletedAsync(); - if(dbContext.Database.IsSqlServer()) - await dbContext.Database.MigrateAsync(); - else + if(!dbContext.Database.IsSqlServer()) await dbContext.Database.EnsureCreatedAsync(); } } diff --git a/src/service/notification-api/src/FamilyHubs.Notification.Data/Repository/ApplicationDbContextInitialiser.cs b/src/service/notification-api/src/FamilyHubs.Notification.Data/Repository/ApplicationDbContextInitialiser.cs index 67232cdbf..74a2653c7 100644 --- a/src/service/notification-api/src/FamilyHubs.Notification.Data/Repository/ApplicationDbContextInitialiser.cs +++ b/src/service/notification-api/src/FamilyHubs.Notification.Data/Repository/ApplicationDbContextInitialiser.cs @@ -24,11 +24,7 @@ public async Task InitialiseAsync(bool isProduction, bool shouldRestDatabaseOnRe await _context.Database.EnsureDeletedAsync(); if (_context.Database.IsSqlServer()) - await _context.Database.MigrateAsync(); - else await _context.Database.EnsureCreatedAsync(); - - await SeedAsync(); } } catch (Exception ex) @@ -37,23 +33,4 @@ public async Task InitialiseAsync(bool isProduction, bool shouldRestDatabaseOnRe throw; } } - - public async Task SeedAsync() - { - try - { - await TrySeedAsync(); - } - catch (Exception ex) - { - _logger.LogError(ex, "An error occurred while seeding the database."); - throw; - } - } - - public async Task TrySeedAsync() - { - - await _context.SaveChangesAsync(); - } } diff --git a/src/service/referral-api/src/FamilyHubs.Referral.Data/Repository/ApplicationDbContextInitialiser.cs b/src/service/referral-api/src/FamilyHubs.Referral.Data/Repository/ApplicationDbContextInitialiser.cs index 8634aac83..e7e62025e 100644 --- a/src/service/referral-api/src/FamilyHubs.Referral.Data/Repository/ApplicationDbContextInitialiser.cs +++ b/src/service/referral-api/src/FamilyHubs.Referral.Data/Repository/ApplicationDbContextInitialiser.cs @@ -18,9 +18,7 @@ public async Task InitialiseAsync(bool isProduction, bool shouldRestDatabaseOnRe if (shouldRestDatabaseOnRestart) await _context.Database.EnsureDeletedAsync(); - if (_context.Database.IsSqlServer()) - await _context.Database.MigrateAsync(); - else + if (!_context.Database.IsSqlServer()) await _context.Database.EnsureCreatedAsync(); await SeedAsync(); diff --git a/src/service/service-directory-api/src/FamilyHubs.ServiceDirectory.Data/Repository/ApplicationDbContextInitialiser.cs b/src/service/service-directory-api/src/FamilyHubs.ServiceDirectory.Data/Repository/ApplicationDbContextInitialiser.cs index 51f584bc4..279f19696 100644 --- a/src/service/service-directory-api/src/FamilyHubs.ServiceDirectory.Data/Repository/ApplicationDbContextInitialiser.cs +++ b/src/service/service-directory-api/src/FamilyHubs.ServiceDirectory.Data/Repository/ApplicationDbContextInitialiser.cs @@ -19,11 +19,7 @@ public async Task InitialiseAsync(bool isProduction, bool shouldRestDatabaseOnRe if (shouldRestDatabaseOnRestart) await _context.Database.EnsureDeletedAsync(); - if (_context.Database.IsSqlServer()) - { - await _context.Database.MigrateAsync(); - } - else + if (!_context.Database.IsSqlServer()) { await _context.Database.EnsureCreatedAsync(); await _context.Database.ExecuteSqlRawAsync("UPDATE geometry_columns SET srid = 4326 WHERE f_table_name = 'locations';"); From a402a8c1eaf01d7e8bc9018bd0b5f3ae0baf68a3 Mon Sep 17 00:00:00 2001 From: Thomas Cheyney Date: Fri, 8 Nov 2024 15:52:16 +0000 Subject: [PATCH 2/9] Remove checks for production env --- .../src/FamilyHubs.Idam.Api/Program.cs | 2 +- .../FamilyHubs.Idam.Api/StartupExtensions.cs | 15 +++++-------- .../FamilyHubs.Notification.Api/Program.cs | 2 +- .../StartupExtensions.cs | 13 +++++------ .../ApplicationDbContextInitialiser.cs | 13 +++++------ .../src/FamilyHubs.Referral.Api/Program.cs | 2 +- .../StartupExtensions.cs | 13 ++++------- .../ApplicationDbContextInitialiser.cs | 15 +++++-------- .../Program.cs | 2 +- .../StartupExtensions.cs | 4 ++-- .../ApplicationDbContextInitialiser.cs | 22 ++++++++----------- 11 files changed, 41 insertions(+), 62 deletions(-) diff --git a/src/service/idam-api/src/FamilyHubs.Idam.Api/Program.cs b/src/service/idam-api/src/FamilyHubs.Idam.Api/Program.cs index 8655262c4..511f06beb 100644 --- a/src/service/idam-api/src/FamilyHubs.Idam.Api/Program.cs +++ b/src/service/idam-api/src/FamilyHubs.Idam.Api/Program.cs @@ -23,7 +23,7 @@ public static async Task Main(string[] args) builder.Services.RegisterApplicationComponents(builder.Configuration); - builder.Services.ConfigureServices(builder.Configuration, builder.Environment.IsProduction()); + builder.Services.ConfigureServices(builder.Configuration); var webApplication = builder.Build(); diff --git a/src/service/idam-api/src/FamilyHubs.Idam.Api/StartupExtensions.cs b/src/service/idam-api/src/FamilyHubs.Idam.Api/StartupExtensions.cs index 8d0dda7bf..e7ea8bddb 100644 --- a/src/service/idam-api/src/FamilyHubs.Idam.Api/StartupExtensions.cs +++ b/src/service/idam-api/src/FamilyHubs.Idam.Api/StartupExtensions.cs @@ -110,7 +110,7 @@ private static void RegisterMediator(this IServiceCollection services) services.AddTransient(); } - public static void ConfigureServices(this IServiceCollection services, IConfiguration configuration, bool isProduction) + public static void ConfigureServices(this IServiceCollection services, IConfiguration configuration) { services.AddSingleton(); services.AddApplicationInsightsTelemetry(); @@ -159,14 +159,11 @@ private static async Task InitialiseDatabase(this WebApplication webApplication) // Seed Database var dbContext = scope.ServiceProvider.GetRequiredService(); var shouldRestDatabaseOnRestart = webApplication.Configuration.GetValue("ShouldRestDatabaseOnRestart"); - - if (!webApplication.Environment.IsProduction()) - { - if (shouldRestDatabaseOnRestart) - await dbContext.Database.EnsureDeletedAsync(); - if(!dbContext.Database.IsSqlServer()) - await dbContext.Database.EnsureCreatedAsync(); - } + if (shouldRestDatabaseOnRestart) + await dbContext.Database.EnsureDeletedAsync(); + + if(!dbContext.Database.IsSqlServer()) + await dbContext.Database.EnsureCreatedAsync(); } } diff --git a/src/service/notification-api/src/FamilyHubs.Notification.Api/Program.cs b/src/service/notification-api/src/FamilyHubs.Notification.Api/Program.cs index f7cbffd8d..c30939e71 100644 --- a/src/service/notification-api/src/FamilyHubs.Notification.Api/Program.cs +++ b/src/service/notification-api/src/FamilyHubs.Notification.Api/Program.cs @@ -24,7 +24,7 @@ public static async Task Main(string[] args) builder.Services.RegisterApplicationComponents(builder.Configuration); - builder.Services.ConfigureServices(builder.Configuration, builder.Environment.IsProduction()); + builder.Services.ConfigureServices(builder.Configuration); var webApplication = builder.Build(); diff --git a/src/service/notification-api/src/FamilyHubs.Notification.Api/StartupExtensions.cs b/src/service/notification-api/src/FamilyHubs.Notification.Api/StartupExtensions.cs index a7f9d3869..ea66b08a6 100644 --- a/src/service/notification-api/src/FamilyHubs.Notification.Api/StartupExtensions.cs +++ b/src/service/notification-api/src/FamilyHubs.Notification.Api/StartupExtensions.cs @@ -151,7 +151,7 @@ public static void RegisterMediator(this IServiceCollection services) services.AddTransient(); } - public static void ConfigureServices(this IServiceCollection services, IConfiguration configuration, bool isProduction) + public static void ConfigureServices(this IServiceCollection services, IConfiguration configuration) { services.AddApplicationInsightsTelemetry(); @@ -196,13 +196,10 @@ private static async Task RegisterEndPoints(this WebApplication app) try { - if (!app.Environment.IsProduction()) - { - // Seed Database - var initialiser = scope.ServiceProvider.GetRequiredService(); - var shouldRestDatabaseOnRestart = app.Configuration.GetValue("ShouldRestDatabaseOnRestart"); - await initialiser.InitialiseAsync(app.Environment.IsProduction(), shouldRestDatabaseOnRestart); - } + // Seed Database + var initialiser = scope.ServiceProvider.GetRequiredService(); + var shouldRestDatabaseOnRestart = app.Configuration.GetValue("ShouldRestDatabaseOnRestart"); + await initialiser.InitialiseAsync(shouldRestDatabaseOnRestart); } catch (Exception ex) { diff --git a/src/service/notification-api/src/FamilyHubs.Notification.Data/Repository/ApplicationDbContextInitialiser.cs b/src/service/notification-api/src/FamilyHubs.Notification.Data/Repository/ApplicationDbContextInitialiser.cs index 74a2653c7..b9c6b377d 100644 --- a/src/service/notification-api/src/FamilyHubs.Notification.Data/Repository/ApplicationDbContextInitialiser.cs +++ b/src/service/notification-api/src/FamilyHubs.Notification.Data/Repository/ApplicationDbContextInitialiser.cs @@ -14,18 +14,15 @@ public ApplicationDbContextInitialiser(ILogger _context = context; } - public async Task InitialiseAsync(bool isProduction, bool shouldRestDatabaseOnRestart) + public async Task InitialiseAsync(bool shouldRestDatabaseOnRestart) { try { - if (!isProduction) - { - if (shouldRestDatabaseOnRestart) - await _context.Database.EnsureDeletedAsync(); + if (shouldRestDatabaseOnRestart) + await _context.Database.EnsureDeletedAsync(); - if (_context.Database.IsSqlServer()) - await _context.Database.EnsureCreatedAsync(); - } + if (_context.Database.IsSqlServer()) + await _context.Database.EnsureCreatedAsync(); } catch (Exception ex) { diff --git a/src/service/referral-api/src/FamilyHubs.Referral.Api/Program.cs b/src/service/referral-api/src/FamilyHubs.Referral.Api/Program.cs index 8ca0917eb..e9ca60a25 100644 --- a/src/service/referral-api/src/FamilyHubs.Referral.Api/Program.cs +++ b/src/service/referral-api/src/FamilyHubs.Referral.Api/Program.cs @@ -23,7 +23,7 @@ public static async Task Main(string[] args) builder.Services.RegisterApplicationComponents(builder.Configuration); - builder.Services.ConfigureServices(builder.Configuration, builder.Environment.IsProduction()); + builder.Services.ConfigureServices(builder.Configuration); var webApplication = builder.Build(); diff --git a/src/service/referral-api/src/FamilyHubs.Referral.Api/StartupExtensions.cs b/src/service/referral-api/src/FamilyHubs.Referral.Api/StartupExtensions.cs index 2abd4761c..c8907031a 100644 --- a/src/service/referral-api/src/FamilyHubs.Referral.Api/StartupExtensions.cs +++ b/src/service/referral-api/src/FamilyHubs.Referral.Api/StartupExtensions.cs @@ -170,7 +170,7 @@ public static void RegisterMediator(this IServiceCollection services) services.AddTransient(); } - public static void ConfigureServices(this IServiceCollection services, IConfiguration configuration, bool isProduction) + public static void ConfigureServices(this IServiceCollection services, IConfiguration configuration) { services.AddSingleton(); services.AddApplicationInsightsTelemetry(); @@ -227,14 +227,9 @@ private static async Task RegisterEndPoints(this WebApplication app) try { - if (!app.Environment.IsProduction()) - { - // Seed Database - // Seed Database - var initialiser = scope.ServiceProvider.GetRequiredService(); - var shouldRestDatabaseOnRestart = app.Configuration.GetValue("ShouldRestDatabaseOnRestart"); - await initialiser.InitialiseAsync(app.Environment.IsProduction(), shouldRestDatabaseOnRestart); - } + var initialiser = scope.ServiceProvider.GetRequiredService(); + var shouldRestDatabaseOnRestart = app.Configuration.GetValue("ShouldRestDatabaseOnRestart"); + await initialiser.InitialiseAsync(shouldRestDatabaseOnRestart); } catch (Exception ex) { diff --git a/src/service/referral-api/src/FamilyHubs.Referral.Data/Repository/ApplicationDbContextInitialiser.cs b/src/service/referral-api/src/FamilyHubs.Referral.Data/Repository/ApplicationDbContextInitialiser.cs index e7e62025e..192191297 100644 --- a/src/service/referral-api/src/FamilyHubs.Referral.Data/Repository/ApplicationDbContextInitialiser.cs +++ b/src/service/referral-api/src/FamilyHubs.Referral.Data/Repository/ApplicationDbContextInitialiser.cs @@ -11,18 +11,15 @@ public ApplicationDbContextInitialiser(ApplicationDbContext context) _context = context; } - public async Task InitialiseAsync(bool isProduction, bool shouldRestDatabaseOnRestart) + public async Task InitialiseAsync(bool shouldRestDatabaseOnRestart) { - if (!isProduction) - { - if (shouldRestDatabaseOnRestart) - await _context.Database.EnsureDeletedAsync(); + if (shouldRestDatabaseOnRestart) + await _context.Database.EnsureDeletedAsync(); - if (!_context.Database.IsSqlServer()) - await _context.Database.EnsureCreatedAsync(); + if (!_context.Database.IsSqlServer()) + await _context.Database.EnsureCreatedAsync(); - await SeedAsync(); - } + await SeedAsync(); } private async Task SeedAsync() diff --git a/src/service/service-directory-api/src/FamilyHubs.ServiceDirectory.Api/Program.cs b/src/service/service-directory-api/src/FamilyHubs.ServiceDirectory.Api/Program.cs index d330c31cb..67070a68e 100644 --- a/src/service/service-directory-api/src/FamilyHubs.ServiceDirectory.Api/Program.cs +++ b/src/service/service-directory-api/src/FamilyHubs.ServiceDirectory.Api/Program.cs @@ -21,7 +21,7 @@ public static async Task Main(string[] args) builder.Services.RegisterApplicationComponents(builder.Configuration); - builder.Services.ConfigureServices(builder.Configuration, builder.Environment.IsProduction()); + builder.Services.ConfigureServices(builder.Configuration); var webApplication = builder.Build(); diff --git a/src/service/service-directory-api/src/FamilyHubs.ServiceDirectory.Api/StartupExtensions.cs b/src/service/service-directory-api/src/FamilyHubs.ServiceDirectory.Api/StartupExtensions.cs index ac116c0db..7b147eee2 100644 --- a/src/service/service-directory-api/src/FamilyHubs.ServiceDirectory.Api/StartupExtensions.cs +++ b/src/service/service-directory-api/src/FamilyHubs.ServiceDirectory.Api/StartupExtensions.cs @@ -126,7 +126,7 @@ public static void RegisterMediator(this IServiceCollection services) services.AddTransient(); } - public static void ConfigureServices(this IServiceCollection services, IConfiguration configuration, bool isProduction) + public static void ConfigureServices(this IServiceCollection services, IConfiguration configuration) { services.AddSingleton(); services.AddApplicationInsightsTelemetry(); @@ -189,7 +189,7 @@ private static async Task RegisterEndPoints(this WebApplication webApplication) // Seed Database var initialiser = scope.ServiceProvider.GetRequiredService(); var shouldRestDatabaseOnRestart = webApplication.Configuration.GetValue("ShouldRestDatabaseOnRestart"); - await initialiser.InitialiseAsync(webApplication.Environment.IsProduction(), shouldRestDatabaseOnRestart); + await initialiser.InitialiseAsync(shouldRestDatabaseOnRestart); } catch (Exception ex) { diff --git a/src/service/service-directory-api/src/FamilyHubs.ServiceDirectory.Data/Repository/ApplicationDbContextInitialiser.cs b/src/service/service-directory-api/src/FamilyHubs.ServiceDirectory.Data/Repository/ApplicationDbContextInitialiser.cs index 279f19696..7b952d0be 100644 --- a/src/service/service-directory-api/src/FamilyHubs.ServiceDirectory.Data/Repository/ApplicationDbContextInitialiser.cs +++ b/src/service/service-directory-api/src/FamilyHubs.ServiceDirectory.Data/Repository/ApplicationDbContextInitialiser.cs @@ -11,22 +11,18 @@ public ApplicationDbContextInitialiser(ApplicationDbContext context) _context = context; } - public async Task InitialiseAsync(bool isProduction, bool shouldRestDatabaseOnRestart) + public async Task InitialiseAsync(bool shouldRestDatabaseOnRestart) { - if (!isProduction) - { - - if (shouldRestDatabaseOnRestart) - await _context.Database.EnsureDeletedAsync(); - - if (!_context.Database.IsSqlServer()) - { - await _context.Database.EnsureCreatedAsync(); - await _context.Database.ExecuteSqlRawAsync("UPDATE geometry_columns SET srid = 4326 WHERE f_table_name = 'locations';"); - } + if (shouldRestDatabaseOnRestart) + await _context.Database.EnsureDeletedAsync(); - await SeedAsync(); + if (!_context.Database.IsSqlServer()) + { + await _context.Database.EnsureCreatedAsync(); + await _context.Database.ExecuteSqlRawAsync("UPDATE geometry_columns SET srid = 4326 WHERE f_table_name = 'locations';"); } + + await SeedAsync(); } private async Task SeedAsync() From cf6156aa296b10bf157cedb23c913bdb2d508d76 Mon Sep 17 00:00:00 2001 From: Thomas Cheyney Date: Mon, 11 Nov 2024 09:27:21 +0000 Subject: [PATCH 3/9] Remove reset db on restart flag --- .../idam-api/src/FamilyHubs.Idam.Api/StartupExtensions.cs | 4 ---- .../idam-api/src/FamilyHubs.Idam.Api/appsettings.json | 1 - .../src/FamilyHubs.Notification.Api/StartupExtensions.cs | 3 +-- .../src/FamilyHubs.Notification.Api/appsettings.json | 1 - .../Repository/ApplicationDbContextInitialiser.cs | 5 +---- .../src/FamilyHubs.Referral.Api/StartupExtensions.cs | 3 +-- .../src/FamilyHubs.Referral.Api/appsettings.json | 1 - .../Repository/ApplicationDbContextInitialiser.cs | 5 +---- .../report-api/src/FamilyHubs.Report.Api/appsettings.json | 1 - .../src/FamilyHubs.ServiceDirectory.Api/StartupExtensions.cs | 3 +-- .../Repository/ApplicationDbContextInitialiser.cs | 5 +---- 11 files changed, 6 insertions(+), 26 deletions(-) diff --git a/src/service/idam-api/src/FamilyHubs.Idam.Api/StartupExtensions.cs b/src/service/idam-api/src/FamilyHubs.Idam.Api/StartupExtensions.cs index e7ea8bddb..3915abbe9 100644 --- a/src/service/idam-api/src/FamilyHubs.Idam.Api/StartupExtensions.cs +++ b/src/service/idam-api/src/FamilyHubs.Idam.Api/StartupExtensions.cs @@ -158,10 +158,6 @@ private static async Task InitialiseDatabase(this WebApplication webApplication) // Seed Database var dbContext = scope.ServiceProvider.GetRequiredService(); - var shouldRestDatabaseOnRestart = webApplication.Configuration.GetValue("ShouldRestDatabaseOnRestart"); - - if (shouldRestDatabaseOnRestart) - await dbContext.Database.EnsureDeletedAsync(); if(!dbContext.Database.IsSqlServer()) await dbContext.Database.EnsureCreatedAsync(); diff --git a/src/service/idam-api/src/FamilyHubs.Idam.Api/appsettings.json b/src/service/idam-api/src/FamilyHubs.Idam.Api/appsettings.json index 459aeb0e4..df5c589b3 100644 --- a/src/service/idam-api/src/FamilyHubs.Idam.Api/appsettings.json +++ b/src/service/idam-api/src/FamilyHubs.Idam.Api/appsettings.json @@ -30,7 +30,6 @@ "aeg-sas-key": "", "ServiceDirectoryApiBaseUrl": "https://localhost:7022/", "UseSqlite": false, - "ShouldRestDatabaseOnRestart": false, "LogLevel": "Verbose", "AllowedHosts": "*", "APPINSIGHTS_INSTRUMENTATIONKEY": "", diff --git a/src/service/notification-api/src/FamilyHubs.Notification.Api/StartupExtensions.cs b/src/service/notification-api/src/FamilyHubs.Notification.Api/StartupExtensions.cs index ea66b08a6..78fb7f9c0 100644 --- a/src/service/notification-api/src/FamilyHubs.Notification.Api/StartupExtensions.cs +++ b/src/service/notification-api/src/FamilyHubs.Notification.Api/StartupExtensions.cs @@ -198,8 +198,7 @@ private static async Task RegisterEndPoints(this WebApplication app) { // Seed Database var initialiser = scope.ServiceProvider.GetRequiredService(); - var shouldRestDatabaseOnRestart = app.Configuration.GetValue("ShouldRestDatabaseOnRestart"); - await initialiser.InitialiseAsync(shouldRestDatabaseOnRestart); + await initialiser.InitialiseAsync(); } catch (Exception ex) { diff --git a/src/service/notification-api/src/FamilyHubs.Notification.Api/appsettings.json b/src/service/notification-api/src/FamilyHubs.Notification.Api/appsettings.json index e85f58609..1d5fb62a9 100644 --- a/src/service/notification-api/src/FamilyHubs.Notification.Api/appsettings.json +++ b/src/service/notification-api/src/FamilyHubs.Notification.Api/appsettings.json @@ -4,7 +4,6 @@ "NotificationConnection": "Data Source=(localdb)\\MSSQLLocalDB;Initial Catalog=FamilyHubs.Notify.Database;Integrated Security=True;MultipleActiveResultSets=True;Pooling=False;Connect Timeout=30;" }, "UseSqlite": false, - "ShouldRestDatabaseOnRestart": false, "Crypto": { "DbEncryptionKey": "", "DbEncryptionIVKey": "" diff --git a/src/service/notification-api/src/FamilyHubs.Notification.Data/Repository/ApplicationDbContextInitialiser.cs b/src/service/notification-api/src/FamilyHubs.Notification.Data/Repository/ApplicationDbContextInitialiser.cs index b9c6b377d..66dd30604 100644 --- a/src/service/notification-api/src/FamilyHubs.Notification.Data/Repository/ApplicationDbContextInitialiser.cs +++ b/src/service/notification-api/src/FamilyHubs.Notification.Data/Repository/ApplicationDbContextInitialiser.cs @@ -14,13 +14,10 @@ public ApplicationDbContextInitialiser(ILogger _context = context; } - public async Task InitialiseAsync(bool shouldRestDatabaseOnRestart) + public async Task InitialiseAsync() { try { - if (shouldRestDatabaseOnRestart) - await _context.Database.EnsureDeletedAsync(); - if (_context.Database.IsSqlServer()) await _context.Database.EnsureCreatedAsync(); } diff --git a/src/service/referral-api/src/FamilyHubs.Referral.Api/StartupExtensions.cs b/src/service/referral-api/src/FamilyHubs.Referral.Api/StartupExtensions.cs index c8907031a..b73d6274e 100644 --- a/src/service/referral-api/src/FamilyHubs.Referral.Api/StartupExtensions.cs +++ b/src/service/referral-api/src/FamilyHubs.Referral.Api/StartupExtensions.cs @@ -228,8 +228,7 @@ private static async Task RegisterEndPoints(this WebApplication app) try { var initialiser = scope.ServiceProvider.GetRequiredService(); - var shouldRestDatabaseOnRestart = app.Configuration.GetValue("ShouldRestDatabaseOnRestart"); - await initialiser.InitialiseAsync(shouldRestDatabaseOnRestart); + await initialiser.InitialiseAsync(); } catch (Exception ex) { diff --git a/src/service/referral-api/src/FamilyHubs.Referral.Api/appsettings.json b/src/service/referral-api/src/FamilyHubs.Referral.Api/appsettings.json index dddf34587..fdd89a817 100644 --- a/src/service/referral-api/src/FamilyHubs.Referral.Api/appsettings.json +++ b/src/service/referral-api/src/FamilyHubs.Referral.Api/appsettings.json @@ -4,7 +4,6 @@ "ReferralConnection": "Data Source=(localdb)\\MSSQLLocalDB;Initial Catalog=FamilyHubs.Referral.Database;Integrated Security=True;MultipleActiveResultSets=True;Pooling=False;Connect Timeout=30;" }, "UseSqlite": false, - "ShouldRestDatabaseOnRestart": false, "GovUkOidcConfiguration": { "BearerTokenSigningKey": "" }, diff --git a/src/service/referral-api/src/FamilyHubs.Referral.Data/Repository/ApplicationDbContextInitialiser.cs b/src/service/referral-api/src/FamilyHubs.Referral.Data/Repository/ApplicationDbContextInitialiser.cs index 192191297..2c55754f7 100644 --- a/src/service/referral-api/src/FamilyHubs.Referral.Data/Repository/ApplicationDbContextInitialiser.cs +++ b/src/service/referral-api/src/FamilyHubs.Referral.Data/Repository/ApplicationDbContextInitialiser.cs @@ -11,11 +11,8 @@ public ApplicationDbContextInitialiser(ApplicationDbContext context) _context = context; } - public async Task InitialiseAsync(bool shouldRestDatabaseOnRestart) + public async Task InitialiseAsync() { - if (shouldRestDatabaseOnRestart) - await _context.Database.EnsureDeletedAsync(); - if (!_context.Database.IsSqlServer()) await _context.Database.EnsureCreatedAsync(); diff --git a/src/service/report-api/src/FamilyHubs.Report.Api/appsettings.json b/src/service/report-api/src/FamilyHubs.Report.Api/appsettings.json index 5d13d5c23..9de8a323c 100644 --- a/src/service/report-api/src/FamilyHubs.Report.Api/appsettings.json +++ b/src/service/report-api/src/FamilyHubs.Report.Api/appsettings.json @@ -4,7 +4,6 @@ "ReportConnection": "Data Source=(localdb)\\MSSQLLocalDB;Initial Catalog=s181d01-fh-report-db;Integrated Security=True;MultipleActiveResultSets=True;Pooling=False;Connect Timeout=30;" }, "UseSqlite": false, - "ShouldRestDatabaseOnRestart": false, "GovUkOidcConfiguration": { "BearerTokenSigningKey": "StubPrivateKey123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ" }, diff --git a/src/service/service-directory-api/src/FamilyHubs.ServiceDirectory.Api/StartupExtensions.cs b/src/service/service-directory-api/src/FamilyHubs.ServiceDirectory.Api/StartupExtensions.cs index 7b147eee2..479fc52ae 100644 --- a/src/service/service-directory-api/src/FamilyHubs.ServiceDirectory.Api/StartupExtensions.cs +++ b/src/service/service-directory-api/src/FamilyHubs.ServiceDirectory.Api/StartupExtensions.cs @@ -188,8 +188,7 @@ private static async Task RegisterEndPoints(this WebApplication webApplication) { // Seed Database var initialiser = scope.ServiceProvider.GetRequiredService(); - var shouldRestDatabaseOnRestart = webApplication.Configuration.GetValue("ShouldRestDatabaseOnRestart"); - await initialiser.InitialiseAsync(shouldRestDatabaseOnRestart); + await initialiser.InitialiseAsync(); } catch (Exception ex) { diff --git a/src/service/service-directory-api/src/FamilyHubs.ServiceDirectory.Data/Repository/ApplicationDbContextInitialiser.cs b/src/service/service-directory-api/src/FamilyHubs.ServiceDirectory.Data/Repository/ApplicationDbContextInitialiser.cs index 7b952d0be..689679f17 100644 --- a/src/service/service-directory-api/src/FamilyHubs.ServiceDirectory.Data/Repository/ApplicationDbContextInitialiser.cs +++ b/src/service/service-directory-api/src/FamilyHubs.ServiceDirectory.Data/Repository/ApplicationDbContextInitialiser.cs @@ -11,11 +11,8 @@ public ApplicationDbContextInitialiser(ApplicationDbContext context) _context = context; } - public async Task InitialiseAsync(bool shouldRestDatabaseOnRestart) + public async Task InitialiseAsync() { - if (shouldRestDatabaseOnRestart) - await _context.Database.EnsureDeletedAsync(); - if (!_context.Database.IsSqlServer()) { await _context.Database.EnsureCreatedAsync(); From a986b8f7b5b8ce461d21ae00b6f5186a398836db Mon Sep 17 00:00:00 2001 From: Thomas Cheyney Date: Mon, 11 Nov 2024 09:41:59 +0000 Subject: [PATCH 4/9] Move EnsureCreatedAsync calls to tests --- .../src/FamilyHubs.Idam.Api/Program.cs | 2 +- .../FamilyHubs.Idam.Api/StartupExtensions.cs | 15 +--------- .../CustomWebApplicationFactory.cs | 1 + .../FamilyHubs.Notification.Api/Program.cs | 2 +- .../StartupExtensions.cs | 18 ++--------- .../ApplicationDbContextInitialiser.cs | 30 ------------------- .../CustomWebApplicationFactory.cs | 6 +--- .../ApplicationDbContextInitialiser.cs | 3 -- .../appsettings.json | 1 - .../ApplicationDbContextInitialiser.cs | 6 ---- .../CustomWebApplicationFactory.cs | 2 ++ 11 files changed, 10 insertions(+), 76 deletions(-) delete mode 100644 src/service/notification-api/src/FamilyHubs.Notification.Data/Repository/ApplicationDbContextInitialiser.cs diff --git a/src/service/idam-api/src/FamilyHubs.Idam.Api/Program.cs b/src/service/idam-api/src/FamilyHubs.Idam.Api/Program.cs index 511f06beb..006eb828e 100644 --- a/src/service/idam-api/src/FamilyHubs.Idam.Api/Program.cs +++ b/src/service/idam-api/src/FamilyHubs.Idam.Api/Program.cs @@ -27,7 +27,7 @@ public static async Task Main(string[] args) var webApplication = builder.Build(); - await webApplication.ConfigureWebApplication(); + webApplication.ConfigureWebApplication(); await webApplication.RunAsync(); } diff --git a/src/service/idam-api/src/FamilyHubs.Idam.Api/StartupExtensions.cs b/src/service/idam-api/src/FamilyHubs.Idam.Api/StartupExtensions.cs index 3915abbe9..15367399d 100644 --- a/src/service/idam-api/src/FamilyHubs.Idam.Api/StartupExtensions.cs +++ b/src/service/idam-api/src/FamilyHubs.Idam.Api/StartupExtensions.cs @@ -132,7 +132,7 @@ public static void ConfigureServices(this IServiceCollection services, IConfigur services.AddFamilyHubsHealthChecks(configuration); } - public static async Task ConfigureWebApplication(this WebApplication webApplication) + public static void ConfigureWebApplication(this WebApplication webApplication) { webApplication.UseSerilogRequestLogging(); @@ -148,18 +148,5 @@ public static async Task ConfigureWebApplication(this WebApplication webApplicat webApplication.MapControllers(); webApplication.MapFamilyHubsHealthChecks(typeof(StartupExtensions).Assembly); - - await webApplication.InitialiseDatabase(); - } - - private static async Task InitialiseDatabase(this WebApplication webApplication) - { - using var scope = webApplication.Services.CreateScope(); - - // Seed Database - var dbContext = scope.ServiceProvider.GetRequiredService(); - - if(!dbContext.Database.IsSqlServer()) - await dbContext.Database.EnsureCreatedAsync(); } } diff --git a/src/service/idam-api/tests/FamilyHubs.Idam.Api.FunctionalTests/CustomWebApplicationFactory.cs b/src/service/idam-api/tests/FamilyHubs.Idam.Api.FunctionalTests/CustomWebApplicationFactory.cs index 640ffac03..92cf1eb67 100644 --- a/src/service/idam-api/tests/FamilyHubs.Idam.Api.FunctionalTests/CustomWebApplicationFactory.cs +++ b/src/service/idam-api/tests/FamilyHubs.Idam.Api.FunctionalTests/CustomWebApplicationFactory.cs @@ -45,6 +45,7 @@ public void SetupTestData(bool many = false) { var context = scopedServices.GetRequiredService(); + context.Database.EnsureCreated(); context.Accounts.Add(TestDataProvider.GetTestAccount(many)); context.SaveChanges(); diff --git a/src/service/notification-api/src/FamilyHubs.Notification.Api/Program.cs b/src/service/notification-api/src/FamilyHubs.Notification.Api/Program.cs index c30939e71..caecf7892 100644 --- a/src/service/notification-api/src/FamilyHubs.Notification.Api/Program.cs +++ b/src/service/notification-api/src/FamilyHubs.Notification.Api/Program.cs @@ -28,7 +28,7 @@ public static async Task Main(string[] args) var webApplication = builder.Build(); - await webApplication.ConfigureWebApplication(); + webApplication.ConfigureWebApplication(); await webApplication.RunAsync(); } diff --git a/src/service/notification-api/src/FamilyHubs.Notification.Api/StartupExtensions.cs b/src/service/notification-api/src/FamilyHubs.Notification.Api/StartupExtensions.cs index 78fb7f9c0..3050a0a11 100644 --- a/src/service/notification-api/src/FamilyHubs.Notification.Api/StartupExtensions.cs +++ b/src/service/notification-api/src/FamilyHubs.Notification.Api/StartupExtensions.cs @@ -101,7 +101,6 @@ private static void RegisterAutoMapper(this IServiceCollection services) private static void RegisterAppDbContext(this IServiceCollection services, IConfiguration configuration) { services.AddTransient(); - services.AddTransient(); var connectionString = configuration.GetConnectionString("NotificationConnection"); ArgumentException.ThrowIfNullOrEmpty(connectionString); @@ -167,7 +166,7 @@ public static void ConfigureServices(this IServiceCollection services, IConfigur }); } - public static async Task ConfigureWebApplication(this WebApplication webApplication) + public static void ConfigureWebApplication(this WebApplication webApplication) { webApplication.UseSerilogRequestLogging(); @@ -184,25 +183,14 @@ public static async Task ConfigureWebApplication(this WebApplication webApplicat webApplication.MapFamilyHubsHealthChecks(typeof(StartupExtensions).Assembly); - await RegisterEndPoints(webApplication); + RegisterEndPoints(webApplication); } - private static async Task RegisterEndPoints(this WebApplication app) + private static void RegisterEndPoints(this WebApplication app) { using var scope = app.Services.CreateScope(); var notifyApi = scope.ServiceProvider.GetService(); notifyApi?.RegisterMinimalNotifyEndPoints(app); - - try - { - // Seed Database - var initialiser = scope.ServiceProvider.GetRequiredService(); - await initialiser.InitialiseAsync(); - } - catch (Exception ex) - { - Log.Error(ex, "An error occurred seeding the DB. {exceptionMessage}", ex.Message); - } } } diff --git a/src/service/notification-api/src/FamilyHubs.Notification.Data/Repository/ApplicationDbContextInitialiser.cs b/src/service/notification-api/src/FamilyHubs.Notification.Data/Repository/ApplicationDbContextInitialiser.cs deleted file mode 100644 index 66dd30604..000000000 --- a/src/service/notification-api/src/FamilyHubs.Notification.Data/Repository/ApplicationDbContextInitialiser.cs +++ /dev/null @@ -1,30 +0,0 @@ -using Microsoft.EntityFrameworkCore; -using Microsoft.Extensions.Logging; - -namespace FamilyHubs.Notification.Data.Repository; - -public class ApplicationDbContextInitialiser -{ - private readonly ILogger _logger; - private readonly ApplicationDbContext _context; - - public ApplicationDbContextInitialiser(ILogger logger, ApplicationDbContext context) - { - _logger = logger; - _context = context; - } - - public async Task InitialiseAsync() - { - try - { - if (_context.Database.IsSqlServer()) - await _context.Database.EnsureCreatedAsync(); - } - catch (Exception ex) - { - _logger.LogError(ex, "An error occurred while initialising the database."); - throw; - } - } -} diff --git a/src/service/notification-api/tests/FamilyHubs.Notification.FunctionalTests/CustomWebApplicationFactory.cs b/src/service/notification-api/tests/FamilyHubs.Notification.FunctionalTests/CustomWebApplicationFactory.cs index d3d1f1a1b..fb44667c9 100644 --- a/src/service/notification-api/tests/FamilyHubs.Notification.FunctionalTests/CustomWebApplicationFactory.cs +++ b/src/service/notification-api/tests/FamilyHubs.Notification.FunctionalTests/CustomWebApplicationFactory.cs @@ -73,12 +73,8 @@ public void SetupTestDatabaseAndSeedData() try { -#pragma warning disable S1481 var context = scopedServices.GetRequiredService(); -#pragma warning restore S1481 - - - + context.Database.EnsureCreated(); } catch (Exception ex) { diff --git a/src/service/referral-api/src/FamilyHubs.Referral.Data/Repository/ApplicationDbContextInitialiser.cs b/src/service/referral-api/src/FamilyHubs.Referral.Data/Repository/ApplicationDbContextInitialiser.cs index 2c55754f7..fb2cc93e3 100644 --- a/src/service/referral-api/src/FamilyHubs.Referral.Data/Repository/ApplicationDbContextInitialiser.cs +++ b/src/service/referral-api/src/FamilyHubs.Referral.Data/Repository/ApplicationDbContextInitialiser.cs @@ -13,9 +13,6 @@ public ApplicationDbContextInitialiser(ApplicationDbContext context) public async Task InitialiseAsync() { - if (!_context.Database.IsSqlServer()) - await _context.Database.EnsureCreatedAsync(); - await SeedAsync(); } diff --git a/src/service/service-directory-api/src/FamilyHubs.ServiceDirectory.Api/appsettings.json b/src/service/service-directory-api/src/FamilyHubs.ServiceDirectory.Api/appsettings.json index 42561fbac..d390cc28a 100644 --- a/src/service/service-directory-api/src/FamilyHubs.ServiceDirectory.Api/appsettings.json +++ b/src/service/service-directory-api/src/FamilyHubs.ServiceDirectory.Api/appsettings.json @@ -5,7 +5,6 @@ //"ServiceDirectoryConnection": "Host=localhost:5432;Database=s181d01-fh-servicedirectory;Username=postgres;Password=postgres;Include Error Detail=True" }, "UseSqlite": false, - "ShouldRestDatabaseOnRestart": false, "aeg-sas-key": "", "LogLevel": "Verbose", "AllowedHosts": "*", diff --git a/src/service/service-directory-api/src/FamilyHubs.ServiceDirectory.Data/Repository/ApplicationDbContextInitialiser.cs b/src/service/service-directory-api/src/FamilyHubs.ServiceDirectory.Data/Repository/ApplicationDbContextInitialiser.cs index 689679f17..b30b57c7b 100644 --- a/src/service/service-directory-api/src/FamilyHubs.ServiceDirectory.Data/Repository/ApplicationDbContextInitialiser.cs +++ b/src/service/service-directory-api/src/FamilyHubs.ServiceDirectory.Data/Repository/ApplicationDbContextInitialiser.cs @@ -13,12 +13,6 @@ public ApplicationDbContextInitialiser(ApplicationDbContext context) public async Task InitialiseAsync() { - if (!_context.Database.IsSqlServer()) - { - await _context.Database.EnsureCreatedAsync(); - await _context.Database.ExecuteSqlRawAsync("UPDATE geometry_columns SET srid = 4326 WHERE f_table_name = 'locations';"); - } - await SeedAsync(); } diff --git a/src/service/service-directory-api/tests/FamilyHubs.ServiceDirectory.Api.FunctionalTests/CustomWebApplicationFactory.cs b/src/service/service-directory-api/tests/FamilyHubs.ServiceDirectory.Api.FunctionalTests/CustomWebApplicationFactory.cs index d82ba511a..f3e8a1385 100644 --- a/src/service/service-directory-api/tests/FamilyHubs.ServiceDirectory.Api.FunctionalTests/CustomWebApplicationFactory.cs +++ b/src/service/service-directory-api/tests/FamilyHubs.ServiceDirectory.Api.FunctionalTests/CustomWebApplicationFactory.cs @@ -53,6 +53,8 @@ public void SetupTestDatabaseAndSeedData() { var context = scopedServices.GetRequiredService(); + context.Database.ExecuteSqlRaw("UPDATE geometry_columns SET srid = 4326 WHERE f_table_name = 'locations';"); + var testOrganisations = context.Organisations.Select(o => new { o.Id, o.Name }) .Where(o => o.Name == "Bristol County Council" || o.Name == "Salford City Council") .ToDictionary(arg => arg.Name, arg => arg.Id); From a84cb046dd1d37def0a7ae8d600deb5595e50381 Mon Sep 17 00:00:00 2001 From: Thomas Cheyney Date: Mon, 11 Nov 2024 11:24:09 +0000 Subject: [PATCH 5/9] Move sd api seeding to migration --- .../Program.cs | 2 +- .../StartupExtensions.cs | 18 +- .../20241111100056_SeedData.Designer.cs | 3759 +++++++++++++++++ .../Migrations/20241111100056_SeedData.cs | 132 + .../ApplicationDbContextModelSnapshot.cs | 2 +- .../ApplicationDbContextInitialiser.cs | 29 - .../CustomWebApplicationFactory.cs | 10 +- .../OrganisationSeedData.cs | 13 +- .../DataIntegrationTestBase.cs | 10 +- 9 files changed, 3913 insertions(+), 62 deletions(-) create mode 100644 src/service/service-directory-api/src/FamilyHubs.ServiceDirectory.Data/Migrations/20241111100056_SeedData.Designer.cs create mode 100644 src/service/service-directory-api/src/FamilyHubs.ServiceDirectory.Data/Migrations/20241111100056_SeedData.cs delete mode 100644 src/service/service-directory-api/src/FamilyHubs.ServiceDirectory.Data/Repository/ApplicationDbContextInitialiser.cs rename src/service/service-directory-api/{src/FamilyHubs.ServiceDirectory.Data/Repository => tests/FamilyHubs.ServiceDirectory.Api.FunctionalTests}/OrganisationSeedData.cs (96%) diff --git a/src/service/service-directory-api/src/FamilyHubs.ServiceDirectory.Api/Program.cs b/src/service/service-directory-api/src/FamilyHubs.ServiceDirectory.Api/Program.cs index 67070a68e..5b739fb72 100644 --- a/src/service/service-directory-api/src/FamilyHubs.ServiceDirectory.Api/Program.cs +++ b/src/service/service-directory-api/src/FamilyHubs.ServiceDirectory.Api/Program.cs @@ -25,7 +25,7 @@ public static async Task Main(string[] args) var webApplication = builder.Build(); - await webApplication.ConfigureWebApplication(); + webApplication.ConfigureWebApplication(); await webApplication.RunAsync(); } diff --git a/src/service/service-directory-api/src/FamilyHubs.ServiceDirectory.Api/StartupExtensions.cs b/src/service/service-directory-api/src/FamilyHubs.ServiceDirectory.Api/StartupExtensions.cs index 479fc52ae..4ea51a057 100644 --- a/src/service/service-directory-api/src/FamilyHubs.ServiceDirectory.Api/StartupExtensions.cs +++ b/src/service/service-directory-api/src/FamilyHubs.ServiceDirectory.Api/StartupExtensions.cs @@ -77,7 +77,6 @@ private static void RegisterAutoMapper(this IServiceCollection services) private static void RegisterAppDbContext(this IServiceCollection services, IConfiguration configuration) { services.AddTransient(); - services.AddTransient(); var connectionString = configuration.GetConnectionString("ServiceDirectoryConnection"); ArgumentException.ThrowIfNullOrEmpty(connectionString); @@ -147,7 +146,7 @@ public static void ConfigureServices(this IServiceCollection services, IConfigur services.AddFamilyHubsHealthChecks(configuration); } - public static async Task ConfigureWebApplication(this WebApplication webApplication) + public static void ConfigureWebApplication(this WebApplication webApplication) { webApplication.UseSerilogRequestLogging(); @@ -162,10 +161,10 @@ public static async Task ConfigureWebApplication(this WebApplication webApplicat webApplication.MapControllers(); webApplication.MapFamilyHubsHealthChecks(typeof(StartupExtensions).Assembly); - await RegisterEndPoints(webApplication); + RegisterEndPoints(webApplication); } - private static async Task RegisterEndPoints(this WebApplication webApplication) + private static void RegisterEndPoints(this WebApplication webApplication) { using var scope = webApplication.Services.CreateScope(); @@ -183,16 +182,5 @@ private static async Task RegisterEndPoints(this WebApplication webApplication) var metricsEndPoints = scope.ServiceProvider.GetService(); metricsEndPoints?.RegisterMetricsEndPoints(webApplication); - - try - { - // Seed Database - var initialiser = scope.ServiceProvider.GetRequiredService(); - await initialiser.InitialiseAsync(); - } - catch (Exception ex) - { - Log.Error(ex, "An error occurred seeding the DB. {ExceptionMessage}", ex.Message); - } } } diff --git a/src/service/service-directory-api/src/FamilyHubs.ServiceDirectory.Data/Migrations/20241111100056_SeedData.Designer.cs b/src/service/service-directory-api/src/FamilyHubs.ServiceDirectory.Data/Migrations/20241111100056_SeedData.Designer.cs new file mode 100644 index 000000000..63b60d241 --- /dev/null +++ b/src/service/service-directory-api/src/FamilyHubs.ServiceDirectory.Data/Migrations/20241111100056_SeedData.Designer.cs @@ -0,0 +1,3759 @@ +// +using System; +using FamilyHubs.ServiceDirectory.Data.Repository; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Metadata; +using Microsoft.EntityFrameworkCore.Migrations; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; +using NetTopologySuite.Geometries; + +#nullable disable + +namespace FamilyHubs.ServiceDirectory.Data.Migrations +{ + [DbContext(typeof(ApplicationDbContext))] + [Migration("20241111100056_SeedData")] + partial class SeedData + { + /// + protected override void BuildTargetModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder + .HasAnnotation("ProductVersion", "8.0.8") + .HasAnnotation("Relational:MaxIdentifierLength", 128); + + SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder); + + modelBuilder.Entity("AccessibilityAttribute", b => + { + b.Property("AccessibilityId") + .HasColumnType("uniqueidentifier"); + + b.Property("AttributesId") + .HasColumnType("uniqueidentifier"); + + b.HasKey("AccessibilityId", "AttributesId"); + + b.HasIndex("AttributesId"); + + b.ToTable("AccessibilityAttributes", "dedsmeta"); + }); + + modelBuilder.Entity("AccessibilityMetadata", b => + { + b.Property("AccessibilityId") + .HasColumnType("uniqueidentifier"); + + b.Property("MetadataId") + .HasColumnType("uniqueidentifier"); + + b.HasKey("AccessibilityId", "MetadataId"); + + b.HasIndex("MetadataId"); + + b.ToTable("AccessibilityMetadata", "dedsmeta"); + }); + + modelBuilder.Entity("AddressAttribute", b => + { + b.Property("AddressId") + .HasColumnType("uniqueidentifier"); + + b.Property("AttributesId") + .HasColumnType("uniqueidentifier"); + + b.HasKey("AddressId", "AttributesId"); + + b.HasIndex("AttributesId"); + + b.ToTable("AddressAttributes", "dedsmeta"); + }); + + modelBuilder.Entity("AddressMetadata", b => + { + b.Property("AddressId") + .HasColumnType("uniqueidentifier"); + + b.Property("MetadataId") + .HasColumnType("uniqueidentifier"); + + b.HasKey("AddressId", "MetadataId"); + + b.HasIndex("MetadataId"); + + b.ToTable("AddressMetadata", "dedsmeta"); + }); + + modelBuilder.Entity("AttributeContact", b => + { + b.Property("AttributesId") + .HasColumnType("uniqueidentifier"); + + b.Property("ContactId") + .HasColumnType("uniqueidentifier"); + + b.HasKey("AttributesId", "ContactId"); + + b.HasIndex("ContactId"); + + b.ToTable("ContactAttributes", "dedsmeta"); + }); + + modelBuilder.Entity("AttributeCostOption", b => + { + b.Property("AttributesId") + .HasColumnType("uniqueidentifier"); + + b.Property("CostOptionId") + .HasColumnType("uniqueidentifier"); + + b.HasKey("AttributesId", "CostOptionId"); + + b.HasIndex("CostOptionId"); + + b.ToTable("CostOptionAttributes", "dedsmeta"); + }); + + modelBuilder.Entity("AttributeFunding", b => + { + b.Property("AttributesId") + .HasColumnType("uniqueidentifier"); + + b.Property("FundingId") + .HasColumnType("uniqueidentifier"); + + b.HasKey("AttributesId", "FundingId"); + + b.HasIndex("FundingId"); + + b.ToTable("FundingAttributes", "dedsmeta"); + }); + + modelBuilder.Entity("AttributeLanguage", b => + { + b.Property("AttributesId") + .HasColumnType("uniqueidentifier"); + + b.Property("LanguageId") + .HasColumnType("uniqueidentifier"); + + b.HasKey("AttributesId", "LanguageId"); + + b.HasIndex("LanguageId"); + + b.ToTable("LanguageAttributes", "dedsmeta"); + }); + + modelBuilder.Entity("AttributeLocation", b => + { + b.Property("AttributesId") + .HasColumnType("uniqueidentifier"); + + b.Property("LocationId") + .HasColumnType("uniqueidentifier"); + + b.HasKey("AttributesId", "LocationId"); + + b.HasIndex("LocationId"); + + b.ToTable("LocationAttributes", "dedsmeta"); + }); + + modelBuilder.Entity("AttributeMetaTableDescription", b => + { + b.Property("AttributesId") + .HasColumnType("uniqueidentifier"); + + b.Property("MetaTableDescriptionId") + .HasColumnType("uniqueidentifier"); + + b.HasKey("AttributesId", "MetaTableDescriptionId"); + + b.HasIndex("MetaTableDescriptionId"); + + b.ToTable("MetaTableDescriptionAttributes", "dedsmeta"); + }); + + modelBuilder.Entity("AttributeMetadata", b => + { + b.Property("AttributeId") + .HasColumnType("uniqueidentifier"); + + b.Property("MetadataId") + .HasColumnType("uniqueidentifier"); + + b.HasKey("AttributeId", "MetadataId"); + + b.HasIndex("MetadataId"); + + b.ToTable("AttributeMetadata", "dedsmeta"); + }); + + modelBuilder.Entity("AttributeOrganization", b => + { + b.Property("AttributesId") + .HasColumnType("uniqueidentifier"); + + b.Property("OrganizationId") + .HasColumnType("uniqueidentifier"); + + b.HasKey("AttributesId", "OrganizationId"); + + b.HasIndex("OrganizationId"); + + b.ToTable("OrganizationAttributes", "dedsmeta"); + }); + + modelBuilder.Entity("AttributeOrganizationIdentifier", b => + { + b.Property("AttributesId") + .HasColumnType("uniqueidentifier"); + + b.Property("OrganizationIdentifierId") + .HasColumnType("uniqueidentifier"); + + b.HasKey("AttributesId", "OrganizationIdentifierId"); + + b.HasIndex("OrganizationIdentifierId"); + + b.ToTable("OrganizationIdentifierAttributes", "dedsmeta"); + }); + + modelBuilder.Entity("AttributePhone", b => + { + b.Property("AttributesId") + .HasColumnType("uniqueidentifier"); + + b.Property("PhoneId") + .HasColumnType("uniqueidentifier"); + + b.HasKey("AttributesId", "PhoneId"); + + b.HasIndex("PhoneId"); + + b.ToTable("PhoneAttributes", "dedsmeta"); + }); + + modelBuilder.Entity("AttributeProgram", b => + { + b.Property("AttributesId") + .HasColumnType("uniqueidentifier"); + + b.Property("ProgramId") + .HasColumnType("uniqueidentifier"); + + b.HasKey("AttributesId", "ProgramId"); + + b.HasIndex("ProgramId"); + + b.ToTable("ProgramAttributes", "dedsmeta"); + }); + + modelBuilder.Entity("AttributeRequiredDocument", b => + { + b.Property("AttributesId") + .HasColumnType("uniqueidentifier"); + + b.Property("RequiredDocumentId") + .HasColumnType("uniqueidentifier"); + + b.HasKey("AttributesId", "RequiredDocumentId"); + + b.HasIndex("RequiredDocumentId"); + + b.ToTable("RequiredDocumentAttributes", "dedsmeta"); + }); + + modelBuilder.Entity("AttributeSchedule", b => + { + b.Property("AttributesId") + .HasColumnType("uniqueidentifier"); + + b.Property("ScheduleId") + .HasColumnType("uniqueidentifier"); + + b.HasKey("AttributesId", "ScheduleId"); + + b.HasIndex("ScheduleId"); + + b.ToTable("ScheduleAttributes", "dedsmeta"); + }); + + modelBuilder.Entity("AttributeService", b => + { + b.Property("AttributesId") + .HasColumnType("uniqueidentifier"); + + b.Property("ServiceId") + .HasColumnType("uniqueidentifier"); + + b.HasKey("AttributesId", "ServiceId"); + + b.HasIndex("ServiceId"); + + b.ToTable("ServiceAttributes", "dedsmeta"); + }); + + modelBuilder.Entity("AttributeServiceArea", b => + { + b.Property("AttributesId") + .HasColumnType("uniqueidentifier"); + + b.Property("ServiceAreaId") + .HasColumnType("uniqueidentifier"); + + b.HasKey("AttributesId", "ServiceAreaId"); + + b.HasIndex("ServiceAreaId"); + + b.ToTable("ServiceAreaAttributes", "dedsmeta"); + }); + + modelBuilder.Entity("AttributeServiceAtLocation", b => + { + b.Property("AttributesId") + .HasColumnType("uniqueidentifier"); + + b.Property("ServiceAtLocationId") + .HasColumnType("uniqueidentifier"); + + b.HasKey("AttributesId", "ServiceAtLocationId"); + + b.HasIndex("ServiceAtLocationId"); + + b.ToTable("ServiceAtLocationAttributes", "dedsmeta"); + }); + + modelBuilder.Entity("ContactMetadata", b => + { + b.Property("ContactId") + .HasColumnType("uniqueidentifier"); + + b.Property("MetadataId") + .HasColumnType("uniqueidentifier"); + + b.HasKey("ContactId", "MetadataId"); + + b.HasIndex("MetadataId"); + + b.ToTable("ContactMetadata", "dedsmeta"); + }); + + modelBuilder.Entity("CostOptionMetadata", b => + { + b.Property("CostOptionId") + .HasColumnType("uniqueidentifier"); + + b.Property("MetadataId") + .HasColumnType("uniqueidentifier"); + + b.HasKey("CostOptionId", "MetadataId"); + + b.HasIndex("MetadataId"); + + b.ToTable("CostOptionMetadata", "dedsmeta"); + }); + + modelBuilder.Entity("FamilyHubs.ServiceDirectory.Data.Entities.AccessibilityForDisabilities", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("Accessibility") + .HasMaxLength(255) + .HasColumnType("nvarchar(255)"); + + b.Property("Created") + .HasColumnType("datetime2"); + + b.Property("CreatedBy") + .HasColumnType("bigint"); + + b.Property("LastModified") + .HasColumnType("datetime2"); + + b.Property("LastModifiedBy") + .HasColumnType("bigint"); + + b.Property("LocationId") + .HasColumnType("bigint"); + + b.HasKey("Id"); + + b.HasIndex("LocationId"); + + b.ToTable("AccessibilityForDisabilities"); + }); + + modelBuilder.Entity("FamilyHubs.ServiceDirectory.Data.Entities.Contact", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("Created") + .HasColumnType("datetime2"); + + b.Property("CreatedBy") + .HasColumnType("bigint"); + + b.Property("Email") + .HasColumnType("nvarchar(max)"); + + b.Property("LastModified") + .HasColumnType("datetime2"); + + b.Property("LastModifiedBy") + .HasColumnType("bigint"); + + b.Property("LocationId") + .HasColumnType("bigint"); + + b.Property("Name") + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("ServiceId") + .HasColumnType("bigint"); + + b.Property("Telephone") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("TextPhone") + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("Title") + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("Url") + .HasMaxLength(2083) + .HasColumnType("nvarchar(2083)"); + + b.HasKey("Id"); + + b.HasIndex("LocationId"); + + b.HasIndex("ServiceId") + .HasDatabaseName("IX_Contacts_ServiceId_Id"); + + SqlServerIndexBuilderExtensions.IncludeProperties(b.HasIndex("ServiceId"), new[] { "Id", "Title", "Name", "Telephone", "TextPhone", "Url", "Email" }); + + b.ToTable("Contacts"); + }); + + modelBuilder.Entity("FamilyHubs.ServiceDirectory.Data.Entities.CostOption", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("Amount") + .HasColumnType("decimal(18,2)"); + + b.Property("AmountDescription") + .HasMaxLength(500) + .HasColumnType("nvarchar(500)"); + + b.Property("Created") + .HasColumnType("datetime2"); + + b.Property("CreatedBy") + .HasColumnType("bigint"); + + b.Property("Currency") + .HasMaxLength(3) + .HasColumnType("nvarchar(3)"); + + b.Property("LastModified") + .HasColumnType("datetime2"); + + b.Property("LastModifiedBy") + .HasColumnType("bigint"); + + b.Property("Option") + .HasMaxLength(20) + .HasColumnType("nvarchar(20)"); + + b.Property("ServiceId") + .HasColumnType("bigint"); + + b.Property("ValidFrom") + .HasColumnType("datetime2"); + + b.Property("ValidTo") + .HasColumnType("datetime2"); + + b.HasKey("Id"); + + b.HasIndex("ServiceId"); + + b.ToTable("CostOptions"); + }); + + modelBuilder.Entity("FamilyHubs.ServiceDirectory.Data.Entities.Eligibility", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("Created") + .HasColumnType("datetime2"); + + b.Property("CreatedBy") + .HasColumnType("bigint"); + + b.Property("EligibilityType") + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("LastModified") + .HasColumnType("datetime2"); + + b.Property("LastModifiedBy") + .HasColumnType("bigint"); + + b.Property("MaximumAge") + .HasColumnType("int"); + + b.Property("MinimumAge") + .HasColumnType("int"); + + b.Property("ServiceId") + .HasColumnType("bigint"); + + b.HasKey("Id"); + + b.HasIndex("ServiceId"); + + b.ToTable("Eligibilities"); + }); + + modelBuilder.Entity("FamilyHubs.ServiceDirectory.Data.Entities.Funding", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("Created") + .HasColumnType("datetime2"); + + b.Property("CreatedBy") + .HasColumnType("bigint"); + + b.Property("LastModified") + .HasColumnType("datetime2"); + + b.Property("LastModifiedBy") + .HasColumnType("bigint"); + + b.Property("ServiceId") + .HasColumnType("bigint"); + + b.Property("Source") + .HasMaxLength(255) + .HasColumnType("nvarchar(255)"); + + b.HasKey("Id"); + + b.HasIndex("ServiceId"); + + b.ToTable("Fundings"); + }); + + modelBuilder.Entity("FamilyHubs.ServiceDirectory.Data.Entities.Language", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("Code") + .IsRequired() + .HasMaxLength(3) + .HasColumnType("nvarchar(3)"); + + b.Property("Created") + .HasColumnType("datetime2"); + + b.Property("CreatedBy") + .HasColumnType("bigint"); + + b.Property("LastModified") + .HasColumnType("datetime2"); + + b.Property("LastModifiedBy") + .HasColumnType("bigint"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(100) + .HasColumnType("nvarchar(100)"); + + b.Property("Note") + .HasMaxLength(512) + .HasColumnType("nvarchar(512)"); + + b.Property("ServiceId") + .HasColumnType("bigint"); + + b.HasKey("Id"); + + b.HasIndex("ServiceId"); + + b.ToTable("Languages"); + }); + + modelBuilder.Entity("FamilyHubs.ServiceDirectory.Data.Entities.Location", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("Address1") + .IsRequired() + .HasMaxLength(100) + .HasColumnType("nvarchar(100)"); + + b.Property("Address2") + .HasMaxLength(100) + .HasColumnType("nvarchar(100)"); + + b.Property("AddressType") + .HasMaxLength(10) + .HasColumnType("nvarchar(10)"); + + b.Property("AlternateName") + .HasMaxLength(255) + .HasColumnType("nvarchar(255)"); + + b.Property("Attention") + .HasMaxLength(255) + .HasColumnType("nvarchar(255)"); + + b.Property("City") + .IsRequired() + .HasMaxLength(60) + .HasColumnType("nvarchar(60)"); + + b.Property("Country") + .IsRequired() + .HasMaxLength(60) + .HasColumnType("nvarchar(60)"); + + b.Property("Created") + .HasColumnType("datetime2"); + + b.Property("CreatedBy") + .HasColumnType("bigint"); + + b.Property("Description") + .HasMaxLength(1000) + .HasColumnType("nvarchar(1000)"); + + b.Property("ExternalIdentifier") + .HasMaxLength(500) + .HasColumnType("nvarchar(500)"); + + b.Property("ExternalIdentifierType") + .HasMaxLength(500) + .HasColumnType("nvarchar(500)"); + + b.Property("GeoPoint") + .IsRequired() + .HasColumnType("geography"); + + b.Property("LastModified") + .HasColumnType("datetime2"); + + b.Property("LastModifiedBy") + .HasColumnType("bigint"); + + b.Property("Latitude") + .HasColumnType("float"); + + b.Property("LocationType") + .IsRequired() + .HasMaxLength(8) + .IsUnicode(false) + .HasColumnType("varchar(8)"); + + b.Property("LocationTypeCategory") + .IsRequired() + .HasMaxLength(9) + .IsUnicode(false) + .HasColumnType("varchar(9)"); + + b.Property("Longitude") + .HasColumnType("float"); + + b.Property("Name") + .HasMaxLength(255) + .HasColumnType("nvarchar(255)"); + + b.Property("OrganisationId") + .HasColumnType("bigint"); + + b.Property("PostCode") + .IsRequired() + .HasMaxLength(15) + .HasColumnType("nvarchar(15)"); + + b.Property("Region") + .HasMaxLength(255) + .HasColumnType("nvarchar(255)"); + + b.Property("StateProvince") + .IsRequired() + .HasMaxLength(60) + .HasColumnType("nvarchar(60)"); + + b.Property("Transportation") + .HasMaxLength(500) + .HasColumnType("nvarchar(500)"); + + b.Property("Url") + .HasMaxLength(2083) + .HasColumnType("nvarchar(2083)"); + + b.HasKey("Id"); + + b.HasIndex("OrganisationId"); + + b.ToTable("Locations"); + }); + + modelBuilder.Entity("FamilyHubs.ServiceDirectory.Data.Entities.ManyToMany.ServiceAtLocation", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("Created") + .HasColumnType("datetime2"); + + b.Property("CreatedBy") + .HasColumnType("bigint"); + + b.Property("Description") + .HasColumnType("nvarchar(max)"); + + b.Property("LastModified") + .HasColumnType("datetime2"); + + b.Property("LastModifiedBy") + .HasColumnType("bigint"); + + b.Property("LocationId") + .HasColumnType("bigint"); + + b.Property("ServiceId") + .HasColumnType("bigint"); + + b.HasKey("Id"); + + b.HasIndex("LocationId"); + + b.HasIndex("ServiceId"); + + b.ToTable("ServiceAtLocations", (string)null); + }); + + modelBuilder.Entity("FamilyHubs.ServiceDirectory.Data.Entities.Organisation", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("AdminAreaCode") + .IsRequired() + .HasMaxLength(15) + .HasColumnType("nvarchar(15)"); + + b.Property("AssociatedOrganisationId") + .HasColumnType("bigint"); + + b.Property("Created") + .HasColumnType("datetime2"); + + b.Property("CreatedBy") + .HasColumnType("bigint"); + + b.Property("Description") + .IsRequired() + .HasMaxLength(500) + .HasColumnType("nvarchar(500)"); + + b.Property("LastModified") + .HasColumnType("datetime2"); + + b.Property("LastModifiedBy") + .HasColumnType("bigint"); + + b.Property("Logo") + .HasMaxLength(2083) + .HasColumnType("nvarchar(2083)"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(255) + .HasColumnType("nvarchar(255)"); + + b.Property("OrganisationType") + .IsRequired() + .HasMaxLength(50) + .IsUnicode(false) + .HasColumnType("varchar(50)"); + + b.Property("Uri") + .HasMaxLength(2083) + .HasColumnType("nvarchar(2083)"); + + b.Property("Url") + .HasMaxLength(2083) + .HasColumnType("nvarchar(2083)"); + + b.HasKey("Id"); + + b.ToTable("Organisations"); + }); + + modelBuilder.Entity("FamilyHubs.ServiceDirectory.Data.Entities.Schedule", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("AttendingType") + .HasColumnType("nvarchar(max)"); + + b.Property("ByDay") + .HasMaxLength(34) + .IsUnicode(false) + .HasColumnType("varchar(34)"); + + b.Property("ByMonthDay") + .HasMaxLength(15) + .IsUnicode(false) + .HasColumnType("varchar(15)"); + + b.Property("ByWeekNo") + .HasMaxLength(300) + .IsUnicode(false) + .HasColumnType("varchar(300)"); + + b.Property("ByYearDay") + .HasMaxLength(300) + .IsUnicode(false) + .HasColumnType("varchar(300)"); + + b.Property("ClosesAt") + .HasColumnType("datetime2"); + + b.Property("Count") + .HasColumnType("int"); + + b.Property("Created") + .HasColumnType("datetime2"); + + b.Property("CreatedBy") + .HasColumnType("bigint"); + + b.Property("Description") + .HasColumnType("nvarchar(max)"); + + b.Property("DtStart") + .HasMaxLength(30) + .IsUnicode(false) + .HasColumnType("varchar(30)"); + + b.Property("Freq") + .HasMaxLength(8) + .IsUnicode(false) + .HasColumnType("varchar(8)"); + + b.Property("Interval") + .HasColumnType("int"); + + b.Property("LastModified") + .HasColumnType("datetime2"); + + b.Property("LastModifiedBy") + .HasColumnType("bigint"); + + b.Property("LocationId") + .HasColumnType("bigint"); + + b.Property("Notes") + .HasColumnType("nvarchar(max)"); + + b.Property("OpensAt") + .HasColumnType("datetime2"); + + b.Property("ScheduleLink") + .HasMaxLength(600) + .IsUnicode(false) + .HasColumnType("varchar(600)"); + + b.Property("ServiceAtLocationId") + .HasColumnType("bigint"); + + b.Property("ServiceId") + .HasColumnType("bigint"); + + b.Property("Timezone") + .HasColumnType("int"); + + b.Property("Until") + .HasMaxLength(300) + .IsUnicode(false) + .HasColumnType("varchar(300)"); + + b.Property("ValidFrom") + .HasColumnType("datetime2"); + + b.Property("ValidTo") + .HasColumnType("datetime2"); + + b.Property("WkSt") + .HasMaxLength(300) + .IsUnicode(false) + .HasColumnType("varchar(300)"); + + b.HasKey("Id"); + + b.HasIndex("LocationId"); + + b.HasIndex("ServiceAtLocationId"); + + b.HasIndex("ServiceId"); + + b.ToTable("Schedules"); + }); + + modelBuilder.Entity("FamilyHubs.ServiceDirectory.Data.Entities.Service", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("Accreditations") + .HasColumnType("nvarchar(max)"); + + b.Property("AssuredDate") + .HasColumnType("datetime2"); + + b.Property("CanFamilyChooseDeliveryLocation") + .HasColumnType("bit"); + + b.Property("Created") + .HasColumnType("datetime2"); + + b.Property("CreatedBy") + .HasColumnType("bigint"); + + b.Property("DeliverableType") + .IsRequired() + .HasMaxLength(50) + .IsUnicode(false) + .HasColumnType("varchar(50)"); + + b.Property("Description") + .HasColumnType("nvarchar(max)"); + + b.Property("Fees") + .HasColumnType("nvarchar(max)"); + + b.Property("InterpretationServices") + .HasMaxLength(512) + .HasColumnType("nvarchar(512)"); + + b.Property("LastModified") + .HasColumnType("datetime2"); + + b.Property("LastModifiedBy") + .HasColumnType("bigint"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(255) + .HasColumnType("nvarchar(255)"); + + b.Property("OrganisationId") + .HasColumnType("bigint"); + + b.Property("ServiceType") + .IsRequired() + .HasMaxLength(18) + .IsUnicode(false) + .HasColumnType("varchar(18)"); + + b.Property("Status") + .IsRequired() + .HasMaxLength(50) + .IsUnicode(false) + .HasColumnType("varchar(50)"); + + b.Property("Summary") + .HasMaxLength(400) + .HasColumnType("nvarchar(400)"); + + b.HasKey("Id"); + + b.HasIndex("OrganisationId", "Id") + .HasDatabaseName("IX_Services_OrganisationId_Id"); + + SqlServerIndexBuilderExtensions.IncludeProperties(b.HasIndex("OrganisationId", "Id"), new[] { "ServiceType", "Status" }); + + b.HasIndex("ServiceType", "Id", "OrganisationId", "Status") + .HasDatabaseName("IX_ServiceType_OrganisationId_Status"); + + b.ToTable("Services"); + }); + + modelBuilder.Entity("FamilyHubs.ServiceDirectory.Data.Entities.ServiceArea", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("Created") + .HasColumnType("datetime2"); + + b.Property("CreatedBy") + .HasColumnType("bigint"); + + b.Property("Extent") + .HasMaxLength(255) + .HasColumnType("nvarchar(255)"); + + b.Property("LastModified") + .HasColumnType("datetime2"); + + b.Property("LastModifiedBy") + .HasColumnType("bigint"); + + b.Property("ServiceAreaName") + .HasMaxLength(255) + .HasColumnType("nvarchar(255)"); + + b.Property("ServiceId") + .HasColumnType("bigint"); + + b.Property("Uri") + .HasMaxLength(2083) + .HasColumnType("nvarchar(2083)"); + + b.HasKey("Id"); + + b.HasIndex("ServiceId"); + + b.ToTable("ServiceAreas"); + }); + + modelBuilder.Entity("FamilyHubs.ServiceDirectory.Data.Entities.ServiceDelivery", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("Created") + .HasColumnType("datetime2"); + + b.Property("CreatedBy") + .HasColumnType("bigint"); + + b.Property("LastModified") + .HasColumnType("datetime2"); + + b.Property("LastModifiedBy") + .HasColumnType("bigint"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(50) + .IsUnicode(false) + .HasColumnType("varchar(50)"); + + b.Property("ServiceId") + .HasColumnType("bigint"); + + b.HasKey("Id"); + + b.HasIndex("ServiceId"); + + b.HasIndex("Name", "ServiceId", "Id") + .HasDatabaseName("IX_ServiceDeliveryNonClustered"); + + SqlServerIndexBuilderExtensions.IsClustered(b.HasIndex("Name", "ServiceId", "Id"), false); + + b.ToTable("ServiceDeliveries"); + }); + + modelBuilder.Entity("FamilyHubs.ServiceDirectory.Data.Entities.Taxonomy", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("Created") + .HasColumnType("datetime2"); + + b.Property("CreatedBy") + .HasColumnType("bigint"); + + b.Property("LastModified") + .HasColumnType("datetime2"); + + b.Property("LastModifiedBy") + .HasColumnType("bigint"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(255) + .HasColumnType("nvarchar(255)"); + + b.Property("ParentId") + .HasColumnType("bigint"); + + b.Property("TaxonomyType") + .IsRequired() + .HasMaxLength(50) + .IsUnicode(false) + .HasColumnType("varchar(50)"); + + b.HasKey("Id"); + + b.ToTable("Taxonomies"); + }); + + modelBuilder.Entity("FamilyHubs.ServiceDirectory.Data.Event", b => + { + b.Property("Id") + .HasColumnType("smallint"); + + b.Property("Description") + .HasMaxLength(500) + .HasColumnType("nvarchar(500)"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(100) + .HasColumnType("nvarchar(100)"); + + b.HasKey("Id"); + + b.ToTable("Events", (string)null); + + b.HasData( + new + { + Id = (short)1, + Description = "Describes an initial, unfiltered search by a user.", + Name = "ServiceDirectoryInitialSearch" + }, + new + { + Id = (short)2, + Description = "Describes a filtered search by a user.", + Name = "ServiceDirectorySearchFilter" + }); + }); + + modelBuilder.Entity("FamilyHubs.ServiceDirectory.Data.ServiceSearch", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("CorrelationId") + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("HttpResponseCode") + .HasColumnType("smallint"); + + b.Property("OrganisationId") + .HasColumnType("bigint"); + + b.Property("RequestTimestamp") + .HasColumnType("datetime2"); + + b.Property("ResponseTimestamp") + .HasColumnType("datetime2"); + + b.Property("SearchPostcode") + .IsRequired() + .HasMaxLength(10) + .HasColumnType("nvarchar(10)"); + + b.Property("SearchRadiusMiles") + .HasColumnType("tinyint"); + + b.Property("SearchTriggerEventId") + .HasColumnType("smallint"); + + b.Property("ServiceSearchTypeId") + .HasColumnType("tinyint"); + + b.Property("UserId") + .HasColumnType("bigint"); + + b.HasKey("Id"); + + b.HasIndex("SearchTriggerEventId"); + + b.HasIndex("ServiceSearchTypeId"); + + b.ToTable("ServiceSearches", (string)null); + }); + + modelBuilder.Entity("FamilyHubs.ServiceDirectory.Data.ServiceSearchResult", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("ServiceId") + .HasColumnType("bigint"); + + b.Property("ServiceSearchId") + .HasColumnType("bigint"); + + b.HasKey("Id"); + + b.HasIndex("ServiceId"); + + b.HasIndex("ServiceSearchId"); + + b.ToTable("ServiceSearchResults", (string)null); + }); + + modelBuilder.Entity("FamilyHubs.ServiceDirectory.Data.ServiceType", b => + { + b.Property("Id") + .HasColumnType("tinyint"); + + b.Property("Description") + .HasMaxLength(255) + .HasColumnType("nvarchar(255)"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.HasKey("Id"); + + b.ToTable("ServiceTypes", (string)null); + + b.HasData( + new + { + Id = (byte)2, + Description = "Find", + Name = "FamilyExperience" + }, + new + { + Id = (byte)1, + Description = "Connect", + Name = "InformationSharing" + }); + }); + + modelBuilder.Entity("FamilyHubs.SharedKernel.OpenReferral.Entities.Accessibility", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uniqueidentifier"); + + b.Property("Description") + .HasColumnType("nvarchar(max)") + .HasAnnotation("Relational:JsonPropertyName", "description"); + + b.Property("Details") + .HasColumnType("nvarchar(max)") + .HasAnnotation("Relational:JsonPropertyName", "details"); + + b.Property("LocationId") + .HasColumnType("uniqueidentifier"); + + b.Property("OrId") + .HasColumnType("uniqueidentifier") + .HasAnnotation("Relational:JsonPropertyName", "id"); + + b.Property("Url") + .HasMaxLength(2048) + .HasColumnType("nvarchar(2048)") + .HasAnnotation("Relational:JsonPropertyName", "url"); + + b.HasKey("Id"); + + SqlServerKeyBuilderExtensions.IsClustered(b.HasKey("Id"), false); + + b.HasIndex("LocationId"); + + b.ToTable("Accessibilities", "deds"); + + b.HasAnnotation("Relational:JsonPropertyName", "accessibility"); + }); + + modelBuilder.Entity("FamilyHubs.SharedKernel.OpenReferral.Entities.Address", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uniqueidentifier"); + + b.Property("Address1") + .IsRequired() + .HasMaxLength(255) + .HasColumnType("nvarchar(255)") + .HasAnnotation("Relational:JsonPropertyName", "address_1"); + + b.Property("Address2") + .HasMaxLength(255) + .HasColumnType("nvarchar(255)") + .HasAnnotation("Relational:JsonPropertyName", "address_2"); + + b.Property("AddressType") + .IsRequired() + .HasMaxLength(255) + .HasColumnType("nvarchar(255)") + .HasAnnotation("Relational:JsonPropertyName", "address_type"); + + b.Property("Attention") + .HasMaxLength(255) + .HasColumnType("nvarchar(255)") + .HasAnnotation("Relational:JsonPropertyName", "attention"); + + b.Property("City") + .IsRequired() + .HasMaxLength(255) + .HasColumnType("nvarchar(255)") + .HasAnnotation("Relational:JsonPropertyName", "city"); + + b.Property("Country") + .IsRequired() + .HasMaxLength(255) + .HasColumnType("nvarchar(255)") + .HasAnnotation("Relational:JsonPropertyName", "country"); + + b.Property("LocationId") + .HasColumnType("uniqueidentifier"); + + b.Property("OrId") + .HasColumnType("uniqueidentifier") + .HasAnnotation("Relational:JsonPropertyName", "id"); + + b.Property("PostalCode") + .IsRequired() + .HasMaxLength(255) + .HasColumnType("nvarchar(255)") + .HasAnnotation("Relational:JsonPropertyName", "postal_code"); + + b.Property("Region") + .HasMaxLength(255) + .HasColumnType("nvarchar(255)") + .HasAnnotation("Relational:JsonPropertyName", "region"); + + b.Property("StateProvince") + .IsRequired() + .HasMaxLength(255) + .HasColumnType("nvarchar(255)") + .HasAnnotation("Relational:JsonPropertyName", "state_province"); + + b.HasKey("Id"); + + SqlServerKeyBuilderExtensions.IsClustered(b.HasKey("Id"), false); + + b.HasIndex("LocationId"); + + b.ToTable("Addresses", "deds"); + + b.HasAnnotation("Relational:JsonPropertyName", "addresses"); + }); + + modelBuilder.Entity("FamilyHubs.SharedKernel.OpenReferral.Entities.Attribute", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uniqueidentifier"); + + b.Property("LinkEntity") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("nvarchar(50)") + .HasAnnotation("Relational:JsonPropertyName", "link_entity"); + + b.Property("LinkId") + .HasColumnType("uniqueidentifier") + .HasAnnotation("Relational:JsonPropertyName", "link_id"); + + b.Property("LinkType") + .HasMaxLength(50) + .HasColumnType("nvarchar(50)") + .HasAnnotation("Relational:JsonPropertyName", "link_type"); + + b.Property("OrId") + .HasColumnType("uniqueidentifier") + .HasAnnotation("Relational:JsonPropertyName", "id"); + + b.Property("TaxonomyTermId") + .HasColumnType("uniqueidentifier"); + + b.Property("Value") + .HasMaxLength(50) + .HasColumnType("nvarchar(50)") + .HasAnnotation("Relational:JsonPropertyName", "value"); + + b.HasKey("Id"); + + SqlServerKeyBuilderExtensions.IsClustered(b.HasKey("Id"), false); + + b.HasIndex("TaxonomyTermId") + .IsUnique() + .HasFilter("[TaxonomyTermId] IS NOT NULL"); + + b.ToTable("Attributes", "deds"); + + b.HasAnnotation("Relational:JsonPropertyName", "attributes"); + }); + + modelBuilder.Entity("FamilyHubs.SharedKernel.OpenReferral.Entities.Contact", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uniqueidentifier"); + + b.Property("Department") + .HasMaxLength(255) + .HasColumnType("nvarchar(255)") + .HasAnnotation("Relational:JsonPropertyName", "department"); + + b.Property("Email") + .HasMaxLength(255) + .HasColumnType("nvarchar(255)") + .HasAnnotation("Relational:JsonPropertyName", "email"); + + b.Property("LocationId") + .HasColumnType("uniqueidentifier"); + + b.Property("Name") + .HasMaxLength(255) + .HasColumnType("nvarchar(255)") + .HasAnnotation("Relational:JsonPropertyName", "name"); + + b.Property("OrId") + .HasColumnType("uniqueidentifier") + .HasAnnotation("Relational:JsonPropertyName", "id"); + + b.Property("OrganizationId") + .HasColumnType("uniqueidentifier"); + + b.Property("ServiceAtLocationId") + .HasColumnType("uniqueidentifier"); + + b.Property("ServiceId") + .HasColumnType("uniqueidentifier"); + + b.Property("Title") + .HasMaxLength(255) + .HasColumnType("nvarchar(255)") + .HasAnnotation("Relational:JsonPropertyName", "title"); + + b.HasKey("Id"); + + SqlServerKeyBuilderExtensions.IsClustered(b.HasKey("Id"), false); + + b.HasIndex("LocationId"); + + b.HasIndex("OrganizationId"); + + b.HasIndex("ServiceAtLocationId"); + + b.HasIndex("ServiceId"); + + b.ToTable("Contacts", "deds"); + + b.HasAnnotation("Relational:JsonPropertyName", "contacts"); + }); + + modelBuilder.Entity("FamilyHubs.SharedKernel.OpenReferral.Entities.CostOption", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uniqueidentifier"); + + b.Property("Amount") + .HasPrecision(18, 2) + .HasColumnType("decimal(18,2)") + .HasAnnotation("Relational:JsonPropertyName", "amount"); + + b.Property("AmountDescription") + .HasColumnType("nvarchar(max)") + .HasAnnotation("Relational:JsonPropertyName", "amount_description"); + + b.Property("Currency") + .HasColumnType("nchar(3)") + .HasAnnotation("Relational:JsonPropertyName", "currency"); + + b.Property("Option") + .HasColumnType("nvarchar(max)") + .HasAnnotation("Relational:JsonPropertyName", "option"); + + b.Property("OrId") + .HasColumnType("uniqueidentifier") + .HasAnnotation("Relational:JsonPropertyName", "id"); + + b.Property("ServiceId") + .HasColumnType("uniqueidentifier"); + + b.Property("ValidFrom") + .HasColumnType("date") + .HasAnnotation("Relational:JsonPropertyName", "valid_from"); + + b.Property("ValidTo") + .HasColumnType("date") + .HasAnnotation("Relational:JsonPropertyName", "valid_to"); + + b.HasKey("Id"); + + SqlServerKeyBuilderExtensions.IsClustered(b.HasKey("Id"), false); + + b.HasIndex("ServiceId"); + + b.ToTable("CostOptions", "deds"); + + b.HasAnnotation("Relational:JsonPropertyName", "cost_options"); + }); + + modelBuilder.Entity("FamilyHubs.SharedKernel.OpenReferral.Entities.Funding", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uniqueidentifier"); + + b.Property("OrId") + .HasColumnType("uniqueidentifier") + .HasAnnotation("Relational:JsonPropertyName", "id"); + + b.Property("OrganizationId") + .HasColumnType("uniqueidentifier"); + + b.Property("ServiceId") + .HasColumnType("uniqueidentifier"); + + b.Property("Source") + .HasColumnType("nvarchar(max)") + .HasAnnotation("Relational:JsonPropertyName", "source"); + + b.HasKey("Id"); + + SqlServerKeyBuilderExtensions.IsClustered(b.HasKey("Id"), false); + + b.HasIndex("OrganizationId"); + + b.HasIndex("ServiceId"); + + b.ToTable("Fundings", "deds"); + + b.HasAnnotation("Relational:JsonPropertyName", "funding"); + }); + + modelBuilder.Entity("FamilyHubs.SharedKernel.OpenReferral.Entities.Language", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uniqueidentifier"); + + b.Property("Code") + .HasMaxLength(50) + .HasColumnType("nvarchar(50)") + .HasAnnotation("Relational:JsonPropertyName", "code"); + + b.Property("LocationId") + .HasColumnType("uniqueidentifier"); + + b.Property("Name") + .HasMaxLength(255) + .HasColumnType("nvarchar(255)") + .HasAnnotation("Relational:JsonPropertyName", "name"); + + b.Property("Note") + .HasColumnType("nvarchar(max)") + .HasAnnotation("Relational:JsonPropertyName", "note"); + + b.Property("OrId") + .HasColumnType("uniqueidentifier") + .HasAnnotation("Relational:JsonPropertyName", "id"); + + b.Property("PhoneId") + .HasColumnType("uniqueidentifier"); + + b.Property("ServiceId") + .HasColumnType("uniqueidentifier"); + + b.HasKey("Id"); + + SqlServerKeyBuilderExtensions.IsClustered(b.HasKey("Id"), false); + + b.HasIndex("LocationId"); + + b.HasIndex("PhoneId"); + + b.HasIndex("ServiceId"); + + b.ToTable("Languages", "deds"); + + b.HasAnnotation("Relational:JsonPropertyName", "languages"); + }); + + modelBuilder.Entity("FamilyHubs.SharedKernel.OpenReferral.Entities.Location", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uniqueidentifier"); + + b.Property("AlternateName") + .HasMaxLength(255) + .HasColumnType("nvarchar(255)") + .HasAnnotation("Relational:JsonPropertyName", "alternate_name"); + + b.Property("Description") + .HasColumnType("nvarchar(max)") + .HasAnnotation("Relational:JsonPropertyName", "description"); + + b.Property("ExternalIdentifier") + .HasMaxLength(255) + .HasColumnType("nvarchar(255)") + .HasAnnotation("Relational:JsonPropertyName", "external_identifier"); + + b.Property("ExternalIdentifierType") + .HasMaxLength(255) + .HasColumnType("nvarchar(255)") + .HasAnnotation("Relational:JsonPropertyName", "external_identifier_type"); + + b.Property("Latitude") + .HasPrecision(18, 2) + .HasColumnType("decimal(18,2)") + .HasAnnotation("Relational:JsonPropertyName", "latitude"); + + b.Property("LocationType") + .IsRequired() + .HasMaxLength(2048) + .HasColumnType("nvarchar(2048)") + .HasAnnotation("Relational:JsonPropertyName", "location_type"); + + b.Property("Longitude") + .HasPrecision(18, 2) + .HasColumnType("decimal(18,2)") + .HasAnnotation("Relational:JsonPropertyName", "longitude"); + + b.Property("Name") + .HasMaxLength(255) + .HasColumnType("nvarchar(255)") + .HasAnnotation("Relational:JsonPropertyName", "name"); + + b.Property("OrId") + .HasColumnType("uniqueidentifier") + .HasAnnotation("Relational:JsonPropertyName", "id"); + + b.Property("OrganizationId") + .HasColumnType("uniqueidentifier"); + + b.Property("Transportation") + .HasMaxLength(255) + .HasColumnType("nvarchar(255)") + .HasAnnotation("Relational:JsonPropertyName", "transportation"); + + b.Property("Url") + .HasColumnType("nvarchar(max)") + .HasAnnotation("Relational:JsonPropertyName", "url"); + + b.HasKey("Id"); + + SqlServerKeyBuilderExtensions.IsClustered(b.HasKey("Id"), false); + + b.HasIndex("OrganizationId"); + + b.ToTable("Locations", "deds"); + + b.HasAnnotation("Relational:JsonPropertyName", "location"); + }); + + modelBuilder.Entity("FamilyHubs.SharedKernel.OpenReferral.Entities.MetaTableDescription", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uniqueidentifier"); + + b.Property("CharacterSet") + .HasMaxLength(50) + .HasColumnType("nvarchar(50)") + .HasAnnotation("Relational:JsonPropertyName", "character_set"); + + b.Property("Language") + .HasMaxLength(50) + .HasColumnType("nvarchar(50)") + .HasAnnotation("Relational:JsonPropertyName", "language"); + + b.Property("Name") + .HasMaxLength(255) + .HasColumnType("nvarchar(255)") + .HasAnnotation("Relational:JsonPropertyName", "name"); + + b.Property("OrId") + .HasColumnType("uniqueidentifier") + .HasAnnotation("Relational:JsonPropertyName", "id"); + + b.HasKey("Id"); + + SqlServerKeyBuilderExtensions.IsClustered(b.HasKey("Id"), false); + + b.ToTable("MetaTableDescriptions", "deds"); + }); + + modelBuilder.Entity("FamilyHubs.SharedKernel.OpenReferral.Entities.Metadata", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uniqueidentifier"); + + b.Property("FieldName") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("nvarchar(50)") + .HasAnnotation("Relational:JsonPropertyName", "field_name"); + + b.Property("LastActionDate") + .HasColumnType("date") + .HasAnnotation("Relational:JsonPropertyName", "last_action_date"); + + b.Property("LastActionType") + .IsRequired() + .HasMaxLength(255) + .HasColumnType("nvarchar(255)") + .HasAnnotation("Relational:JsonPropertyName", "last_action_type"); + + b.Property("OrId") + .HasColumnType("uniqueidentifier") + .HasAnnotation("Relational:JsonPropertyName", "id"); + + b.Property("PreviousValue") + .IsRequired() + .HasColumnType("nvarchar(max)") + .HasAnnotation("Relational:JsonPropertyName", "previous_value"); + + b.Property("ReplacementValue") + .IsRequired() + .HasColumnType("nvarchar(max)") + .HasAnnotation("Relational:JsonPropertyName", "replacement_value"); + + b.Property("ResourceId") + .HasColumnType("uniqueidentifier") + .HasAnnotation("Relational:JsonPropertyName", "resource_id"); + + b.Property("ResourceType") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("nvarchar(50)") + .HasAnnotation("Relational:JsonPropertyName", "resource_type"); + + b.Property("UpdatedBy") + .IsRequired() + .HasMaxLength(255) + .HasColumnType("nvarchar(255)") + .HasAnnotation("Relational:JsonPropertyName", "updated_by"); + + b.HasKey("Id"); + + SqlServerKeyBuilderExtensions.IsClustered(b.HasKey("Id"), false); + + b.ToTable("Metadata", "deds"); + + b.HasAnnotation("Relational:JsonPropertyName", "metadata"); + }); + + modelBuilder.Entity("FamilyHubs.SharedKernel.OpenReferral.Entities.Organization", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uniqueidentifier"); + + b.Property("AlternateName") + .HasMaxLength(255) + .HasColumnType("nvarchar(255)") + .HasAnnotation("Relational:JsonPropertyName", "alternate_name"); + + b.Property("Description") + .IsRequired() + .HasColumnType("nvarchar(max)") + .HasAnnotation("Relational:JsonPropertyName", "description"); + + b.Property("Email") + .HasMaxLength(255) + .HasColumnType("nvarchar(255)") + .HasAnnotation("Relational:JsonPropertyName", "email"); + + b.Property("LegalStatus") + .IsRequired() + .HasMaxLength(255) + .HasColumnType("nvarchar(255)") + .HasAnnotation("Relational:JsonPropertyName", "legal_status"); + + b.Property("Logo") + .HasMaxLength(2048) + .HasColumnType("nvarchar(2048)") + .HasAnnotation("Relational:JsonPropertyName", "logo"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(255) + .HasColumnType("nvarchar(255)") + .HasAnnotation("Relational:JsonPropertyName", "name"); + + b.Property("OrId") + .HasColumnType("uniqueidentifier") + .HasAnnotation("Relational:JsonPropertyName", "id"); + + b.Property("ParentOrganizationId") + .HasColumnType("uniqueidentifier") + .HasAnnotation("Relational:JsonPropertyName", "parent_organization_id"); + + b.Property("Uri") + .HasMaxLength(2048) + .HasColumnType("nvarchar(2048)") + .HasAnnotation("Relational:JsonPropertyName", "uri"); + + b.Property("Website") + .HasMaxLength(2048) + .HasColumnType("nvarchar(2048)") + .HasAnnotation("Relational:JsonPropertyName", "website"); + + b.Property("YearIncorporated") + .HasColumnType("smallint") + .HasAnnotation("Relational:JsonPropertyName", "year_incorporated"); + + b.HasKey("Id"); + + SqlServerKeyBuilderExtensions.IsClustered(b.HasKey("Id"), false); + + b.ToTable("Organizations", "deds"); + + b.HasAnnotation("Relational:JsonPropertyName", "organization"); + }); + + modelBuilder.Entity("FamilyHubs.SharedKernel.OpenReferral.Entities.OrganizationIdentifier", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uniqueidentifier"); + + b.Property("Identifier") + .HasMaxLength(255) + .HasColumnType("nvarchar(255)") + .HasAnnotation("Relational:JsonPropertyName", "identifier"); + + b.Property("IdentifierScheme") + .HasMaxLength(50) + .HasColumnType("nvarchar(50)") + .HasAnnotation("Relational:JsonPropertyName", "identifier_scheme"); + + b.Property("IdentifierType") + .HasMaxLength(50) + .HasColumnType("nvarchar(50)") + .HasAnnotation("Relational:JsonPropertyName", "identifier_type"); + + b.Property("OrId") + .HasColumnType("uniqueidentifier") + .HasAnnotation("Relational:JsonPropertyName", "id"); + + b.Property("OrganizationId") + .HasColumnType("uniqueidentifier"); + + b.HasKey("Id"); + + SqlServerKeyBuilderExtensions.IsClustered(b.HasKey("Id"), false); + + b.HasIndex("OrganizationId"); + + b.ToTable("OrganizationIdentifiers", "deds"); + + b.HasAnnotation("Relational:JsonPropertyName", "organization_identifiers"); + }); + + modelBuilder.Entity("FamilyHubs.SharedKernel.OpenReferral.Entities.Phone", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uniqueidentifier"); + + b.Property("ContactId") + .HasColumnType("uniqueidentifier"); + + b.Property("Description") + .HasColumnType("nvarchar(max)") + .HasAnnotation("Relational:JsonPropertyName", "description"); + + b.Property("Extension") + .HasColumnType("smallint") + .HasAnnotation("Relational:JsonPropertyName", "extension"); + + b.Property("LocationId") + .HasColumnType("uniqueidentifier"); + + b.Property("Number") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("nvarchar(50)") + .HasAnnotation("Relational:JsonPropertyName", "number"); + + b.Property("OrId") + .HasColumnType("uniqueidentifier") + .HasAnnotation("Relational:JsonPropertyName", "id"); + + b.Property("OrganizationId") + .HasColumnType("uniqueidentifier"); + + b.Property("ServiceAtLocationId") + .HasColumnType("uniqueidentifier"); + + b.Property("ServiceId") + .HasColumnType("uniqueidentifier"); + + b.Property("Type") + .HasMaxLength(50) + .HasColumnType("nvarchar(50)") + .HasAnnotation("Relational:JsonPropertyName", "type"); + + b.HasKey("Id"); + + SqlServerKeyBuilderExtensions.IsClustered(b.HasKey("Id"), false); + + b.HasIndex("ContactId"); + + b.HasIndex("LocationId"); + + b.HasIndex("OrganizationId"); + + b.HasIndex("ServiceAtLocationId"); + + b.HasIndex("ServiceId"); + + b.ToTable("Phones", "deds"); + + b.HasAnnotation("Relational:JsonPropertyName", "phones"); + }); + + modelBuilder.Entity("FamilyHubs.SharedKernel.OpenReferral.Entities.Program", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uniqueidentifier"); + + b.Property("AlternateName") + .HasMaxLength(255) + .HasColumnType("nvarchar(255)") + .HasAnnotation("Relational:JsonPropertyName", "alternate_name"); + + b.Property("Description") + .HasColumnType("nvarchar(max)") + .HasAnnotation("Relational:JsonPropertyName", "description"); + + b.Property("Name") + .HasMaxLength(255) + .HasColumnType("nvarchar(255)") + .HasAnnotation("Relational:JsonPropertyName", "name"); + + b.Property("OrId") + .HasColumnType("uniqueidentifier") + .HasAnnotation("Relational:JsonPropertyName", "id"); + + b.Property("OrganizationId") + .HasColumnType("uniqueidentifier"); + + b.HasKey("Id"); + + SqlServerKeyBuilderExtensions.IsClustered(b.HasKey("Id"), false); + + b.HasIndex("OrganizationId"); + + b.ToTable("Programs", "deds"); + + b.HasAnnotation("Relational:JsonPropertyName", "program"); + }); + + modelBuilder.Entity("FamilyHubs.SharedKernel.OpenReferral.Entities.RequiredDocument", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uniqueidentifier"); + + b.Property("Document") + .HasColumnType("nvarchar(max)") + .HasAnnotation("Relational:JsonPropertyName", "document"); + + b.Property("OrId") + .HasColumnType("uniqueidentifier") + .HasAnnotation("Relational:JsonPropertyName", "id"); + + b.Property("ServiceId") + .HasColumnType("uniqueidentifier"); + + b.Property("Uri") + .HasMaxLength(2048) + .HasColumnType("nvarchar(2048)") + .HasAnnotation("Relational:JsonPropertyName", "uri"); + + b.HasKey("Id"); + + SqlServerKeyBuilderExtensions.IsClustered(b.HasKey("Id"), false); + + b.HasIndex("ServiceId"); + + b.ToTable("RequiredDocuments", "deds"); + + b.HasAnnotation("Relational:JsonPropertyName", "required_documents"); + }); + + modelBuilder.Entity("FamilyHubs.SharedKernel.OpenReferral.Entities.Schedule", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uniqueidentifier"); + + b.Property("AttendingType") + .HasColumnType("nvarchar(max)") + .HasAnnotation("Relational:JsonPropertyName", "attending_type"); + + b.Property("ByDay") + .HasMaxLength(255) + .HasColumnType("nvarchar(255)") + .HasAnnotation("Relational:JsonPropertyName", "byday"); + + b.Property("ByMonthDay") + .HasMaxLength(255) + .HasColumnType("nvarchar(255)") + .HasAnnotation("Relational:JsonPropertyName", "bymonthday"); + + b.Property("ByWeekNo") + .HasMaxLength(255) + .HasColumnType("nvarchar(255)") + .HasAnnotation("Relational:JsonPropertyName", "byweekno"); + + b.Property("ByYearDay") + .HasMaxLength(255) + .HasColumnType("nvarchar(255)") + .HasAnnotation("Relational:JsonPropertyName", "byyearday"); + + b.Property("ClosesAt") + .HasColumnType("time") + .HasAnnotation("Relational:JsonPropertyName", "closes_at"); + + b.Property("Count") + .HasColumnType("smallint") + .HasAnnotation("Relational:JsonPropertyName", "count"); + + b.Property("Description") + .HasColumnType("nvarchar(max)") + .HasAnnotation("Relational:JsonPropertyName", "description"); + + b.Property("DtStart") + .HasMaxLength(50) + .HasColumnType("datetime2") + .HasAnnotation("Relational:JsonPropertyName", "dtstart"); + + b.Property("Freq") + .HasMaxLength(50) + .HasColumnType("nvarchar(50)") + .HasAnnotation("Relational:JsonPropertyName", "freq"); + + b.Property("Interval") + .HasColumnType("smallint") + .HasAnnotation("Relational:JsonPropertyName", "interval"); + + b.Property("LocationId") + .HasColumnType("uniqueidentifier"); + + b.Property("Notes") + .HasColumnType("nvarchar(max)") + .HasAnnotation("Relational:JsonPropertyName", "notes"); + + b.Property("OpensAt") + .HasColumnType("time") + .HasAnnotation("Relational:JsonPropertyName", "opens_at"); + + b.Property("OrId") + .HasColumnType("uniqueidentifier") + .HasAnnotation("Relational:JsonPropertyName", "id"); + + b.Property("ScheduleLink") + .HasMaxLength(2048) + .HasColumnType("nvarchar(2048)") + .HasAnnotation("Relational:JsonPropertyName", "schedule_link"); + + b.Property("ServiceAtLocationId") + .HasColumnType("uniqueidentifier"); + + b.Property("ServiceId") + .HasColumnType("uniqueidentifier"); + + b.Property("Timezone") + .HasColumnType("tinyint") + .HasAnnotation("Relational:JsonPropertyName", "timezone"); + + b.Property("Until") + .HasMaxLength(50) + .HasColumnType("datetime2") + .HasAnnotation("Relational:JsonPropertyName", "until"); + + b.Property("ValidFrom") + .HasColumnType("date") + .HasAnnotation("Relational:JsonPropertyName", "valid_from"); + + b.Property("ValidTo") + .HasColumnType("date") + .HasAnnotation("Relational:JsonPropertyName", "valid_to"); + + b.Property("Wkst") + .HasMaxLength(50) + .HasColumnType("nvarchar(50)") + .HasAnnotation("Relational:JsonPropertyName", "wkst"); + + b.HasKey("Id"); + + SqlServerKeyBuilderExtensions.IsClustered(b.HasKey("Id"), false); + + b.HasIndex("LocationId"); + + b.HasIndex("ServiceAtLocationId"); + + b.HasIndex("ServiceId"); + + b.ToTable("Schedules", "deds"); + + b.HasAnnotation("Relational:JsonPropertyName", "schedules"); + }); + + modelBuilder.Entity("FamilyHubs.SharedKernel.OpenReferral.Entities.Service", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uniqueidentifier"); + + b.Property("Accreditations") + .HasColumnType("nvarchar(max)") + .HasAnnotation("Relational:JsonPropertyName", "accreditations"); + + b.Property("Alert") + .HasMaxLength(255) + .HasColumnType("nvarchar(255)") + .HasAnnotation("Relational:JsonPropertyName", "alert"); + + b.Property("AlternateName") + .HasMaxLength(255) + .HasColumnType("nvarchar(255)") + .HasAnnotation("Relational:JsonPropertyName", "alternate_name"); + + b.Property("ApplicationProcess") + .HasMaxLength(512) + .HasColumnType("nvarchar(512)") + .HasAnnotation("Relational:JsonPropertyName", "application_process"); + + b.Property("AssuredDate") + .HasColumnType("date") + .HasAnnotation("Relational:JsonPropertyName", "assured_date"); + + b.Property("AssurerEmail") + .HasMaxLength(255) + .HasColumnType("nvarchar(255)") + .HasAnnotation("Relational:JsonPropertyName", "assurer_email"); + + b.Property("Description") + .HasColumnType("nvarchar(max)") + .HasAnnotation("Relational:JsonPropertyName", "description"); + + b.Property("EligibilityDescription") + .HasColumnType("nvarchar(max)") + .HasAnnotation("Relational:JsonPropertyName", "eligibility_description"); + + b.Property("Email") + .HasMaxLength(255) + .HasColumnType("nvarchar(255)") + .HasAnnotation("Relational:JsonPropertyName", "email"); + + b.Property("FeesDescription") + .HasColumnType("nvarchar(max)") + .HasAnnotation("Relational:JsonPropertyName", "fees_description"); + + b.Property("InterpretationServices") + .HasMaxLength(512) + .HasColumnType("nvarchar(512)") + .HasAnnotation("Relational:JsonPropertyName", "interpretation_services"); + + b.Property("LastModified") + .HasPrecision(7) + .HasColumnType("datetime2(7)") + .HasAnnotation("Relational:JsonPropertyName", "last_modified"); + + b.Property("MaximumAge") + .HasColumnType("tinyint") + .HasAnnotation("Relational:JsonPropertyName", "maximum_age"); + + b.Property("MinimumAge") + .HasColumnType("tinyint") + .HasAnnotation("Relational:JsonPropertyName", "minimum_age"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(255) + .HasColumnType("nvarchar(255)") + .HasAnnotation("Relational:JsonPropertyName", "name"); + + b.Property("OrId") + .HasColumnType("uniqueidentifier") + .HasAnnotation("Relational:JsonPropertyName", "id"); + + b.Property("OrganizationId") + .HasColumnType("uniqueidentifier"); + + b.Property("ProgramId") + .HasColumnType("uniqueidentifier"); + + b.Property("Status") + .IsRequired() + .HasMaxLength(255) + .HasColumnType("nvarchar(255)") + .HasAnnotation("Relational:JsonPropertyName", "status"); + + b.Property("Url") + .HasMaxLength(2048) + .HasColumnType("nvarchar(2048)") + .HasAnnotation("Relational:JsonPropertyName", "url"); + + b.HasKey("Id"); + + SqlServerKeyBuilderExtensions.IsClustered(b.HasKey("Id"), false); + + b.HasIndex("OrganizationId"); + + b.HasIndex("ProgramId"); + + b.ToTable("Services", "deds"); + }); + + modelBuilder.Entity("FamilyHubs.SharedKernel.OpenReferral.Entities.ServiceArea", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uniqueidentifier"); + + b.Property("Description") + .HasColumnType("nvarchar(max)") + .HasAnnotation("Relational:JsonPropertyName", "description"); + + b.Property("Extent") + .HasMaxLength(255) + .HasColumnType("nvarchar(255)") + .HasAnnotation("Relational:JsonPropertyName", "extent"); + + b.Property("ExtentType") + .HasMaxLength(255) + .HasColumnType("nvarchar(255)") + .HasAnnotation("Relational:JsonPropertyName", "extent_type"); + + b.Property("Name") + .HasMaxLength(255) + .HasColumnType("nvarchar(255)") + .HasAnnotation("Relational:JsonPropertyName", "name"); + + b.Property("OrId") + .HasColumnType("uniqueidentifier") + .HasAnnotation("Relational:JsonPropertyName", "id"); + + b.Property("ServiceId") + .HasColumnType("uniqueidentifier"); + + b.Property("Uri") + .HasMaxLength(2048) + .HasColumnType("nvarchar(2048)") + .HasAnnotation("Relational:JsonPropertyName", "uri"); + + b.HasKey("Id"); + + SqlServerKeyBuilderExtensions.IsClustered(b.HasKey("Id"), false); + + b.HasIndex("ServiceId"); + + b.ToTable("ServiceAreas", "deds"); + + b.HasAnnotation("Relational:JsonPropertyName", "service_areas"); + }); + + modelBuilder.Entity("FamilyHubs.SharedKernel.OpenReferral.Entities.ServiceAtLocation", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uniqueidentifier"); + + b.Property("Description") + .HasColumnType("nvarchar(max)") + .HasAnnotation("Relational:JsonPropertyName", "description"); + + b.Property("LocationId") + .HasColumnType("uniqueidentifier"); + + b.Property("OrId") + .HasColumnType("uniqueidentifier") + .HasAnnotation("Relational:JsonPropertyName", "id"); + + b.Property("ServiceId") + .HasColumnType("uniqueidentifier"); + + b.HasKey("Id"); + + SqlServerKeyBuilderExtensions.IsClustered(b.HasKey("Id"), false); + + b.HasIndex("LocationId"); + + b.HasIndex("ServiceId"); + + b.ToTable("ServiceAtLocations", "deds"); + + b.HasAnnotation("Relational:JsonPropertyName", "service_at_locations"); + }); + + modelBuilder.Entity("FamilyHubs.SharedKernel.OpenReferral.Entities.Taxonomy", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uniqueidentifier"); + + b.Property("Description") + .IsRequired() + .HasColumnType("nvarchar(max)") + .HasAnnotation("Relational:JsonPropertyName", "description"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(255) + .HasColumnType("nvarchar(255)") + .HasAnnotation("Relational:JsonPropertyName", "name"); + + b.Property("OrId") + .HasColumnType("uniqueidentifier") + .HasAnnotation("Relational:JsonPropertyName", "id"); + + b.Property("Uri") + .HasMaxLength(2048) + .HasColumnType("nvarchar(2048)") + .HasAnnotation("Relational:JsonPropertyName", "uri"); + + b.Property("Version") + .HasMaxLength(50) + .HasColumnType("nvarchar(50)") + .HasAnnotation("Relational:JsonPropertyName", "version"); + + b.HasKey("Id"); + + SqlServerKeyBuilderExtensions.IsClustered(b.HasKey("Id"), false); + + b.ToTable("Taxonomies", "deds"); + + b.HasAnnotation("Relational:JsonPropertyName", "taxonomy_detail"); + }); + + modelBuilder.Entity("FamilyHubs.SharedKernel.OpenReferral.Entities.TaxonomyTerm", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uniqueidentifier"); + + b.Property("Code") + .IsRequired() + .HasMaxLength(255) + .HasColumnType("nvarchar(255)") + .HasAnnotation("Relational:JsonPropertyName", "code"); + + b.Property("Description") + .IsRequired() + .HasColumnType("nvarchar(max)") + .HasAnnotation("Relational:JsonPropertyName", "description"); + + b.Property("Language") + .HasMaxLength(50) + .HasColumnType("nvarchar(50)") + .HasAnnotation("Relational:JsonPropertyName", "language"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(255) + .HasColumnType("nvarchar(255)") + .HasAnnotation("Relational:JsonPropertyName", "name"); + + b.Property("OrId") + .HasColumnType("uniqueidentifier") + .HasAnnotation("Relational:JsonPropertyName", "id"); + + b.Property("ParentId") + .HasColumnType("uniqueidentifier") + .HasAnnotation("Relational:JsonPropertyName", "parent_id"); + + b.Property("Taxonomy") + .HasMaxLength(255) + .HasColumnType("nvarchar(255)") + .HasAnnotation("Relational:JsonPropertyName", "taxonomy"); + + b.Property("TaxonomyId") + .HasColumnType("uniqueidentifier"); + + b.Property("TermUri") + .HasMaxLength(2048) + .HasColumnType("nvarchar(2048)") + .HasAnnotation("Relational:JsonPropertyName", "term_uri"); + + b.HasKey("Id"); + + SqlServerKeyBuilderExtensions.IsClustered(b.HasKey("Id"), false); + + b.HasIndex("TaxonomyId") + .IsUnique() + .HasFilter("[TaxonomyId] IS NOT NULL"); + + b.ToTable("TaxonomyTerms", "deds"); + + b.HasAnnotation("Relational:JsonPropertyName", "taxonomy_term"); + }); + + modelBuilder.Entity("FundingMetadata", b => + { + b.Property("FundingId") + .HasColumnType("uniqueidentifier"); + + b.Property("MetadataId") + .HasColumnType("uniqueidentifier"); + + b.HasKey("FundingId", "MetadataId"); + + b.HasIndex("MetadataId"); + + b.ToTable("FundingMetadata", "dedsmeta"); + }); + + modelBuilder.Entity("LanguageMetadata", b => + { + b.Property("LanguageId") + .HasColumnType("uniqueidentifier"); + + b.Property("MetadataId") + .HasColumnType("uniqueidentifier"); + + b.HasKey("LanguageId", "MetadataId"); + + b.HasIndex("MetadataId"); + + b.ToTable("LanguageMetadata", "dedsmeta"); + }); + + modelBuilder.Entity("LocationMetadata", b => + { + b.Property("LocationId") + .HasColumnType("uniqueidentifier"); + + b.Property("MetadataId") + .HasColumnType("uniqueidentifier"); + + b.HasKey("LocationId", "MetadataId"); + + b.HasIndex("MetadataId"); + + b.ToTable("LocationMetadata", "dedsmeta"); + }); + + modelBuilder.Entity("MetaTableDescriptionMetadata", b => + { + b.Property("MetaTableDescriptionId") + .HasColumnType("uniqueidentifier"); + + b.Property("MetadataId") + .HasColumnType("uniqueidentifier"); + + b.HasKey("MetaTableDescriptionId", "MetadataId"); + + b.HasIndex("MetadataId"); + + b.ToTable("MetaTableDescriptionMetadata", "dedsmeta"); + }); + + modelBuilder.Entity("MetadataOrganization", b => + { + b.Property("MetadataId") + .HasColumnType("uniqueidentifier"); + + b.Property("OrganizationId") + .HasColumnType("uniqueidentifier"); + + b.HasKey("MetadataId", "OrganizationId"); + + b.HasIndex("OrganizationId"); + + b.ToTable("OrganizationMetadata", "dedsmeta"); + }); + + modelBuilder.Entity("MetadataOrganizationIdentifier", b => + { + b.Property("MetadataId") + .HasColumnType("uniqueidentifier"); + + b.Property("OrganizationIdentifierId") + .HasColumnType("uniqueidentifier"); + + b.HasKey("MetadataId", "OrganizationIdentifierId"); + + b.HasIndex("OrganizationIdentifierId"); + + b.ToTable("OrganizationIdentifierMetadata", "dedsmeta"); + }); + + modelBuilder.Entity("MetadataPhone", b => + { + b.Property("MetadataId") + .HasColumnType("uniqueidentifier"); + + b.Property("PhoneId") + .HasColumnType("uniqueidentifier"); + + b.HasKey("MetadataId", "PhoneId"); + + b.HasIndex("PhoneId"); + + b.ToTable("PhoneMetadata", "dedsmeta"); + }); + + modelBuilder.Entity("MetadataProgram", b => + { + b.Property("MetadataId") + .HasColumnType("uniqueidentifier"); + + b.Property("ProgramId") + .HasColumnType("uniqueidentifier"); + + b.HasKey("MetadataId", "ProgramId"); + + b.HasIndex("ProgramId"); + + b.ToTable("ProgramMetadata", "dedsmeta"); + }); + + modelBuilder.Entity("MetadataRequiredDocument", b => + { + b.Property("MetadataId") + .HasColumnType("uniqueidentifier"); + + b.Property("RequiredDocumentId") + .HasColumnType("uniqueidentifier"); + + b.HasKey("MetadataId", "RequiredDocumentId"); + + b.HasIndex("RequiredDocumentId"); + + b.ToTable("RequiredDocumentMetadata", "dedsmeta"); + }); + + modelBuilder.Entity("MetadataSchedule", b => + { + b.Property("MetadataId") + .HasColumnType("uniqueidentifier"); + + b.Property("ScheduleId") + .HasColumnType("uniqueidentifier"); + + b.HasKey("MetadataId", "ScheduleId"); + + b.HasIndex("ScheduleId"); + + b.ToTable("ScheduleMetadata", "dedsmeta"); + }); + + modelBuilder.Entity("MetadataService", b => + { + b.Property("MetadataId") + .HasColumnType("uniqueidentifier"); + + b.Property("ServiceId") + .HasColumnType("uniqueidentifier"); + + b.HasKey("MetadataId", "ServiceId"); + + b.HasIndex("ServiceId"); + + b.ToTable("ServiceMetadata", "dedsmeta"); + }); + + modelBuilder.Entity("MetadataServiceArea", b => + { + b.Property("MetadataId") + .HasColumnType("uniqueidentifier"); + + b.Property("ServiceAreaId") + .HasColumnType("uniqueidentifier"); + + b.HasKey("MetadataId", "ServiceAreaId"); + + b.HasIndex("ServiceAreaId"); + + b.ToTable("ServiceAreaMetadata", "dedsmeta"); + }); + + modelBuilder.Entity("MetadataServiceAtLocation", b => + { + b.Property("MetadataId") + .HasColumnType("uniqueidentifier"); + + b.Property("ServiceAtLocationId") + .HasColumnType("uniqueidentifier"); + + b.HasKey("MetadataId", "ServiceAtLocationId"); + + b.HasIndex("ServiceAtLocationId"); + + b.ToTable("ServiceAtLocationMetadata", "dedsmeta"); + }); + + modelBuilder.Entity("MetadataTaxonomy", b => + { + b.Property("MetadataId") + .HasColumnType("uniqueidentifier"); + + b.Property("TaxonomyId") + .HasColumnType("uniqueidentifier"); + + b.HasKey("MetadataId", "TaxonomyId"); + + b.HasIndex("TaxonomyId"); + + b.ToTable("TaxonomyMetadata", "dedsmeta"); + }); + + modelBuilder.Entity("MetadataTaxonomyTerm", b => + { + b.Property("MetadataId") + .HasColumnType("uniqueidentifier"); + + b.Property("TaxonomyTermId") + .HasColumnType("uniqueidentifier"); + + b.HasKey("MetadataId", "TaxonomyTermId"); + + b.HasIndex("TaxonomyTermId"); + + b.ToTable("TaxonomyTermMetadata", "dedsmeta"); + }); + + modelBuilder.Entity("ServiceTaxonomies", b => + { + b.Property("ServiceId") + .HasColumnType("bigint"); + + b.Property("TaxonomyId") + .HasColumnType("bigint"); + + b.HasKey("ServiceId", "TaxonomyId"); + + b.HasIndex("TaxonomyId"); + + b.ToTable("ServiceTaxonomies"); + }); + + modelBuilder.Entity("AccessibilityAttribute", b => + { + b.HasOne("FamilyHubs.SharedKernel.OpenReferral.Entities.Accessibility", null) + .WithMany() + .HasForeignKey("AccessibilityId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("FamilyHubs.SharedKernel.OpenReferral.Entities.Attribute", null) + .WithMany() + .HasForeignKey("AttributesId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("AccessibilityMetadata", b => + { + b.HasOne("FamilyHubs.SharedKernel.OpenReferral.Entities.Accessibility", null) + .WithMany() + .HasForeignKey("AccessibilityId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("FamilyHubs.SharedKernel.OpenReferral.Entities.Metadata", null) + .WithMany() + .HasForeignKey("MetadataId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("AddressAttribute", b => + { + b.HasOne("FamilyHubs.SharedKernel.OpenReferral.Entities.Address", null) + .WithMany() + .HasForeignKey("AddressId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("FamilyHubs.SharedKernel.OpenReferral.Entities.Attribute", null) + .WithMany() + .HasForeignKey("AttributesId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("AddressMetadata", b => + { + b.HasOne("FamilyHubs.SharedKernel.OpenReferral.Entities.Address", null) + .WithMany() + .HasForeignKey("AddressId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("FamilyHubs.SharedKernel.OpenReferral.Entities.Metadata", null) + .WithMany() + .HasForeignKey("MetadataId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("AttributeContact", b => + { + b.HasOne("FamilyHubs.SharedKernel.OpenReferral.Entities.Attribute", null) + .WithMany() + .HasForeignKey("AttributesId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("FamilyHubs.SharedKernel.OpenReferral.Entities.Contact", null) + .WithMany() + .HasForeignKey("ContactId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("AttributeCostOption", b => + { + b.HasOne("FamilyHubs.SharedKernel.OpenReferral.Entities.Attribute", null) + .WithMany() + .HasForeignKey("AttributesId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("FamilyHubs.SharedKernel.OpenReferral.Entities.CostOption", null) + .WithMany() + .HasForeignKey("CostOptionId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("AttributeFunding", b => + { + b.HasOne("FamilyHubs.SharedKernel.OpenReferral.Entities.Attribute", null) + .WithMany() + .HasForeignKey("AttributesId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("FamilyHubs.SharedKernel.OpenReferral.Entities.Funding", null) + .WithMany() + .HasForeignKey("FundingId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("AttributeLanguage", b => + { + b.HasOne("FamilyHubs.SharedKernel.OpenReferral.Entities.Attribute", null) + .WithMany() + .HasForeignKey("AttributesId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("FamilyHubs.SharedKernel.OpenReferral.Entities.Language", null) + .WithMany() + .HasForeignKey("LanguageId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("AttributeLocation", b => + { + b.HasOne("FamilyHubs.SharedKernel.OpenReferral.Entities.Attribute", null) + .WithMany() + .HasForeignKey("AttributesId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("FamilyHubs.SharedKernel.OpenReferral.Entities.Location", null) + .WithMany() + .HasForeignKey("LocationId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("AttributeMetaTableDescription", b => + { + b.HasOne("FamilyHubs.SharedKernel.OpenReferral.Entities.Attribute", null) + .WithMany() + .HasForeignKey("AttributesId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("FamilyHubs.SharedKernel.OpenReferral.Entities.MetaTableDescription", null) + .WithMany() + .HasForeignKey("MetaTableDescriptionId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("AttributeMetadata", b => + { + b.HasOne("FamilyHubs.SharedKernel.OpenReferral.Entities.Attribute", null) + .WithMany() + .HasForeignKey("AttributeId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("FamilyHubs.SharedKernel.OpenReferral.Entities.Metadata", null) + .WithMany() + .HasForeignKey("MetadataId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("AttributeOrganization", b => + { + b.HasOne("FamilyHubs.SharedKernel.OpenReferral.Entities.Attribute", null) + .WithMany() + .HasForeignKey("AttributesId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("FamilyHubs.SharedKernel.OpenReferral.Entities.Organization", null) + .WithMany() + .HasForeignKey("OrganizationId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("AttributeOrganizationIdentifier", b => + { + b.HasOne("FamilyHubs.SharedKernel.OpenReferral.Entities.Attribute", null) + .WithMany() + .HasForeignKey("AttributesId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("FamilyHubs.SharedKernel.OpenReferral.Entities.OrganizationIdentifier", null) + .WithMany() + .HasForeignKey("OrganizationIdentifierId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("AttributePhone", b => + { + b.HasOne("FamilyHubs.SharedKernel.OpenReferral.Entities.Attribute", null) + .WithMany() + .HasForeignKey("AttributesId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("FamilyHubs.SharedKernel.OpenReferral.Entities.Phone", null) + .WithMany() + .HasForeignKey("PhoneId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("AttributeProgram", b => + { + b.HasOne("FamilyHubs.SharedKernel.OpenReferral.Entities.Attribute", null) + .WithMany() + .HasForeignKey("AttributesId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("FamilyHubs.SharedKernel.OpenReferral.Entities.Program", null) + .WithMany() + .HasForeignKey("ProgramId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("AttributeRequiredDocument", b => + { + b.HasOne("FamilyHubs.SharedKernel.OpenReferral.Entities.Attribute", null) + .WithMany() + .HasForeignKey("AttributesId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("FamilyHubs.SharedKernel.OpenReferral.Entities.RequiredDocument", null) + .WithMany() + .HasForeignKey("RequiredDocumentId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("AttributeSchedule", b => + { + b.HasOne("FamilyHubs.SharedKernel.OpenReferral.Entities.Attribute", null) + .WithMany() + .HasForeignKey("AttributesId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("FamilyHubs.SharedKernel.OpenReferral.Entities.Schedule", null) + .WithMany() + .HasForeignKey("ScheduleId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("AttributeService", b => + { + b.HasOne("FamilyHubs.SharedKernel.OpenReferral.Entities.Attribute", null) + .WithMany() + .HasForeignKey("AttributesId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("FamilyHubs.SharedKernel.OpenReferral.Entities.Service", null) + .WithMany() + .HasForeignKey("ServiceId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("AttributeServiceArea", b => + { + b.HasOne("FamilyHubs.SharedKernel.OpenReferral.Entities.Attribute", null) + .WithMany() + .HasForeignKey("AttributesId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("FamilyHubs.SharedKernel.OpenReferral.Entities.ServiceArea", null) + .WithMany() + .HasForeignKey("ServiceAreaId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("AttributeServiceAtLocation", b => + { + b.HasOne("FamilyHubs.SharedKernel.OpenReferral.Entities.Attribute", null) + .WithMany() + .HasForeignKey("AttributesId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("FamilyHubs.SharedKernel.OpenReferral.Entities.ServiceAtLocation", null) + .WithMany() + .HasForeignKey("ServiceAtLocationId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("ContactMetadata", b => + { + b.HasOne("FamilyHubs.SharedKernel.OpenReferral.Entities.Contact", null) + .WithMany() + .HasForeignKey("ContactId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("FamilyHubs.SharedKernel.OpenReferral.Entities.Metadata", null) + .WithMany() + .HasForeignKey("MetadataId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("CostOptionMetadata", b => + { + b.HasOne("FamilyHubs.SharedKernel.OpenReferral.Entities.CostOption", null) + .WithMany() + .HasForeignKey("CostOptionId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("FamilyHubs.SharedKernel.OpenReferral.Entities.Metadata", null) + .WithMany() + .HasForeignKey("MetadataId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("FamilyHubs.ServiceDirectory.Data.Entities.AccessibilityForDisabilities", b => + { + b.HasOne("FamilyHubs.ServiceDirectory.Data.Entities.Location", null) + .WithMany("AccessibilityForDisabilities") + .HasForeignKey("LocationId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("FamilyHubs.ServiceDirectory.Data.Entities.Contact", b => + { + b.HasOne("FamilyHubs.ServiceDirectory.Data.Entities.Location", null) + .WithMany("Contacts") + .HasForeignKey("LocationId") + .OnDelete(DeleteBehavior.Cascade); + + b.HasOne("FamilyHubs.ServiceDirectory.Data.Entities.Service", null) + .WithMany("Contacts") + .HasForeignKey("ServiceId") + .OnDelete(DeleteBehavior.Cascade); + }); + + modelBuilder.Entity("FamilyHubs.ServiceDirectory.Data.Entities.CostOption", b => + { + b.HasOne("FamilyHubs.ServiceDirectory.Data.Entities.Service", null) + .WithMany("CostOptions") + .HasForeignKey("ServiceId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("FamilyHubs.ServiceDirectory.Data.Entities.Eligibility", b => + { + b.HasOne("FamilyHubs.ServiceDirectory.Data.Entities.Service", null) + .WithMany("Eligibilities") + .HasForeignKey("ServiceId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("FamilyHubs.ServiceDirectory.Data.Entities.Funding", b => + { + b.HasOne("FamilyHubs.ServiceDirectory.Data.Entities.Service", null) + .WithMany("Fundings") + .HasForeignKey("ServiceId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("FamilyHubs.ServiceDirectory.Data.Entities.Language", b => + { + b.HasOne("FamilyHubs.ServiceDirectory.Data.Entities.Service", null) + .WithMany("Languages") + .HasForeignKey("ServiceId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("FamilyHubs.ServiceDirectory.Data.Entities.Location", b => + { + b.HasOne("FamilyHubs.ServiceDirectory.Data.Entities.Organisation", null) + .WithMany("Locations") + .HasForeignKey("OrganisationId") + .OnDelete(DeleteBehavior.Restrict); + }); + + modelBuilder.Entity("FamilyHubs.ServiceDirectory.Data.Entities.ManyToMany.ServiceAtLocation", b => + { + b.HasOne("FamilyHubs.ServiceDirectory.Data.Entities.Location", "Location") + .WithMany() + .HasForeignKey("LocationId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("FamilyHubs.ServiceDirectory.Data.Entities.Service", "Service") + .WithMany("ServiceAtLocations") + .HasForeignKey("ServiceId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Location"); + + b.Navigation("Service"); + }); + + modelBuilder.Entity("FamilyHubs.ServiceDirectory.Data.Entities.Schedule", b => + { + b.HasOne("FamilyHubs.ServiceDirectory.Data.Entities.Location", null) + .WithMany("Schedules") + .HasForeignKey("LocationId") + .OnDelete(DeleteBehavior.Cascade); + + b.HasOne("FamilyHubs.ServiceDirectory.Data.Entities.ManyToMany.ServiceAtLocation", null) + .WithMany("Schedules") + .HasForeignKey("ServiceAtLocationId") + .OnDelete(DeleteBehavior.NoAction); + + b.HasOne("FamilyHubs.ServiceDirectory.Data.Entities.Service", null) + .WithMany("Schedules") + .HasForeignKey("ServiceId") + .OnDelete(DeleteBehavior.Cascade); + }); + + modelBuilder.Entity("FamilyHubs.ServiceDirectory.Data.Entities.Service", b => + { + b.HasOne("FamilyHubs.ServiceDirectory.Data.Entities.Organisation", null) + .WithMany("Services") + .HasForeignKey("OrganisationId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("FamilyHubs.ServiceDirectory.Data.Entities.ServiceArea", b => + { + b.HasOne("FamilyHubs.ServiceDirectory.Data.Entities.Service", null) + .WithMany("ServiceAreas") + .HasForeignKey("ServiceId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("FamilyHubs.ServiceDirectory.Data.Entities.ServiceDelivery", b => + { + b.HasOne("FamilyHubs.ServiceDirectory.Data.Entities.Service", null) + .WithMany("ServiceDeliveries") + .HasForeignKey("ServiceId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("FamilyHubs.ServiceDirectory.Data.ServiceSearch", b => + { + b.HasOne("FamilyHubs.ServiceDirectory.Data.Event", "SearchTriggerEvent") + .WithMany("ServiceSearches") + .HasForeignKey("SearchTriggerEventId"); + + b.HasOne("FamilyHubs.ServiceDirectory.Data.ServiceType", "ServiceSearchType") + .WithMany("ServiceSearches") + .HasForeignKey("ServiceSearchTypeId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("SearchTriggerEvent"); + + b.Navigation("ServiceSearchType"); + }); + + modelBuilder.Entity("FamilyHubs.ServiceDirectory.Data.ServiceSearchResult", b => + { + b.HasOne("FamilyHubs.ServiceDirectory.Data.Entities.Service", "Service") + .WithMany("ServiceSearchResults") + .HasForeignKey("ServiceId") + .OnDelete(DeleteBehavior.NoAction) + .IsRequired(); + + b.HasOne("FamilyHubs.ServiceDirectory.Data.ServiceSearch", null) + .WithMany("ServiceSearchResults") + .HasForeignKey("ServiceSearchId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Service"); + }); + + modelBuilder.Entity("FamilyHubs.SharedKernel.OpenReferral.Entities.Accessibility", b => + { + b.HasOne("FamilyHubs.SharedKernel.OpenReferral.Entities.Location", null) + .WithMany("Accessibilities") + .HasForeignKey("LocationId"); + }); + + modelBuilder.Entity("FamilyHubs.SharedKernel.OpenReferral.Entities.Address", b => + { + b.HasOne("FamilyHubs.SharedKernel.OpenReferral.Entities.Location", null) + .WithMany("Addresses") + .HasForeignKey("LocationId"); + }); + + modelBuilder.Entity("FamilyHubs.SharedKernel.OpenReferral.Entities.Attribute", b => + { + b.HasOne("FamilyHubs.SharedKernel.OpenReferral.Entities.TaxonomyTerm", "TaxonomyTerm") + .WithOne() + .HasForeignKey("FamilyHubs.SharedKernel.OpenReferral.Entities.Attribute", "TaxonomyTermId"); + + b.Navigation("TaxonomyTerm"); + }); + + modelBuilder.Entity("FamilyHubs.SharedKernel.OpenReferral.Entities.Contact", b => + { + b.HasOne("FamilyHubs.SharedKernel.OpenReferral.Entities.Location", null) + .WithMany("Contacts") + .HasForeignKey("LocationId"); + + b.HasOne("FamilyHubs.SharedKernel.OpenReferral.Entities.Organization", null) + .WithMany("Contacts") + .HasForeignKey("OrganizationId"); + + b.HasOne("FamilyHubs.SharedKernel.OpenReferral.Entities.ServiceAtLocation", null) + .WithMany("Contacts") + .HasForeignKey("ServiceAtLocationId"); + + b.HasOne("FamilyHubs.SharedKernel.OpenReferral.Entities.Service", null) + .WithMany("Contacts") + .HasForeignKey("ServiceId"); + }); + + modelBuilder.Entity("FamilyHubs.SharedKernel.OpenReferral.Entities.CostOption", b => + { + b.HasOne("FamilyHubs.SharedKernel.OpenReferral.Entities.Service", null) + .WithMany("CostOptions") + .HasForeignKey("ServiceId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("FamilyHubs.SharedKernel.OpenReferral.Entities.Funding", b => + { + b.HasOne("FamilyHubs.SharedKernel.OpenReferral.Entities.Organization", null) + .WithMany("Funding") + .HasForeignKey("OrganizationId"); + + b.HasOne("FamilyHubs.SharedKernel.OpenReferral.Entities.Service", null) + .WithMany("Funding") + .HasForeignKey("ServiceId"); + }); + + modelBuilder.Entity("FamilyHubs.SharedKernel.OpenReferral.Entities.Language", b => + { + b.HasOne("FamilyHubs.SharedKernel.OpenReferral.Entities.Location", null) + .WithMany("Languages") + .HasForeignKey("LocationId"); + + b.HasOne("FamilyHubs.SharedKernel.OpenReferral.Entities.Phone", null) + .WithMany("Languages") + .HasForeignKey("PhoneId"); + + b.HasOne("FamilyHubs.SharedKernel.OpenReferral.Entities.Service", null) + .WithMany("Languages") + .HasForeignKey("ServiceId"); + }); + + modelBuilder.Entity("FamilyHubs.SharedKernel.OpenReferral.Entities.Location", b => + { + b.HasOne("FamilyHubs.SharedKernel.OpenReferral.Entities.Organization", null) + .WithMany("Locations") + .HasForeignKey("OrganizationId"); + }); + + modelBuilder.Entity("FamilyHubs.SharedKernel.OpenReferral.Entities.OrganizationIdentifier", b => + { + b.HasOne("FamilyHubs.SharedKernel.OpenReferral.Entities.Organization", null) + .WithMany("OrganizationIdentifiers") + .HasForeignKey("OrganizationId"); + }); + + modelBuilder.Entity("FamilyHubs.SharedKernel.OpenReferral.Entities.Phone", b => + { + b.HasOne("FamilyHubs.SharedKernel.OpenReferral.Entities.Contact", null) + .WithMany("Phones") + .HasForeignKey("ContactId"); + + b.HasOne("FamilyHubs.SharedKernel.OpenReferral.Entities.Location", null) + .WithMany("Phones") + .HasForeignKey("LocationId"); + + b.HasOne("FamilyHubs.SharedKernel.OpenReferral.Entities.Organization", null) + .WithMany("Phones") + .HasForeignKey("OrganizationId"); + + b.HasOne("FamilyHubs.SharedKernel.OpenReferral.Entities.ServiceAtLocation", null) + .WithMany("Phones") + .HasForeignKey("ServiceAtLocationId"); + + b.HasOne("FamilyHubs.SharedKernel.OpenReferral.Entities.Service", null) + .WithMany("Phones") + .HasForeignKey("ServiceId"); + }); + + modelBuilder.Entity("FamilyHubs.SharedKernel.OpenReferral.Entities.Program", b => + { + b.HasOne("FamilyHubs.SharedKernel.OpenReferral.Entities.Organization", null) + .WithMany("Programs") + .HasForeignKey("OrganizationId"); + }); + + modelBuilder.Entity("FamilyHubs.SharedKernel.OpenReferral.Entities.RequiredDocument", b => + { + b.HasOne("FamilyHubs.SharedKernel.OpenReferral.Entities.Service", null) + .WithMany("RequiredDocuments") + .HasForeignKey("ServiceId"); + }); + + modelBuilder.Entity("FamilyHubs.SharedKernel.OpenReferral.Entities.Schedule", b => + { + b.HasOne("FamilyHubs.SharedKernel.OpenReferral.Entities.Location", null) + .WithMany("Schedules") + .HasForeignKey("LocationId"); + + b.HasOne("FamilyHubs.SharedKernel.OpenReferral.Entities.ServiceAtLocation", null) + .WithMany("Schedules") + .HasForeignKey("ServiceAtLocationId"); + + b.HasOne("FamilyHubs.SharedKernel.OpenReferral.Entities.Service", null) + .WithMany("Schedules") + .HasForeignKey("ServiceId"); + }); + + modelBuilder.Entity("FamilyHubs.SharedKernel.OpenReferral.Entities.Service", b => + { + b.HasOne("FamilyHubs.SharedKernel.OpenReferral.Entities.Organization", "Organization") + .WithMany() + .HasForeignKey("OrganizationId"); + + b.HasOne("FamilyHubs.SharedKernel.OpenReferral.Entities.Program", "Program") + .WithMany() + .HasForeignKey("ProgramId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Organization"); + + b.Navigation("Program"); + }); + + modelBuilder.Entity("FamilyHubs.SharedKernel.OpenReferral.Entities.ServiceArea", b => + { + b.HasOne("FamilyHubs.SharedKernel.OpenReferral.Entities.Service", null) + .WithMany("ServiceAreas") + .HasForeignKey("ServiceId"); + }); + + modelBuilder.Entity("FamilyHubs.SharedKernel.OpenReferral.Entities.ServiceAtLocation", b => + { + b.HasOne("FamilyHubs.SharedKernel.OpenReferral.Entities.Location", "Location") + .WithMany() + .HasForeignKey("LocationId"); + + b.HasOne("FamilyHubs.SharedKernel.OpenReferral.Entities.Service", null) + .WithMany("ServiceAtLocations") + .HasForeignKey("ServiceId"); + + b.Navigation("Location"); + }); + + modelBuilder.Entity("FamilyHubs.SharedKernel.OpenReferral.Entities.TaxonomyTerm", b => + { + b.HasOne("FamilyHubs.SharedKernel.OpenReferral.Entities.Taxonomy", "TaxonomyDetail") + .WithOne() + .HasForeignKey("FamilyHubs.SharedKernel.OpenReferral.Entities.TaxonomyTerm", "TaxonomyId"); + + b.Navigation("TaxonomyDetail"); + }); + + modelBuilder.Entity("FundingMetadata", b => + { + b.HasOne("FamilyHubs.SharedKernel.OpenReferral.Entities.Funding", null) + .WithMany() + .HasForeignKey("FundingId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("FamilyHubs.SharedKernel.OpenReferral.Entities.Metadata", null) + .WithMany() + .HasForeignKey("MetadataId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("LanguageMetadata", b => + { + b.HasOne("FamilyHubs.SharedKernel.OpenReferral.Entities.Language", null) + .WithMany() + .HasForeignKey("LanguageId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("FamilyHubs.SharedKernel.OpenReferral.Entities.Metadata", null) + .WithMany() + .HasForeignKey("MetadataId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("LocationMetadata", b => + { + b.HasOne("FamilyHubs.SharedKernel.OpenReferral.Entities.Location", null) + .WithMany() + .HasForeignKey("LocationId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("FamilyHubs.SharedKernel.OpenReferral.Entities.Metadata", null) + .WithMany() + .HasForeignKey("MetadataId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("MetaTableDescriptionMetadata", b => + { + b.HasOne("FamilyHubs.SharedKernel.OpenReferral.Entities.MetaTableDescription", null) + .WithMany() + .HasForeignKey("MetaTableDescriptionId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("FamilyHubs.SharedKernel.OpenReferral.Entities.Metadata", null) + .WithMany() + .HasForeignKey("MetadataId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("MetadataOrganization", b => + { + b.HasOne("FamilyHubs.SharedKernel.OpenReferral.Entities.Metadata", null) + .WithMany() + .HasForeignKey("MetadataId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("FamilyHubs.SharedKernel.OpenReferral.Entities.Organization", null) + .WithMany() + .HasForeignKey("OrganizationId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("MetadataOrganizationIdentifier", b => + { + b.HasOne("FamilyHubs.SharedKernel.OpenReferral.Entities.Metadata", null) + .WithMany() + .HasForeignKey("MetadataId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("FamilyHubs.SharedKernel.OpenReferral.Entities.OrganizationIdentifier", null) + .WithMany() + .HasForeignKey("OrganizationIdentifierId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("MetadataPhone", b => + { + b.HasOne("FamilyHubs.SharedKernel.OpenReferral.Entities.Metadata", null) + .WithMany() + .HasForeignKey("MetadataId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("FamilyHubs.SharedKernel.OpenReferral.Entities.Phone", null) + .WithMany() + .HasForeignKey("PhoneId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("MetadataProgram", b => + { + b.HasOne("FamilyHubs.SharedKernel.OpenReferral.Entities.Metadata", null) + .WithMany() + .HasForeignKey("MetadataId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("FamilyHubs.SharedKernel.OpenReferral.Entities.Program", null) + .WithMany() + .HasForeignKey("ProgramId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("MetadataRequiredDocument", b => + { + b.HasOne("FamilyHubs.SharedKernel.OpenReferral.Entities.Metadata", null) + .WithMany() + .HasForeignKey("MetadataId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("FamilyHubs.SharedKernel.OpenReferral.Entities.RequiredDocument", null) + .WithMany() + .HasForeignKey("RequiredDocumentId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("MetadataSchedule", b => + { + b.HasOne("FamilyHubs.SharedKernel.OpenReferral.Entities.Metadata", null) + .WithMany() + .HasForeignKey("MetadataId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("FamilyHubs.SharedKernel.OpenReferral.Entities.Schedule", null) + .WithMany() + .HasForeignKey("ScheduleId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("MetadataService", b => + { + b.HasOne("FamilyHubs.SharedKernel.OpenReferral.Entities.Metadata", null) + .WithMany() + .HasForeignKey("MetadataId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("FamilyHubs.SharedKernel.OpenReferral.Entities.Service", null) + .WithMany() + .HasForeignKey("ServiceId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("MetadataServiceArea", b => + { + b.HasOne("FamilyHubs.SharedKernel.OpenReferral.Entities.Metadata", null) + .WithMany() + .HasForeignKey("MetadataId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("FamilyHubs.SharedKernel.OpenReferral.Entities.ServiceArea", null) + .WithMany() + .HasForeignKey("ServiceAreaId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("MetadataServiceAtLocation", b => + { + b.HasOne("FamilyHubs.SharedKernel.OpenReferral.Entities.Metadata", null) + .WithMany() + .HasForeignKey("MetadataId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("FamilyHubs.SharedKernel.OpenReferral.Entities.ServiceAtLocation", null) + .WithMany() + .HasForeignKey("ServiceAtLocationId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("MetadataTaxonomy", b => + { + b.HasOne("FamilyHubs.SharedKernel.OpenReferral.Entities.Metadata", null) + .WithMany() + .HasForeignKey("MetadataId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("FamilyHubs.SharedKernel.OpenReferral.Entities.Taxonomy", null) + .WithMany() + .HasForeignKey("TaxonomyId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("MetadataTaxonomyTerm", b => + { + b.HasOne("FamilyHubs.SharedKernel.OpenReferral.Entities.Metadata", null) + .WithMany() + .HasForeignKey("MetadataId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("FamilyHubs.SharedKernel.OpenReferral.Entities.TaxonomyTerm", null) + .WithMany() + .HasForeignKey("TaxonomyTermId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("ServiceTaxonomies", b => + { + b.HasOne("FamilyHubs.ServiceDirectory.Data.Entities.Service", null) + .WithMany() + .HasForeignKey("ServiceId") + .OnDelete(DeleteBehavior.Cascade); + + b.HasOne("FamilyHubs.ServiceDirectory.Data.Entities.Taxonomy", null) + .WithMany() + .HasForeignKey("TaxonomyId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("FamilyHubs.ServiceDirectory.Data.Entities.Location", b => + { + b.Navigation("AccessibilityForDisabilities"); + + b.Navigation("Contacts"); + + b.Navigation("Schedules"); + }); + + modelBuilder.Entity("FamilyHubs.ServiceDirectory.Data.Entities.ManyToMany.ServiceAtLocation", b => + { + b.Navigation("Schedules"); + }); + + modelBuilder.Entity("FamilyHubs.ServiceDirectory.Data.Entities.Organisation", b => + { + b.Navigation("Locations"); + + b.Navigation("Services"); + }); + + modelBuilder.Entity("FamilyHubs.ServiceDirectory.Data.Entities.Service", b => + { + b.Navigation("Contacts"); + + b.Navigation("CostOptions"); + + b.Navigation("Eligibilities"); + + b.Navigation("Fundings"); + + b.Navigation("Languages"); + + b.Navigation("Schedules"); + + b.Navigation("ServiceAreas"); + + b.Navigation("ServiceAtLocations"); + + b.Navigation("ServiceDeliveries"); + + b.Navigation("ServiceSearchResults"); + }); + + modelBuilder.Entity("FamilyHubs.ServiceDirectory.Data.Event", b => + { + b.Navigation("ServiceSearches"); + }); + + modelBuilder.Entity("FamilyHubs.ServiceDirectory.Data.ServiceSearch", b => + { + b.Navigation("ServiceSearchResults"); + }); + + modelBuilder.Entity("FamilyHubs.ServiceDirectory.Data.ServiceType", b => + { + b.Navigation("ServiceSearches"); + }); + + modelBuilder.Entity("FamilyHubs.SharedKernel.OpenReferral.Entities.Contact", b => + { + b.Navigation("Phones"); + }); + + modelBuilder.Entity("FamilyHubs.SharedKernel.OpenReferral.Entities.Location", b => + { + b.Navigation("Accessibilities"); + + b.Navigation("Addresses"); + + b.Navigation("Contacts"); + + b.Navigation("Languages"); + + b.Navigation("Phones"); + + b.Navigation("Schedules"); + }); + + modelBuilder.Entity("FamilyHubs.SharedKernel.OpenReferral.Entities.Organization", b => + { + b.Navigation("Contacts"); + + b.Navigation("Funding"); + + b.Navigation("Locations"); + + b.Navigation("OrganizationIdentifiers"); + + b.Navigation("Phones"); + + b.Navigation("Programs"); + }); + + modelBuilder.Entity("FamilyHubs.SharedKernel.OpenReferral.Entities.Phone", b => + { + b.Navigation("Languages"); + }); + + modelBuilder.Entity("FamilyHubs.SharedKernel.OpenReferral.Entities.Service", b => + { + b.Navigation("Contacts"); + + b.Navigation("CostOptions"); + + b.Navigation("Funding"); + + b.Navigation("Languages"); + + b.Navigation("Phones"); + + b.Navigation("RequiredDocuments"); + + b.Navigation("Schedules"); + + b.Navigation("ServiceAreas"); + + b.Navigation("ServiceAtLocations"); + }); + + modelBuilder.Entity("FamilyHubs.SharedKernel.OpenReferral.Entities.ServiceAtLocation", b => + { + b.Navigation("Contacts"); + + b.Navigation("Phones"); + + b.Navigation("Schedules"); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/src/service/service-directory-api/src/FamilyHubs.ServiceDirectory.Data/Migrations/20241111100056_SeedData.cs b/src/service/service-directory-api/src/FamilyHubs.ServiceDirectory.Data/Migrations/20241111100056_SeedData.cs new file mode 100644 index 000000000..83f4de5ff --- /dev/null +++ b/src/service/service-directory-api/src/FamilyHubs.ServiceDirectory.Data/Migrations/20241111100056_SeedData.cs @@ -0,0 +1,132 @@ +using FamilyHubs.ServiceDirectory.Data.Entities; +using FamilyHubs.ServiceDirectory.Shared.Enums; +using Microsoft.EntityFrameworkCore.Migrations; + +#nullable disable + +namespace FamilyHubs.ServiceDirectory.Data.Migrations +{ + /// + public partial class SeedData : Migration + { + /// + protected override void Up(MigrationBuilder migrationBuilder) + { + SeedTaxonomies(migrationBuilder); + SeedOrganisations(migrationBuilder); + } + + /// + protected override void Down(MigrationBuilder migrationBuilder) + { + // Not supported + } + + public void SeedTaxonomies(MigrationBuilder migrationBuilder) + { + migrationBuilder.Sql(""" + IF NOT EXISTS (SELECT * FROM Taxonomies) + BEGIN + BEGIN TRANSACTION; + DECLARE @ParentTaxonomies table(id bigint, name nvarchar(255)); + DECLARE @Taxonomy bigint; + + INSERT Taxonomies (Name, TaxonomyType) OUTPUT INSERTED.Id, INSERTED.Name INTO @ParentTaxonomies VALUES + ('Activities, clubs and groups', 'ServiceCategory'), + ('Family support', 'ServiceCategory'), + ('Health', 'ServiceCategory'), + ('Pregnancy, birth and early years', 'ServiceCategory'), + ('Special educational needs and disabilities (SEND)', 'ServiceCategory'), + ('Transport', 'ServiceCategory'); + + SELECT @Taxonomy = id FROM @ParentTaxonomies WHERE name = 'Activities, clubs and groups'; + INSERT INTO Taxonomies (Name, TaxonomyType, ParentId) VALUES + ('Activities', 'ServiceCategory', @Taxonomy), + ('Before and after school clubs', 'ServiceCategory', @Taxonomy), + ('Holiday clubs and schemes', 'ServiceCategory', @Taxonomy), + ('Music, arts and dance', 'ServiceCategory', @Taxonomy), + ('Parent, baby and toddler groups', 'ServiceCategory', @Taxonomy), + ('Pre-school playgroup', 'ServiceCategory', @Taxonomy), + ('Sports and recreation', 'ServiceCategory', @Taxonomy); + + SELECT @Taxonomy = id FROM @ParentTaxonomies WHERE name = 'Family support'; + INSERT INTO Taxonomies (Name, TaxonomyType, ParentId) VALUES + ('Bullying and cyber bullying', 'ServiceCategory', @Taxonomy), + ('Debt and welfare advice', 'ServiceCategory', @Taxonomy), + ('Domestic abuse', 'ServiceCategory', @Taxonomy), + ('Intensive targeted family support', 'ServiceCategory', @Taxonomy), + ('Money, benefits and housing', 'ServiceCategory', @Taxonomy), + ('Parenting support', 'ServiceCategory', @Taxonomy), + ('Reducing parental conflict', 'ServiceCategory', @Taxonomy), + ('Separating and separated parent support', 'ServiceCategory', @Taxonomy), + ('Stopping smoking', 'ServiceCategory', @Taxonomy), + ('Substance misuse (including alcohol and drug)', 'ServiceCategory', @Taxonomy), + ('Targeted youth support', 'ServiceCategory', @Taxonomy), + ('Youth justice services', 'ServiceCategory', @Taxonomy); + + SELECT @Taxonomy = id FROM @ParentTaxonomies WHERE name = 'Health'; + INSERT INTO Taxonomies (Name, TaxonomyType, ParentId) VALUES + ('Hearing and sight', 'ServiceCategory', @Taxonomy), + ('Mental health, social and emotional support', 'ServiceCategory', @Taxonomy), + ('Nutrition and weight management', 'ServiceCategory', @Taxonomy), + ('Oral health', 'ServiceCategory', @Taxonomy), + ('Public health services', 'ServiceCategory', @Taxonomy); + + SELECT @Taxonomy = id FROM @ParentTaxonomies WHERE name = 'Pregnancy, birth and early years'; + INSERT INTO Taxonomies (Name, TaxonomyType, ParentId) VALUES + ('Birth registration', 'ServiceCategory', @Taxonomy), + ('Early years language and learning', 'ServiceCategory', @Taxonomy), + ('Health visiting', 'ServiceCategory', @Taxonomy), + ('Infant feeding support (including breastfeeding)', 'ServiceCategory', @Taxonomy), + ('Midwife and maternity', 'ServiceCategory', @Taxonomy), + ('Perinatal mental health support (pregnancy to one year post birth)', 'ServiceCategory', @Taxonomy); + + SELECT @Taxonomy = id FROM @ParentTaxonomies WHERE name = 'Special educational needs and disabilities (SEND)'; + INSERT INTO Taxonomies (Name, TaxonomyType, ParentId) VALUES + ('Autistic Spectrum Disorder (ASD)', 'ServiceCategory', @Taxonomy), + ('Breaks and respite', 'ServiceCategory', @Taxonomy), + ('Early years support', 'ServiceCategory', @Taxonomy), + ('Groups for parents and carers of children with SEND', 'ServiceCategory', @Taxonomy), + ('Hearing impairment', 'ServiceCategory', @Taxonomy), + ('Learning difficulties and disabilities', 'ServiceCategory', @Taxonomy), + ('Multi-sensory impairment', 'ServiceCategory', @Taxonomy), + ('Other difficulties or disabilities', 'ServiceCategory', @Taxonomy), + ('Physical disabilities', 'ServiceCategory', @Taxonomy), + ('Social, emotional and mental health support', 'ServiceCategory', @Taxonomy), + ('Speech, language and communication needs', 'ServiceCategory', @Taxonomy), + ('Visual impairment', 'ServiceCategory', @Taxonomy); + + SELECT @Taxonomy = id FROM @ParentTaxonomies WHERE name = 'Transport'; + INSERT INTO Taxonomies (Name, TaxonomyType, ParentId) VALUES + ('Community transport', 'ServiceCategory', @Taxonomy); + + COMMIT; + END; + """); + } + + public void SeedOrganisations(MigrationBuilder migrationBuilder) + { + migrationBuilder.Sql(""" + IF NOT EXISTS (SELECT * FROM Organisations) + BEGIN + BEGIN TRANSACTION; + + INSERT INTO Organisations (OrganisationType, Name, Description, AdminAreaCode, Uri, Url) VALUES + ('LA', 'Bristol County Council', 'Bristol County Council', 'E06000023', 'https://www.bristol.gov.uk/', 'https://www.bristol.gov.uk/'), + ('LA', 'Lancashire County Council', 'Lancashire County Council', 'E10000017', 'https://www.lancashire.gov.uk/', 'https://www.lancashire.gov.uk/'), + ('LA', 'London Borough of Redbridge', 'London Borough of Redbridge', 'E09000026', 'https://www.redbridge.gov.uk/', 'https://www.redbridge.gov.uk/'), + ('LA', 'Salford City Council', 'Salford City Council', 'E08000006', 'https://www.salford.gov.uk/', 'https://www.salford.gov.uk/'), + ('LA', 'Suffolk County Council', 'Suffolk County Council', 'E10000029', 'https://www.suffolk.gov.uk/', 'https://www.suffolk.gov.uk/'), + ('LA', 'Tower Hamlets Council', 'Tower Hamlets Council', 'E09000030', 'https://www.towerhamlets.gov.uk/', 'https://www.towerhamlets.gov.uk/'), + ('LA', 'Lewisham Council', 'Lewisham Council', 'E09000023', 'https://lewisham.gov.uk/', 'https://lewisham.gov.uk/'), + ('LA', 'North East Lincolnshire Council', 'North East Lincolnshire Council', 'E06000012', 'https://www.nelincs.gov.uk/', 'https://www.nelincs.gov.uk/'), + ('LA', 'City of Wolverhampton Council', 'City of Wolverhampton Council', 'E08000031', 'https://www.wolverhampton.gov.uk/', 'https://www.wolverhampton.gov.uk/'), + ('LA', 'Sheffield City Council', 'Sheffield City Council', 'E08000019', 'https://www.sheffield.gov.uk/', 'https://www.sheffield.gov.uk/'); + + COMMIT; + END; + """); + } + } +} diff --git a/src/service/service-directory-api/src/FamilyHubs.ServiceDirectory.Data/Migrations/ApplicationDbContextModelSnapshot.cs b/src/service/service-directory-api/src/FamilyHubs.ServiceDirectory.Data/Migrations/ApplicationDbContextModelSnapshot.cs index 35835e05c..e600879c5 100644 --- a/src/service/service-directory-api/src/FamilyHubs.ServiceDirectory.Data/Migrations/ApplicationDbContextModelSnapshot.cs +++ b/src/service/service-directory-api/src/FamilyHubs.ServiceDirectory.Data/Migrations/ApplicationDbContextModelSnapshot.cs @@ -18,7 +18,7 @@ protected override void BuildModel(ModelBuilder modelBuilder) { #pragma warning disable 612, 618 modelBuilder - .HasAnnotation("ProductVersion", "7.0.18") + .HasAnnotation("ProductVersion", "8.0.8") .HasAnnotation("Relational:MaxIdentifierLength", 128); SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder); diff --git a/src/service/service-directory-api/src/FamilyHubs.ServiceDirectory.Data/Repository/ApplicationDbContextInitialiser.cs b/src/service/service-directory-api/src/FamilyHubs.ServiceDirectory.Data/Repository/ApplicationDbContextInitialiser.cs deleted file mode 100644 index b30b57c7b..000000000 --- a/src/service/service-directory-api/src/FamilyHubs.ServiceDirectory.Data/Repository/ApplicationDbContextInitialiser.cs +++ /dev/null @@ -1,29 +0,0 @@ -using Microsoft.EntityFrameworkCore; - -namespace FamilyHubs.ServiceDirectory.Data.Repository; - -public class ApplicationDbContextInitialiser -{ - private readonly ApplicationDbContext _context; - - public ApplicationDbContextInitialiser(ApplicationDbContext context) - { - _context = context; - } - - public async Task InitialiseAsync() - { - await SeedAsync(); - } - - private async Task SeedAsync() - { - var organisationSeedData = new OrganisationSeedData(_context); - - if (!await _context.Taxonomies.AnyAsync()) - await organisationSeedData.SeedTaxonomies(); - - if (!await _context.Organisations.AnyAsync()) - await organisationSeedData.SeedOrganisations(); - } -} diff --git a/src/service/service-directory-api/tests/FamilyHubs.ServiceDirectory.Api.FunctionalTests/CustomWebApplicationFactory.cs b/src/service/service-directory-api/tests/FamilyHubs.ServiceDirectory.Api.FunctionalTests/CustomWebApplicationFactory.cs index f3e8a1385..05cbf9c2b 100644 --- a/src/service/service-directory-api/tests/FamilyHubs.ServiceDirectory.Api.FunctionalTests/CustomWebApplicationFactory.cs +++ b/src/service/service-directory-api/tests/FamilyHubs.ServiceDirectory.Api.FunctionalTests/CustomWebApplicationFactory.cs @@ -42,6 +42,7 @@ protected override void ConfigureWebHost(IWebHostBuilder builder) builder.UseEnvironment("Development"); } + public void SetupTestDatabaseAndSeedData() { using var scope = Services.CreateScope(); @@ -53,7 +54,14 @@ public void SetupTestDatabaseAndSeedData() { var context = scopedServices.GetRequiredService(); - context.Database.ExecuteSqlRaw("UPDATE geometry_columns SET srid = 4326 WHERE f_table_name = 'locations';"); + // I wish I could just call Migrate() but our migrations don't work on sqlite? + context.Database.EnsureCreated(); + var seedData = new OrganisationSeedData(context); + seedData.SeedTaxonomies(); + seedData.SeedOrganisations(); + + if (!context.Database.IsSqlServer()) + context.Database.ExecuteSqlRaw("UPDATE geometry_columns SET srid = 4326 WHERE f_table_name = 'locations';"); var testOrganisations = context.Organisations.Select(o => new { o.Id, o.Name }) .Where(o => o.Name == "Bristol County Council" || o.Name == "Salford City Council") diff --git a/src/service/service-directory-api/src/FamilyHubs.ServiceDirectory.Data/Repository/OrganisationSeedData.cs b/src/service/service-directory-api/tests/FamilyHubs.ServiceDirectory.Api.FunctionalTests/OrganisationSeedData.cs similarity index 96% rename from src/service/service-directory-api/src/FamilyHubs.ServiceDirectory.Data/Repository/OrganisationSeedData.cs rename to src/service/service-directory-api/tests/FamilyHubs.ServiceDirectory.Api.FunctionalTests/OrganisationSeedData.cs index ceaf0d053..6995dd5ad 100644 --- a/src/service/service-directory-api/src/FamilyHubs.ServiceDirectory.Data/Repository/OrganisationSeedData.cs +++ b/src/service/service-directory-api/tests/FamilyHubs.ServiceDirectory.Api.FunctionalTests/OrganisationSeedData.cs @@ -1,7 +1,8 @@ using FamilyHubs.ServiceDirectory.Data.Entities; +using FamilyHubs.ServiceDirectory.Data.Repository; using FamilyHubs.ServiceDirectory.Shared.Enums; -namespace FamilyHubs.ServiceDirectory.Data.Repository; +namespace FamilyHubs.ServiceDirectory.Api.FunctionalTests; #pragma warning disable S1075 public class OrganisationSeedData @@ -13,7 +14,7 @@ public OrganisationSeedData(ApplicationDbContext dbContext) _dbContext = dbContext; } - public async Task SeedTaxonomies() + public void SeedTaxonomies() { var activity = new Taxonomy { Name = "Activities, clubs and groups", TaxonomyType = TaxonomyType.ServiceCategory }; var support = new Taxonomy { Name = "Family support", TaxonomyType = TaxonomyType.ServiceCategory }; @@ -33,7 +34,7 @@ public async Task SeedTaxonomies() }; _dbContext.Taxonomies.AddRange(parentTaxonomies); - await _dbContext.SaveChangesAsync(); + _dbContext.SaveChanges(); var taxonomies = new List { @@ -89,10 +90,10 @@ public async Task SeedTaxonomies() }; _dbContext.Taxonomies.AddRange(taxonomies); - await _dbContext.SaveChangesAsync(); + _dbContext.SaveChanges(); } - public async Task SeedOrganisations() + public void SeedOrganisations() { const OrganisationType organisationType = OrganisationType.LA; var organisations = new List @@ -190,7 +191,7 @@ public async Task SeedOrganisations() }; _dbContext.Organisations.AddRange(organisations); - await _dbContext.SaveChangesAsync(); + _dbContext.SaveChanges(); } } #pragma warning restore S1075 diff --git a/src/service/service-directory-api/tests/FamilyHubs.ServiceDirectory.Core.IntegrationTests/DataIntegrationTestBase.cs b/src/service/service-directory-api/tests/FamilyHubs.ServiceDirectory.Core.IntegrationTests/DataIntegrationTestBase.cs index f39382a9e..6e09f8072 100644 --- a/src/service/service-directory-api/tests/FamilyHubs.ServiceDirectory.Core.IntegrationTests/DataIntegrationTestBase.cs +++ b/src/service/service-directory-api/tests/FamilyHubs.ServiceDirectory.Core.IntegrationTests/DataIntegrationTestBase.cs @@ -136,17 +136,9 @@ protected async Task> CreateManyTestServicesQueryTesting() private void InitialiseDatabase() { + TestDbContext.Database.ExecuteSqlRaw($"UPDATE geometry_columns SET srid = {GeoPoint.WGS84} WHERE f_table_name = 'locations';"); TestDbContext.Database.EnsureDeleted(); TestDbContext.Database.EnsureCreated(); - TestDbContext.Database.ExecuteSqlRaw($"UPDATE geometry_columns SET srid = {GeoPoint.WGS84} WHERE f_table_name = 'locations';"); - - var organisationSeedData = new OrganisationSeedData(TestDbContext); - - if (!TestDbContext.Taxonomies.Any()) - organisationSeedData.SeedTaxonomies().GetAwaiter().GetResult(); - - if (!TestDbContext.Organisations.Any()) - organisationSeedData.SeedOrganisations().GetAwaiter().GetResult(); } private ServiceProvider CreateNewServiceProvider() From 32f20cb35b01e75e8f6fa8c81338fc5b8399046d Mon Sep 17 00:00:00 2001 From: Thomas Cheyney Date: Mon, 11 Nov 2024 11:40:58 +0000 Subject: [PATCH 6/9] Move referral seeding to migration --- .../src/FamilyHubs.Referral.Api/Program.cs | 2 +- .../StartupExtensions.cs | 17 +- .../20241111112651_SeedData.Designer.cs | 707 ++++++++++++++++++ .../Migrations/20241111112651_SeedData.cs | 45 ++ .../ApplicationDbContextModelSnapshot.cs | 2 +- .../ApplicationDbContextInitialiser.cs | 104 --- .../Repository/ReferralSeedData.cs | 4 - .../Migrations/20241111100056_SeedData.cs | 4 - 8 files changed, 757 insertions(+), 128 deletions(-) create mode 100644 src/service/referral-api/src/FamilyHubs.Referral.Data/Migrations/20241111112651_SeedData.Designer.cs create mode 100644 src/service/referral-api/src/FamilyHubs.Referral.Data/Migrations/20241111112651_SeedData.cs delete mode 100644 src/service/referral-api/src/FamilyHubs.Referral.Data/Repository/ApplicationDbContextInitialiser.cs diff --git a/src/service/referral-api/src/FamilyHubs.Referral.Api/Program.cs b/src/service/referral-api/src/FamilyHubs.Referral.Api/Program.cs index e9ca60a25..9f346d239 100644 --- a/src/service/referral-api/src/FamilyHubs.Referral.Api/Program.cs +++ b/src/service/referral-api/src/FamilyHubs.Referral.Api/Program.cs @@ -27,7 +27,7 @@ public static async Task Main(string[] args) var webApplication = builder.Build(); - await webApplication.ConfigureWebApplication(); + webApplication.ConfigureWebApplication(); await webApplication.RunAsync(); } diff --git a/src/service/referral-api/src/FamilyHubs.Referral.Api/StartupExtensions.cs b/src/service/referral-api/src/FamilyHubs.Referral.Api/StartupExtensions.cs index b73d6274e..34693cb3e 100644 --- a/src/service/referral-api/src/FamilyHubs.Referral.Api/StartupExtensions.cs +++ b/src/service/referral-api/src/FamilyHubs.Referral.Api/StartupExtensions.cs @@ -120,7 +120,6 @@ private static void RegisterAutoMapper(this IServiceCollection services) private static void RegisterAppDbContext(this IServiceCollection services, IConfiguration configuration) { services.AddTransient(); - services.AddTransient(); var connectionString = configuration.GetConnectionString("ReferralConnection"); ArgumentException.ThrowIfNullOrEmpty(connectionString); @@ -187,7 +186,7 @@ public static void ConfigureServices(this IServiceCollection services, IConfigur }); } - public static async Task ConfigureWebApplication(this WebApplication webApplication) + public static void ConfigureWebApplication(this WebApplication webApplication) { webApplication.UseSerilogRequestLogging(); @@ -204,10 +203,10 @@ public static async Task ConfigureWebApplication(this WebApplication webApplicat webApplication.MapFamilyHubsHealthChecks(typeof(StartupExtensions).Assembly); - await RegisterEndPoints(webApplication); + RegisterEndPoints(webApplication); } - private static async Task RegisterEndPoints(this WebApplication app) + private static void RegisterEndPoints(this WebApplication app) { using var scope = app.Services.CreateScope(); @@ -224,15 +223,5 @@ private static async Task RegisterEndPoints(this WebApplication app) throw new InvalidOperationException("MinimalUserAccountEndPoints is not registered"); } userAccountsApi.RegisterUserAccountEndPoints(app); - - try - { - var initialiser = scope.ServiceProvider.GetRequiredService(); - await initialiser.InitialiseAsync(); - } - catch (Exception ex) - { - Log.Error(ex, "An error occurred seeding the DB. {ExceptionMessage}", ex.Message); - } } } diff --git a/src/service/referral-api/src/FamilyHubs.Referral.Data/Migrations/20241111112651_SeedData.Designer.cs b/src/service/referral-api/src/FamilyHubs.Referral.Data/Migrations/20241111112651_SeedData.Designer.cs new file mode 100644 index 000000000..d4e98440b --- /dev/null +++ b/src/service/referral-api/src/FamilyHubs.Referral.Data/Migrations/20241111112651_SeedData.Designer.cs @@ -0,0 +1,707 @@ +// +using System; +using System.ComponentModel.DataAnnotations; +using FamilyHubs.Referral.Data.Repository; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Metadata; +using Microsoft.EntityFrameworkCore.Migrations; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; + +#nullable disable + +namespace FamilyHubs.Referral.Data.Migrations +{ + [DbContext(typeof(ApplicationDbContext))] + [Migration("20241111112651_SeedData")] + partial class SeedData + { + /// + protected override void BuildTargetModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder + .HasAnnotation("ProductVersion", "8.0.8") + .HasAnnotation("Relational:MaxIdentifierLength", 128); + + SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder); + + modelBuilder.Entity("FamilyHubs.Referral.Data.Entities.Metrics.ConnectionRequestsSentMetric", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("ConnectionRequestId") + .HasColumnType("bigint"); + + b.Property("ConnectionRequestReferenceCode") + .HasColumnType("nchar(6)"); + + b.Property("Created") + .IsRequired() + .HasColumnType("datetime2"); + + b.Property("CreatedBy") + .IsRequired() + .HasMaxLength(512) + .HasColumnType("nvarchar(512)") + .HasAnnotation("Microsoft.EntityFrameworkCore.DataEncryption.IsEncrypted", true) + .HasAnnotation("Microsoft.EntityFrameworkCore.DataEncryption.StorageFormat", StorageFormat.Default); + + b.Property("HttpResponseCode") + .HasColumnType("smallint"); + + b.Property("LaOrganisationId") + .HasColumnType("bigint"); + + b.Property("LastModified") + .HasColumnType("datetime2"); + + b.Property("LastModifiedBy") + .HasMaxLength(512) + .HasColumnType("nvarchar(512)") + .HasAnnotation("Microsoft.EntityFrameworkCore.DataEncryption.IsEncrypted", true) + .HasAnnotation("Microsoft.EntityFrameworkCore.DataEncryption.StorageFormat", StorageFormat.Default); + + b.Property("RequestCorrelationId") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("RequestTimestamp") + .HasColumnType("datetime2"); + + b.Property("ResponseTimestamp") + .HasColumnType("datetime2"); + + b.Property("UserAccountId") + .HasColumnType("bigint"); + + b.Property("VcsOrganisationId") + .HasColumnType("bigint"); + + b.HasKey("Id"); + + b.HasIndex("RequestCorrelationId") + .IsUnique(); + + b.ToTable("ConnectionRequestsSentMetric"); + }); + + modelBuilder.Entity("FamilyHubs.Referral.Data.Entities.Organisation", b => + { + b.Property("Id") + .HasColumnType("bigint"); + + b.Property("Created") + .IsRequired() + .HasColumnType("datetime2"); + + b.Property("CreatedBy") + .IsRequired() + .HasMaxLength(512) + .HasColumnType("nvarchar(512)") + .HasAnnotation("Microsoft.EntityFrameworkCore.DataEncryption.IsEncrypted", true) + .HasAnnotation("Microsoft.EntityFrameworkCore.DataEncryption.StorageFormat", StorageFormat.Default); + + b.Property("Description") + .HasColumnType("nvarchar(max)"); + + b.Property("LastModified") + .HasColumnType("datetime2"); + + b.Property("LastModifiedBy") + .HasMaxLength(512) + .HasColumnType("nvarchar(512)") + .HasAnnotation("Microsoft.EntityFrameworkCore.DataEncryption.IsEncrypted", true) + .HasAnnotation("Microsoft.EntityFrameworkCore.DataEncryption.StorageFormat", StorageFormat.Default); + + b.Property("Name") + .IsRequired() + .HasMaxLength(256) + .HasColumnType("nvarchar(256)"); + + b.HasKey("Id"); + + b.ToTable("Organisations"); + }); + + modelBuilder.Entity("FamilyHubs.Referral.Data.Entities.Recipient", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("AddressLine1") + .HasColumnType("nvarchar(max)") + .HasAnnotation("Microsoft.EntityFrameworkCore.DataEncryption.IsEncrypted", true) + .HasAnnotation("Microsoft.EntityFrameworkCore.DataEncryption.StorageFormat", StorageFormat.Default); + + b.Property("AddressLine2") + .HasColumnType("nvarchar(max)") + .HasAnnotation("Microsoft.EntityFrameworkCore.DataEncryption.IsEncrypted", true) + .HasAnnotation("Microsoft.EntityFrameworkCore.DataEncryption.StorageFormat", StorageFormat.Default); + + b.Property("County") + .HasColumnType("nvarchar(max)") + .HasAnnotation("Microsoft.EntityFrameworkCore.DataEncryption.IsEncrypted", true) + .HasAnnotation("Microsoft.EntityFrameworkCore.DataEncryption.StorageFormat", StorageFormat.Default); + + b.Property("Created") + .IsRequired() + .HasColumnType("datetime2"); + + b.Property("CreatedBy") + .IsRequired() + .HasMaxLength(512) + .HasColumnType("nvarchar(512)") + .HasAnnotation("Microsoft.EntityFrameworkCore.DataEncryption.IsEncrypted", true) + .HasAnnotation("Microsoft.EntityFrameworkCore.DataEncryption.StorageFormat", StorageFormat.Default); + + b.Property("Email") + .HasMaxLength(512) + .HasColumnType("nvarchar(512)") + .HasAnnotation("Microsoft.EntityFrameworkCore.DataEncryption.IsEncrypted", true) + .HasAnnotation("Microsoft.EntityFrameworkCore.DataEncryption.StorageFormat", StorageFormat.Default); + + b.Property("LastModified") + .HasColumnType("datetime2"); + + b.Property("LastModifiedBy") + .HasMaxLength(512) + .HasColumnType("nvarchar(512)") + .HasAnnotation("Microsoft.EntityFrameworkCore.DataEncryption.IsEncrypted", true) + .HasAnnotation("Microsoft.EntityFrameworkCore.DataEncryption.StorageFormat", StorageFormat.Default); + + b.Property("Name") + .IsRequired() + .HasMaxLength(512) + .HasColumnType("nvarchar(512)") + .HasAnnotation("Microsoft.EntityFrameworkCore.DataEncryption.IsEncrypted", true) + .HasAnnotation("Microsoft.EntityFrameworkCore.DataEncryption.StorageFormat", StorageFormat.Default); + + b.Property("PostCode") + .HasColumnType("nvarchar(max)") + .HasAnnotation("Microsoft.EntityFrameworkCore.DataEncryption.IsEncrypted", true) + .HasAnnotation("Microsoft.EntityFrameworkCore.DataEncryption.StorageFormat", StorageFormat.Default); + + b.Property("Telephone") + .HasColumnType("nvarchar(max)") + .HasAnnotation("Microsoft.EntityFrameworkCore.DataEncryption.IsEncrypted", true) + .HasAnnotation("Microsoft.EntityFrameworkCore.DataEncryption.StorageFormat", StorageFormat.Default); + + b.Property("TextPhone") + .HasColumnType("nvarchar(max)") + .HasAnnotation("Microsoft.EntityFrameworkCore.DataEncryption.IsEncrypted", true) + .HasAnnotation("Microsoft.EntityFrameworkCore.DataEncryption.StorageFormat", StorageFormat.Default); + + b.Property("TownOrCity") + .HasColumnType("nvarchar(max)") + .HasAnnotation("Microsoft.EntityFrameworkCore.DataEncryption.IsEncrypted", true) + .HasAnnotation("Microsoft.EntityFrameworkCore.DataEncryption.StorageFormat", StorageFormat.Default); + + b.HasKey("Id"); + + b.ToTable("Recipients"); + }); + + modelBuilder.Entity("FamilyHubs.Referral.Data.Entities.Referral", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("Created") + .IsRequired() + .HasColumnType("datetime2"); + + b.Property("CreatedBy") + .IsRequired() + .HasMaxLength(512) + .HasColumnType("nvarchar(512)") + .HasAnnotation("Microsoft.EntityFrameworkCore.DataEncryption.IsEncrypted", true) + .HasAnnotation("Microsoft.EntityFrameworkCore.DataEncryption.StorageFormat", StorageFormat.Default); + + b.Property("EngageWithFamily") + .IsRequired() + .HasColumnType("nvarchar(max)") + .HasAnnotation("Microsoft.EntityFrameworkCore.DataEncryption.IsEncrypted", true) + .HasAnnotation("Microsoft.EntityFrameworkCore.DataEncryption.StorageFormat", StorageFormat.Default); + + b.Property("LastModified") + .HasColumnType("datetime2"); + + b.Property("LastModifiedBy") + .HasMaxLength(512) + .HasColumnType("nvarchar(512)") + .HasAnnotation("Microsoft.EntityFrameworkCore.DataEncryption.IsEncrypted", true) + .HasAnnotation("Microsoft.EntityFrameworkCore.DataEncryption.StorageFormat", StorageFormat.Default); + + b.Property("ReasonForDecliningSupport") + .HasColumnType("nvarchar(max)") + .HasAnnotation("Microsoft.EntityFrameworkCore.DataEncryption.IsEncrypted", true) + .HasAnnotation("Microsoft.EntityFrameworkCore.DataEncryption.StorageFormat", StorageFormat.Default); + + b.Property("ReasonForSupport") + .IsRequired() + .HasColumnType("nvarchar(max)") + .HasAnnotation("Microsoft.EntityFrameworkCore.DataEncryption.IsEncrypted", true) + .HasAnnotation("Microsoft.EntityFrameworkCore.DataEncryption.StorageFormat", StorageFormat.Default); + + b.Property("RecipientId") + .HasColumnType("bigint"); + + b.Property("ReferralServiceId") + .HasColumnType("bigint"); + + b.Property("ReferrerTelephone") + .HasColumnType("nvarchar(max)"); + + b.Property("StatusId") + .HasColumnType("tinyint"); + + b.Property("UserAccountId") + .HasColumnType("bigint"); + + b.HasKey("Id"); + + b.HasIndex("RecipientId"); + + b.HasIndex("ReferralServiceId"); + + b.HasIndex("StatusId"); + + b.HasIndex("UserAccountId"); + + b.ToTable("Referrals"); + }); + + modelBuilder.Entity("FamilyHubs.Referral.Data.Entities.ReferralService", b => + { + b.Property("Id") + .HasColumnType("bigint"); + + b.Property("Created") + .IsRequired() + .HasColumnType("datetime2"); + + b.Property("CreatedBy") + .IsRequired() + .HasMaxLength(512) + .HasColumnType("nvarchar(512)") + .HasAnnotation("Microsoft.EntityFrameworkCore.DataEncryption.IsEncrypted", true) + .HasAnnotation("Microsoft.EntityFrameworkCore.DataEncryption.StorageFormat", StorageFormat.Default); + + b.Property("Description") + .HasColumnType("nvarchar(max)"); + + b.Property("LastModified") + .HasColumnType("datetime2"); + + b.Property("LastModifiedBy") + .HasMaxLength(512) + .HasColumnType("nvarchar(512)") + .HasAnnotation("Microsoft.EntityFrameworkCore.DataEncryption.IsEncrypted", true) + .HasAnnotation("Microsoft.EntityFrameworkCore.DataEncryption.StorageFormat", StorageFormat.Default); + + b.Property("Name") + .IsRequired() + .HasMaxLength(256) + .HasColumnType("nvarchar(256)"); + + b.Property("OrganizationId") + .HasColumnType("bigint"); + + b.Property("Url") + .HasColumnType("nvarchar(max)"); + + b.HasKey("Id"); + + b.HasIndex("OrganizationId"); + + b.ToTable("ReferralServices"); + }); + + modelBuilder.Entity("FamilyHubs.Referral.Data.Entities.Role", b => + { + b.Property("Id") + .HasColumnType("tinyint"); + + b.Property("Created") + .IsRequired() + .HasColumnType("datetime2"); + + b.Property("CreatedBy") + .IsRequired() + .HasMaxLength(512) + .HasColumnType("nvarchar(512)") + .HasAnnotation("Microsoft.EntityFrameworkCore.DataEncryption.IsEncrypted", true) + .HasAnnotation("Microsoft.EntityFrameworkCore.DataEncryption.StorageFormat", StorageFormat.Default); + + b.Property("Description") + .HasColumnType("nvarchar(max)"); + + b.Property("LastModified") + .HasColumnType("datetime2"); + + b.Property("LastModifiedBy") + .HasMaxLength(512) + .HasColumnType("nvarchar(512)") + .HasAnnotation("Microsoft.EntityFrameworkCore.DataEncryption.IsEncrypted", true) + .HasAnnotation("Microsoft.EntityFrameworkCore.DataEncryption.StorageFormat", StorageFormat.Default); + + b.Property("Name") + .IsRequired() + .HasMaxLength(256) + .HasColumnType("nvarchar(256)"); + + b.HasKey("Id"); + + b.ToTable("Roles"); + }); + + modelBuilder.Entity("FamilyHubs.Referral.Data.Entities.Status", b => + { + b.Property("Id") + .HasColumnType("tinyint"); + + b.Property("Created") + .IsRequired() + .HasColumnType("datetime2"); + + b.Property("CreatedBy") + .IsRequired() + .HasMaxLength(512) + .HasColumnType("nvarchar(512)") + .HasAnnotation("Microsoft.EntityFrameworkCore.DataEncryption.IsEncrypted", true) + .HasAnnotation("Microsoft.EntityFrameworkCore.DataEncryption.StorageFormat", StorageFormat.Default); + + b.Property("LastModified") + .HasColumnType("datetime2"); + + b.Property("LastModifiedBy") + .HasMaxLength(512) + .HasColumnType("nvarchar(512)") + .HasAnnotation("Microsoft.EntityFrameworkCore.DataEncryption.IsEncrypted", true) + .HasAnnotation("Microsoft.EntityFrameworkCore.DataEncryption.StorageFormat", StorageFormat.Default); + + b.Property("Name") + .IsRequired() + .HasMaxLength(256) + .HasColumnType("nvarchar(256)"); + + b.Property("SecondrySortOrder") + .HasColumnType("tinyint"); + + b.Property("SortOrder") + .HasColumnType("tinyint"); + + b.HasKey("Id"); + + b.ToTable("Statuses"); + }); + + modelBuilder.Entity("FamilyHubs.Referral.Data.Entities.UserAccount", b => + { + b.Property("Id") + .HasColumnType("bigint"); + + b.Property("Created") + .IsRequired() + .HasColumnType("datetime2"); + + b.Property("CreatedBy") + .IsRequired() + .HasMaxLength(512) + .HasColumnType("nvarchar(512)") + .HasAnnotation("Microsoft.EntityFrameworkCore.DataEncryption.IsEncrypted", true) + .HasAnnotation("Microsoft.EntityFrameworkCore.DataEncryption.StorageFormat", StorageFormat.Default); + + b.Property("EmailAddress") + .IsRequired() + .HasColumnType("nvarchar(max)") + .HasAnnotation("Microsoft.EntityFrameworkCore.DataEncryption.IsEncrypted", true) + .HasAnnotation("Microsoft.EntityFrameworkCore.DataEncryption.StorageFormat", StorageFormat.Default); + + b.Property("LastModified") + .HasColumnType("datetime2"); + + b.Property("LastModifiedBy") + .HasMaxLength(512) + .HasColumnType("nvarchar(512)") + .HasAnnotation("Microsoft.EntityFrameworkCore.DataEncryption.IsEncrypted", true) + .HasAnnotation("Microsoft.EntityFrameworkCore.DataEncryption.StorageFormat", StorageFormat.Default); + + b.Property("Name") + .IsRequired() + .HasMaxLength(512) + .HasColumnType("nvarchar(512)") + .HasAnnotation("Microsoft.EntityFrameworkCore.DataEncryption.IsEncrypted", true) + .HasAnnotation("Microsoft.EntityFrameworkCore.DataEncryption.StorageFormat", StorageFormat.Default); + + b.Property("PhoneNumber") + .HasColumnType("nvarchar(max)") + .HasAnnotation("Microsoft.EntityFrameworkCore.DataEncryption.IsEncrypted", true) + .HasAnnotation("Microsoft.EntityFrameworkCore.DataEncryption.StorageFormat", StorageFormat.Default); + + b.Property("Team") + .HasColumnType("nvarchar(max)") + .HasAnnotation("Microsoft.EntityFrameworkCore.DataEncryption.IsEncrypted", true) + .HasAnnotation("Microsoft.EntityFrameworkCore.DataEncryption.StorageFormat", StorageFormat.Default); + + b.HasKey("Id"); + + b.ToTable("UserAccounts"); + }); + + modelBuilder.Entity("FamilyHubs.Referral.Data.Entities.UserAccountOrganisation", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("Created") + .IsRequired() + .HasColumnType("datetime2"); + + b.Property("CreatedBy") + .IsRequired() + .HasMaxLength(512) + .HasColumnType("nvarchar(512)") + .HasAnnotation("Microsoft.EntityFrameworkCore.DataEncryption.IsEncrypted", true) + .HasAnnotation("Microsoft.EntityFrameworkCore.DataEncryption.StorageFormat", StorageFormat.Default); + + b.Property("LastModified") + .HasColumnType("datetime2"); + + b.Property("LastModifiedBy") + .HasMaxLength(512) + .HasColumnType("nvarchar(512)") + .HasAnnotation("Microsoft.EntityFrameworkCore.DataEncryption.IsEncrypted", true) + .HasAnnotation("Microsoft.EntityFrameworkCore.DataEncryption.StorageFormat", StorageFormat.Default); + + b.Property("OrganisationId") + .HasColumnType("bigint"); + + b.Property("UserAccountId") + .HasColumnType("bigint"); + + b.HasKey("Id"); + + b.HasIndex("OrganisationId"); + + b.HasIndex("UserAccountId"); + + b.ToTable("UserAccountOrganisations"); + }); + + modelBuilder.Entity("FamilyHubs.Referral.Data.Entities.UserAccountRole", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("Created") + .IsRequired() + .HasColumnType("datetime2"); + + b.Property("CreatedBy") + .IsRequired() + .HasMaxLength(512) + .HasColumnType("nvarchar(512)") + .HasAnnotation("Microsoft.EntityFrameworkCore.DataEncryption.IsEncrypted", true) + .HasAnnotation("Microsoft.EntityFrameworkCore.DataEncryption.StorageFormat", StorageFormat.Default); + + b.Property("LastModified") + .HasColumnType("datetime2"); + + b.Property("LastModifiedBy") + .HasMaxLength(512) + .HasColumnType("nvarchar(512)") + .HasAnnotation("Microsoft.EntityFrameworkCore.DataEncryption.IsEncrypted", true) + .HasAnnotation("Microsoft.EntityFrameworkCore.DataEncryption.StorageFormat", StorageFormat.Default); + + b.Property("RoleId") + .HasColumnType("tinyint"); + + b.Property("UserAccountId") + .HasColumnType("bigint"); + + b.HasKey("Id"); + + b.HasIndex("RoleId"); + + b.HasIndex("UserAccountId"); + + b.ToTable("UserAccountRoles"); + }); + + modelBuilder.Entity("FamilyHubs.Referral.Data.Entities.UserAccountService", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("Created") + .IsRequired() + .HasColumnType("datetime2"); + + b.Property("CreatedBy") + .IsRequired() + .HasMaxLength(512) + .HasColumnType("nvarchar(512)") + .HasAnnotation("Microsoft.EntityFrameworkCore.DataEncryption.IsEncrypted", true) + .HasAnnotation("Microsoft.EntityFrameworkCore.DataEncryption.StorageFormat", StorageFormat.Default); + + b.Property("LastModified") + .HasColumnType("datetime2"); + + b.Property("LastModifiedBy") + .HasMaxLength(512) + .HasColumnType("nvarchar(512)") + .HasAnnotation("Microsoft.EntityFrameworkCore.DataEncryption.IsEncrypted", true) + .HasAnnotation("Microsoft.EntityFrameworkCore.DataEncryption.StorageFormat", StorageFormat.Default); + + b.Property("ReferralServiceId") + .HasColumnType("bigint"); + + b.Property("UserAccountId") + .HasColumnType("bigint"); + + b.HasKey("Id"); + + b.HasIndex("ReferralServiceId"); + + b.HasIndex("UserAccountId"); + + b.ToTable("UserAccountServices"); + }); + + modelBuilder.Entity("FamilyHubs.Referral.Data.Entities.Referral", b => + { + b.HasOne("FamilyHubs.Referral.Data.Entities.Recipient", "Recipient") + .WithMany() + .HasForeignKey("RecipientId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("FamilyHubs.Referral.Data.Entities.ReferralService", "ReferralService") + .WithMany() + .HasForeignKey("ReferralServiceId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("FamilyHubs.Referral.Data.Entities.Status", "Status") + .WithMany() + .HasForeignKey("StatusId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("FamilyHubs.Referral.Data.Entities.UserAccount", "UserAccount") + .WithMany() + .HasForeignKey("UserAccountId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Recipient"); + + b.Navigation("ReferralService"); + + b.Navigation("Status"); + + b.Navigation("UserAccount"); + }); + + modelBuilder.Entity("FamilyHubs.Referral.Data.Entities.ReferralService", b => + { + b.HasOne("FamilyHubs.Referral.Data.Entities.Organisation", "Organisation") + .WithMany() + .HasForeignKey("OrganizationId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Organisation"); + }); + + modelBuilder.Entity("FamilyHubs.Referral.Data.Entities.UserAccountOrganisation", b => + { + b.HasOne("FamilyHubs.Referral.Data.Entities.Organisation", "Organisation") + .WithMany() + .HasForeignKey("OrganisationId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("FamilyHubs.Referral.Data.Entities.UserAccount", "UserAccount") + .WithMany("OrganisationUserAccounts") + .HasForeignKey("UserAccountId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Organisation"); + + b.Navigation("UserAccount"); + }); + + modelBuilder.Entity("FamilyHubs.Referral.Data.Entities.UserAccountRole", b => + { + b.HasOne("FamilyHubs.Referral.Data.Entities.Role", "Role") + .WithMany() + .HasForeignKey("RoleId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("FamilyHubs.Referral.Data.Entities.UserAccount", "UserAccount") + .WithMany("UserAccountRoles") + .HasForeignKey("UserAccountId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Role"); + + b.Navigation("UserAccount"); + }); + + modelBuilder.Entity("FamilyHubs.Referral.Data.Entities.UserAccountService", b => + { + b.HasOne("FamilyHubs.Referral.Data.Entities.ReferralService", "ReferralService") + .WithMany() + .HasForeignKey("ReferralServiceId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("FamilyHubs.Referral.Data.Entities.UserAccount", "UserAccount") + .WithMany("ServiceUserAccounts") + .HasForeignKey("UserAccountId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("ReferralService"); + + b.Navigation("UserAccount"); + }); + + modelBuilder.Entity("FamilyHubs.Referral.Data.Entities.UserAccount", b => + { + b.Navigation("OrganisationUserAccounts"); + + b.Navigation("ServiceUserAccounts"); + + b.Navigation("UserAccountRoles"); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/src/service/referral-api/src/FamilyHubs.Referral.Data/Migrations/20241111112651_SeedData.cs b/src/service/referral-api/src/FamilyHubs.Referral.Data/Migrations/20241111112651_SeedData.cs new file mode 100644 index 000000000..bf6604d64 --- /dev/null +++ b/src/service/referral-api/src/FamilyHubs.Referral.Data/Migrations/20241111112651_SeedData.cs @@ -0,0 +1,45 @@ +using Microsoft.EntityFrameworkCore.Migrations; + +#nullable disable + +namespace FamilyHubs.Referral.Data.Migrations +{ + /// + public partial class SeedData : Migration + { + /// + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.Sql(""" + IF NOT EXISTS (SELECT * FROM Statuses) + BEGIN + INSERT INTO Statuses (Id, Name, SortOrder, SecondrySortOrder) VALUES + (1, 'New', 0, 1), + (2, 'Opened', 1, 1), + (3, 'Accepted', 2, 2), + (4, 'Declined', 3, 0); + END; + """); + + migrationBuilder.Sql(""" + IF NOT EXISTS (SELECT * FROM Roles) + BEGIN + INSERT INTO Roles (Id, Name, Description) VALUES + (1, 'DfeAdmin', 'DfE Administrator'), + (2, 'LaManager', 'Local Authority Manager'), + (3, 'VcsManager', 'VCS Manager'), + (4, 'LaProfessional', 'Local Authority Professional'), + (5, 'VcsProfessional', 'VCS Professional'), + (6, 'LaDualRole', 'Local Authority Dual Role'), + (7, 'VcsDualRole', 'VCS Dual Role'); + END; + """); + } + + /// + protected override void Down(MigrationBuilder migrationBuilder) + { + // Not supported + } + } +} diff --git a/src/service/referral-api/src/FamilyHubs.Referral.Data/Migrations/ApplicationDbContextModelSnapshot.cs b/src/service/referral-api/src/FamilyHubs.Referral.Data/Migrations/ApplicationDbContextModelSnapshot.cs index 10a26a58e..57c8d1f1a 100644 --- a/src/service/referral-api/src/FamilyHubs.Referral.Data/Migrations/ApplicationDbContextModelSnapshot.cs +++ b/src/service/referral-api/src/FamilyHubs.Referral.Data/Migrations/ApplicationDbContextModelSnapshot.cs @@ -18,7 +18,7 @@ protected override void BuildModel(ModelBuilder modelBuilder) { #pragma warning disable 612, 618 modelBuilder - .HasAnnotation("ProductVersion", "7.0.20") + .HasAnnotation("ProductVersion", "8.0.8") .HasAnnotation("Relational:MaxIdentifierLength", 128); SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder); diff --git a/src/service/referral-api/src/FamilyHubs.Referral.Data/Repository/ApplicationDbContextInitialiser.cs b/src/service/referral-api/src/FamilyHubs.Referral.Data/Repository/ApplicationDbContextInitialiser.cs deleted file mode 100644 index fb2cc93e3..000000000 --- a/src/service/referral-api/src/FamilyHubs.Referral.Data/Repository/ApplicationDbContextInitialiser.cs +++ /dev/null @@ -1,104 +0,0 @@ -using Microsoft.EntityFrameworkCore; - -namespace FamilyHubs.Referral.Data.Repository; - -public class ApplicationDbContextInitialiser -{ - private readonly ApplicationDbContext _context; - - public ApplicationDbContextInitialiser(ApplicationDbContext context) - { - _context = context; - } - - public async Task InitialiseAsync() - { - await SeedAsync(); - } - - private async Task SeedAsync() - { - var statuses = ReferralSeedData.SeedStatuses(); - if (!await _context.Statuses.AnyAsync()) - { - _context.Statuses.AddRange(statuses); - - await _context.SaveChangesAsync(); - } - else - { - foreach (var seedStatus in statuses) - { - var dbStatus = await _context.Statuses.FirstOrDefaultAsync(x => x.Name == seedStatus.Name); - if (!seedStatus.Equals(dbStatus)) - { - if (dbStatus == null) - { - dbStatus = seedStatus; - } - else - { - dbStatus.Name = seedStatus.Name; - dbStatus.SortOrder = seedStatus.SortOrder; - dbStatus.SecondrySortOrder = seedStatus.SecondrySortOrder; - } - - _context.Statuses.Update(dbStatus); - } - } - - await _context.SaveChangesAsync(); - } - - var roles = ReferralSeedData.SeedRoles(); - if (!await _context.Roles.AnyAsync()) - { - _context.Roles.AddRange(roles); - - await _context.SaveChangesAsync(); - } - else - { - foreach (var seedRole in roles) - { - var dbRole = await _context.Roles.FirstOrDefaultAsync(x => x.Name == seedRole.Name); - if (!seedRole.Equals(dbRole)) - { - if (dbRole == null) - { - dbRole = seedRole; - } - else - { - dbRole.Name = seedRole.Name; - dbRole.Description = seedRole.Description; - - } - - _context.Roles.Update(dbRole); - } - } - - await _context.SaveChangesAsync(); - } - - - if (_context.Database.IsSqlite() && !await _context.Referrals.AnyAsync()) - { - var referrals = ReferralSeedData.SeedReferral(); - - foreach (Entities.Referral referral in referrals) - { - var status = await _context.Statuses.SingleOrDefaultAsync(x => x.Name == referral.Status.Name); - if (status != null) - { - referral.Status = status; - } - } - - _context.Referrals.AddRange(referrals); - - await _context.SaveChangesAsync(); - } - } -} diff --git a/src/service/referral-api/src/FamilyHubs.Referral.Data/Repository/ReferralSeedData.cs b/src/service/referral-api/src/FamilyHubs.Referral.Data/Repository/ReferralSeedData.cs index 6a600e29d..ed3f19c76 100644 --- a/src/service/referral-api/src/FamilyHubs.Referral.Data/Repository/ReferralSeedData.cs +++ b/src/service/referral-api/src/FamilyHubs.Referral.Data/Repository/ReferralSeedData.cs @@ -4,10 +4,6 @@ namespace FamilyHubs.Referral.Data.Repository; public static class ReferralSeedData { -#if SeedJasonService - const string JsonService = "{\"Id\":\"ba1cca90-b02a-4a0b-afa0-d8aed1083c0d\",\"Name\":\"Test County Council\",\"Description\":\"Test County Council\",\"Logo\":null,\"Uri\":\"https://www.test.gov.uk/\",\"Url\":\"https://www.test.gov.uk/\",\"Services\":[{\"Id\":\"c1b5dd80-7506-4424-9711-fe175fa13eb8\",\"Name\":\"Test Organisation for Children with Tracheostomies\",\"Description\":\"Test Organisation for for Children with Tracheostomies is a national self help group operating as a registered charity and is run by parents of children with a tracheostomy and by people who sympathise with the needs of such families. ACT as an organisation is non profit making, it links groups and individual members throughout Great Britain and Northern Ireland.\",\"Accreditations\":null,\"Assured_date\":null,\"Attending_access\":null,\"Attending_type\":null,\"Deliverable_type\":null,\"Status\":\"active\",\"Url\":\"www.testservice.com\",\"Email\":\"support@testservice.com\",\"Fees\":null,\"ServiceDelivery\":[{\"Id\":\"14db2aef-9292-4afc-be09-5f6f43765938\",\"ServiceDelivery\":2}],\"Eligibilities\":[{\"Id\":\"Test9109Children\",\"Eligibility\":\"\",\"Maximum_age\":0,\"Minimum_age\":13}],\"Contacts\":[{\"Id\":\"5eac5cb6-cc7e-444d-a29b-76ccb85be866\",\"Title\":\"Service\",\"Name\":\"\",\"Phones\":[{\"Id\":\"1568\",\"Number\":\"01827 65779\"}]}],\"Cost_options\":[],\"Languages\":[{\"Id\":\"442a06cd-aa14-4ea3-9f11-b45c1bc4861f\",\"Language\":\"English\"}],\"Service_areas\":[{\"Id\":\"68af19cd-bc81-4585-99a2-85a2b0d62a1d\",\"Service_area\":\"National\",\"Extent\":null,\"Uri\":\"http://statistics.data.gov.uk/id/statistical-geography/K02000001\"}],\"Service_at_locations\":[{\"Id\":\"Test1749\",\"Location\":{\"Id\":\"a878aadc-6097-4a0f-b3e1-77fd4511175d\",\"Name\":\"\",\"Description\":\"\",\"Latitude\":52.6312,\"Longitude\":-1.66526,\"Physical_addresses\":[{\"Id\":\"1076aaa8-f99d-4395-8e4f-c0dde8095085\",\"Address_1\":\"75 Sheepcote Lane\",\"City\":\", Stathe, Tamworth, Staffordshire, \",\"Postal_code\":\"B77 3JN\",\"Country\":\"England\",\"State_province\":null}]}}],\"Service_taxonomys\":[{\"Id\":\"Test9107\",\"Taxonomy\":{\"Id\":\"Test bccsource:Organisation\",\"Name\":\"Organisation\",\"Vocabulary\":\"Test BCC Data Sources\",\"Parent\":null}},{\"Id\":\"Test9108\",\"Taxonomy\":{\"Id\":\"Test bccprimaryservicetype:38\",\"Name\":\"Support\",\"Vocabulary\":\"Test BCC Primary Services\",\"Parent\":null}},{\"Id\":\"Test9109\",\"Taxonomy\":{\"Id\":\"Test bccagegroup:37\",\"Name\":\"Children\",\"Vocabulary\":\"Test BCC Age Groups\",\"Parent\":null}},{\"Id\":\"Test9110\",\"Taxonomy\":{\"Id\":\"Testbccusergroup:56\",\"Name\":\"Long Term Health Conditions\",\"Vocabulary\":\"Test BCC User Groups\",\"Parent\":null}}]}]}"; -#endif - public static IReadOnlyCollection SeedRoles() { return new List() diff --git a/src/service/service-directory-api/src/FamilyHubs.ServiceDirectory.Data/Migrations/20241111100056_SeedData.cs b/src/service/service-directory-api/src/FamilyHubs.ServiceDirectory.Data/Migrations/20241111100056_SeedData.cs index 83f4de5ff..f1b7e93ae 100644 --- a/src/service/service-directory-api/src/FamilyHubs.ServiceDirectory.Data/Migrations/20241111100056_SeedData.cs +++ b/src/service/service-directory-api/src/FamilyHubs.ServiceDirectory.Data/Migrations/20241111100056_SeedData.cs @@ -110,8 +110,6 @@ public void SeedOrganisations(MigrationBuilder migrationBuilder) migrationBuilder.Sql(""" IF NOT EXISTS (SELECT * FROM Organisations) BEGIN - BEGIN TRANSACTION; - INSERT INTO Organisations (OrganisationType, Name, Description, AdminAreaCode, Uri, Url) VALUES ('LA', 'Bristol County Council', 'Bristol County Council', 'E06000023', 'https://www.bristol.gov.uk/', 'https://www.bristol.gov.uk/'), ('LA', 'Lancashire County Council', 'Lancashire County Council', 'E10000017', 'https://www.lancashire.gov.uk/', 'https://www.lancashire.gov.uk/'), @@ -123,8 +121,6 @@ INSERT INTO Organisations (OrganisationType, Name, Description, AdminAreaCode, U ('LA', 'North East Lincolnshire Council', 'North East Lincolnshire Council', 'E06000012', 'https://www.nelincs.gov.uk/', 'https://www.nelincs.gov.uk/'), ('LA', 'City of Wolverhampton Council', 'City of Wolverhampton Council', 'E08000031', 'https://www.wolverhampton.gov.uk/', 'https://www.wolverhampton.gov.uk/'), ('LA', 'Sheffield City Council', 'Sheffield City Council', 'E08000019', 'https://www.sheffield.gov.uk/', 'https://www.sheffield.gov.uk/'); - - COMMIT; END; """); } From bf42de1f497ecb4f19193cde71ecb37d802ebf76 Mon Sep 17 00:00:00 2001 From: Thomas Cheyney Date: Mon, 11 Nov 2024 12:09:04 +0000 Subject: [PATCH 7/9] Revert redordering in sd core tests --- .../DataIntegrationTestBase.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/service/service-directory-api/tests/FamilyHubs.ServiceDirectory.Core.IntegrationTests/DataIntegrationTestBase.cs b/src/service/service-directory-api/tests/FamilyHubs.ServiceDirectory.Core.IntegrationTests/DataIntegrationTestBase.cs index 6e09f8072..8f0a28a50 100644 --- a/src/service/service-directory-api/tests/FamilyHubs.ServiceDirectory.Core.IntegrationTests/DataIntegrationTestBase.cs +++ b/src/service/service-directory-api/tests/FamilyHubs.ServiceDirectory.Core.IntegrationTests/DataIntegrationTestBase.cs @@ -136,9 +136,9 @@ protected async Task> CreateManyTestServicesQueryTesting() private void InitialiseDatabase() { - TestDbContext.Database.ExecuteSqlRaw($"UPDATE geometry_columns SET srid = {GeoPoint.WGS84} WHERE f_table_name = 'locations';"); TestDbContext.Database.EnsureDeleted(); TestDbContext.Database.EnsureCreated(); + TestDbContext.Database.ExecuteSqlRaw($"UPDATE geometry_columns SET srid = {GeoPoint.WGS84} WHERE f_table_name = 'locations';"); } private ServiceProvider CreateNewServiceProvider() From e678779984dd31d5285d2cc6ace1a540ed61057c Mon Sep 17 00:00:00 2001 From: Thomas Cheyney Date: Mon, 11 Nov 2024 12:17:50 +0000 Subject: [PATCH 8/9] Move OrganisationSeedData back to Data project --- .../Repository}/OrganisationSeedData.cs | 3 +-- .../DataIntegrationTestBase.cs | 3 +++ 2 files changed, 4 insertions(+), 2 deletions(-) rename src/service/service-directory-api/{tests/FamilyHubs.ServiceDirectory.Api.FunctionalTests => src/FamilyHubs.ServiceDirectory.Data/Repository}/OrganisationSeedData.cs (97%) diff --git a/src/service/service-directory-api/tests/FamilyHubs.ServiceDirectory.Api.FunctionalTests/OrganisationSeedData.cs b/src/service/service-directory-api/src/FamilyHubs.ServiceDirectory.Data/Repository/OrganisationSeedData.cs similarity index 97% rename from src/service/service-directory-api/tests/FamilyHubs.ServiceDirectory.Api.FunctionalTests/OrganisationSeedData.cs rename to src/service/service-directory-api/src/FamilyHubs.ServiceDirectory.Data/Repository/OrganisationSeedData.cs index 6995dd5ad..9fbe2bec6 100644 --- a/src/service/service-directory-api/tests/FamilyHubs.ServiceDirectory.Api.FunctionalTests/OrganisationSeedData.cs +++ b/src/service/service-directory-api/src/FamilyHubs.ServiceDirectory.Data/Repository/OrganisationSeedData.cs @@ -1,8 +1,7 @@ using FamilyHubs.ServiceDirectory.Data.Entities; -using FamilyHubs.ServiceDirectory.Data.Repository; using FamilyHubs.ServiceDirectory.Shared.Enums; -namespace FamilyHubs.ServiceDirectory.Api.FunctionalTests; +namespace FamilyHubs.ServiceDirectory.Data.Repository; #pragma warning disable S1075 public class OrganisationSeedData diff --git a/src/service/service-directory-api/tests/FamilyHubs.ServiceDirectory.Core.IntegrationTests/DataIntegrationTestBase.cs b/src/service/service-directory-api/tests/FamilyHubs.ServiceDirectory.Core.IntegrationTests/DataIntegrationTestBase.cs index 8f0a28a50..f10c50658 100644 --- a/src/service/service-directory-api/tests/FamilyHubs.ServiceDirectory.Core.IntegrationTests/DataIntegrationTestBase.cs +++ b/src/service/service-directory-api/tests/FamilyHubs.ServiceDirectory.Core.IntegrationTests/DataIntegrationTestBase.cs @@ -139,6 +139,9 @@ private void InitialiseDatabase() TestDbContext.Database.EnsureDeleted(); TestDbContext.Database.EnsureCreated(); TestDbContext.Database.ExecuteSqlRaw($"UPDATE geometry_columns SET srid = {GeoPoint.WGS84} WHERE f_table_name = 'locations';"); + var seedData = new OrganisationSeedData(TestDbContext); + seedData.SeedTaxonomies(); + seedData.SeedOrganisations(); } private ServiceProvider CreateNewServiceProvider() From 85c29af71eff7dca208ec75c66afc782fbfaf943 Mon Sep 17 00:00:00 2001 From: Thomas Cheyney Date: Mon, 11 Nov 2024 12:38:58 +0000 Subject: [PATCH 9/9] Fix referral migrations --- .../Migrations/20241111112651_SeedData.cs | 26 +++++++++---------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/src/service/referral-api/src/FamilyHubs.Referral.Data/Migrations/20241111112651_SeedData.cs b/src/service/referral-api/src/FamilyHubs.Referral.Data/Migrations/20241111112651_SeedData.cs index bf6604d64..d5747ccbb 100644 --- a/src/service/referral-api/src/FamilyHubs.Referral.Data/Migrations/20241111112651_SeedData.cs +++ b/src/service/referral-api/src/FamilyHubs.Referral.Data/Migrations/20241111112651_SeedData.cs @@ -13,25 +13,25 @@ protected override void Up(MigrationBuilder migrationBuilder) migrationBuilder.Sql(""" IF NOT EXISTS (SELECT * FROM Statuses) BEGIN - INSERT INTO Statuses (Id, Name, SortOrder, SecondrySortOrder) VALUES - (1, 'New', 0, 1), - (2, 'Opened', 1, 1), - (3, 'Accepted', 2, 2), - (4, 'Declined', 3, 0); + INSERT INTO Statuses (Id, Name, SortOrder, SecondrySortOrder, Created, CreatedBy) VALUES + (1, 'New', 0, 1, getutcdate(), 'SYSTEM'), + (2, 'Opened', 1, 1, getutcdate(), 'SYSTEM'), + (3, 'Accepted', 2, 2, getutcdate(), 'SYSTEM'), + (4, 'Declined', 3, 0, getutcdate(), 'SYSTEM'); END; """); migrationBuilder.Sql(""" IF NOT EXISTS (SELECT * FROM Roles) BEGIN - INSERT INTO Roles (Id, Name, Description) VALUES - (1, 'DfeAdmin', 'DfE Administrator'), - (2, 'LaManager', 'Local Authority Manager'), - (3, 'VcsManager', 'VCS Manager'), - (4, 'LaProfessional', 'Local Authority Professional'), - (5, 'VcsProfessional', 'VCS Professional'), - (6, 'LaDualRole', 'Local Authority Dual Role'), - (7, 'VcsDualRole', 'VCS Dual Role'); + INSERT INTO Roles (Id, Name, Description, Created, CreatedBy) VALUES + (1, 'DfeAdmin', 'DfE Administrator', getutcdate(), 'SYSTEM'), + (2, 'LaManager', 'Local Authority Manager', getutcdate(), 'SYSTEM'), + (3, 'VcsManager', 'VCS Manager', getutcdate(), 'SYSTEM'), + (4, 'LaProfessional', 'Local Authority Professional', getutcdate(), 'SYSTEM'), + (5, 'VcsProfessional', 'VCS Professional', getutcdate(), 'SYSTEM'), + (6, 'LaDualRole', 'Local Authority Dual Role', getutcdate(), 'SYSTEM'), + (7, 'VcsDualRole', 'VCS Dual Role', getutcdate(), 'SYSTEM'); END; """); }