mirror of
https://github.com/aaronpo97/the-biergarten-app.git
synced 2026-02-16 10:42:08 +00:00
Update seeds
This commit is contained in:
15
.idea/.idea.biergarten/.idea/.gitignore
generated
vendored
15
.idea/.idea.biergarten/.idea/.gitignore
generated
vendored
@@ -1,15 +0,0 @@
|
|||||||
# Default ignored files
|
|
||||||
/shelf/
|
|
||||||
/workspace.xml
|
|
||||||
# Rider ignored files
|
|
||||||
/.idea.biergarten.iml
|
|
||||||
/contentModel.xml
|
|
||||||
/modules.xml
|
|
||||||
/projectSettingsUpdater.xml
|
|
||||||
# Ignored default folder with query files
|
|
||||||
/queries/
|
|
||||||
# Datasource local storage ignored files
|
|
||||||
/dataSources/
|
|
||||||
/dataSources.local.xml
|
|
||||||
# Editor-based HTTP Client requests
|
|
||||||
/httpRequests/
|
|
||||||
1
.idea/.idea.biergarten/.idea/.name
generated
1
.idea/.idea.biergarten/.idea/.name
generated
@@ -1 +0,0 @@
|
|||||||
biergarten
|
|
||||||
24
.idea/.idea.biergarten/.idea/dataSources.xml
generated
24
.idea/.idea.biergarten/.idea/dataSources.xml
generated
@@ -1,24 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<project version="4">
|
|
||||||
<component name="DataSourceManagerImpl" format="xml" multifile-model="true">
|
|
||||||
<data-source
|
|
||||||
source="LOCAL"
|
|
||||||
name="Biergarten@localhost"
|
|
||||||
uuid="7eb1584d-925b-46f8-a3a2-a73152a2d625"
|
|
||||||
>
|
|
||||||
<driver-ref>sqlserver.jb</driver-ref>
|
|
||||||
<synchronize>true</synchronize>
|
|
||||||
<jdbc-driver>com.jetbrains.jdbc.sqlserver.SqlServerDriver</jdbc-driver>
|
|
||||||
<jdbc-url>Server=localhost;Database=Biergarten;TrustServerCertificate=True;</jdbc-url>
|
|
||||||
<jdbc-additional-properties>
|
|
||||||
<property name="com.intellij.clouds.kubernetes.db.host.port" />
|
|
||||||
<property
|
|
||||||
name="com.intellij.clouds.kubernetes.db.enabled"
|
|
||||||
value="false"
|
|
||||||
/>
|
|
||||||
<property name="com.intellij.clouds.kubernetes.db.container.port" />
|
|
||||||
</jdbc-additional-properties>
|
|
||||||
<working-dir>$ProjectFileDir$</working-dir>
|
|
||||||
</data-source>
|
|
||||||
</component>
|
|
||||||
</project>
|
|
||||||
17
.idea/.idea.biergarten/.idea/data_source_mapping.xml
generated
17
.idea/.idea.biergarten/.idea/data_source_mapping.xml
generated
@@ -1,17 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<project version="4">
|
|
||||||
<component name="DataSourcePerFileMappings">
|
|
||||||
<file
|
|
||||||
url="file://$APPLICATION_CONFIG_DIR$/consoles/db/7eb1584d-925b-46f8-a3a2-a73152a2d625/console.sql"
|
|
||||||
value="7eb1584d-925b-46f8-a3a2-a73152a2d625"
|
|
||||||
/>
|
|
||||||
<file
|
|
||||||
url="file://$PROJECT_DIR$/DataLayer/scripts/01-schema/schema.sql"
|
|
||||||
value="7eb1584d-925b-46f8-a3a2-a73152a2d625"
|
|
||||||
/>
|
|
||||||
<file
|
|
||||||
url="file://$PROJECT_DIR$/DataLayer/scripts/03-crud/02-UserCredential/USP_AddUserCredential.sql"
|
|
||||||
value="7eb1584d-925b-46f8-a3a2-a73152a2d625"
|
|
||||||
/>
|
|
||||||
</component>
|
|
||||||
</project>
|
|
||||||
8
.idea/.idea.biergarten/.idea/indexLayout.xml
generated
8
.idea/.idea.biergarten/.idea/indexLayout.xml
generated
@@ -1,8 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<project version="4">
|
|
||||||
<component name="UserContentModel">
|
|
||||||
<attachedFolders />
|
|
||||||
<explicitIncludes />
|
|
||||||
<explicitExcludes />
|
|
||||||
</component>
|
|
||||||
</project>
|
|
||||||
15
.idea/.idea.biergarten/.idea/sqldialects.xml
generated
15
.idea/.idea.biergarten/.idea/sqldialects.xml
generated
@@ -1,15 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<project version="4">
|
|
||||||
<component name="SqlDialectMappings">
|
|
||||||
<file url="file://$PROJECT_DIR$/DataLayer/scripts/01-schema/schema.sql" dialect="TSQL" />
|
|
||||||
<file url="file://$PROJECT_DIR$/DataLayer/scripts/02-functions/UDF_GetCountryIdByCode.sql" dialect="TSQL" />
|
|
||||||
<file url="file://$PROJECT_DIR$/DataLayer/scripts/02-functions/UDF_GetStateProvinceIdByCode.sql" dialect="TSQL" />
|
|
||||||
<file url="file://$PROJECT_DIR$/DataLayer/scripts/03-crud/01-UserAccount/USP_CreateUserAccount.sql" dialect="TSQL" />
|
|
||||||
<file url="file://$PROJECT_DIR$/DataLayer/scripts/03-crud/01-UserAccount/USP_GetAllUserAccounts.sql" dialect="TSQL" />
|
|
||||||
<file url="file://$PROJECT_DIR$/DataLayer/scripts/03-crud/01-UserAccount/USP_GetUserAccountByEmail.sql" dialect="TSQL" />
|
|
||||||
<file url="file://$PROJECT_DIR$/DataLayer/scripts/03-crud/01-UserAccount/USP_GetUserAccountById.sql" dialect="TSQL" />
|
|
||||||
<file url="file://$PROJECT_DIR$/DataLayer/scripts/03-crud/01-UserAccount/USP_GetUserAccountByUsername.sql" dialect="TSQL" />
|
|
||||||
<file url="file://$PROJECT_DIR$/DataLayer/scripts/03-crud/02-UserCredential/USP_AddUserCredential.sql" dialect="TSQL" />
|
|
||||||
<file url="file://$PROJECT_DIR$/DataLayer/scripts/03-crud/03-UserVerification/USP_AddUserVerification.sql" dialect="TSQL" />
|
|
||||||
</component>
|
|
||||||
</project>
|
|
||||||
6
.idea/.idea.biergarten/.idea/vcs.xml
generated
6
.idea/.idea.biergarten/.idea/vcs.xml
generated
@@ -1,6 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<project version="4">
|
|
||||||
<component name="VcsDirectoryMappings">
|
|
||||||
<mapping directory="" vcs="Git" />
|
|
||||||
</component>
|
|
||||||
</project>
|
|
||||||
6
DBSeed/ISeeder.cs
Normal file
6
DBSeed/ISeeder.cs
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
using Microsoft.Data.SqlClient;
|
||||||
|
|
||||||
|
interface ISeeder
|
||||||
|
{
|
||||||
|
Task SeedAsync(SqlConnection connection);
|
||||||
|
}
|
||||||
@@ -3,7 +3,7 @@ using Microsoft.Data.SqlClient;
|
|||||||
|
|
||||||
namespace DBSeed;
|
namespace DBSeed;
|
||||||
|
|
||||||
internal static class LocationSeeder
|
class LocationSeeder : ISeeder
|
||||||
{
|
{
|
||||||
private static readonly IReadOnlyList<(
|
private static readonly IReadOnlyList<(
|
||||||
string CountryName,
|
string CountryName,
|
||||||
@@ -244,7 +244,7 @@ internal static class LocationSeeder
|
|||||||
("MX-ZAC", "Zacatecas"),
|
("MX-ZAC", "Zacatecas"),
|
||||||
];
|
];
|
||||||
|
|
||||||
internal static async Task SeedAsync(SqlConnection connection)
|
public async Task SeedAsync(SqlConnection connection)
|
||||||
{
|
{
|
||||||
foreach (var (countryName, countryCode) in Countries)
|
foreach (var (countryName, countryCode) in Countries)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -16,11 +16,18 @@ try
|
|||||||
|
|
||||||
Console.WriteLine("Connected to database.");
|
Console.WriteLine("Connected to database.");
|
||||||
|
|
||||||
await LocationSeeder.SeedAsync(connection);
|
ISeeder[] seeders =
|
||||||
Console.WriteLine("Seeded locations.");
|
[
|
||||||
|
new LocationSeeder(),
|
||||||
|
new UserSeeder(),
|
||||||
|
];
|
||||||
|
|
||||||
await UserSeeder.SeedAsync(connection);
|
foreach (var seeder in seeders)
|
||||||
Console.WriteLine("Seeded users.");
|
{
|
||||||
|
Console.WriteLine($"Seeding {seeder.GetType().Name}...");
|
||||||
|
await seeder.SeedAsync(connection);
|
||||||
|
Console.WriteLine($"{seeder.GetType().Name} seeded.");
|
||||||
|
}
|
||||||
|
|
||||||
Console.WriteLine("Seed completed successfully.");
|
Console.WriteLine("Seed completed successfully.");
|
||||||
return 0;
|
return 0;
|
||||||
|
|||||||
@@ -7,114 +7,116 @@ using Microsoft.Data.SqlClient;
|
|||||||
|
|
||||||
namespace DBSeed;
|
namespace DBSeed;
|
||||||
|
|
||||||
internal static class UserSeeder
|
class UserSeeder : ISeeder
|
||||||
{
|
{
|
||||||
private static readonly IReadOnlyList<(string FirstName, string LastName)>
|
private static readonly IReadOnlyList<(
|
||||||
SeedNames =
|
string FirstName,
|
||||||
[
|
string LastName
|
||||||
("Aarya", "Mathews"),
|
)> SeedNames =
|
||||||
("Aiden", "Wells"),
|
[
|
||||||
("Aleena", "Gonzalez"),
|
("Aarya", "Mathews"),
|
||||||
("Alessandra", "Nelson"),
|
("Aiden", "Wells"),
|
||||||
("Amari", "Tucker"),
|
("Aleena", "Gonzalez"),
|
||||||
("Ameer", "Huff"),
|
("Alessandra", "Nelson"),
|
||||||
("Amirah", "Hicks"),
|
("Amari", "Tucker"),
|
||||||
("Analia", "Dominguez"),
|
("Ameer", "Huff"),
|
||||||
("Anne", "Jenkins"),
|
("Amirah", "Hicks"),
|
||||||
("Apollo", "Davis"),
|
("Analia", "Dominguez"),
|
||||||
("Arianna", "White"),
|
("Anne", "Jenkins"),
|
||||||
("Aubree", "Moore"),
|
("Apollo", "Davis"),
|
||||||
("Aubrielle", "Raymond"),
|
("Arianna", "White"),
|
||||||
("Aydin", "Odom"),
|
("Aubree", "Moore"),
|
||||||
("Bowen", "Casey"),
|
("Aubrielle", "Raymond"),
|
||||||
("Brock", "Huber"),
|
("Aydin", "Odom"),
|
||||||
("Caiden", "Strong"),
|
("Bowen", "Casey"),
|
||||||
("Cecilia", "Rosales"),
|
("Brock", "Huber"),
|
||||||
("Celeste", "Barber"),
|
("Caiden", "Strong"),
|
||||||
("Chance", "Small"),
|
("Cecilia", "Rosales"),
|
||||||
("Clara", "Roberts"),
|
("Celeste", "Barber"),
|
||||||
("Collins", "Brandt"),
|
("Chance", "Small"),
|
||||||
("Damir", "Wallace"),
|
("Clara", "Roberts"),
|
||||||
("Declan", "Crawford"),
|
("Collins", "Brandt"),
|
||||||
("Dennis", "Decker"),
|
("Damir", "Wallace"),
|
||||||
("Dylan", "Lang"),
|
("Declan", "Crawford"),
|
||||||
("Eliza", "Kane"),
|
("Dennis", "Decker"),
|
||||||
("Elle", "Poole"),
|
("Dylan", "Lang"),
|
||||||
("Elliott", "Miles"),
|
("Eliza", "Kane"),
|
||||||
("Emelia", "Lucas"),
|
("Elle", "Poole"),
|
||||||
("Emilia", "Simpson"),
|
("Elliott", "Miles"),
|
||||||
("Emmett", "Lugo"),
|
("Emelia", "Lucas"),
|
||||||
("Ethan", "Stephens"),
|
("Emilia", "Simpson"),
|
||||||
("Etta", "Woods"),
|
("Emmett", "Lugo"),
|
||||||
("Gael", "Moran"),
|
("Ethan", "Stephens"),
|
||||||
("Grant", "Benson"),
|
("Etta", "Woods"),
|
||||||
("Gwen", "James"),
|
("Gael", "Moran"),
|
||||||
("Huxley", "Chen"),
|
("Grant", "Benson"),
|
||||||
("Isabella", "Fisher"),
|
("Gwen", "James"),
|
||||||
("Ivan", "Mathis"),
|
("Huxley", "Chen"),
|
||||||
("Jamir", "McMillan"),
|
("Isabella", "Fisher"),
|
||||||
("Jaxson", "Shields"),
|
("Ivan", "Mathis"),
|
||||||
("Jimmy", "Richmond"),
|
("Jamir", "McMillan"),
|
||||||
("Josiah", "Flores"),
|
("Jaxson", "Shields"),
|
||||||
("Kaden", "Enriquez"),
|
("Jimmy", "Richmond"),
|
||||||
("Kai", "Lawson"),
|
("Josiah", "Flores"),
|
||||||
("Karsyn", "Adkins"),
|
("Kaden", "Enriquez"),
|
||||||
("Karsyn", "Proctor"),
|
("Kai", "Lawson"),
|
||||||
("Kayden", "Henson"),
|
("Karsyn", "Adkins"),
|
||||||
("Kaylie", "Spears"),
|
("Karsyn", "Proctor"),
|
||||||
("Kinslee", "Jones"),
|
("Kayden", "Henson"),
|
||||||
("Kora", "Guerra"),
|
("Kaylie", "Spears"),
|
||||||
("Lane", "Skinner"),
|
("Kinslee", "Jones"),
|
||||||
("Laylani", "Christian"),
|
("Kora", "Guerra"),
|
||||||
("Ledger", "Carroll"),
|
("Lane", "Skinner"),
|
||||||
("Leilany", "Small"),
|
("Laylani", "Christian"),
|
||||||
("Leland", "McCall"),
|
("Ledger", "Carroll"),
|
||||||
("Leonard", "Calhoun"),
|
("Leilany", "Small"),
|
||||||
("Levi", "Ochoa"),
|
("Leland", "McCall"),
|
||||||
("Lillie", "Vang"),
|
("Leonard", "Calhoun"),
|
||||||
("Lola", "Sheppard"),
|
("Levi", "Ochoa"),
|
||||||
("Luciana", "Poole"),
|
("Lillie", "Vang"),
|
||||||
("Maddox", "Hughes"),
|
("Lola", "Sheppard"),
|
||||||
("Mara", "Blackwell"),
|
("Luciana", "Poole"),
|
||||||
("Marcellus", "Bartlett"),
|
("Maddox", "Hughes"),
|
||||||
("Margo", "Koch"),
|
("Mara", "Blackwell"),
|
||||||
("Maurice", "Gibson"),
|
("Marcellus", "Bartlett"),
|
||||||
("Maxton", "Dodson"),
|
("Margo", "Koch"),
|
||||||
("Mia", "Parrish"),
|
("Maurice", "Gibson"),
|
||||||
("Millie", "Fuentes"),
|
("Maxton", "Dodson"),
|
||||||
("Nellie", "Villanueva"),
|
("Mia", "Parrish"),
|
||||||
("Nicolas", "Mata"),
|
("Millie", "Fuentes"),
|
||||||
("Nicolas", "Miller"),
|
("Nellie", "Villanueva"),
|
||||||
("Oakleigh", "Foster"),
|
("Nicolas", "Mata"),
|
||||||
("Octavia", "Pierce"),
|
("Nicolas", "Miller"),
|
||||||
("Paisley", "Allison"),
|
("Oakleigh", "Foster"),
|
||||||
("Quincy", "Andersen"),
|
("Octavia", "Pierce"),
|
||||||
("Quincy", "Frazier"),
|
("Paisley", "Allison"),
|
||||||
("Raiden", "Roberts"),
|
("Quincy", "Andersen"),
|
||||||
("Raquel", "Lara"),
|
("Quincy", "Frazier"),
|
||||||
("Rudy", "McIntosh"),
|
("Raiden", "Roberts"),
|
||||||
("Salvador", "Stein"),
|
("Raquel", "Lara"),
|
||||||
("Samantha", "Dickson"),
|
("Rudy", "McIntosh"),
|
||||||
("Solomon", "Richards"),
|
("Salvador", "Stein"),
|
||||||
("Sylvia", "Hanna"),
|
("Samantha", "Dickson"),
|
||||||
("Talia", "Trujillo"),
|
("Solomon", "Richards"),
|
||||||
("Thalia", "Farrell"),
|
("Sylvia", "Hanna"),
|
||||||
("Trent", "Mayo"),
|
("Talia", "Trujillo"),
|
||||||
("Trinity", "Cummings"),
|
("Thalia", "Farrell"),
|
||||||
("Ty", "Perry"),
|
("Trent", "Mayo"),
|
||||||
("Tyler", "Romero"),
|
("Trinity", "Cummings"),
|
||||||
("Valeria", "Pierce"),
|
("Ty", "Perry"),
|
||||||
("Vance", "Neal"),
|
("Tyler", "Romero"),
|
||||||
("Whitney", "Bell"),
|
("Valeria", "Pierce"),
|
||||||
("Wilder", "Graves"),
|
("Vance", "Neal"),
|
||||||
("William", "Logan"),
|
("Whitney", "Bell"),
|
||||||
("Zara", "Wilkinson"),
|
("Wilder", "Graves"),
|
||||||
("Zaria", "Gibson"),
|
("William", "Logan"),
|
||||||
("Zion", "Watkins"),
|
("Zara", "Wilkinson"),
|
||||||
("Zoie", "Armstrong"),
|
("Zaria", "Gibson"),
|
||||||
];
|
("Zion", "Watkins"),
|
||||||
|
("Zoie", "Armstrong"),
|
||||||
|
];
|
||||||
|
|
||||||
public static async Task SeedAsync(SqlConnection connection)
|
public async Task SeedAsync(SqlConnection connection)
|
||||||
{
|
{
|
||||||
var generator = new PasswordGenerator();
|
var generator = new PasswordGenerator();
|
||||||
var random = new Random();
|
var random = new Random();
|
||||||
|
|||||||
21
README.md
21
README.md
@@ -5,10 +5,10 @@ This solution is a monolith-oriented Web API with a layered structure. The curre
|
|||||||
## High-level projects
|
## High-level projects
|
||||||
|
|
||||||
- `WebAPI/` - ASP.NET Core API endpoints (controllers) and application entrypoint.
|
- `WebAPI/` - ASP.NET Core API endpoints (controllers) and application entrypoint.
|
||||||
- `BusinessLayer/` - Intended home for domain/business logic (currently minimal).
|
- `BusinessLayer/` - Intended home for domain/business logic
|
||||||
- `DataAccessLayer/` - Repository implementations, entities (POCOs), and SQL helpers.
|
- `DataAccessLayer/` - Repository implementations, entities (POCOs), and SQL helpers.
|
||||||
- `DataLayer/` - Database schema, seed scripts, and data sources.
|
- `DataLayer/` - DbUp console app that applies embedded schema/functions/procedures.
|
||||||
- `WebCrawler/` - Separate crawler executable.
|
- `DBSeed/` - Console app for seeding locations and test user data.
|
||||||
- `DALTests/` - Data access tests.
|
- `DALTests/` - Data access tests.
|
||||||
|
|
||||||
## Data access architecture
|
## Data access architecture
|
||||||
@@ -16,12 +16,12 @@ This solution is a monolith-oriented Web API with a layered structure. The curre
|
|||||||
- **Entities (POCOs)** live in `DataAccessLayer/Entities/`.
|
- **Entities (POCOs)** live in `DataAccessLayer/Entities/`.
|
||||||
- **Repositories** live in `DataAccessLayer/Repositories/` and implement interfaces like `IUserAccountRepository`.
|
- **Repositories** live in `DataAccessLayer/Repositories/` and implement interfaces like `IUserAccountRepository`.
|
||||||
- **SQL execution** lives in `DataAccessLayer/Sql/`.
|
- **SQL execution** lives in `DataAccessLayer/Sql/`.
|
||||||
- **Stored procedures** for CRUD live under `DataAccessLayer/Sql/crud/` and are invoked by repositories.
|
- **Stored procedures** for CRUD live under `DataLayer/scripts/03-crud/` and are invoked by repositories.
|
||||||
|
|
||||||
Example flow:
|
Example flow:
|
||||||
|
|
||||||
```
|
```
|
||||||
WebAPI Controller -> IUserAccountRepository -> UserAccountRepository -> stored procedure
|
WebAPI Controller -> UserService -> UserAccountRepository -> stored procedure
|
||||||
```
|
```
|
||||||
|
|
||||||
The repositories are currently responsible for:
|
The repositories are currently responsible for:
|
||||||
@@ -29,12 +29,13 @@ The repositories are currently responsible for:
|
|||||||
- Executing stored procedures
|
- Executing stored procedures
|
||||||
- Mapping result sets to POCOs
|
- Mapping result sets to POCOs
|
||||||
|
|
||||||
## Database schema and seed
|
## Database schema and seed tooling
|
||||||
|
|
||||||
- `DataLayer/schema.sql` contains the database schema definitions.
|
- `DataLayer/scripts/01-schema/schema.sql` contains the database schema definitions.
|
||||||
- `DataLayer/database/` holds application functions and CRUD procedures.
|
- `DataLayer/scripts/02-functions/` holds application functions.
|
||||||
- `DataLayer/seed/` holds seed-only procedures and the `SeedDB.cs` entry point.
|
- `DataLayer/scripts/03-crud/` holds CRUD stored procedures.
|
||||||
- `SeedDB.cs` honors `SEED_MODE` (`database`, `seed`, or `all`) to control which scripts run.
|
- `DataLayer/Program.cs` runs DbUp to apply embedded scripts to the database.
|
||||||
|
- `DBSeed/Program.cs` runs the location and user seeders using `DB_CONNECTION_STRING`.
|
||||||
|
|
||||||
## Key conventions
|
## Key conventions
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user