REST API for the Triton Engineering Student Council event manager. This project is open-source, and we welcome any contributions!
This project is built on .NET 6, C# 10. It is assumed you have Docker CLI and Docker Desktop, as well as the .NET SDK (in particular, the .NET CLI) installed on your local machine.
- Clone the repository with ssh:
git clone git@github.com:UCSDTESC/tesc-events.git
. - Navigate to the directory:
cd tesc-events/TescEvents
. - Install PostgreSQL. See installation instructions below.
- Create or overwrite the
appsettings.Development.json
file using Sample appsettings.Development.json as a template - Create or overwrite the
.env
file using Sample .env (this is used for the database running in Docker) - Fill out the
appsettings.Development.json
file. - Run containerized services (e.g. PostgreSQL):
docker compose up -d
. - Restore NuGet packages with:
dotnet restore
. - Install Entity Framework Core tools:
dotnet tool install --global dotnet-ef
. - Verify the EF Core CLI is correctly installed:
dotnet ef
. - Initialize the database:
dotnet ef database update
. - Start the project:
dotnet run
.
MacOS and Linux users can install Postgres version 14.5 via Homebrew, and Linux users can use apt
. Windows users will need to download the Postgres 14.5 installer from here, run the installer, and add the Postgres bin to the PATH environment variable.
We use a code-first approach to our database migrations. This means every time we want to change the schema, we have to modify the schema within the code, then create a "migration" to upgrade the database.
- Modify the schema
- Run
dotnet ef migrations add [MIGRATION NAME HERE]
, e.g.dotnet ef migrations add 0005-AddFirstNameColumnToUserTable
. - In the
TescEvents/Migrations/
directory, ensure the class name of the created migration in0005-AddFirstNameColumnToUserTable.cs
matches the form_0005AddFirstNameColumnToUserTable
. - In the
TescEvents/Migrations/
directory, ensure the annotation in0005-AddFirstNameColumnToUserTable.Designer.cs
, matches the form[Migration("0005-AddFirstNameColumnToUserTable")]
. - Update the database with
dotnet ef database update
.
{
"Logging": {
"LogLevel": {
"Default": "Information",
"Microsoft.AspNetCore": "Warning"
}
},
"Db": {
"Host": "localhost",
"Port": 5432,
"Database": "tesc-events",
"User": "tesc-dev",
"Password": "password"
},
"Jwt": {
"Key": "superultrahypermetasecretkey",
"Issuer": "https://localhost:7208",
"Audience": "https://localhost:7208"
}
}
DB_DATABASE="tesc-events"
DB_USER="tesc-dev"
DB_PASSWORD="password"
DB_PORT=5432
NOTE: For Windows users, localhost
won't work—you'll need to set DB_HOST
to the Docker machine's IP address
- Run
docker network inspect -f '{{range .IPAM.Config}}{{.Subnet}}{{end}}' tescevents_default
. - Set
DB_HOST={{ip without subnet mask}}
in your.env
file.