restructure seed

This commit is contained in:
Aaron Po
2026-01-13 20:10:39 -05:00
parent 7fbdfbf542
commit b5ab6f6893
40 changed files with 1002 additions and 873 deletions

33
DBSeed/Program.cs Normal file
View File

@@ -0,0 +1,33 @@
using DBSeed;
using Microsoft.Data.SqlClient;
try
{
var connectionString = Environment.GetEnvironmentVariable(
"DB_CONNECTION_STRING"
);
if (string.IsNullOrWhiteSpace(connectionString))
throw new InvalidOperationException(
"Environment variable DB_CONNECTION_STRING is not set or is empty."
);
await using var connection = new SqlConnection(connectionString);
await connection.OpenAsync();
Console.WriteLine("Connected to database.");
await LocationSeeder.SeedAsync(connection);
Console.WriteLine("Seeded locations.");
await UserSeeder.SeedAsync(connection);
Console.WriteLine("Seeded users.");
Console.WriteLine("Seed completed successfully.");
return 0;
}
catch (Exception ex)
{
Console.Error.WriteLine("Seed failed:");
Console.Error.WriteLine(ex);
return 1;
}