You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: Backend/Database/DatabaseSeeder.cs
+32-24Lines changed: 32 additions & 24 deletions
Original file line number
Diff line number
Diff line change
@@ -3,14 +3,15 @@
3
3
usingBackend.Services;
4
4
usingBackend.Utils.DateTime;
5
5
usingMicrosoft.EntityFrameworkCore;
6
+
usingNpgsql;
6
7
7
8
namespaceBackend.Database;
8
9
9
10
/// <summary>
10
11
/// The DatabaseSeeder class is responsible for seeding the database with initial data and ensuring that certain essential settings and groups exist when the application starts. It implements the IHostedService interface, allowing it to run as a background service during the application's startup process. The seeder checks for the existence of specific settings and groups, creating them if they do not already exist, and also ensures that a backup board account is created if there are no existing board members. This helps to ensure that the application has the necessary configuration and data in place for proper functionality from the moment it is launched.
11
12
/// </summary>
12
13
/// <param name="scopeFactory">The factory for creating service scopes.</param>
/// Starts the database seeding process. This method is called when the application starts and is responsible for ensuring that essential settings and groups are present in the database. It creates a new service scope to access the database context and performs checks to create default settings and groups if they do not already exist. Additionally, it ensures that a backup board account is created if there are no existing board members, providing a fallback option for administrative access. The seeding process helps to establish a baseline configuration for the application, allowing it to function correctly from the outset.
@@ -19,43 +20,50 @@ public class DatabaseSeeder(IServiceScopeFactory scopeFactory) : IHostedService
19
20
/// <returns>A task representing the asynchronous operation.</returns>
Copy file name to clipboardExpand all lines: Backend/Program.cs
+3-2Lines changed: 3 additions & 2 deletions
Original file line number
Diff line number
Diff line change
@@ -15,6 +15,7 @@
15
15
usingMicrosoft.AspNetCore.HttpLogging;
16
16
usingSystem.Text;
17
17
usingSystem.Net.Http.Headers;
18
+
usingNpgsql;
18
19
19
20
Env.Load();
20
21
@@ -156,12 +157,12 @@
156
157
157
158
c.SupportNonNullableReferenceTypes();
158
159
});
159
-
stringconnectionstring=Environment.GetEnvironmentVariable("PostgresqlConnectionString")??thrownewInvalidOperationException("PostgresConnectionString environment variable is not set.");
0 commit comments