diff options
| author | ivarlovlie <git@ivarlovlie.no> | 2022-10-05 14:45:21 +0200 |
|---|---|---|
| committer | ivarlovlie <git@ivarlovlie.no> | 2022-10-05 14:45:21 +0200 |
| commit | b7e39b59fd0fc7b5610ebff29035bf622079e0d8 (patch) | |
| tree | 64be84ebbdac9f7ceced983390c53b10d575af5c /server | |
| parent | 2001c035fbb417ab0a3d42cfb04d17420bde4086 (diff) | |
| download | greatoffice-b7e39b59fd0fc7b5610ebff29035bf622079e0d8.tar.xz greatoffice-b7e39b59fd0fc7b5610ebff29035bf622079e0d8.zip | |
refactor: Change file structure
Diffstat (limited to 'server')
142 files changed, 0 insertions, 14012 deletions
diff --git a/server/.build.yaml b/server/.build.yaml deleted file mode 100644 index 412cd17..0000000 --- a/server/.build.yaml +++ /dev/null @@ -1,23 +0,0 @@ -image: ubuntu/lts -packages: - - docker.io -secrets: - - ea28f7fe-b300-4b79-addf-d487ed6eb1ef - - b6c0403d-10a9-4238-89cc-5402dc0c9fe5 -sources: - - git@git.ivar.systems:greatoffice -tasks: - - setup: | - echo "export IMAGE_NAME=greatoffice/server - export HUB_NAME=dr.ivar.systems/greatoffice/server - export CURRENT_VERSION=$(cat ~/greatoffice/server/.version) - export CURRENT_VERSION_INT=${CURRENT_VERSION//[!0-9]/} - export NEW_VERSION=v$(CURRENT_VERSION_INT+1)-server" >> .buildenv - - build: | - sudo docker build -t $IMAGE_NAME:$NEW_VERSION ~/greatoffice/server - - publish: | - cat ~/.dockerpassword | sudo docker login dr.ivar.systems -u builder --password-stdin - sudo docker tag $IMAGE_NAME:$NEW_VERSION $HUB_NAME:$NEW_VERSION - sudo docker tag $IMAGE_NAME:$NEW_VERSION $HUB_NAME:latest - sudo docker push -a - complete-build()
\ No newline at end of file diff --git a/server/.dockerignore b/server/.dockerignore deleted file mode 100644 index 2b24da3..0000000 --- a/server/.dockerignore +++ /dev/null @@ -1,10 +0,0 @@ -*/**/bin* -*/**/obj* -server-secrets.* -.git -*/**/node_modules/* -src/web-app -src/web-shared -src/tests -build_and_push.sh -cloc.sh diff --git a/server/.version b/server/.version deleted file mode 100644 index f20f9eb..0000000 --- a/server/.version +++ /dev/null @@ -1 +0,0 @@ -v22-server diff --git a/server/.version-dev b/server/.version-dev deleted file mode 100644 index 9cf68da..0000000 --- a/server/.version-dev +++ /dev/null @@ -1 +0,0 @@ -v47-server-dev diff --git a/server/CHANGELOG.md b/server/CHANGELOG.md deleted file mode 100644 index 88710c3..0000000 --- a/server/CHANGELOG.md +++ /dev/null @@ -1,123 +0,0 @@ -# Changelog - -## [unreleased] - -### Miscellaneous Tasks - -- Bump version -- Update CHANGELOG.md for v41-server-dev - -### Refactor - -- Implement caching in VaultService and use VaultService instead of IOptions - -## [unreleased] - -### Miscellaneous Tasks - -- Bump version -- Update CHANGELOG.md for v40-server-dev - -### Refactor - -- Use Vault to get configuration - -## [unreleased] - -### Features - -- !WIP start implementation of svelte-query - -### Miscellaneous Tasks - -- Bump version -- Remove logging of quartz db host -- Update CHANGELOG.md for v6-projects-dev -- Bump version -- Bump version -- Bump version -- Update CHANGELOG.md for v39-server-dev - -### Refactor - -- Use Vault to get configuration -- Small changes on button style -- Add a small box-shadow - -## [unreleased] - -### Bug Fixes - -- !WIP flickering dropdown on multi dropdowns with new focus strategy -- Fix route matching when deciding which tab is open - -### Miscellaneous Tasks - -- Bump version -- Update CHANGELOG.md for v22-server -- Bump version -- Update CHANGELOG.md for v15-portal-dev -- Bump version -- Bump version -- Update CHANGELOG.md for v14-portal-dev -- Bump version -- Bump version -- Bump version -- Update CHANGELOG.md for v38-server-dev - -### Refactor - -- Dont loose focus on search input when navigating results -- Make optional base fields nullable -- Remove text -- Rename accounts to portal -- Rename accounts to portal -- Rename accounts to portal -- Rename noResultsText - -## [unreleased] - -### Bug Fixes - -- !WIP flickering dropdown on multi dropdowns with new focus strategy -- Fix route matching when deciding which tab is open - -### Miscellaneous Tasks - -- Bump version -- Update CHANGELOG.md for v15-portal-dev -- Bump version -- Bump version -- Update CHANGELOG.md for v14-portal-dev -- Bump version -- Bump version -- Bump version -- Update CHANGELOG.md for v37-server-dev -- Bump version -- Bump version -- Update CHANGELOG.md for v22-server - -### Refactor - -- Dont loose focus on search input when navigating results -- Make optional base fields nullable -- Remove text -- Rename accounts to portal -- Rename accounts to portal -- Rename accounts to portal -- Rename noResultsText - -## [unreleased] - -### Miscellaneous Tasks - -- Bump version -- Update CHANGELOG.md for v37-server-dev - -## [unreleased] - -### Miscellaneous Tasks - -- Bump version -- Update CHANGELOG.md for v21-server - diff --git a/server/Dockerfile b/server/Dockerfile deleted file mode 100644 index adc4be3..0000000 --- a/server/Dockerfile +++ /dev/null @@ -1,16 +0,0 @@ -FROM mcr.microsoft.com/dotnet/sdk:6.0 AS build-env -WORKDIR /source - -# Copy csproj and restore as distinct layers -COPY src/*.csproj ./ -RUN dotnet restore - -# Copy everything else and build -COPY src/ ./ -RUN dotnet publish -c Release -o out - -# Build runtime image -FROM mcr.microsoft.com/dotnet/aspnet:6.0 -WORKDIR /app -COPY --from=build-env /source/out . -ENTRYPOINT ["dotnet", "IOL.GreatOffice.Api.dll"] diff --git a/server/build_and_push.sh b/server/build_and_push.sh deleted file mode 100755 index dd88916..0000000 --- a/server/build_and_push.sh +++ /dev/null @@ -1,93 +0,0 @@ -#!/usr/bin/env bash - -set -Eueo pipefail - -CURRENT_DEV_VERSION=$(cat .version-dev) -CURRENT_DEV_VERSION_INT=${CURRENT_DEV_VERSION//[!0-9]/} -CURRENT_VERSION=$(cat .version) -CURRENT_VERSION_INT=${CURRENT_VERSION//[!0-9]/} -if [ ${1-prod} == "dev" ]; then - NEW_VERSION="v$((CURRENT_DEV_VERSION_INT+1))-server-dev" - OLD_VERSION=$CURRENT_DEV_VERSION -else - NEW_VERSION="v$((CURRENT_VERSION_INT+1))-server" - OLD_VERSION=$CURRENT_VERSION -fi -IMAGE_NAME="greatoffice/server" -HUB_NAME="dr.ivar.systems/greatoffice/server" - -# Check for uncommited changes and optionally commit them -if [ "$(git status --untracked-files=no --porcelain)" ]; then - echo "Unclean git tree! press CTRL+C to exit or press ENTER to commit and push to the default branch" - read -n 1 - - read -p "Enter commit message: " COMMIT_MESSAGE - git add .. - git commit --quiet -m "$COMMIT_MESSAGE" -fi - -if [ ${1-prod} == "dev" ]; then - echo $NEW_VERSION >| .version-dev - git add .version-dev -else - echo $NEW_VERSION >| .version - git add .version -fi - -echo "Starting build of $HUB_NAME:$NEW_VERSION at $(date -u)..." -echo - -# Put version.txt inside of server -pushd src/wwwroot -echo "$NEW_VERSION" >version.txt -git add version.txt -popd - -git commit --quiet -m "chore(release): Bump version"; - - -read -p "Do you want to tag this build? (y/n) " -n 1 -r -echo -if [[ $REPLY =~ ^[Yy]$ ]] -then - read -p "Enter tag message (can be empty): " TAG_MESSAGE - git tag -am "$TAG_MESSAGE" $NEW_VERSION -fi - -read -p "Do you want to push the latest commits and tags to origin? (y/n) " -n 1 -r -echo -if [[ $REPLY =~ ^[Yy]$ ]] -then - echo "Pushing latest changes to remotes..." - echo - git push --quiet --follow-tags -fi - - -# Build docker image -echo "Building docker image" -echo - -docker buildx build --platform linux/amd64 -t $IMAGE_NAME:$NEW_VERSION . - -docker tag $IMAGE_NAME:$NEW_VERSION $HUB_NAME:$NEW_VERSION - -if [ ${1-prod} == "dev" ]; then - docker tag $IMAGE_NAME:$NEW_VERSION $HUB_NAME:latest-dev -fi -if [ ${1-prod} == "prod" ]; then - docker tag $IMAGE_NAME:$NEW_VERSION $HUB_NAME:latest -fi - -# Optionally push images to docker registry -echo "Press CTRL+C to exit or press ENTER to push docker image to registry" -read -n 1 -docker push $HUB_NAME:$NEW_VERSION - -if [ ${1-prod} == "dev" ]; then - docker push $HUB_NAME:latest-dev -fi - -if [ ${1-prod} == "prod" ]; then - docker push $HUB_NAME:latest -fi diff --git a/server/cliff.toml b/server/cliff.toml deleted file mode 100644 index 7299951..0000000 --- a/server/cliff.toml +++ /dev/null @@ -1,62 +0,0 @@ -# configuration file for git-cliff (0.1.0) - -[changelog] -# changelog header -header = """ -# Changelog\n -""" -# template for the changelog body -# https://tera.netlify.app/docs/#introduction -body = """ -{% if version %}\ - ## [{{ version | trim_start_matches(pat="v") }}] - {{ timestamp | date(format="%Y-%m-%d") }} -{% else %}\ - ## [unreleased] -{% endif %}\ -{% for group, commits in commits | group_by(attribute="group") %} - ### {{ group | upper_first }} - {% for commit in commits %} - - {% if commit.breaking %}[**breaking**] {% endif %}{{ commit.message | upper_first }}\ - {% endfor %} -{% endfor %}\n -""" -# remove the leading and trailing whitespace from the template -trim = true -# changelog footer -footer = """ -<!-- generated by git-cliff --> -""" - -[git] -# parse the commits based on https://www.conventionalcommits.org -conventional_commits = true -# filter out the commits that are not conventional -filter_unconventional = true -# regex for preprocessing the commit messages -commit_preprocessors = [ - { pattern = "([ \\n])(([a-f0-9]{7})[a-f0-9]*)", replace = "${1}commit # [${3}](https://git.ivar.systems/greatoffice/commit/${2})" }, - { pattern = "https://git.ivar.systems/greatoffice/commit/([a-f0-9]{7})[a-f0-9]*", replace = "commit # [${1}](${0})" }, -] -# regex for parsing and grouping commits -commit_parsers = [ - { message = "^feat", group = "Features" }, - { message = "^fix", group = "Bug Fixes" }, - { message = "^doc", group = "Documentation" }, - { message = "^perf", group = "Performance" }, - { message = "^refactor", group = "Refactor" }, - { message = "^style", group = "Styling" }, - { message = "^test", group = "Testing" }, - { message = "^chore", group = "Miscellaneous Tasks" }, -] -# filter out the commits that are not matched by commit parsers -filter_commits = true -# glob pattern for matching git tags -tag_pattern = "v.*" -# regex for skipping tags -skip_tags = "v0.1.0-beta.1" -# regex for ignoring tags -ignore_tags = "" -# sort the tags chronologically -date_order = true -# sort the commits inside sections by oldest/newest order -sort_commits = "newest" diff --git a/server/src/Data/AppDbContext.cs b/server/src/Data/AppDbContext.cs deleted file mode 100644 index c970429..0000000 --- a/server/src/Data/AppDbContext.cs +++ /dev/null @@ -1,51 +0,0 @@ -using Microsoft.AspNetCore.DataProtection.EntityFrameworkCore; - -namespace IOL.GreatOffice.Api.Data; - -public class AppDbContext : DbContext, IDataProtectionKeyContext -{ - public AppDbContext(DbContextOptions<AppDbContext> options) : base(options) { } - public DbSet<User> Users { get; set; } - public DbSet<ForgotPasswordRequest> ForgotPasswordRequests { get; set; } - public DbSet<TimeLabel> TimeLabels { get; set; } - public DbSet<TimeEntry> TimeEntries { get; set; } - public DbSet<TimeCategory> TimeCategories { get; set; } - public DbSet<ApiAccessToken> AccessTokens { get; set; } - public DbSet<Tenant> Tenants { get; set; } - public DbSet<DataProtectionKey> DataProtectionKeys { get; set; } - - protected override void OnModelCreating(ModelBuilder modelBuilder) { - modelBuilder.Entity<User>(e => { - e.ToTable("users"); - }); - - modelBuilder.Entity<ForgotPasswordRequest>(e => { - e.HasOne(c => c.User); - e.ToTable("forgot_password_requests"); - }); - - modelBuilder.Entity<TimeCategory>(e => { - e.ToTable("time_categories"); - }); - - modelBuilder.Entity<TimeLabel>(e => { - e.ToTable("time_labels"); - }); - - modelBuilder.Entity<TimeEntry>(e => { - e.HasOne(c => c.Category); - e.HasMany(c => c.Labels); - e.ToTable("time_entries"); - }); - - modelBuilder.Entity<ApiAccessToken>(e => { - e.ToTable("api_access_tokens"); - }); - - modelBuilder.Entity<Tenant>(e => { - e.ToTable("tenants"); - }); - - base.OnModelCreating(modelBuilder); - } -} diff --git a/server/src/Data/Database/ApiAccessToken.cs b/server/src/Data/Database/ApiAccessToken.cs deleted file mode 100644 index 9582869..0000000 --- a/server/src/Data/Database/ApiAccessToken.cs +++ /dev/null @@ -1,31 +0,0 @@ -namespace IOL.GreatOffice.Api.Data.Database; - -public class ApiAccessToken : Base -{ - public User User { get; set; } - public DateTime ExpiryDate { get; set; } - public bool AllowRead { get; set; } - public bool AllowCreate { get; set; } - public bool AllowUpdate { get; set; } - public bool AllowDelete { get; set; } - public bool HasExpired => ExpiryDate < AppDateTime.UtcNow; - public ApiAccessTokenDto AsDto => new(this); - - public class ApiAccessTokenDto - { - public ApiAccessTokenDto(ApiAccessToken source) { - ExpiryDate = source.ExpiryDate; - AllowRead = source.AllowRead; - AllowCreate = source.AllowCreate; - AllowUpdate = source.AllowUpdate; - AllowDelete = source.AllowDelete; - } - - public DateTime ExpiryDate { get; set; } - public bool AllowRead { get; set; } - public bool AllowCreate { get; set; } - public bool AllowUpdate { get; set; } - public bool AllowDelete { get; set; } - public bool HasExpired => ExpiryDate < AppDateTime.UtcNow; - } -}
\ No newline at end of file diff --git a/server/src/Data/Database/Base.cs b/server/src/Data/Database/Base.cs deleted file mode 100644 index ae9efa2..0000000 --- a/server/src/Data/Database/Base.cs +++ /dev/null @@ -1,15 +0,0 @@ -namespace IOL.GreatOffice.Api.Data.Database; - -public class Base -{ - protected Base() { - Id = Guid.NewGuid(); - CreatedAt = AppDateTime.UtcNow; - } - - public Guid Id { get; init; } - public DateTime CreatedAt { get; init; } - public DateTime? ModifiedAt { get; private set; } - public bool Deleted { get; set; } - public void Modified() => ModifiedAt = AppDateTime.UtcNow; -}
\ No newline at end of file diff --git a/server/src/Data/Database/BaseWithOwner.cs b/server/src/Data/Database/BaseWithOwner.cs deleted file mode 100644 index 1eb99f4..0000000 --- a/server/src/Data/Database/BaseWithOwner.cs +++ /dev/null @@ -1,19 +0,0 @@ -namespace IOL.GreatOffice.Api.Data.Database; - -/// <summary> -/// Base class for all entities. -/// </summary> -public class BaseWithOwner : Base -{ - protected BaseWithOwner() { } - - protected BaseWithOwner(Guid userId) { - UserId = userId; - } - - public Guid? UserId { get; set; } - public Guid? TenantId { get; init; } - public Guid? ModifiedById { get; init; } - public Guid? CreatedById { get; init; } - public Guid? DeletedById { get; init; } -}
\ No newline at end of file diff --git a/server/src/Data/Database/Customer.cs b/server/src/Data/Database/Customer.cs deleted file mode 100644 index c6b06a4..0000000 --- a/server/src/Data/Database/Customer.cs +++ /dev/null @@ -1,6 +0,0 @@ -namespace IOL.GreatOffice.Api.Data.Database; - -public class Customer : BaseWithOwner -{ - public string Name { get; set; } -}
\ No newline at end of file diff --git a/server/src/Data/Database/CustomerContact.cs b/server/src/Data/Database/CustomerContact.cs deleted file mode 100644 index f5a951d..0000000 --- a/server/src/Data/Database/CustomerContact.cs +++ /dev/null @@ -1,12 +0,0 @@ -namespace IOL.GreatOffice.Api.Data.Database; - -public class CustomerContact : BaseWithOwner -{ - public Customer Customer { get; set; } - public string FirstName { get; set; } - public string LastName { get; set; } - public string Email { get; set; } - public string Phone { get; set; } - public string WorkTitle { get; set; } - public string Note { get; set; } -} diff --git a/server/src/Data/Database/CustomerEvent.cs b/server/src/Data/Database/CustomerEvent.cs deleted file mode 100644 index da3e3ed..0000000 --- a/server/src/Data/Database/CustomerEvent.cs +++ /dev/null @@ -1,7 +0,0 @@ -namespace IOL.GreatOffice.Api.Data.Database; - -public class CustomerEvent : BaseWithOwner -{ - public Customer Customer { get; set; } - public string Name { get; set; } -} diff --git a/server/src/Data/Database/ForgotPasswordRequest.cs b/server/src/Data/Database/ForgotPasswordRequest.cs deleted file mode 100644 index 1510a35..0000000 --- a/server/src/Data/Database/ForgotPasswordRequest.cs +++ /dev/null @@ -1,23 +0,0 @@ -namespace IOL.GreatOffice.Api.Data.Database; - -public class ForgotPasswordRequest -{ - public ForgotPasswordRequest() { } - - public ForgotPasswordRequest(User user) { - CreatedAt = AppDateTime.UtcNow; - Id = Guid.NewGuid(); - User = user; - } - - public Guid Id { get; set; } - public Guid UserId { get; set; } - public User User { get; set; } - public DateTime CreatedAt { get; set; } - - [NotMapped] - public DateTime ExpirationDate => CreatedAt.AddMinutes(15); - - [NotMapped] - public bool IsExpired => DateTime.Compare(ExpirationDate, AppDateTime.UtcNow) < 0; -} diff --git a/server/src/Data/Database/Project.cs b/server/src/Data/Database/Project.cs deleted file mode 100644 index 7e694ee..0000000 --- a/server/src/Data/Database/Project.cs +++ /dev/null @@ -1,7 +0,0 @@ -namespace IOL.GreatOffice.Api.Data.Database; - -public class Project : BaseWithOwner -{ - public string Name { get; set; } - public Guid? CustomerId { get; set; } -} diff --git a/server/src/Data/Database/Tenant.cs b/server/src/Data/Database/Tenant.cs deleted file mode 100644 index b185c7a..0000000 --- a/server/src/Data/Database/Tenant.cs +++ /dev/null @@ -1,11 +0,0 @@ -namespace IOL.GreatOffice.Api.Data.Database; - -public class Tenant : BaseWithOwner -{ - public string Name { get; set; } - public string Description { get; set; } - public string ContactEmail { get; set; } - public Guid MasterUserId { get; set; } - public string MasterUserPassword { get; set; } - public ICollection<User> Users { get; set; } -} diff --git a/server/src/Data/Database/TimeCategory.cs b/server/src/Data/Database/TimeCategory.cs deleted file mode 100644 index 69c6957..0000000 --- a/server/src/Data/Database/TimeCategory.cs +++ /dev/null @@ -1,31 +0,0 @@ -namespace IOL.GreatOffice.Api.Data.Database; - -public class TimeCategory : BaseWithOwner -{ - public TimeCategory() { } - public TimeCategory(Guid userId) : base(userId) { } - public string Name { get; set; } - public string Color { get; set; } - public TimeCategoryDto AsDto => new(this); - - public class TimeCategoryDto - { - public TimeCategoryDto() { } - - public TimeCategoryDto(TimeCategory sourceEntry = default) { - if (sourceEntry == default) { - return; - } - - Id = sourceEntry.Id; - ModifiedAt = sourceEntry.ModifiedAt; - Name = sourceEntry.Name; - Color = sourceEntry.Color; - } - - public Guid Id { get; set; } - public DateTime? ModifiedAt { get; set; } - public string Name { get; set; } - public string Color { get; set; } - } -} diff --git a/server/src/Data/Database/TimeEntry.cs b/server/src/Data/Database/TimeEntry.cs deleted file mode 100644 index 46c62e1..0000000 --- a/server/src/Data/Database/TimeEntry.cs +++ /dev/null @@ -1,45 +0,0 @@ -namespace IOL.GreatOffice.Api.Data.Database; - -public class TimeEntry : BaseWithOwner -{ - public TimeEntry() { } - public TimeEntry(Guid userId) : base(userId) { } - public DateTime Start { get; set; } - public DateTime Stop { get; set; } - public string Description { get; set; } - public ICollection<TimeLabel> Labels { get; set; } - public TimeCategory Category { get; set; } - public TimeEntryDto AsDto => new(this); - - public class TimeEntryDto - { - public TimeEntryDto() { } - - public TimeEntryDto(TimeEntry sourceEntry = default) { - if (sourceEntry == default) { - return; - } - - Id = sourceEntry.Id; - ModifiedAt = sourceEntry.ModifiedAt; - Stop = sourceEntry.Stop; - Start = sourceEntry.Start; - Description = sourceEntry.Description; - if (sourceEntry.Labels != default) { - Labels = sourceEntry.Labels - .Select(t => t.AsDto) - .ToList(); - } - - Category = sourceEntry.Category.AsDto; - } - - public Guid? Id { get; set; } - public DateTime? ModifiedAt { get; set; } - public DateTime Start { get; set; } - public DateTime Stop { get; set; } - public string Description { get; set; } - public List<TimeLabel.TimeLabelDto> Labels { get; set; } - public TimeCategory.TimeCategoryDto Category { get; set; } - } -} diff --git a/server/src/Data/Database/TimeLabel.cs b/server/src/Data/Database/TimeLabel.cs deleted file mode 100644 index 55e20b0..0000000 --- a/server/src/Data/Database/TimeLabel.cs +++ /dev/null @@ -1,31 +0,0 @@ -namespace IOL.GreatOffice.Api.Data.Database; - -public class TimeLabel : BaseWithOwner -{ - public TimeLabel() { } - public TimeLabel(Guid userId) : base(userId) { } - public string Name { get; set; } - public string Color { get; set; } - - [NotMapped] - public TimeLabelDto AsDto => new(this); - - public class TimeLabelDto - { - public TimeLabelDto() { } - - public TimeLabelDto(TimeLabel sourceEntry) { - Id = sourceEntry.Id; - CreatedAt = sourceEntry.CreatedAt; - ModifiedAt = sourceEntry.ModifiedAt; - Name = sourceEntry.Name; - Color = sourceEntry.Color; - } - - public Guid Id { get; set; } - public DateTime CreatedAt { get; set; } - public DateTime? ModifiedAt { get; set; } - public string Name { get; set; } - public string Color { get; set; } - } -} diff --git a/server/src/Data/Database/Todo.cs b/server/src/Data/Database/Todo.cs deleted file mode 100644 index 5fe3c9a..0000000 --- a/server/src/Data/Database/Todo.cs +++ /dev/null @@ -1,13 +0,0 @@ -namespace IOL.GreatOffice.Api.Data.Database; - -public class Todo : BaseWithOwner -{ - public int PublicId { get; set; } - public TodoStatus Status { get; set; } - public TodoProject Project { get; set; } - public Guid? AssignedUserId { get; set; } - public string Title { get; set; } - public string Description { get; set; } - public ICollection<TodoLabel> Labels { get; set; } - public ICollection<TodoComment> Comments { get; set; } -} diff --git a/server/src/Data/Database/TodoComment.cs b/server/src/Data/Database/TodoComment.cs deleted file mode 100644 index 44dcbed..0000000 --- a/server/src/Data/Database/TodoComment.cs +++ /dev/null @@ -1,7 +0,0 @@ -namespace IOL.GreatOffice.Api.Data.Database; - -public class TodoComment : BaseWithOwner -{ - public string Value { get; set; } - public Todo Todo { get; set; } -} diff --git a/server/src/Data/Database/TodoLabel.cs b/server/src/Data/Database/TodoLabel.cs deleted file mode 100644 index 7753ade..0000000 --- a/server/src/Data/Database/TodoLabel.cs +++ /dev/null @@ -1,8 +0,0 @@ -namespace IOL.GreatOffice.Api.Data.Database; - -public class TodoLabel : BaseWithOwner -{ - public string Name { get; set; } - public string Color { get; set; } - public Todo Todo { get; set; } -} diff --git a/server/src/Data/Database/TodoProject.cs b/server/src/Data/Database/TodoProject.cs deleted file mode 100644 index 0a4a7be..0000000 --- a/server/src/Data/Database/TodoProject.cs +++ /dev/null @@ -1,16 +0,0 @@ -namespace IOL.GreatOffice.Api.Data.Database; - -public class TodoProject : BaseWithOwner -{ - public string Name { get; set; } - public TodoVisibility Visibility { get; set; } - public Guid? ProjectId { get; set; } -} - -public enum TodoVisibility -{ - PRIVATE = 0, - UNLISTED = 1, - TENANT_WIDE = 2, - PUBLIC = 3, -} diff --git a/server/src/Data/Database/TodoProjectAccessControl.cs b/server/src/Data/Database/TodoProjectAccessControl.cs deleted file mode 100644 index 964f831..0000000 --- a/server/src/Data/Database/TodoProjectAccessControl.cs +++ /dev/null @@ -1,11 +0,0 @@ -namespace IOL.GreatOffice.Api.Data.Database; - -public class TodoProjectAccessControl -{ - public TodoProject Project { get; set; } - public Guid? UserId { get; set; } - public bool Browse { get; set; } - public bool Submit { get; set; } - public bool Comment { get; set; } - public bool Edit { get; set; } -} diff --git a/server/src/Data/Database/TodoStatus.cs b/server/src/Data/Database/TodoStatus.cs deleted file mode 100644 index 416212d..0000000 --- a/server/src/Data/Database/TodoStatus.cs +++ /dev/null @@ -1,45 +0,0 @@ -namespace IOL.GreatOffice.Api.Data.Database; - -public class TodoStatus : BaseWithOwner -{ - public string Name { get; set; } - public string Color { get; set; } - public Todo Todo { get; set; } - - public static List<TodoStatus> GetDefaultStatusSetForTenant(Guid tenantId) { - return new List<TodoStatus>() { - new() { - Name = "Reported", - TenantId = tenantId - }, - new() { - Name = "Resolved", - TenantId = tenantId - }, - new() { - Name = "Fixed", - TenantId = tenantId - }, - new() { - Name = "Implemented", - TenantId = tenantId - }, - new() { - Name = "Won't fix", - TenantId = tenantId - }, - new() { - Name = "By design", - TenantId = tenantId - }, - new() { - Name = "Invalid", - TenantId = tenantId - }, - new() { - Name = "Duplicate", - TenantId = tenantId - } - }; - } -} diff --git a/server/src/Data/Database/User.cs b/server/src/Data/Database/User.cs deleted file mode 100644 index 9db5d35..0000000 --- a/server/src/Data/Database/User.cs +++ /dev/null @@ -1,37 +0,0 @@ -namespace IOL.GreatOffice.Api.Data.Database; - -public class User : Base -{ - public User() { } - - public User(string username) { - Username = username; - } - - public string FirstName { get; set; } - public string LastName { get; set; } - public string Email { get; set; } - public string Username { get; set; } - public string Password { get; set; } - public ICollection<Tenant> Tenants { get; set; } - - public string DisplayName() { - if (FirstName.HasValue() && LastName.HasValue()) return FirstName + " " + LastName; - return FirstName.HasValue() ? FirstName : Email; - } - - public void HashAndSetPassword(string password) { - Password = PasswordHelper.HashPassword(password); - } - - public bool VerifyPassword(string password) { - return PasswordHelper.Verify(password, Password); - } - - public IEnumerable<Claim> DefaultClaims() { - return new Claim[] { - new(AppClaims.USER_ID, Id.ToString()), - new(AppClaims.NAME, Username), - }; - } -}
\ No newline at end of file diff --git a/server/src/Data/Dtos/TimeQueryDto.cs b/server/src/Data/Dtos/TimeQueryDto.cs deleted file mode 100644 index f734cb1..0000000 --- a/server/src/Data/Dtos/TimeQueryDto.cs +++ /dev/null @@ -1,34 +0,0 @@ - -namespace IOL.GreatOffice.Api.Data.Dtos; - -public class TimeQueryDto -{ - public TimeQueryDto() { - Results = new List<TimeEntry.TimeEntryDto>(); - } - - /// <summary> - /// List of entries. - /// </summary> - public List<TimeEntry.TimeEntryDto> Results { get; set; } - - /// <summary> - /// Curren page. - /// </summary> - public int Page { get; set; } - - /// <summary> - /// Maximum count of entries in a page. - /// </summary> - public int PageSize { get; set; } - - /// <summary> - /// Total count of entries. - /// </summary> - public int TotalSize { get; set; } - - /// <summary> - /// Total count of pages. - /// </summary> - public int TotalPageCount { get; set; } -} diff --git a/server/src/Data/Dtos/UserArchiveDto.cs b/server/src/Data/Dtos/UserArchiveDto.cs deleted file mode 100644 index 42e0600..0000000 --- a/server/src/Data/Dtos/UserArchiveDto.cs +++ /dev/null @@ -1,131 +0,0 @@ - -namespace IOL.GreatOffice.Api.Data.Dtos; - -/// <summary> -/// Represents a user archive as it is provided to users. -/// </summary> -public class UserArchiveDto -{ - /// <inheritdoc cref="UserArchiveDto"/> - public UserArchiveDto(User user) { - Meta = new MetaDto { - GeneratedAt = AppDateTime.UtcNow.ToString("yyyy-MM-ddTHH:mm:ssZ") - }; - User = new UserDto(user); - Entries = new List<EntryDto>(); - } - - /// <summary> - /// Metadata for the user archive. - /// </summary> - public MetaDto Meta { get; } - - /// <summary> - /// Relevant user data for the archive. - /// </summary> - public UserDto User { get; } - - /// <summary> - /// List of entries that the user has created. - /// </summary> - public List<EntryDto> Entries { get; } - - public void CountEntries() { - Meta.EntryCount = Entries.Count; - } - - /// <summary> - /// Represents a time entry in the data archive. - /// </summary> - public class EntryDto - { - public string CreatedAt { get; init; } - - [JsonIgnore] - public DateTime StartDateTime { get; init; } - - /// <summary> - /// ISO 8601 string of the UTC date the time entry started. - /// </summary> - public string Start => StartDateTime.ToString("yyyy-MM-ddTHH:mm:ssZ"); - - [JsonIgnore] - public DateTime StopDateTime { get; init; } - - /// <summary> - /// ISO 8601 string of the UTC date the time entry stopped. - /// </summary> - public string Stop => StopDateTime.ToString("yyyy-MM-ddTHH:mm:ssZ"); - - /// <summary> - /// Total amount of minutes elapsed from start to stop on this time entry. - /// </summary> - public double Minutes => StopDateTime.Subtract(StartDateTime).TotalMinutes; - - public string Description { get; init; } - - /// <summary> - /// Archive spesific category for this time entry. - /// </summary> - public CategoryDto Category { get; init; } - - /// <summary> - /// Archive spesific list of labels for this time entry. - /// </summary> - public List<LabelDto> Labels { get; init; } - } - - /// <summary> - /// Time entry category as it is written to the user archive. - /// </summary> - public class CategoryDto - { - public string Name { get; init; } - public string Color { get; init; } - } - - /// <summary> - /// Time entry label as it is written to the user archive. - /// </summary> - public class LabelDto - { - public string Name { get; init; } - public string Color { get; init; } - } - - - /// <summary> - /// Represents the user who this archive's data is based on. - /// </summary> - public class UserDto - { - /// <inheritdoc cref="UserDto"/> - public UserDto(User user) { - Username = user.Username; - CreatedAt = user.CreatedAt; - } - - /// <summary> - /// UTC date this user was created. - /// </summary> - public DateTime CreatedAt { get; } - - public string Username { get; } - } - - /// <summary> - /// Represents the meta object which contains metdata for this archive. - /// </summary> - public class MetaDto - { - /// <summary> - /// ISO 8601 UTC date string for when this archive was created. - /// </summary> - public string GeneratedAt { get; init; } - - /// <summary> - /// Amount of entries in the archive. - /// </summary> - public int EntryCount { get; set; } - } -} diff --git a/server/src/Data/Enums/TimeEntryQueryDuration.cs b/server/src/Data/Enums/TimeEntryQueryDuration.cs deleted file mode 100644 index af70ca6..0000000 --- a/server/src/Data/Enums/TimeEntryQueryDuration.cs +++ /dev/null @@ -1,37 +0,0 @@ -namespace IOL.GreatOffice.Api.Data.Enums; - -/// <summary> -/// Specify a duration filter for time entry queries. -/// </summary> -public enum TimeEntryQueryDuration -{ - /// <summary> - /// Only query entries created today. - /// </summary> - TODAY = 0, - - /// <summary> - /// Only query entries created this week. - /// </summary> - THIS_WEEK = 1, - - /// <summary> - /// Only query entries created this month. - /// </summary> - THIS_MONTH = 2, - - /// <summary> - /// Only query entries created this year. - /// </summary> - THIS_YEAR = 3, - - /// <summary> - /// Only query entries created at a spesific date. - /// </summary> - SPECIFIC_DATE = 4, - - /// <summary> - /// Only query entries created between two dates. - /// </summary> - DATE_RANGE = 5, -} diff --git a/server/src/Data/Exceptions/ForgotPasswordRequestNotFoundException.cs b/server/src/Data/Exceptions/ForgotPasswordRequestNotFoundException.cs deleted file mode 100644 index 02474b4..0000000 --- a/server/src/Data/Exceptions/ForgotPasswordRequestNotFoundException.cs +++ /dev/null @@ -1,21 +0,0 @@ -namespace IOL.GreatOffice.Api.Data.Exceptions; - -[Serializable] -public class ForgotPasswordRequestNotFoundException : Exception -{ - // - // For guidelines regarding the creation of new exception types, see - // http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpgenref/html/cpconerrorraisinghandlingguidelines.asp - // and - // http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dncscol/html/csharp07192001.asp - // - - public ForgotPasswordRequestNotFoundException() { } - public ForgotPasswordRequestNotFoundException(string message) : base(message) { } - public ForgotPasswordRequestNotFoundException(string message, Exception inner) : base(message, inner) { } - - protected ForgotPasswordRequestNotFoundException( - SerializationInfo info, - StreamingContext context - ) : base(info, context) { } -} diff --git a/server/src/Data/Exceptions/UserNotFoundException.cs b/server/src/Data/Exceptions/UserNotFoundException.cs deleted file mode 100644 index 06b57a9..0000000 --- a/server/src/Data/Exceptions/UserNotFoundException.cs +++ /dev/null @@ -1,19 +0,0 @@ -namespace IOL.GreatOffice.Api.Data.Exceptions; - -[Serializable] -public class UserNotFoundException : Exception -{ - // For guidelines regarding the creation of new exception types, see - // http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpgenref/html/cpconerrorraisinghandlingguidelines.asp - // and - // http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dncscol/html/csharp07192001.asp - - public UserNotFoundException() { } - public UserNotFoundException(string message) : base(message) { } - public UserNotFoundException(string message, Exception inner) : base(message, inner) { } - - protected UserNotFoundException( - SerializationInfo info, - StreamingContext context - ) : base(info, context) { } -} diff --git a/server/src/Data/Models/ApiSpecDocument.cs b/server/src/Data/Models/ApiSpecDocument.cs deleted file mode 100644 index 1c7d936..0000000 --- a/server/src/Data/Models/ApiSpecDocument.cs +++ /dev/null @@ -1,9 +0,0 @@ -namespace IOL.GreatOffice.Api.Data.Models; - -public class ApiSpecDocument -{ - public string VersionName { get; set; } - public string SwaggerPath { get; set; } - public ApiVersion Version { get; set; } - public OpenApiInfo OpenApiInfo { get; set; } -} diff --git a/server/src/Data/Models/AppPath.cs b/server/src/Data/Models/AppPath.cs deleted file mode 100644 index e47e48c..0000000 --- a/server/src/Data/Models/AppPath.cs +++ /dev/null @@ -1,23 +0,0 @@ -namespace IOL.GreatOffice.Api.Data.Models; - -public sealed record AppPath -{ - public string HostPath { get; init; } - public string WebPath { get; init; } - - public string GetHostPathForFilename(string filename, string fallback = "") { - if (filename.IsNullOrWhiteSpace()) { - return fallback; - } - - return Path.Combine(HostPath, filename); - } - - public string GetWebPathForFilename(string filename, string fallback = "") { - if (filename.IsNullOrWhiteSpace()) { - return fallback; - } - - return Path.Combine(WebPath, filename); - } -} diff --git a/server/src/Data/Models/LoggedInUserModel.cs b/server/src/Data/Models/LoggedInUserModel.cs deleted file mode 100644 index d802b77..0000000 --- a/server/src/Data/Models/LoggedInUserModel.cs +++ /dev/null @@ -1,7 +0,0 @@ -namespace IOL.GreatOffice.Api.Data.Models; - -public class LoggedInUserModel -{ - public Guid Id { get; set; } - public string Username { get; set; } -} diff --git a/server/src/Data/Results/ErrorResult.cs b/server/src/Data/Results/ErrorResult.cs deleted file mode 100644 index fd2fd6a..0000000 --- a/server/src/Data/Results/ErrorResult.cs +++ /dev/null @@ -1,12 +0,0 @@ -namespace IOL.GreatOffice.Api.Data.Results; - -public class ErrorResult -{ - public ErrorResult(string title = default, string text = default) { - Title = title; - Text = text; - } - - public string Title { get; set; } - public string Text { get; set; } -} diff --git a/server/src/Data/Static/AppClaims.cs b/server/src/Data/Static/AppClaims.cs deleted file mode 100644 index 8b6d3a8..0000000 --- a/server/src/Data/Static/AppClaims.cs +++ /dev/null @@ -1,8 +0,0 @@ -namespace IOL.GreatOffice.Api.Data.Static; - -public static class AppClaims -{ - public const string USER_ID = "user_id"; - public const string NAME = "name"; - public const string GITHUB_ACCESS_TOKEN = ""; -} diff --git a/server/src/Data/Static/AppConfiguration.cs b/server/src/Data/Static/AppConfiguration.cs deleted file mode 100644 index 4ee7a8e..0000000 --- a/server/src/Data/Static/AppConfiguration.cs +++ /dev/null @@ -1,58 +0,0 @@ -using System.Security.Cryptography.X509Certificates; - -namespace IOL.GreatOffice.Api.Data.Static; - -public class AppConfiguration -{ - public string DB_HOST { get; set; } - public string DB_PORT { get; set; } - public string DB_USER { get; set; } - public string DB_PASSWORD { get; set; } - public string DB_NAME { get; set; } - public string QUARTZ_DB_HOST { get; set; } - public string QUARTZ_DB_PORT { get; set; } - public string QUARTZ_DB_USER { get; set; } - public string QUARTZ_DB_PASSWORD { get; set; } - public string QUARTZ_DB_NAME { get; set; } - public string SEQ_API_KEY { get; set; } - public string SEQ_API_URL { get; set; } - public string SMTP_HOST { get; set; } - public string SMTP_PORT { get; set; } - public string SMTP_USER { get; set; } - public string SMTP_PASSWORD { get; set; } - public string EMAIL_FROM_ADDRESS { get; set; } - public string EMAIL_FROM_DISPLAY_NAME { get; set; } - public string PORTAL_URL { get; set; } - public string GITHUB_CLIENT_ID { get; set; } - public string GITHUB_CLIENT_SECRET { get; set; } - public string APP_AES_KEY { get; set; } - public string APP_CERT { get; set; } - - public X509Certificate2 CERT1() => new (Convert.FromBase64String(APP_CERT)); - - public object GetPublicVersion() { - return new { - DB_HOST, - DB_PORT, - DB_USER, - DB_PASSWORD = DB_PASSWORD.Obfuscate() ?? "", - QUARTZ_DB_HOST, - QUARTZ_DB_PORT, - QUARTZ_DB_USER, - QUARTZ_DB_PASSWORD = QUARTZ_DB_PASSWORD.Obfuscate() ?? "", - SEQ_API_KEY = SEQ_API_KEY.Obfuscate() ?? "", - SEQ_API_URL, - SMTP_HOST, - SMTP_PORT, - SMTP_USER = SMTP_USER.Obfuscate() ?? "", - SMTP_PASSWORD = SMTP_PASSWORD.Obfuscate() ?? "", - EMAIL_FROM_ADDRESS, - EMAIL_FROM_DISPLAY_NAME, - PORTAL_URL, - GITHUB_CLIENT_ID = GITHUB_CLIENT_ID.Obfuscate() ?? "", - GITHUB_CLIENT_SECRET = GITHUB_CLIENT_SECRET.Obfuscate() ?? "", - APP_AES_KEY = APP_AES_KEY.Obfuscate() ?? "", - CERT1 = CERT1().PublicKey.Oid.FriendlyName - }; - } -} diff --git a/server/src/Data/Static/AppConstants.cs b/server/src/Data/Static/AppConstants.cs deleted file mode 100644 index 461317b..0000000 --- a/server/src/Data/Static/AppConstants.cs +++ /dev/null @@ -1,12 +0,0 @@ -namespace IOL.GreatOffice.Api.Data.Static; - -public static class AppConstants -{ - public const string API_NAME = "Great Office API"; - public const string BASIC_AUTH_SCHEME = "BasicAuthenticationScheme"; - public const string TOKEN_ALLOW_READ = "TOKEN_ALLOW_READ"; - public const string TOKEN_ALLOW_CREATE = "TOKEN_ALLOW_CREATE"; - public const string TOKEN_ALLOW_UPDATE = "TOKEN_ALLOW_UPDATE"; - public const string TOKEN_ALLOW_DELETE = "TOKEN_ALLOW_DELETE"; - public const string VAULT_CACHE_KEY = "VAULT_CACHE_KEY"; -} diff --git a/server/src/Data/Static/AppDateTime.cs b/server/src/Data/Static/AppDateTime.cs deleted file mode 100644 index 880d2a8..0000000 --- a/server/src/Data/Static/AppDateTime.cs +++ /dev/null @@ -1,16 +0,0 @@ -namespace IOL.GreatOffice.Api.Data.Static; - -public static class AppDateTime -{ - private static DateTime? dateTime; - - public static DateTime UtcNow => dateTime ?? DateTime.UtcNow; - - public static void Set(DateTime setDateTime) { - dateTime = setDateTime; - } - - public static void Reset() { - dateTime = null; - } -} diff --git a/server/src/Data/Static/AppEnvironmentVariables.cs b/server/src/Data/Static/AppEnvironmentVariables.cs deleted file mode 100644 index c3f821d..0000000 --- a/server/src/Data/Static/AppEnvironmentVariables.cs +++ /dev/null @@ -1,21 +0,0 @@ -namespace IOL.GreatOffice.Api.Data.Static; - -public static class AppEnvironmentVariables -{ - /// <summary> - /// An access token that can be used to access the Hashicorp Vault instance that is available at VAULT_URL - /// </summary> - public const string VAULT_TOKEN = "VAULT_TOKEN"; - /// <summary> - /// An url pointing to the Hashicorp Vault instance the app should use - /// </summary> - public const string VAULT_URL = "VAULT_URL"; - /// <summary> - /// The duration of which to keep a local cached version of the configuration - /// </summary> - public const string VAULT_CACHE_TTL = "VAULT_CACHE_TTL"; - /// <summary> - /// The vault key name for the main configuration json object, described by <see cref="AppConfiguration"/> - /// </summary> - public const string MAIN_CONFIG_SHEET = "MAIN_CONFIG_SHEET"; -} diff --git a/server/src/Data/Static/AppHeaders.cs b/server/src/Data/Static/AppHeaders.cs deleted file mode 100644 index 7912418..0000000 --- a/server/src/Data/Static/AppHeaders.cs +++ /dev/null @@ -1,7 +0,0 @@ -namespace IOL.GreatOffice.Api.Data.Static; - -public static class AppHeaders -{ - public const string BROWSER_TIME_ZONE = "X-TimeZone"; - public const string VAULT_TOKEN = "X-Vault-Token"; -} diff --git a/server/src/Data/Static/AppPaths.cs b/server/src/Data/Static/AppPaths.cs deleted file mode 100644 index a24f5af..0000000 --- a/server/src/Data/Static/AppPaths.cs +++ /dev/null @@ -1,17 +0,0 @@ - -namespace IOL.GreatOffice.Api.Data.Static; - -public static class AppPaths -{ - public static AppPath AppData => new() { - HostPath = Path.Combine(Directory.GetCurrentDirectory(), "AppData") - }; - - public static AppPath DataProtectionKeys => new() { - HostPath = Path.Combine(Directory.GetCurrentDirectory(), "AppData", "dp-keys") - }; - - public static AppPath Frontend => new() { - HostPath = Path.Combine(Directory.GetCurrentDirectory(), "Frontend") - }; -} diff --git a/server/src/Data/Static/JsonSettings.cs b/server/src/Data/Static/JsonSettings.cs deleted file mode 100644 index a163c11..0000000 --- a/server/src/Data/Static/JsonSettings.cs +++ /dev/null @@ -1,11 +0,0 @@ -namespace IOL.GreatOffice.Api.Data.Static; - -public static class JsonSettings -{ - public static Action<JsonOptions> Default { get; } = options => { - options.JsonSerializerOptions.ReferenceHandler = ReferenceHandler.IgnoreCycles; - options.JsonSerializerOptions.PropertyNameCaseInsensitive = true; - options.JsonSerializerOptions.NumberHandling = JsonNumberHandling.AllowReadingFromString; - options.JsonSerializerOptions.PropertyNamingPolicy = JsonNamingPolicy.CamelCase; - }; -} diff --git a/server/src/Endpoints/Internal/Account/CreateAccountPayload.cs b/server/src/Endpoints/Internal/Account/CreateAccountPayload.cs deleted file mode 100644 index dc73e68..0000000 --- a/server/src/Endpoints/Internal/Account/CreateAccountPayload.cs +++ /dev/null @@ -1,17 +0,0 @@ -namespace IOL.GreatOffice.Api.Endpoints.Internal.Account; - -/// <summary> -/// Payload for creating new user accounts. -/// </summary> -public class CreateAccountPayload -{ - /// <summary> - /// Username for the new account. - /// </summary> - public string Username { get; set; } - - /// <summary> - /// Password for the new account. - /// </summary> - public string Password { get; set; } -} diff --git a/server/src/Endpoints/Internal/Account/CreateAccountRoute.cs b/server/src/Endpoints/Internal/Account/CreateAccountRoute.cs deleted file mode 100644 index 954fbf5..0000000 --- a/server/src/Endpoints/Internal/Account/CreateAccountRoute.cs +++ /dev/null @@ -1,44 +0,0 @@ -namespace IOL.GreatOffice.Api.Endpoints.Internal.Account; - -/// <inheritdoc /> -public class CreateAccountRoute : RouteBaseAsync.WithRequest<CreateAccountPayload>.WithActionResult -{ - private readonly AppDbContext _context; - private readonly UserService _userService; - - /// <inheritdoc /> - public CreateAccountRoute(UserService userService, AppDbContext context) { - _userService = userService; - _context = context; - } - - /// <summary> - /// Create a new user account. - /// </summary> - /// <param name="request"></param> - /// <param name="cancellationToken"></param> - /// <returns></returns> - [AllowAnonymous] - [HttpPost("~/_/account/create")] - public override async Task<ActionResult> HandleAsync(CreateAccountPayload request, CancellationToken cancellationToken = default) { - if (request.Username.IsValidEmailAddress() == false) { - return BadRequest(new ErrorResult("Invalid form", request.Username + " does not look like a valid email")); - } - - if (request.Password.Length < 6) { - return BadRequest(new ErrorResult("Invalid form", "The password requires 6 or more characters.")); - } - - var username = request.Username.Trim(); - if (_context.Users.Any(c => c.Username == username)) { - return BadRequest(new ErrorResult("Username is not available", "There is already a user registered with email: " + username)); - } - - var user = new User(username); - user.HashAndSetPassword(request.Password); - _context.Users.Add(user); - await _context.SaveChangesAsync(cancellationToken); - await _userService.LogInUser(HttpContext, user); - return Ok(); - } -} diff --git a/server/src/Endpoints/Internal/Account/CreateInitialAccountRoute.cs b/server/src/Endpoints/Internal/Account/CreateInitialAccountRoute.cs deleted file mode 100644 index 13fbdf4..0000000 --- a/server/src/Endpoints/Internal/Account/CreateInitialAccountRoute.cs +++ /dev/null @@ -1,34 +0,0 @@ -namespace IOL.GreatOffice.Api.Endpoints.Internal.Account; - -/// <inheritdoc /> -public class CreateInitialAccountRoute : RouteBaseAsync.WithoutRequest.WithActionResult -{ - private readonly AppDbContext _context; - private readonly UserService _userService; - - /// <inheritdoc /> - public CreateInitialAccountRoute(AppDbContext context, UserService userService) { - _context = context; - _userService = userService; - } - - /// <summary> - /// Create an initial user account. - /// </summary> - /// <param name="cancellationToken"></param> - /// <returns></returns> - [AllowAnonymous] - [HttpGet("~/_/account/create-initial")] - public override async Task<ActionResult> HandleAsync(CancellationToken cancellationToken = default) { - if (_context.Users.Any()) { - return NotFound(); - } - - var user = new User("admin@ivarlovlie.no"); - user.HashAndSetPassword("ivar123"); - _context.Users.Add(user); - await _context.SaveChangesAsync(cancellationToken); - await _userService.LogInUser(HttpContext, user); - return Redirect("/"); - } -} diff --git a/server/src/Endpoints/Internal/Account/DeleteAccountRoute.cs b/server/src/Endpoints/Internal/Account/DeleteAccountRoute.cs deleted file mode 100644 index 2149e15..0000000 --- a/server/src/Endpoints/Internal/Account/DeleteAccountRoute.cs +++ /dev/null @@ -1,49 +0,0 @@ -namespace IOL.GreatOffice.Api.Endpoints.Internal.Account; - -public class DeleteAccountRoute : RouteBaseAsync.WithoutRequest.WithActionResult -{ - private readonly AppDbContext _context; - private readonly UserService _userService; - - /// <inheritdoc /> - public DeleteAccountRoute(AppDbContext context, UserService userService) { - _context = context; - _userService = userService; - } - - /// <summary> - /// Delete the logged on user's account. - /// </summary> - /// <param name="cancellationToken"></param> - /// <returns></returns> - [HttpDelete("~/_/account/delete")] - public override async Task<ActionResult> HandleAsync(CancellationToken cancellationToken = default) { - var user = _context.Users.SingleOrDefault(c => c.Id == LoggedInUser.Id); - if (user == default) { - await _userService.LogOutUser(HttpContext); - return Unauthorized(); - } - - if (user.Username == "demo@demo.demo") { - await _userService.LogOutUser(HttpContext); - return Ok(); - } - - var githubMappings = _context.TimeCategories.Where(c => c.UserId == user.Id); - var passwordResets = _context.ForgotPasswordRequests.Where(c => c.UserId == user.Id); - var entries = _context.TimeEntries.Where(c => c.UserId == user.Id); - var labels = _context.TimeLabels.Where(c => c.UserId == user.Id); - var categories = _context.TimeCategories.Where(c => c.UserId == user.Id); - - _context.TimeCategories.RemoveRange(githubMappings); - _context.ForgotPasswordRequests.RemoveRange(passwordResets); - _context.TimeEntries.RemoveRange(entries); - _context.TimeLabels.RemoveRange(labels); - _context.TimeCategories.RemoveRange(categories); - _context.Users.Remove(user); - - await _context.SaveChangesAsync(cancellationToken); - await _userService.LogOutUser(HttpContext); - return Ok(); - } -} diff --git a/server/src/Endpoints/Internal/Account/GetArchiveRoute.cs b/server/src/Endpoints/Internal/Account/GetArchiveRoute.cs deleted file mode 100644 index f1b70f3..0000000 --- a/server/src/Endpoints/Internal/Account/GetArchiveRoute.cs +++ /dev/null @@ -1,62 +0,0 @@ -namespace IOL.GreatOffice.Api.Endpoints.Internal.Account; - -public class GetAccountArchiveRoute : RouteBaseAsync.WithoutRequest.WithActionResult<UserArchiveDto> -{ - private readonly AppDbContext _context; - - /// <inheritdoc /> - public GetAccountArchiveRoute(AppDbContext context) { - _context = context; - } - - /// <summary> - /// Get a data archive with the currently logged on user's data. - /// </summary> - /// <param name="cancellationToken"></param> - /// <returns></returns> - [HttpGet("~/_/account/archive")] - public override async Task<ActionResult<UserArchiveDto>> HandleAsync(CancellationToken cancellationToken = default) { - var user = _context.Users.SingleOrDefault(c => c.Id == LoggedInUser.Id); - if (user == default) { - await HttpContext.SignOutAsync(); - return Unauthorized(); - } - - var entries = _context.TimeEntries - .AsNoTracking() - .Include(c => c.Labels) - .Include(c => c.Category) - .Where(c => c.UserId == user.Id) - .ToList(); - - var jsonOptions = new JsonSerializerOptions { - WriteIndented = true - }; - - var dto = new UserArchiveDto(user); - dto.Entries.AddRange(entries.Select(entry => new UserArchiveDto.EntryDto { - CreatedAt = entry.CreatedAt.ToString("yyyy-MM-ddTHH:mm:ssZ"), - StartDateTime = entry.Start, - StopDateTime = entry.Stop, - Description = entry.Description, - Labels = entry.Labels - .Select(c => new UserArchiveDto.LabelDto { - Name = c.Name, - Color = c.Color - }) - .ToList(), - Category = new UserArchiveDto.CategoryDto { - Name = entry.Category.Name, - Color = entry.Category.Color - }, - })); - - dto.CountEntries(); - - var entriesSerialized = JsonSerializer.SerializeToUtf8Bytes(dto, jsonOptions); - - return File(entriesSerialized, - "application/json", - user.Username + "-time-tracker-archive-" + AppDateTime.UtcNow.ToString("yyyyMMddTHHmmss") + ".json"); - } -} diff --git a/server/src/Endpoints/Internal/Account/GetRoute.cs b/server/src/Endpoints/Internal/Account/GetRoute.cs deleted file mode 100644 index 1aa7ecb..0000000 --- a/server/src/Endpoints/Internal/Account/GetRoute.cs +++ /dev/null @@ -1,31 +0,0 @@ -namespace IOL.GreatOffice.Api.Endpoints.Internal.Account; - -public class GetAccountRoute : RouteBaseAsync.WithoutRequest.WithActionResult<LoggedInUserModel> -{ - private readonly AppDbContext _context; - - public GetAccountRoute(AppDbContext context) { - _context = context; - } - - /// <summary> - /// Get the logged on user's session data. - /// </summary> - /// <param name="cancellationToken"></param> - /// <returns></returns> - [HttpGet("~/_/account")] - public override async Task<ActionResult<LoggedInUserModel>> HandleAsync(CancellationToken cancellationToken = default) { - var user = _context.Users - .Select(x => new {x.Username, x.Id}) - .SingleOrDefault(c => c.Id == LoggedInUser.Id); - if (user != default) { - return Ok(new LoggedInUserModel { - Id = LoggedInUser.Id, - Username = LoggedInUser.Username - }); - } - - await HttpContext.SignOutAsync(); - return Unauthorized(); - } -}
\ No newline at end of file diff --git a/server/src/Endpoints/Internal/Account/LoginPayload.cs b/server/src/Endpoints/Internal/Account/LoginPayload.cs deleted file mode 100644 index 807662c..0000000 --- a/server/src/Endpoints/Internal/Account/LoginPayload.cs +++ /dev/null @@ -1,22 +0,0 @@ -namespace IOL.GreatOffice.Api.Endpoints.Internal.Account; - -/// <summary> -/// Payload for logging in a user. -/// </summary> -public class LoginPayload -{ - /// <summary> - /// Username of the user's account. - /// </summary> - public string Username { get; set; } - - /// <summary> - /// Password of the user's account. - /// </summary> - public string Password { get; set; } - - /// <summary> - /// Specify that the created session should be long lived and continually refreshed. - /// </summary> - public bool Persist { get; set; } -} diff --git a/server/src/Endpoints/Internal/Account/LoginRoute.cs b/server/src/Endpoints/Internal/Account/LoginRoute.cs deleted file mode 100644 index 5b41c61..0000000 --- a/server/src/Endpoints/Internal/Account/LoginRoute.cs +++ /dev/null @@ -1,37 +0,0 @@ -namespace IOL.GreatOffice.Api.Endpoints.Internal.Account; - -public class LoginRoute : RouteBaseAsync - .WithRequest<LoginPayload> - .WithActionResult -{ - private readonly AppDbContext _context; - private readonly UserService _userService; - - /// <inheritdoc /> - public LoginRoute(AppDbContext context, UserService userService) { - _context = context; - _userService = userService; - } - - /// <summary> - /// Login a user. - /// </summary> - /// <param name="request"></param> - /// <param name="cancellationToken"></param> - /// <returns></returns> - [AllowAnonymous] - [HttpPost("~/_/account/login")] - public override async Task<ActionResult> HandleAsync(LoginPayload request, CancellationToken cancellationToken = default) { - if (!ModelState.IsValid) { - return BadRequest(ModelState); - } - - var user = _context.Users.SingleOrDefault(u => u.Username == request.Username); - if (user == default || !user.VerifyPassword(request.Password)) { - return BadRequest(new ErrorResult("Invalid username or password")); - } - - await _userService.LogInUser(HttpContext, user, request.Persist); - return Ok(); - } -} diff --git a/server/src/Endpoints/Internal/Account/LogoutRoute.cs b/server/src/Endpoints/Internal/Account/LogoutRoute.cs deleted file mode 100644 index 4a06f4a..0000000 --- a/server/src/Endpoints/Internal/Account/LogoutRoute.cs +++ /dev/null @@ -1,22 +0,0 @@ -namespace IOL.GreatOffice.Api.Endpoints.Internal.Account; - -public class LogoutRoute : RouteBaseAsync.WithoutRequest.WithActionResult -{ - private readonly UserService _userService; - - public LogoutRoute(UserService userService) { - _userService = userService; - } - - /// <summary> - /// Logout a user. - /// </summary> - /// <param name="cancellationToken"></param> - /// <returns></returns> - [AllowAnonymous] - [HttpGet("~/_/account/logout")] - public override async Task<ActionResult> HandleAsync(CancellationToken cancellationToken = default) { - await _userService.LogOutUser(HttpContext); - return Ok(); - } -} diff --git a/server/src/Endpoints/Internal/Account/UpdateAccountPayload.cs b/server/src/Endpoints/Internal/Account/UpdateAccountPayload.cs deleted file mode 100644 index 88a3237..0000000 --- a/server/src/Endpoints/Internal/Account/UpdateAccountPayload.cs +++ /dev/null @@ -1,17 +0,0 @@ -namespace IOL.GreatOffice.Api.Endpoints.Internal.Account; - -/// <summary> -/// Payload for updating an account. -/// </summary> -public class UpdatePayload -{ - /// <summary> - /// Username to set on the logged on user's account. - /// </summary> - public string Username { get; set; } - - /// <summary> - /// Password to set on the logged on user's account. - /// </summary> - public string Password { get; set; } -} diff --git a/server/src/Endpoints/Internal/Account/UpdateAccountRoute.cs b/server/src/Endpoints/Internal/Account/UpdateAccountRoute.cs deleted file mode 100644 index a997dcb..0000000 --- a/server/src/Endpoints/Internal/Account/UpdateAccountRoute.cs +++ /dev/null @@ -1,51 +0,0 @@ -namespace IOL.GreatOffice.Api.Endpoints.Internal.Account; - -public class UpdateAccountRoute : RouteBaseAsync.WithRequest<UpdatePayload>.WithActionResult -{ - private readonly AppDbContext _context; - - /// <inheritdoc /> - public UpdateAccountRoute(AppDbContext context) { - _context = context; - } - - /// <summary> - /// Update the logged on user's data. - /// </summary> - /// <param name="request"></param> - /// <param name="cancellationToken"></param> - /// <returns></returns> - [HttpPost("~/_/account/update")] - public override async Task<ActionResult> HandleAsync(UpdatePayload request, CancellationToken cancellationToken = default) { - var user = _context.Users.SingleOrDefault(c => c.Id == LoggedInUser.Id); - if (user == default) { - await HttpContext.SignOutAsync(); - return Unauthorized(); - } - - if (request.Password.IsNullOrWhiteSpace() && request.Username.IsNullOrWhiteSpace()) { - return BadRequest(new ErrorResult("Invalid request", "No data was submitted")); - } - - if (request.Password.HasValue() && request.Password.Length < 6) { - return BadRequest(new ErrorResult("Invalid request", - "The new password must contain at least 6 characters")); - } - - if (request.Password.HasValue()) { - user.HashAndSetPassword(request.Password); - } - - if (request.Username.HasValue() && !request.Username.IsValidEmailAddress()) { - return BadRequest(new ErrorResult("Invalid request", - "The new username does not look like a valid email address")); - } - - if (request.Username.HasValue()) { - user.Username = request.Username.Trim(); - } - - await _context.SaveChangesAsync(cancellationToken); - return Ok(); - } -} diff --git a/server/src/Endpoints/Internal/BaseRoute.cs b/server/src/Endpoints/Internal/BaseRoute.cs deleted file mode 100644 index 3e2c6af..0000000 --- a/server/src/Endpoints/Internal/BaseRoute.cs +++ /dev/null @@ -1,16 +0,0 @@ -namespace IOL.GreatOffice.Api.Endpoints.Internal; - -[Authorize] -[ApiController] -[ApiExplorerSettings(IgnoreApi = true)] -[ApiVersionNeutral] -public class BaseRoute : ControllerBase -{ - /// <summary> - /// User data for the currently logged on user. - /// </summary> - protected LoggedInUserModel LoggedInUser => new() { - Username = User.FindFirstValue(AppClaims.NAME), - Id = User.FindFirstValue(AppClaims.USER_ID).AsGuid(), - }; -} diff --git a/server/src/Endpoints/Internal/PasswordResetRequests/CreateResetRequestRoute.cs b/server/src/Endpoints/Internal/PasswordResetRequests/CreateResetRequestRoute.cs deleted file mode 100644 index 8fbc9a0..0000000 --- a/server/src/Endpoints/Internal/PasswordResetRequests/CreateResetRequestRoute.cs +++ /dev/null @@ -1,59 +0,0 @@ -namespace IOL.GreatOffice.Api.Endpoints.Internal.PasswordResetRequests; - -/// <inheritdoc /> -public class CreateResetRequestRoute : RouteBaseAsync.WithRequest<string>.WithActionResult -{ - private readonly ILogger<CreateResetRequestRoute> _logger; - private readonly PasswordResetService _passwordResetService; - private readonly AppDbContext _context; - - /// <inheritdoc /> - public CreateResetRequestRoute(ILogger<CreateResetRequestRoute> logger, PasswordResetService passwordResetService, AppDbContext context) { - _logger = logger; - _passwordResetService = passwordResetService; - _context = context; - } - - /// <summary> - /// Create a new password reset request. - /// </summary> - /// <param name="username"></param> - /// <param name="cancellationToken"></param> - /// <returns></returns> - [AllowAnonymous] - [HttpGet("~/_/forgot-password-requests/create")] - public override async Task<ActionResult> HandleAsync(string username, CancellationToken cancellationToken = default) { - if (!username.IsValidEmailAddress()) { - _logger.LogInformation("Username is invalid, not doing request for password change"); - return BadRequest(new ErrorResult("Invalid email address", username + " looks like an invalid email address")); - } - - Request.Headers.TryGetValue(AppHeaders.BROWSER_TIME_ZONE, out var timeZoneHeader); - var tz = TimeZoneInfo.FindSystemTimeZoneById(timeZoneHeader.ToString().HasValue() ? timeZoneHeader.ToString() : "UTC"); - var offset = tz.BaseUtcOffset.Hours; - - // this is fine as long as the client is not connecting from Australia: Lord Howe Island - // according to https://en.wikipedia.org/wiki/Daylight_saving_time_by_country - if (tz.IsDaylightSavingTime(AppDateTime.UtcNow)) { - offset++; - } - - _logger.LogInformation("Request time zone (" + tz.Id + ") offset is: " + offset + " hours"); - var requestDateTime = TimeZoneInfo.ConvertTimeFromUtc(AppDateTime.UtcNow, tz); - _logger.LogInformation("Creating forgot password request with date time: " + requestDateTime.ToString("u")); - - try { - var user = _context.Users.SingleOrDefault(c => c.Username.Equals(username)); - if (user != default) { - await _passwordResetService.AddRequestAsync(user, tz, cancellationToken); - return Ok(); - } - - _logger.LogInformation("User was not found, not doing request for password change"); - return Ok(); - } catch (Exception e) { - _logger.LogError(e, "ForgotAction failed badly"); - return Ok(); - } - } -} diff --git a/server/src/Endpoints/Internal/PasswordResetRequests/FulfillResetRequestPayload.cs b/server/src/Endpoints/Internal/PasswordResetRequests/FulfillResetRequestPayload.cs deleted file mode 100644 index f0fb59f..0000000 --- a/server/src/Endpoints/Internal/PasswordResetRequests/FulfillResetRequestPayload.cs +++ /dev/null @@ -1,14 +0,0 @@ -namespace IOL.GreatOffice.Api.Endpoints.Internal.PasswordResetRequests; - -public class FulfillResetRequestPayload -{ - /// <summary> - /// Id of the password reset request to fulfill - /// </summary> - public Guid Id { get; set; } - - /// <summary> - /// New password to set on the relevant account - /// </summary> - public string NewPassword { get; set; } -} diff --git a/server/src/Endpoints/Internal/PasswordResetRequests/FulfillResetRequestRoute.cs b/server/src/Endpoints/Internal/PasswordResetRequests/FulfillResetRequestRoute.cs deleted file mode 100644 index 96f344a..0000000 --- a/server/src/Endpoints/Internal/PasswordResetRequests/FulfillResetRequestRoute.cs +++ /dev/null @@ -1,34 +0,0 @@ - -namespace IOL.GreatOffice.Api.Endpoints.Internal.PasswordResetRequests; - -/// <inheritdoc /> -public class FulfillResetRequestRoute : RouteBaseAsync.WithRequest<FulfillResetRequestPayload>.WithActionResult -{ - private readonly PasswordResetService _passwordResetService; - - /// <inheritdoc /> - public FulfillResetRequestRoute(PasswordResetService passwordResetService) { - _passwordResetService = passwordResetService; - } - - /// <summary> - /// Fulfill a password reset request. - /// </summary> - /// <param name="request"></param> - /// <param name="cancellationToken"></param> - /// <returns></returns> - [AllowAnonymous] - [HttpPost("~/_/forgot-password-requests/fulfill")] - public override async Task<ActionResult> HandleAsync(FulfillResetRequestPayload request, CancellationToken cancellationToken = default) { - try { - var fulfilled = await _passwordResetService.FullFillRequestAsync(request.Id, request.NewPassword, cancellationToken); - return Ok(fulfilled); - } catch (Exception e) { - if (e is ForgotPasswordRequestNotFoundException or UserNotFoundException) { - return NotFound(); - } - - throw; - } - } -} diff --git a/server/src/Endpoints/Internal/PasswordResetRequests/IsResetRequestValidRoute.cs b/server/src/Endpoints/Internal/PasswordResetRequests/IsResetRequestValidRoute.cs deleted file mode 100644 index c4dcd22..0000000 --- a/server/src/Endpoints/Internal/PasswordResetRequests/IsResetRequestValidRoute.cs +++ /dev/null @@ -1,29 +0,0 @@ -namespace IOL.GreatOffice.Api.Endpoints.Internal.PasswordResetRequests; - -/// <inheritdoc /> -public class IsResetRequestValidRoute : RouteBaseAsync.WithRequest<Guid>.WithActionResult -{ - private readonly PasswordResetService _passwordResetService; - - /// <inheritdoc /> - public IsResetRequestValidRoute(PasswordResetService passwordResetService) { - _passwordResetService = passwordResetService; - } - - /// <summary> - /// Check if a given password reset request is still valid. - /// </summary> - /// <param name="id"></param> - /// <param name="cancellationToken"></param> - /// <returns></returns> - [AllowAnonymous] - [HttpGet("~/_/forgot-password-requests/is-valid")] - public override async Task<ActionResult> HandleAsync(Guid id, CancellationToken cancellationToken = default) { - var request = await _passwordResetService.GetRequestAsync(id, cancellationToken); - if (request == default) { - return NotFound(); - } - - return Ok(request.IsExpired == false); - } -} diff --git a/server/src/Endpoints/Internal/Root/GetApplicationVersionRoute.cs b/server/src/Endpoints/Internal/Root/GetApplicationVersionRoute.cs deleted file mode 100644 index 5fb8213..0000000 --- a/server/src/Endpoints/Internal/Root/GetApplicationVersionRoute.cs +++ /dev/null @@ -1,21 +0,0 @@ -namespace IOL.GreatOffice.Api.Endpoints.Internal.Root; - -public class GetApplicationVersionRoute : RouteBaseSync.WithoutRequest.WithActionResult<string> -{ - private readonly IWebHostEnvironment _environment; - - /// <inheritdoc /> - public GetApplicationVersionRoute(IWebHostEnvironment environment) { - _environment = environment; - } - - /// <summary> - /// Get the running api version number. - /// </summary> - /// <returns></returns> - [HttpGet("~/_/version")] - public override ActionResult<string> Handle() { - var versionFilePath = Path.Combine(_environment.WebRootPath, "version.txt"); - return Ok(System.IO.File.ReadAllText(versionFilePath)); - } -} diff --git a/server/src/Endpoints/Internal/Root/LogRoute.cs b/server/src/Endpoints/Internal/Root/LogRoute.cs deleted file mode 100644 index 48b497a..0000000 --- a/server/src/Endpoints/Internal/Root/LogRoute.cs +++ /dev/null @@ -1,16 +0,0 @@ -namespace IOL.GreatOffice.Api.Endpoints.Internal.Root; - -public class LogRoute : RouteBaseSync.WithRequest<string>.WithoutResult -{ - private readonly ILogger<LogRoute> _logger; - - public LogRoute(ILogger<LogRoute> logger) { - _logger = logger; - } - - [AllowAnonymous] - [HttpPost("~/_/log")] - public override void Handle([FromBody] string request) { - _logger.LogInformation(request); - } -} diff --git a/server/src/Endpoints/Internal/Root/ReadConfigurationRoute.cs b/server/src/Endpoints/Internal/Root/ReadConfigurationRoute.cs deleted file mode 100644 index e0dcca3..0000000 --- a/server/src/Endpoints/Internal/Root/ReadConfigurationRoute.cs +++ /dev/null @@ -1,17 +0,0 @@ -namespace IOL.GreatOffice.Api.Endpoints.Internal.Root; - -public class ReadConfigurationRoute : RouteBaseSync.WithoutRequest.WithActionResult -{ - private readonly VaultService _vaultService; - - public ReadConfigurationRoute(VaultService vaultService) { - _vaultService = vaultService; - } - - [AllowAnonymous] - [HttpGet("~/_/configuration")] - public override ActionResult Handle() { - var config = _vaultService.GetCurrentAppConfiguration(); - return Content(JsonSerializer.Serialize(config.GetPublicVersion()), "application/json"); - } -} diff --git a/server/src/Endpoints/Internal/Root/RefreshConfigurationRoute.cs b/server/src/Endpoints/Internal/Root/RefreshConfigurationRoute.cs deleted file mode 100644 index 4b1beec..0000000 --- a/server/src/Endpoints/Internal/Root/RefreshConfigurationRoute.cs +++ /dev/null @@ -1,15 +0,0 @@ -namespace IOL.GreatOffice.Api.Endpoints.Internal.Root; - -public class RefreshConfigurationRoute : RouteBaseSync.WithoutRequest.WithoutResult -{ - private readonly VaultService _vaultService; - - public RefreshConfigurationRoute(VaultService vaultService) { - _vaultService = vaultService; - } - - [HttpGet("~/_/refresh-configuration")] - public override void Handle() { - _vaultService.RefreshCurrentAppConfiguration(); - } -} diff --git a/server/src/Endpoints/Internal/Root/ValidSessionRoute.cs b/server/src/Endpoints/Internal/Root/ValidSessionRoute.cs deleted file mode 100644 index f377ff6..0000000 --- a/server/src/Endpoints/Internal/Root/ValidSessionRoute.cs +++ /dev/null @@ -1,10 +0,0 @@ -namespace IOL.GreatOffice.Api.Endpoints.Internal.Root; - -public class ValidSessionRoute : RouteBaseSync.WithoutRequest.WithActionResult -{ - [Authorize] - [HttpGet("~/_/valid-session")] - public override ActionResult Handle() { - return Ok(); - } -}
\ No newline at end of file diff --git a/server/src/Endpoints/Internal/RouteBaseAsync.cs b/server/src/Endpoints/Internal/RouteBaseAsync.cs deleted file mode 100644 index 1bb0af0..0000000 --- a/server/src/Endpoints/Internal/RouteBaseAsync.cs +++ /dev/null @@ -1,73 +0,0 @@ -namespace IOL.GreatOffice.Api.Endpoints.Internal; - -/// <summary> -/// A base class for an endpoint that accepts parameters. -/// </summary> -public static class RouteBaseAsync -{ - public static class WithRequest<TRequest> - { - public abstract class WithResult<TResponse> : BaseRoute - { - public abstract Task<TResponse> HandleAsync( - TRequest request, - CancellationToken cancellationToken = default - ); - } - - public abstract class WithoutResult : BaseRoute - { - public abstract Task HandleAsync( - TRequest request, - CancellationToken cancellationToken = default - ); - } - - public abstract class WithActionResult<TResponse> : BaseRoute - { - public abstract Task<ActionResult<TResponse>> HandleAsync( - TRequest request, - CancellationToken cancellationToken = default - ); - } - - public abstract class WithActionResult : BaseRoute - { - public abstract Task<ActionResult> HandleAsync( - TRequest request, - CancellationToken cancellationToken = default - ); - } - } - - public static class WithoutRequest - { - public abstract class WithResult<TResponse> : BaseRoute - { - public abstract Task<TResponse> HandleAsync( - CancellationToken cancellationToken = default - ); - } - - public abstract class WithoutResult : BaseRoute - { - public abstract Task HandleAsync( - CancellationToken cancellationToken = default - ); - } - - public abstract class WithActionResult<TResponse> : BaseRoute - { - public abstract Task<ActionResult<TResponse>> HandleAsync( - CancellationToken cancellationToken = default - ); - } - - public abstract class WithActionResult : BaseRoute - { - public abstract Task<ActionResult> HandleAsync( - CancellationToken cancellationToken = default - ); - } - } -} diff --git a/server/src/Endpoints/Internal/RouteBaseSync.cs b/server/src/Endpoints/Internal/RouteBaseSync.cs deleted file mode 100644 index 173999d..0000000 --- a/server/src/Endpoints/Internal/RouteBaseSync.cs +++ /dev/null @@ -1,53 +0,0 @@ -namespace IOL.GreatOffice.Api.Endpoints.Internal; - -/// <summary> -/// A base class for an endpoint that accepts parameters. -/// </summary> -public static class RouteBaseSync -{ - public static class WithRequest<TRequest> - { - public abstract class WithResult<TResponse> : BaseRoute - { - public abstract TResponse Handle(TRequest request); - } - - public abstract class WithoutResult : BaseRoute - { - public abstract void Handle(TRequest request); - } - - public abstract class WithActionResult<TResponse> : BaseRoute - { - public abstract ActionResult<TResponse> Handle(TRequest request); - } - - public abstract class WithActionResult : BaseRoute - { - public abstract ActionResult Handle(TRequest request); - } - } - - public static class WithoutRequest - { - public abstract class WithResult<TResponse> : BaseRoute - { - public abstract TResponse Handle(); - } - - public abstract class WithoutResult : BaseRoute - { - public abstract void Handle(); - } - - public abstract class WithActionResult<TResponse> : BaseRoute - { - public abstract ActionResult<TResponse> Handle(); - } - - public abstract class WithActionResult : BaseRoute - { - public abstract ActionResult Handle(); - } - } -} diff --git a/server/src/Endpoints/V1/ApiSpecV1.cs b/server/src/Endpoints/V1/ApiSpecV1.cs deleted file mode 100644 index e4f9cc9..0000000 --- a/server/src/Endpoints/V1/ApiSpecV1.cs +++ /dev/null @@ -1,18 +0,0 @@ -namespace IOL.GreatOffice.Api.Endpoints.V1; - -public static class ApiSpecV1 -{ - private const int MAJOR = 1; - private const int MINOR = 0; - public const string VERSION_STRING = "1.0"; - - public static ApiSpecDocument Document => new() { - Version = new ApiVersion(MAJOR, MINOR), - VersionName = VERSION_STRING, - SwaggerPath = $"/swagger/{VERSION_STRING}/swagger.json", - OpenApiInfo = new OpenApiInfo { - Title = AppConstants.API_NAME, - Version = VERSION_STRING - } - }; -} diff --git a/server/src/Endpoints/V1/ApiTokens/CreateTokenRoute.cs b/server/src/Endpoints/V1/ApiTokens/CreateTokenRoute.cs deleted file mode 100644 index 2086619..0000000 --- a/server/src/Endpoints/V1/ApiTokens/CreateTokenRoute.cs +++ /dev/null @@ -1,57 +0,0 @@ -using System.Text; - -namespace IOL.GreatOffice.Api.Endpoints.V1.ApiTokens; - -public class CreateTokenRoute : RouteBaseSync.WithRequest<ApiAccessToken.ApiAccessTokenDto>.WithActionResult -{ - private readonly AppDbContext _context; - private readonly AppConfiguration _configuration; - private readonly ILogger<CreateTokenRoute> _logger; - - public CreateTokenRoute(AppDbContext context, VaultService vaultService, ILogger<CreateTokenRoute> logger) - { - _context = context; - _configuration = vaultService.GetCurrentAppConfiguration(); - _logger = logger; - } - - /// <summary> - /// Create a new api token with the provided claims. - /// </summary> - /// <param name="request">The claims to set on the api token</param> - /// <returns></returns> - [ApiVersion(ApiSpecV1.VERSION_STRING)] - [HttpPost("~/v{version:apiVersion}/api-tokens/create")] - [ProducesResponseType(200, Type = typeof(string))] - [ProducesResponseType(404, Type = typeof(ErrorResult))] - public override ActionResult Handle(ApiAccessToken.ApiAccessTokenDto request) - { - var user = _context.Users.SingleOrDefault(c => c.Id == LoggedInUser.Id); - if (user == default) - { - return NotFound(new ErrorResult("User does not exist")); - } - - var token_entropy = _configuration.APP_AES_KEY; - if (token_entropy.IsNullOrWhiteSpace()) - { - _logger.LogWarning("No token entropy is available, Basic auth is disabled"); - return NotFound(); - } - - var access_token = new ApiAccessToken() - { - Id = Guid.NewGuid(), - User = user, - ExpiryDate = request.ExpiryDate.ToUniversalTime(), - AllowCreate = request.AllowCreate, - AllowRead = request.AllowRead, - AllowDelete = request.AllowDelete, - AllowUpdate = request.AllowUpdate - }; - - _context.AccessTokens.Add(access_token); - _context.SaveChanges(); - return Ok(Convert.ToBase64String(Encoding.UTF8.GetBytes(access_token.Id.ToString().EncryptWithAes(token_entropy)))); - } -} diff --git a/server/src/Endpoints/V1/ApiTokens/DeleteTokenRoute.cs b/server/src/Endpoints/V1/ApiTokens/DeleteTokenRoute.cs deleted file mode 100644 index a90b4c0..0000000 --- a/server/src/Endpoints/V1/ApiTokens/DeleteTokenRoute.cs +++ /dev/null @@ -1,33 +0,0 @@ -namespace IOL.GreatOffice.Api.Endpoints.V1.ApiTokens; - -public class DeleteTokenRoute : RouteBaseSync.WithRequest<Guid>.WithActionResult -{ - private readonly AppDbContext _context; - private readonly ILogger<DeleteTokenRoute> _logger; - - public DeleteTokenRoute(AppDbContext context, ILogger<DeleteTokenRoute> logger) { - _context = context; - _logger = logger; - } - - /// <summary> - /// Delete an api token, rendering it unusable - /// </summary> - /// <param name="id">Id of the token to delete</param> - /// <returns>Nothing</returns> - [ApiVersion(ApiSpecV1.VERSION_STRING)] - [HttpDelete("~/v{version:apiVersion}/api-tokens/delete")] - [ProducesResponseType(200)] - [ProducesResponseType(404)] - public override ActionResult Handle(Guid id) { - var token = _context.AccessTokens.SingleOrDefault(c => c.Id == id); - if (token == default) { - _logger.LogWarning("A deletion request of an already deleted (maybe) api token was received."); - return NotFound(); - } - - _context.AccessTokens.Remove(token); - _context.SaveChanges(); - return Ok(); - } -} diff --git a/server/src/Endpoints/V1/ApiTokens/GetTokensRoute.cs b/server/src/Endpoints/V1/ApiTokens/GetTokensRoute.cs deleted file mode 100644 index 59fd077..0000000 --- a/server/src/Endpoints/V1/ApiTokens/GetTokensRoute.cs +++ /dev/null @@ -1,22 +0,0 @@ -namespace IOL.GreatOffice.Api.Endpoints.V1.ApiTokens; - -public class GetTokensRoute : RouteBaseSync.WithoutRequest.WithResult<ActionResult<List<ApiAccessToken.ApiAccessTokenDto>>> -{ - private readonly AppDbContext _context; - - public GetTokensRoute(AppDbContext context) { - _context = context; - } - - /// <summary> - /// Get all tokens, both active and inactive. - /// </summary> - /// <returns>A list of tokens</returns> - [ApiVersion(ApiSpecV1.VERSION_STRING)] - [HttpGet("~/v{version:apiVersion}/api-tokens")] - [ProducesResponseType(200, Type = typeof(List<ApiAccessToken.ApiAccessTokenDto>))] - [ProducesResponseType(204)] - public override ActionResult<List<ApiAccessToken.ApiAccessTokenDto>> Handle() { - return Ok(_context.AccessTokens.Where(c => c.User.Id == LoggedInUser.Id).Select(c => c.AsDto)); - } -} diff --git a/server/src/Endpoints/V1/BaseRoute.cs b/server/src/Endpoints/V1/BaseRoute.cs deleted file mode 100644 index e7d72ac..0000000 --- a/server/src/Endpoints/V1/BaseRoute.cs +++ /dev/null @@ -1,39 +0,0 @@ -using System.Net.Http.Headers; - -namespace IOL.GreatOffice.Api.Endpoints.V1; - -/// <inheritdoc /> -[ApiVersion(ApiSpecV1.VERSION_STRING)] -[Authorize(AuthenticationSchemes = AuthSchemes)] -[ApiController] -public class BaseRoute : ControllerBase -{ - private const string AuthSchemes = CookieAuthenticationDefaults.AuthenticationScheme + "," + AppConstants.BASIC_AUTH_SCHEME; - - /// <summary> - /// User data for the currently logged on user. - /// </summary> - protected LoggedInUserModel LoggedInUser => new() { - Username = User.FindFirstValue(AppClaims.NAME), - Id = User.FindFirstValue(AppClaims.USER_ID).AsGuid(), - }; - - protected bool IsApiCall() { - if (!Request.Headers.ContainsKey("Authorization")) return false; - try { - var authHeader = AuthenticationHeaderValue.Parse(Request.Headers["Authorization"]); - if (authHeader.Parameter == null) return false; - } catch { - return false; - } - - return true; - } - - protected bool HasApiPermission(string permission_key) { - var permission_claim = User.Claims.SingleOrDefault(c => c.Type == permission_key); - return permission_claim is { - Value: "True" - }; - } -} diff --git a/server/src/Endpoints/V1/Categories/CreateCategoryRoute.cs b/server/src/Endpoints/V1/Categories/CreateCategoryRoute.cs deleted file mode 100644 index fac2b5e..0000000 --- a/server/src/Endpoints/V1/Categories/CreateCategoryRoute.cs +++ /dev/null @@ -1,43 +0,0 @@ -namespace IOL.GreatOffice.Api.Endpoints.V1.Categories; - -public class CreateCategoryRoute : RouteBaseSync.WithRequest<TimeCategory.TimeCategoryDto>.WithActionResult<TimeCategory.TimeCategoryDto> -{ - private readonly AppDbContext _context; - - public CreateCategoryRoute(AppDbContext context) { - _context = context; - } - - /// <summary> - /// Create a new time entry category. - /// </summary> - /// <param name="categoryTimeCategoryDto"></param> - /// <returns></returns> - [ApiVersion(ApiSpecV1.VERSION_STRING)] - [BasicAuthentication(AppConstants.TOKEN_ALLOW_CREATE)] - [HttpPost("~/v{version:apiVersion}/categories/create")] - [ProducesResponseType(200, Type = typeof(TimeCategory.TimeCategoryDto))] - public override ActionResult<TimeCategory.TimeCategoryDto> Handle(TimeCategory.TimeCategoryDto categoryTimeCategoryDto) { - var duplicate = _context.TimeCategories - .Where(c => c.UserId == LoggedInUser.Id) - .Any(c => c.Name.Trim() == categoryTimeCategoryDto.Name.Trim()); - if (duplicate) { - var category = _context.TimeCategories - .Where(c => c.UserId == LoggedInUser.Id) - .SingleOrDefault(c => c.Name.Trim() == categoryTimeCategoryDto.Name.Trim()); - if (category != default) { - return Ok(category.AsDto); - } - } - - var newCategory = new TimeCategory(LoggedInUser.Id) { - Name = categoryTimeCategoryDto.Name.Trim(), - Color = categoryTimeCategoryDto.Color - }; - - _context.TimeCategories.Add(newCategory); - _context.SaveChanges(); - categoryTimeCategoryDto.Id = newCategory.Id; - return Ok(categoryTimeCategoryDto); - } -} diff --git a/server/src/Endpoints/V1/Categories/DeleteCategoryRoute.cs b/server/src/Endpoints/V1/Categories/DeleteCategoryRoute.cs deleted file mode 100644 index 3d438a0..0000000 --- a/server/src/Endpoints/V1/Categories/DeleteCategoryRoute.cs +++ /dev/null @@ -1,38 +0,0 @@ -namespace IOL.GreatOffice.Api.Endpoints.V1.Categories; - -public class DeleteCategoryRoute : RouteBaseSync.WithRequest<Guid>.WithActionResult -{ - private readonly AppDbContext _context; - - public DeleteCategoryRoute(AppDbContext context) { - _context = context; - } - - /// <summary> - /// Delete a time entry category. - /// </summary> - /// <param name="id"></param> - /// <returns></returns> - [ApiVersion(ApiSpecV1.VERSION_STRING)] - [BasicAuthentication(AppConstants.TOKEN_ALLOW_DELETE)] - [HttpDelete("~/v{version:apiVersion}/categories/{id:guid}/delete")] - [ProducesResponseType(200)] - [ProducesResponseType(404)] - public override ActionResult Handle(Guid id) { - var category = _context.TimeCategories - .Where(c => c.UserId == LoggedInUser.Id) - .SingleOrDefault(c => c.Id == id); - - if (category == default) { - return NotFound(); - } - - var entries = _context.TimeEntries - .Include(c => c.Category) - .Where(c => c.Category.Id == category.Id); - _context.TimeEntries.RemoveRange(entries); - _context.TimeCategories.Remove(category); - _context.SaveChanges(); - return Ok(); - } -} diff --git a/server/src/Endpoints/V1/Categories/GetCategoriesRoute.cs b/server/src/Endpoints/V1/Categories/GetCategoriesRoute.cs deleted file mode 100644 index a40a832..0000000 --- a/server/src/Endpoints/V1/Categories/GetCategoriesRoute.cs +++ /dev/null @@ -1,35 +0,0 @@ -namespace IOL.GreatOffice.Api.Endpoints.V1.Categories; - -/// <inheritdoc /> -public class GetCategoriesRoute : RouteBaseSync.WithoutRequest.WithActionResult<List<TimeCategory.TimeCategoryDto>> -{ - private readonly AppDbContext _context; - - /// <inheritdoc /> - public GetCategoriesRoute(AppDbContext context) { - _context = context; - } - - /// <summary> - /// Get a minimal list of time entry categories. - /// </summary> - /// <returns></returns> - [ApiVersion(ApiSpecV1.VERSION_STRING)] - [ProducesResponseType(200, Type = typeof(List<TimeCategory.TimeCategoryDto>))] - [ProducesResponseType(204)] - [BasicAuthentication(AppConstants.TOKEN_ALLOW_READ)] - [HttpGet("~/v{version:apiVersion}/categories")] - public override ActionResult<List<TimeCategory.TimeCategoryDto>> Handle() { - var categories = _context.TimeCategories - .Where(c => c.UserId == LoggedInUser.Id) - .OrderByDescending(c => c.CreatedAt) - .Select(c => c.AsDto) - .ToList(); - - if (categories.Count == 0) { - return NoContent(); - } - - return Ok(categories); - } -} diff --git a/server/src/Endpoints/V1/Categories/UpdateCategoryRoute.cs b/server/src/Endpoints/V1/Categories/UpdateCategoryRoute.cs deleted file mode 100644 index ca7dfdf..0000000 --- a/server/src/Endpoints/V1/Categories/UpdateCategoryRoute.cs +++ /dev/null @@ -1,39 +0,0 @@ -namespace IOL.GreatOffice.Api.Endpoints.V1.Categories; - -public class UpdateCategoryRoute : RouteBaseSync.WithRequest<TimeCategory.TimeCategoryDto>.WithActionResult -{ - private readonly AppDbContext _context; - - public UpdateCategoryRoute(AppDbContext context) { - _context = context; - } - - /// <summary> - /// Update a time entry category. - /// </summary> - /// <param name="categoryTimeCategoryDto"></param> - /// <returns></returns> - [ApiVersion(ApiSpecV1.VERSION_STRING)] - [BasicAuthentication(AppConstants.TOKEN_ALLOW_UPDATE)] - [HttpPost("~/v{version:apiVersion}/categories/update")] - [ProducesResponseType(200)] - [ProducesResponseType(404)] - [ProducesResponseType(403)] - public override ActionResult Handle(TimeCategory.TimeCategoryDto categoryTimeCategoryDto) { - var category = _context.TimeCategories - .Where(c => c.UserId == LoggedInUser.Id) - .SingleOrDefault(c => c.Id == categoryTimeCategoryDto.Id); - if (category == default) { - return NotFound(); - } - - if (LoggedInUser.Id != category.UserId) { - return Forbid(); - } - - category.Name = categoryTimeCategoryDto.Name; - category.Color = categoryTimeCategoryDto.Color; - _context.SaveChanges(); - return Ok(); - } -} diff --git a/server/src/Endpoints/V1/Entries/CreateEntryRoute.cs b/server/src/Endpoints/V1/Entries/CreateEntryRoute.cs deleted file mode 100644 index 362e430..0000000 --- a/server/src/Endpoints/V1/Entries/CreateEntryRoute.cs +++ /dev/null @@ -1,65 +0,0 @@ -namespace IOL.GreatOffice.Api.Endpoints.V1.Entries; - -public class CreateEntryRoute : RouteBaseSync.WithRequest<TimeEntry.TimeEntryDto>.WithActionResult<TimeEntry.TimeEntryDto> -{ - private readonly AppDbContext _context; - - public CreateEntryRoute(AppDbContext context) { - _context = context; - } - - /// <summary> - /// Create a time entry. - /// </summary> - /// <param name="timeEntryTimeEntryDto"></param> - /// <returns></returns> - [ApiVersion(ApiSpecV1.VERSION_STRING)] - [BasicAuthentication(AppConstants.TOKEN_ALLOW_CREATE)] - [ProducesResponseType(200)] - [ProducesResponseType(400, Type = typeof(ErrorResult))] - [ProducesResponseType(404, Type = typeof(ErrorResult))] - [HttpPost("~/v{version:apiVersion}/entries/create")] - public override ActionResult<TimeEntry.TimeEntryDto> Handle(TimeEntry.TimeEntryDto timeEntryTimeEntryDto) { - if (timeEntryTimeEntryDto.Stop == default) { - return BadRequest(new ErrorResult("Invalid form", "A stop date is required")); - } - - if (timeEntryTimeEntryDto.Start == default) { - return BadRequest(new ErrorResult("Invalid form", "A start date is required")); - } - - if (timeEntryTimeEntryDto.Category == default) { - return BadRequest(new ErrorResult("Invalid form", "A category is required")); - } - - var category = _context.TimeCategories - .Where(c => c.UserId == LoggedInUser.Id) - .SingleOrDefault(c => c.Id == timeEntryTimeEntryDto.Category.Id); - if (category == default) { - return NotFound(new ErrorResult("Not found", $"Could not find category {timeEntryTimeEntryDto.Category.Name}")); - } - - var entry = new TimeEntry(LoggedInUser.Id) { - Category = category, - Start = timeEntryTimeEntryDto.Start.ToUniversalTime(), - Stop = timeEntryTimeEntryDto.Stop.ToUniversalTime(), - Description = timeEntryTimeEntryDto.Description, - }; - - if (timeEntryTimeEntryDto.Labels?.Count > 0) { - var labels = _context.TimeLabels - .Where(c => c.UserId == LoggedInUser.Id) - .Where(c => timeEntryTimeEntryDto.Labels.Select(p => p.Id).Contains(c.Id)) - .ToList(); - if (labels.Count != timeEntryTimeEntryDto.Labels.Count) { - return NotFound(new ErrorResult("Not found", "Could not find all of the specified labels")); - } - - entry.Labels = labels; - } - - _context.TimeEntries.Add(entry); - _context.SaveChanges(); - return Ok(entry.AsDto); - } -} diff --git a/server/src/Endpoints/V1/Entries/DeleteEntryRoute.cs b/server/src/Endpoints/V1/Entries/DeleteEntryRoute.cs deleted file mode 100644 index 0850af0..0000000 --- a/server/src/Endpoints/V1/Entries/DeleteEntryRoute.cs +++ /dev/null @@ -1,35 +0,0 @@ -namespace IOL.GreatOffice.Api.Endpoints.V1.Entries; - -/// <inheritdoc /> -public class DeleteEntryRoute : RouteBaseSync.WithRequest<Guid>.WithActionResult -{ - private readonly AppDbContext _context; - - /// <inheritdoc /> - public DeleteEntryRoute(AppDbContext context) { - _context = context; - } - - /// <summary> - /// Delete a time entry. - /// </summary> - /// <param name="id"></param> - /// <returns></returns> - [ApiVersion(ApiSpecV1.VERSION_STRING)] - [BasicAuthentication(AppConstants.TOKEN_ALLOW_DELETE)] - [HttpDelete("~/v{version:apiVersion}/entries/{id:guid}/delete")] - [ProducesResponseType(404)] - [ProducesResponseType(200)] - public override ActionResult Handle(Guid id) { - var entry = _context.TimeEntries - .Where(c => c.UserId == LoggedInUser.Id) - .SingleOrDefault(c => c.Id == id); - if (entry == default) { - return NotFound(); - } - - _context.TimeEntries.Remove(entry); - _context.SaveChanges(); - return Ok(); - } -} diff --git a/server/src/Endpoints/V1/Entries/EntryQueryPayload.cs b/server/src/Endpoints/V1/Entries/EntryQueryPayload.cs deleted file mode 100644 index 763ac8b..0000000 --- a/server/src/Endpoints/V1/Entries/EntryQueryPayload.cs +++ /dev/null @@ -1,60 +0,0 @@ -namespace IOL.GreatOffice.Api.Endpoints.V1.Entries; - -/// <summary> -/// Query model for querying time entries. -/// </summary> -public class EntryQueryPayload -{ - /// <summary> - /// Duration to filter with. - /// </summary> - public TimeEntryQueryDuration Duration { get; set; } - - /// <summary> - /// List of categories to filter with. - /// </summary> - public List<TimeCategory.TimeCategoryDto> Categories { get; set; } - - /// <summary> - /// List of labels to filter with. - /// </summary> - public List<TimeLabel.TimeLabelDto> Labels { get; set; } - - /// <summary> - /// Date range to filter with, only respected if Duration is set to TimeEntryQueryDuration.DATE_RANGE. - /// </summary> - /// <see cref="TimeEntryQueryDuration"/> - public QueryDateRange DateRange { get; set; } - - /// <summary> - /// Spesific date to filter with, only respected if Duration is set to TimeEntryQueryDuration.SPECIFIC_DATE. - /// </summary> - /// <see cref="TimeEntryQueryDuration"/> - public DateTime SpecificDate { get; set; } - - /// <summary> - /// Optional page number to show, goes well with PageSize. - /// </summary> - public int Page { get; set; } - - /// <summary> - /// Optional page size to show, goes well with Page. - /// </summary> - public int PageSize { get; set; } - - /// <summary> - /// Represents a date range. - /// </summary> - public class QueryDateRange - { - /// <summary> - /// Range start - /// </summary> - public DateTime From { get; set; } - - /// <summary> - /// Range end - /// </summary> - public DateTime To { get; set; } - } -} diff --git a/server/src/Endpoints/V1/Entries/EntryQueryResponse.cs b/server/src/Endpoints/V1/Entries/EntryQueryResponse.cs deleted file mode 100644 index b1b07a3..0000000 --- a/server/src/Endpoints/V1/Entries/EntryQueryResponse.cs +++ /dev/null @@ -1,37 +0,0 @@ -namespace IOL.GreatOffice.Api.Endpoints.V1.Entries; - -/// <summary> -/// Response given for a successful query. -/// </summary> -public class EntryQueryResponse -{ - /// <inheritdoc cref="EntryQueryResponse"/> - public EntryQueryResponse() { - Results = new List<TimeEntry.TimeEntryDto>(); - } - - /// <summary> - /// List of entries. - /// </summary> - public List<TimeEntry.TimeEntryDto> Results { get; set; } - - /// <summary> - /// Current page. - /// </summary> - public int Page { get; set; } - - /// <summary> - /// Current page size (amount of entries). - /// </summary> - public int PageSize { get; set; } - - /// <summary> - /// Total amount of entries in query. - /// </summary> - public int TotalSize { get; set; } - - /// <summary> - /// Total amount of page(s) in query. - /// </summary> - public int TotalPageCount { get; set; } -} diff --git a/server/src/Endpoints/V1/Entries/EntryQueryRoute.cs b/server/src/Endpoints/V1/Entries/EntryQueryRoute.cs deleted file mode 100644 index d431ac5..0000000 --- a/server/src/Endpoints/V1/Entries/EntryQueryRoute.cs +++ /dev/null @@ -1,186 +0,0 @@ -namespace IOL.GreatOffice.Api.Endpoints.V1.Entries; - -public class EntryQueryRoute : RouteBaseSync.WithRequest<EntryQueryPayload>.WithActionResult<EntryQueryResponse> -{ - private readonly ILogger<EntryQueryRoute> _logger; - private readonly AppDbContext _context; - - public EntryQueryRoute(ILogger<EntryQueryRoute> logger, AppDbContext context) { - _logger = logger; - _context = context; - } - - /// <summary> - /// Get a list of entries based on a given query. - /// </summary> - /// <param name="entryQuery"></param> - /// <returns></returns> - /// <exception cref="ArgumentOutOfRangeException"></exception> - [ApiVersion(ApiSpecV1.VERSION_STRING)] - [BasicAuthentication(AppConstants.TOKEN_ALLOW_READ)] - [HttpPost("~/v{version:apiVersion}/entries/query")] - [ProducesResponseType(204)] - [ProducesResponseType(400, Type = typeof(ErrorResult))] - [ProducesResponseType(200, Type = typeof(EntryQueryResponse))] - public override ActionResult<EntryQueryResponse> Handle(EntryQueryPayload entryQuery) { - var result = new TimeQueryDto(); - - Request.Headers.TryGetValue(AppHeaders.BROWSER_TIME_ZONE, out var timeZoneHeader); - var tz = TimeZoneInfo.FindSystemTimeZoneById(timeZoneHeader.ToString().HasValue() ? timeZoneHeader.ToString() : "UTC"); - var offsetInHours = tz.BaseUtcOffset.Hours; - - // this is fine as long as the client is not connecting from Australia: Lord Howe Island - // according to https://en.wikipedia.org/wiki/Daylight_saving_time_by_country - if (tz.IsDaylightSavingTime(AppDateTime.UtcNow)) { - offsetInHours++; - } - - _logger.LogInformation("Request time zone (" + tz.Id + ") offset is: " + offsetInHours + " hours"); - var requestDateTime = TimeZoneInfo.ConvertTimeFromUtc(AppDateTime.UtcNow, tz); - _logger.LogInformation("Querying data with date time: " + requestDateTime.ToString("u")); - - var skipCount = 0; - if (entryQuery.Page > 1) { - skipCount = entryQuery.PageSize * entryQuery.Page; - } - - result.Page = entryQuery.Page; - result.PageSize = entryQuery.PageSize; - - var baseQuery = _context.TimeEntries - .AsNoTracking() - .Include(c => c.Category) - .Include(c => c.Labels) - .Where(c => c.UserId == LoggedInUser.Id) - .ConditionalWhere(entryQuery.Categories?.Any() ?? false, c => entryQuery.Categories.Any(p => p.Id == c.Category.Id)) - .ConditionalWhere(entryQuery.Labels?.Any() ?? false, c => c.Labels.Any(l => entryQuery.Labels.Any(p => p.Id == l.Id))) - .OrderByDescending(c => c.Start); - - switch (entryQuery.Duration) { - case TimeEntryQueryDuration.TODAY: - var baseTodaysEntries = baseQuery - .Where(c => DateTime.Compare(c.Start.AddHours(offsetInHours).Date, AppDateTime.UtcNow.Date) == 0); - var baseTodaysEntriesCount = baseTodaysEntries.Count(); - - if (baseTodaysEntriesCount == 0) { - return NoContent(); - } - - result.TotalSize = baseTodaysEntriesCount; - result.TotalPageCount = Convert.ToInt32(Math.Round((double)baseTodaysEntriesCount / entryQuery.PageSize)); - - var pagedTodaysEntries = baseTodaysEntries.Skip(skipCount).Take(entryQuery.PageSize); - - result.Results.AddRange(pagedTodaysEntries.Select(c => c.AsDto)); - break; - case TimeEntryQueryDuration.THIS_WEEK: - var lastMonday = AppDateTime.UtcNow.StartOfWeek(DayOfWeek.Monday); - - var baseEntriesThisWeek = baseQuery - .Where(c => c.Start.AddHours(offsetInHours).Date >= lastMonday.Date && c.Start.AddHours(offsetInHours).Date <= AppDateTime.UtcNow.Date); - - var baseEntriesThisWeekCount = baseEntriesThisWeek.Count(); - - if (baseEntriesThisWeekCount == 0) { - return NoContent(); - } - - result.TotalSize = baseEntriesThisWeekCount; - result.TotalPageCount = Convert.ToInt32(Math.Round((double)baseEntriesThisWeekCount / entryQuery.PageSize)); - - var pagedEntriesThisWeek = baseEntriesThisWeek.Skip(skipCount).Take(entryQuery.PageSize); - - result.Results.AddRange(pagedEntriesThisWeek.Select(c => c.AsDto)); - break; - case TimeEntryQueryDuration.THIS_MONTH: - var baseEntriesThisMonth = baseQuery - .Where(c => c.Start.AddHours(offsetInHours).Month == AppDateTime.UtcNow.Month - && c.Start.AddHours(offsetInHours).Year == AppDateTime.UtcNow.Year); - var baseEntriesThisMonthCount = baseEntriesThisMonth.Count(); - if (baseEntriesThisMonthCount == 0) { - return NoContent(); - } - - result.TotalSize = baseEntriesThisMonthCount; - result.TotalPageCount = Convert.ToInt32(Math.Round((double)baseEntriesThisMonthCount / entryQuery.PageSize)); - - var pagedEntriesThisMonth = baseEntriesThisMonth.Skip(skipCount).Take(entryQuery.PageSize); - - result.Results.AddRange(pagedEntriesThisMonth.Select(c => c.AsDto)); - break; - case TimeEntryQueryDuration.THIS_YEAR: - var baseEntriesThisYear = baseQuery - .Where(c => c.Start.AddHours(offsetInHours).Year == AppDateTime.UtcNow.Year); - - var baseEntriesThisYearCount = baseEntriesThisYear.Count(); - if (baseEntriesThisYearCount == 0) { - return NoContent(); - } - - result.TotalSize = baseEntriesThisYearCount; - result.TotalPageCount = Convert.ToInt32(Math.Round((double)baseEntriesThisYearCount / entryQuery.PageSize)); - - var pagedEntriesThisYear = baseEntriesThisYear.Skip(skipCount).Take(entryQuery.PageSize); - - result.Results.AddRange(pagedEntriesThisYear.Select(c => c.AsDto)); - break; - case TimeEntryQueryDuration.SPECIFIC_DATE: - var date = DateTime.SpecifyKind(entryQuery.SpecificDate, DateTimeKind.Utc); - var baseEntriesOnThisDate = baseQuery.Where(c => c.Start.AddHours(offsetInHours).Date == date.Date); - var baseEntriesOnThisDateCount = baseEntriesOnThisDate.Count(); - - if (baseEntriesOnThisDateCount == 0) { - return NoContent(); - } - - result.TotalSize = baseEntriesOnThisDateCount; - result.TotalPageCount = Convert.ToInt32(Math.Round((double)baseEntriesOnThisDateCount / entryQuery.PageSize)); - - var pagedEntriesOnThisDate = baseEntriesOnThisDate.Skip(skipCount).Take(entryQuery.PageSize); - - result.Results.AddRange(pagedEntriesOnThisDate.Select(c => c.AsDto)); - break; - case TimeEntryQueryDuration.DATE_RANGE: - if (entryQuery.DateRange.From == default) { - return BadRequest(new ErrorResult("Invalid query", "From date cannot be empty")); - } - - var fromDate = DateTime.SpecifyKind(entryQuery.DateRange.From, DateTimeKind.Utc); - - if (entryQuery.DateRange.To == default) { - return BadRequest(new ErrorResult("Invalid query", "To date cannot be empty")); - } - - var toDate = DateTime.SpecifyKind(entryQuery.DateRange.To, DateTimeKind.Utc); - - if (DateTime.Compare(fromDate, toDate) > 0) { - return BadRequest(new ErrorResult("Invalid query", "To date cannot be less than From date")); - } - - var baseDateRangeEntries = baseQuery - .Where(c => c.Start.AddHours(offsetInHours).Date > fromDate && c.Start.AddHours(offsetInHours).Date <= toDate); - - var baseDateRangeEntriesCount = baseDateRangeEntries.Count(); - if (baseDateRangeEntriesCount == 0) { - return NoContent(); - } - - result.TotalSize = baseDateRangeEntriesCount; - result.TotalPageCount = Convert.ToInt32(Math.Round((double)baseDateRangeEntriesCount / entryQuery.PageSize)); - - var pagedDateRangeEntries = baseDateRangeEntries.Skip(skipCount).Take(entryQuery.PageSize); - - result.Results.AddRange(pagedDateRangeEntries.Select(c => c.AsDto)); - break; - default: - throw new ArgumentOutOfRangeException(nameof(entryQuery), "Unknown duration for query"); - } - - if (result.Results.Any() && result.Page == 0) { - result.Page = 1; - result.TotalPageCount = 1; - } - - return Ok(result); - } -} diff --git a/server/src/Endpoints/V1/Entries/GetEntryRoute.cs b/server/src/Endpoints/V1/Entries/GetEntryRoute.cs deleted file mode 100644 index 87038db..0000000 --- a/server/src/Endpoints/V1/Entries/GetEntryRoute.cs +++ /dev/null @@ -1,34 +0,0 @@ -namespace IOL.GreatOffice.Api.Endpoints.V1.Entries; - -public class GetEntryRoute : RouteBaseSync.WithRequest<Guid>.WithActionResult<TimeEntry.TimeEntryDto> -{ - private readonly AppDbContext _context; - - public GetEntryRoute(AppDbContext context) { - _context = context; - } - - /// <summary> - /// Get a spesific time entry. - /// </summary> - /// <param name="id"></param> - /// <returns></returns> - [ApiVersion(ApiSpecV1.VERSION_STRING)] - [BasicAuthentication(AppConstants.TOKEN_ALLOW_READ)] - [HttpGet("~/v{version:apiVersion}/entries/{id:guid}")] - [ProducesResponseType(404)] - [ProducesResponseType(200, Type = typeof(TimeEntry.TimeEntryDto))] - public override ActionResult<TimeEntry.TimeEntryDto> Handle(Guid id) { - var entry = _context.TimeEntries - .Where(c => c.UserId == LoggedInUser.Id) - .Include(c => c.Category) - .Include(c => c.Labels) - .SingleOrDefault(c => c.Id == id); - - if (entry == default) { - return NotFound(); - } - - return Ok(entry); - } -} diff --git a/server/src/Endpoints/V1/Entries/UpdateEntryRoute.cs b/server/src/Endpoints/V1/Entries/UpdateEntryRoute.cs deleted file mode 100644 index ac233e0..0000000 --- a/server/src/Endpoints/V1/Entries/UpdateEntryRoute.cs +++ /dev/null @@ -1,66 +0,0 @@ -namespace IOL.GreatOffice.Api.Endpoints.V1.Entries; - -public class UpdateEntryRoute : RouteBaseSync.WithRequest<TimeEntry.TimeEntryDto>.WithActionResult<TimeEntry.TimeEntryDto> -{ - private readonly AppDbContext _context; - - public UpdateEntryRoute(AppDbContext context) { - _context = context; - } - - /// <summary> - /// Update a time entry. - /// </summary> - /// <param name="timeEntryTimeEntryDto"></param> - /// <returns></returns> - [ApiVersion(ApiSpecV1.VERSION_STRING)] - [BasicAuthentication(AppConstants.TOKEN_ALLOW_UPDATE)] - [HttpPost("~/v{version:apiVersion}/entries/update")] - [ProducesResponseType(404, Type = typeof(ErrorResult))] - [ProducesResponseType(200, Type = typeof(TimeEntry.TimeEntryDto))] - public override ActionResult<TimeEntry.TimeEntryDto> Handle(TimeEntry.TimeEntryDto timeEntryTimeEntryDto) { - var entry = _context.TimeEntries - .Where(c => c.UserId == LoggedInUser.Id) - .Include(c => c.Labels) - .SingleOrDefault(c => c.Id == timeEntryTimeEntryDto.Id); - - if (entry == default) { - return NotFound(); - } - - var category = _context.TimeCategories - .Where(c => c.UserId == LoggedInUser.Id) - .SingleOrDefault(c => c.Id == timeEntryTimeEntryDto.Category.Id); - if (category == default) { - return NotFound(new ErrorResult("Not found", $"Could not find category {timeEntryTimeEntryDto.Category.Name}")); - } - - entry.Start = timeEntryTimeEntryDto.Start.ToUniversalTime(); - entry.Stop = timeEntryTimeEntryDto.Stop.ToUniversalTime(); - entry.Description = timeEntryTimeEntryDto.Description; - entry.Category = category; - - if (timeEntryTimeEntryDto.Labels?.Count > 0) { - var labels = new List<TimeLabel>(); - - foreach (var labelDto in timeEntryTimeEntryDto.Labels) { - var label = _context.TimeLabels - .Where(c => c.UserId == LoggedInUser.Id) - .SingleOrDefault(c => c.Id == labelDto.Id); - - if (label == default) { - continue; - } - - labels.Add(label); - } - - entry.Labels = labels; - } else { - entry.Labels = default; - } - - _context.SaveChanges(); - return Ok(entry.AsDto); - } -} diff --git a/server/src/Endpoints/V1/Labels/CreateLabelRoute.cs b/server/src/Endpoints/V1/Labels/CreateLabelRoute.cs deleted file mode 100644 index 31ef7d0..0000000 --- a/server/src/Endpoints/V1/Labels/CreateLabelRoute.cs +++ /dev/null @@ -1,46 +0,0 @@ - -namespace IOL.GreatOffice.Api.Endpoints.V1.Labels; - -/// <inheritdoc /> -public class CreateLabelRoute : RouteBaseSync.WithRequest<TimeLabel.TimeLabelDto>.WithActionResult<TimeLabel.TimeLabelDto> -{ - private readonly AppDbContext _context; - - /// <inheritdoc /> - public CreateLabelRoute(AppDbContext context) { - _context = context; - } - - /// <summary> - /// Create a time entry label. - /// </summary> - /// <param name="labelTimeLabelDto"></param> - /// <returns></returns> - [ApiVersion(ApiSpecV1.VERSION_STRING)] - [BasicAuthentication(AppConstants.TOKEN_ALLOW_CREATE)] - [HttpPost("~/v{version:apiVersion}/labels/create")] - public override ActionResult<TimeLabel.TimeLabelDto> Handle(TimeLabel.TimeLabelDto labelTimeLabelDto) { - var duplicate = _context.TimeLabels - .Where(c => c.UserId == LoggedInUser.Id) - .Any(c => c.Name.Trim() == labelTimeLabelDto.Name.Trim()); - if (duplicate) { - var label = _context.TimeLabels - .Where(c => c.UserId == LoggedInUser.Id) - .SingleOrDefault(c => c.Name.Trim() == labelTimeLabelDto.Name.Trim()); - - if (label != default) { - return Ok(label.AsDto); - } - } - - var newLabel = new TimeLabel(LoggedInUser.Id) { - Name = labelTimeLabelDto.Name.Trim(), - Color = labelTimeLabelDto.Color - }; - - _context.TimeLabels.Add(newLabel); - _context.SaveChanges(); - labelTimeLabelDto.Id = newLabel.Id; - return Ok(labelTimeLabelDto); - } -} diff --git a/server/src/Endpoints/V1/Labels/DeleteLabelRoute.cs b/server/src/Endpoints/V1/Labels/DeleteLabelRoute.cs deleted file mode 100644 index d845a6f..0000000 --- a/server/src/Endpoints/V1/Labels/DeleteLabelRoute.cs +++ /dev/null @@ -1,35 +0,0 @@ - -namespace IOL.GreatOffice.Api.Endpoints.V1.Labels; - -/// <inheritdoc /> -public class DeleteLabelEndpoint : RouteBaseSync.WithRequest<Guid>.WithActionResult -{ - private readonly AppDbContext _context; - - /// <inheritdoc /> - public DeleteLabelEndpoint(AppDbContext context) { - _context = context; - } - - /// <summary> - /// Delete a time entry label. - /// </summary> - /// <param name="id"></param> - /// <returns></returns> - [ApiVersion(ApiSpecV1.VERSION_STRING)] - [BasicAuthentication(AppConstants.TOKEN_ALLOW_DELETE)] - [HttpDelete("~/v{version:apiVersion}/labels/{id:guid}/delete")] - public override ActionResult Handle(Guid id) { - var label = _context.TimeLabels - .Where(c => c.UserId == LoggedInUser.Id) - .SingleOrDefault(c => c.Id == id); - - if (label == default) { - return NotFound(); - } - - _context.TimeLabels.Remove(label); - _context.SaveChanges(); - return Ok(); - } -} diff --git a/server/src/Endpoints/V1/Labels/GetLabelRoute.cs b/server/src/Endpoints/V1/Labels/GetLabelRoute.cs deleted file mode 100644 index c9ccef3..0000000 --- a/server/src/Endpoints/V1/Labels/GetLabelRoute.cs +++ /dev/null @@ -1,34 +0,0 @@ - -namespace IOL.GreatOffice.Api.Endpoints.V1.Labels; - -/// <inheritdoc /> -public class GetEndpoint : RouteBaseSync.WithoutRequest.WithActionResult<List<TimeLabel.TimeLabelDto>> -{ - private readonly AppDbContext _context; - - /// <inheritdoc /> - public GetEndpoint(AppDbContext context) { - _context = context; - } - - /// <summary> - /// Get a minimal list of time entry labels. - /// </summary> - /// <returns></returns> - [ApiVersion(ApiSpecV1.VERSION_STRING)] - [BasicAuthentication(AppConstants.TOKEN_ALLOW_READ)] - [HttpGet("~/v{version:apiVersion}/labels")] - public override ActionResult<List<TimeLabel.TimeLabelDto>> Handle() { - var labels = _context.TimeLabels - .Where(c => c.UserId == LoggedInUser.Id) - .OrderByDescending(c => c.CreatedAt) - .Select(c => c.AsDto) - .ToList(); - - if (labels.Count == 0) { - return NoContent(); - } - - return Ok(labels); - } -} diff --git a/server/src/Endpoints/V1/Labels/UpdateLabelRoute.cs b/server/src/Endpoints/V1/Labels/UpdateLabelRoute.cs deleted file mode 100644 index 30d72ec..0000000 --- a/server/src/Endpoints/V1/Labels/UpdateLabelRoute.cs +++ /dev/null @@ -1,38 +0,0 @@ -namespace IOL.GreatOffice.Api.Endpoints.V1.Labels; - -/// <inheritdoc /> -public class UpdateLabelEndpoint : RouteBaseSync.WithRequest<TimeLabel.TimeLabelDto>.WithActionResult -{ - private readonly AppDbContext _context; - - /// <inheritdoc /> - public UpdateLabelEndpoint(AppDbContext context) { - _context = context; - } - - /// <summary> - /// Update a time entry label. - /// </summary> - /// <param name="labelTimeLabelDto"></param> - /// <returns></returns> - [ApiVersion(ApiSpecV1.VERSION_STRING)] - [BasicAuthentication(AppConstants.TOKEN_ALLOW_UPDATE)] - [HttpPost("~/v{version:apiVersion}/labels/update")] - public override ActionResult Handle(TimeLabel.TimeLabelDto labelTimeLabelDto) { - var label = _context.TimeLabels - .Where(c => c.UserId == LoggedInUser.Id) - .SingleOrDefault(c => c.Id == labelTimeLabelDto.Id); - if (label == default) { - return NotFound(); - } - - if (LoggedInUser.Id != label.UserId) { - return Forbid(); - } - - label.Name = labelTimeLabelDto.Name; - label.Color = labelTimeLabelDto.Color; - _context.SaveChanges(); - return Ok(); - } -} diff --git a/server/src/Endpoints/V1/RouteBaseAsync.cs b/server/src/Endpoints/V1/RouteBaseAsync.cs deleted file mode 100644 index 1d179f7..0000000 --- a/server/src/Endpoints/V1/RouteBaseAsync.cs +++ /dev/null @@ -1,73 +0,0 @@ -namespace IOL.GreatOffice.Api.Endpoints.V1; - -/// <summary> -/// A base class for an endpoint that accepts parameters. -/// </summary> -public static class RouteBaseAsync -{ - public static class WithRequest<TRequest> - { - public abstract class WithResult<TResponse> : BaseRoute - { - public abstract Task<TResponse> HandleAsync( - TRequest request, - CancellationToken cancellationToken = default - ); - } - - public abstract class WithoutResult : BaseRoute - { - public abstract Task HandleAsync( - TRequest request, - CancellationToken cancellationToken = default - ); - } - - public abstract class WithActionResult<TResponse> : BaseRoute - { - public abstract Task<ActionResult<TResponse>> HandleAsync( - TRequest request, - CancellationToken cancellationToken = default - ); - } - - public abstract class WithActionResult : BaseRoute - { - public abstract Task<ActionResult> HandleAsync( - TRequest request, - CancellationToken cancellationToken = default - ); - } - } - - public static class WithoutRequest - { - public abstract class WithResult<TResponse> : BaseRoute - { - public abstract Task<TResponse> HandleAsync( - CancellationToken cancellationToken = default - ); - } - - public abstract class WithoutResult : BaseRoute - { - public abstract Task HandleAsync( - CancellationToken cancellationToken = default - ); - } - - public abstract class WithActionResult<TResponse> : BaseRoute - { - public abstract Task<ActionResult<TResponse>> HandleAsync( - CancellationToken cancellationToken = default - ); - } - - public abstract class WithActionResult : BaseRoute - { - public abstract Task<ActionResult> HandleAsync( - CancellationToken cancellationToken = default - ); - } - } -} diff --git a/server/src/Endpoints/V1/RouteBaseSync.cs b/server/src/Endpoints/V1/RouteBaseSync.cs deleted file mode 100644 index cb27c14..0000000 --- a/server/src/Endpoints/V1/RouteBaseSync.cs +++ /dev/null @@ -1,53 +0,0 @@ -namespace IOL.GreatOffice.Api.Endpoints.V1; - -/// <summary> -/// A base class for an endpoint that accepts parameters. -/// </summary> -public static class RouteBaseSync -{ - public static class WithRequest<TRequest> - { - public abstract class WithResult<TResponse> : BaseRoute - { - public abstract TResponse Handle(TRequest request); - } - - public abstract class WithoutResult : BaseRoute - { - public abstract void Handle(TRequest request); - } - - public abstract class WithActionResult<TResponse> : BaseRoute - { - public abstract ActionResult<TResponse> Handle(TRequest request); - } - - public abstract class WithActionResult : BaseRoute - { - public abstract ActionResult Handle(TRequest request); - } - } - - public static class WithoutRequest - { - public abstract class WithResult<TResponse> : BaseRoute - { - public abstract TResponse Handle(); - } - - public abstract class WithoutResult : BaseRoute - { - public abstract void Handle(); - } - - public abstract class WithActionResult<TResponse> : BaseRoute - { - public abstract ActionResult<TResponse> Handle(); - } - - public abstract class WithActionResult : BaseRoute - { - public abstract ActionResult Handle(); - } - } -} diff --git a/server/src/IOL.GreatOffice.Api.csproj b/server/src/IOL.GreatOffice.Api.csproj deleted file mode 100644 index 0b3d37e..0000000 --- a/server/src/IOL.GreatOffice.Api.csproj +++ /dev/null @@ -1,56 +0,0 @@ -<Project Sdk="Microsoft.NET.Sdk.Web"> - - <PropertyGroup> - <TargetFramework>net6.0</TargetFramework> - <UserSecretsId>ed5ff3e5-46e2-4d7e-8272-7081f5abfee4</UserSecretsId> - <GenerateDocumentationFile>true</GenerateDocumentationFile> - <ImplicitUsings>true</ImplicitUsings> - <Nullable>disable</Nullable> - <NoWarn>CS1591</NoWarn> - </PropertyGroup> - - <ItemGroup> - <PackageReference Include="Duende.IdentityServer" Version="6.1.2" /> - <PackageReference Include="Duende.IdentityServer.EntityFramework.Storage" Version="6.1.2" /> - <PackageReference Include="EFCore.NamingConventions" Version="6.0.0" /> - <PackageReference Include="IOL.Helpers" Version="3.1.0" /> - <PackageReference Include="Microsoft.AspNetCore.DataProtection.EntityFrameworkCore" Version="6.0.7" /> - <PackageReference Include="Microsoft.AspNetCore.Mvc.Versioning" Version="5.0.0" /> - <PackageReference Include="Microsoft.AspNetCore.Mvc.Versioning.ApiExplorer" Version="5.0.0" /> - <PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="6.0.7"> - <PrivateAssets>all</PrivateAssets> - <IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets> - </PackageReference> - <PackageReference Include="Npgsql.EntityFrameworkCore.PostgreSQL" Version="6.0.6" /> - <PackageReference Include="Quartz.Extensions.Hosting" Version="3.4.0" /> - <PackageReference Include="Serilog.AspNetCore" Version="6.0.1" /> - <PackageReference Include="Serilog.Expressions" Version="3.4.0" /> - <PackageReference Include="Serilog.Sinks.Seq" Version="5.1.1" /> - <PackageReference Include="Swashbuckle.AspNetCore" Version="6.4.0" /> - <PackageReference Include="Swashbuckle.AspNetCore.Annotations" Version="6.4.0" /> - <PackageReference Include="Swashbuckle.AspNetCore.SwaggerUI" Version="6.4.0" /> - </ItemGroup> - - <ItemGroup Condition="'$(Configuration)' == 'Release'"> - <Content Remove="AppData" /> - </ItemGroup> - - <ItemGroup> - <Content Include="..\..\README.md"> - <Link>README.md</Link> - </Content> - <Content Include="..\build_and_push.sh"> - <Link>build_and_push.sh</Link> - </Content> - <Content Include="..\CHANGELOG.md"> - <Link>CHANGELOG.md</Link> - </Content> - <Content Include="..\cliff.toml"> - <Link>cliff.toml</Link> - </Content> - <Content Include="..\Dockerfile"> - <Link>Dockerfile</Link> - </Content> - </ItemGroup> - -</Project> diff --git a/server/src/Jobs/JobRegister.cs b/server/src/Jobs/JobRegister.cs deleted file mode 100644 index 72c2cc7..0000000 --- a/server/src/Jobs/JobRegister.cs +++ /dev/null @@ -1,18 +0,0 @@ -using Quartz; - -namespace IOL.GreatOffice.Api.Jobs; - -public static class JobRegister -{ - public static readonly JobKey TokenCleanupKey = new("TokenCleanupJob"); - - public static IServiceCollectionQuartzConfigurator RegisterJobs(this IServiceCollectionQuartzConfigurator configurator) { - configurator.AddJob<TokenCleanupJob>(TokenCleanupKey); - configurator.AddTrigger(options => { - options.ForJob(TokenCleanupKey) - .WithIdentity(TokenCleanupKey.Name + "-trigger") - .WithCronSchedule(CronScheduleBuilder.DailyAtHourAndMinute(1, 0)); - }); - return configurator; - } -} diff --git a/server/src/Jobs/TokenCleanupJob.cs b/server/src/Jobs/TokenCleanupJob.cs deleted file mode 100644 index fce40c9..0000000 --- a/server/src/Jobs/TokenCleanupJob.cs +++ /dev/null @@ -1,22 +0,0 @@ -using Quartz; - -namespace IOL.GreatOffice.Api.Jobs; - -public class TokenCleanupJob : IJob -{ - private readonly ILogger<TokenCleanupJob> _logger; - private readonly AppDbContext _context; - - public TokenCleanupJob(ILogger<TokenCleanupJob> logger, AppDbContext context) { - _logger = logger; - _context = context; - } - - public Task Execute(IJobExecutionContext context) { - var staleTokens = _context.AccessTokens.Where(c => c.ExpiryDate < AppDateTime.UtcNow).ToList(); - if (staleTokens.IsNullOrEmpty()) return Task.CompletedTask; - _logger.LogInformation("Removing {0} stale tokens", staleTokens.Count()); - _context.AccessTokens.RemoveRange(staleTokens); - return Task.CompletedTask; - } -} diff --git a/server/src/Jobs/VaultTokenRenewalJob.cs b/server/src/Jobs/VaultTokenRenewalJob.cs deleted file mode 100644 index fffbf7c..0000000 --- a/server/src/Jobs/VaultTokenRenewalJob.cs +++ /dev/null @@ -1,15 +0,0 @@ -using Quartz; - -namespace IOL.GreatOffice.Api.Jobs; - -public class VaultTokenRenewalJob : IJob -{ - private readonly ILogger<VaultTokenRenewalJob> _logger; - public VaultTokenRenewalJob(ILogger<VaultTokenRenewalJob> logger) { - _logger = logger; - } - - public Task Execute(IJobExecutionContext context) { - return Task.CompletedTask; - } -} diff --git a/server/src/Migrations/20210517202115_InitialMigration.Designer.cs b/server/src/Migrations/20210517202115_InitialMigration.Designer.cs deleted file mode 100644 index b6a01ff..0000000 --- a/server/src/Migrations/20210517202115_InitialMigration.Designer.cs +++ /dev/null @@ -1,238 +0,0 @@ -// <auto-generated /> -using System; -using IOL.GreatOffice.Api.Data; -using Microsoft.EntityFrameworkCore; -using Microsoft.EntityFrameworkCore.Infrastructure; -using Microsoft.EntityFrameworkCore.Migrations; -using Microsoft.EntityFrameworkCore.Storage.ValueConversion; -using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata; - -namespace IOL.GreatOffice.Api.Migrations -{ - [DbContext(typeof(AppDbContext))] - [Migration("20210517202115_InitialMigration")] - partial class InitialMigration - { - protected override void BuildTargetModel(ModelBuilder modelBuilder) - { -#pragma warning disable 612, 618 - modelBuilder - .HasAnnotation("Relational:MaxIdentifierLength", 63) - .HasAnnotation("ProductVersion", "5.0.6") - .HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn); - - modelBuilder.Entity("IOL.GreatOffice.Data.Database.ForgotPasswordRequest", b => - { - b.Property<Guid>("Id") - .ValueGeneratedOnAdd() - .HasColumnType("uuid") - .HasColumnName("id"); - - b.Property<DateTime>("Created") - .HasColumnType("timestamp with time zone") - .HasColumnName("created"); - - b.Property<Guid?>("UserId") - .HasColumnType("uuid") - .HasColumnName("user_id"); - - b.HasKey("Id") - .HasName("pk_forgot_password_requests"); - - b.HasIndex("UserId") - .HasDatabaseName("ix_forgot_password_requests_user_id"); - - b.ToTable("forgot_password_requests"); - }); - - modelBuilder.Entity("IOL.GreatOffice.Data.Database.TimeCategory", b => - { - b.Property<Guid>("Id") - .ValueGeneratedOnAdd() - .HasColumnType("uuid") - .HasColumnName("id"); - - b.Property<string>("Color") - .HasColumnType("text") - .HasColumnName("color"); - - b.Property<DateTime>("Created") - .HasColumnType("timestamp with time zone") - .HasColumnName("created"); - - b.Property<string>("Name") - .HasColumnType("text") - .HasColumnName("name"); - - b.Property<Guid>("UserId") - .HasColumnType("uuid") - .HasColumnName("user_id"); - - b.HasKey("Id") - .HasName("pk_time_categories"); - - b.ToTable("time_categories"); - }); - - modelBuilder.Entity("IOL.GreatOffice.Data.Database.TimeEntry", b => - { - b.Property<Guid>("Id") - .ValueGeneratedOnAdd() - .HasColumnType("uuid") - .HasColumnName("id"); - - b.Property<Guid?>("CategoryId") - .HasColumnType("uuid") - .HasColumnName("category_id"); - - b.Property<DateTime>("Created") - .HasColumnType("timestamp with time zone") - .HasColumnName("created"); - - b.Property<string>("Description") - .HasColumnType("text") - .HasColumnName("note"); - - b.Property<DateTime>("Start") - .HasColumnType("timestamp with time zone") - .HasColumnName("start"); - - b.Property<DateTime>("Stop") - .HasColumnType("timestamp with time zone") - .HasColumnName("stop"); - - b.Property<Guid>("UserId") - .HasColumnType("uuid") - .HasColumnName("user_id"); - - b.HasKey("Id") - .HasName("pk_time_entries"); - - b.HasIndex("CategoryId") - .HasDatabaseName("ix_time_entries_category_id"); - - b.ToTable("time_entries"); - }); - - modelBuilder.Entity("IOL.GreatOffice.Data.Database.TimeLabel", b => - { - b.Property<Guid>("Id") - .ValueGeneratedOnAdd() - .HasColumnType("uuid") - .HasColumnName("id"); - - b.Property<string>("Color") - .HasColumnType("text") - .HasColumnName("color"); - - b.Property<DateTime>("Created") - .HasColumnType("timestamp with time zone") - .HasColumnName("created"); - - b.Property<string>("Name") - .HasColumnType("text") - .HasColumnName("name"); - - b.Property<Guid>("UserId") - .HasColumnType("uuid") - .HasColumnName("user_id"); - - b.HasKey("Id") - .HasName("pk_time_labels"); - - b.ToTable("time_labels"); - }); - - modelBuilder.Entity("IOL.GreatOffice.Data.Database.User", b => - { - b.Property<Guid>("Id") - .ValueGeneratedOnAdd() - .HasColumnType("uuid") - .HasColumnName("id"); - - b.Property<DateTime>("Created") - .HasColumnType("timestamp with time zone") - .HasColumnName("created"); - - b.Property<string>("Password") - .HasColumnType("text") - .HasColumnName("password"); - - b.Property<string>("Username") - .HasColumnType("text") - .HasColumnName("username"); - - b.HasKey("Id") - .HasName("pk_users"); - - b.ToTable("users"); - - b.HasData( - new - { - Id = new Guid("784938f0-cc0e-46ec-afa6-fc60b47b28db"), - Created = new DateTime(2021, 5, 17, 20, 21, 14, 827, DateTimeKind.Utc).AddTicks(4868), - Password = "AAAAAAEAACcQAAAAEJdtrX3pEeIbcgY+BDAr56gvfbc420ag1TllA0cK6Q6Gw3+gGDIQtYIZnisW3dmqaQ==", - Username = "admin@ivarlovlie.no" - }); - }); - - modelBuilder.Entity("TimeEntryTimeLabel", b => - { - b.Property<Guid>("EntriesId") - .HasColumnType("uuid") - .HasColumnName("entries_id"); - - b.Property<Guid>("LabelsId") - .HasColumnType("uuid") - .HasColumnName("labels_id"); - - b.HasKey("EntriesId", "LabelsId") - .HasName("pk_time_entry_time_label"); - - b.HasIndex("LabelsId") - .HasDatabaseName("ix_time_entry_time_label_labels_id"); - - b.ToTable("time_entry_time_label"); - }); - - modelBuilder.Entity("IOL.GreatOffice.Data.Database.ForgotPasswordRequest", b => - { - b.HasOne("IOL.GreatOffice.Data.Database.User", "User") - .WithMany() - .HasForeignKey("UserId") - .HasConstraintName("fk_forgot_password_requests_users_user_id"); - - b.Navigation("User"); - }); - - modelBuilder.Entity("IOL.GreatOffice.Data.Database.TimeEntry", b => - { - b.HasOne("IOL.GreatOffice.Data.Database.TimeCategory", "Category") - .WithMany() - .HasForeignKey("CategoryId") - .HasConstraintName("fk_time_entries_time_categories_category_id"); - - b.Navigation("Category"); - }); - - modelBuilder.Entity("TimeEntryTimeLabel", b => - { - b.HasOne("IOL.GreatOffice.Data.Database.TimeEntry", null) - .WithMany() - .HasForeignKey("EntriesId") - .HasConstraintName("fk_time_entry_time_label_time_entries_entries_id") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("IOL.GreatOffice.Data.Database.TimeLabel", null) - .WithMany() - .HasForeignKey("LabelsId") - .HasConstraintName("fk_time_entry_time_label_time_labels_labels_id") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - }); -#pragma warning restore 612, 618 - } - } -} diff --git a/server/src/Migrations/20210517202115_InitialMigration.cs b/server/src/Migrations/20210517202115_InitialMigration.cs deleted file mode 100644 index 8bfaf61..0000000 --- a/server/src/Migrations/20210517202115_InitialMigration.cs +++ /dev/null @@ -1,162 +0,0 @@ -using System; -using Microsoft.EntityFrameworkCore.Migrations; - -namespace IOL.GreatOffice.Api.Migrations -{ - public partial class InitialMigration : Migration - { - protected override void Up(MigrationBuilder migrationBuilder) - { - migrationBuilder.CreateTable( - name: "time_categories", - columns: table => new - { - id = table.Column<Guid>(type: "uuid", nullable: false), - name = table.Column<string>(type: "text", nullable: true), - color = table.Column<string>(type: "text", nullable: true), - user_id = table.Column<Guid>(type: "uuid", nullable: false), - created = table.Column<DateTime>(type: "timestamp with time zone", nullable: false) - }, - constraints: table => - { - table.PrimaryKey("pk_time_categories", x => x.id); - }); - - migrationBuilder.CreateTable( - name: "time_labels", - columns: table => new - { - id = table.Column<Guid>(type: "uuid", nullable: false), - name = table.Column<string>(type: "text", nullable: true), - color = table.Column<string>(type: "text", nullable: true), - user_id = table.Column<Guid>(type: "uuid", nullable: false), - created = table.Column<DateTime>(type: "timestamp with time zone", nullable: false) - }, - constraints: table => - { - table.PrimaryKey("pk_time_labels", x => x.id); - }); - - migrationBuilder.CreateTable( - name: "users", - columns: table => new - { - id = table.Column<Guid>(type: "uuid", nullable: false), - username = table.Column<string>(type: "text", nullable: true), - password = table.Column<string>(type: "text", nullable: true), - created = table.Column<DateTime>(type: "timestamp with time zone", nullable: false) - }, - constraints: table => - { - table.PrimaryKey("pk_users", x => x.id); - }); - - migrationBuilder.CreateTable( - name: "time_entries", - columns: table => new - { - id = table.Column<Guid>(type: "uuid", nullable: false), - start = table.Column<DateTime>(type: "timestamp with time zone", nullable: false), - stop = table.Column<DateTime>(type: "timestamp with time zone", nullable: false), - note = table.Column<string>(type: "text", nullable: true), - user_id = table.Column<Guid>(type: "uuid", nullable: false), - category_id = table.Column<Guid>(type: "uuid", nullable: true), - created = table.Column<DateTime>(type: "timestamp with time zone", nullable: false) - }, - constraints: table => - { - table.PrimaryKey("pk_time_entries", x => x.id); - table.ForeignKey( - name: "fk_time_entries_time_categories_category_id", - column: x => x.category_id, - principalTable: "time_categories", - principalColumn: "id", - onDelete: ReferentialAction.Restrict); - }); - - migrationBuilder.CreateTable( - name: "forgot_password_requests", - columns: table => new - { - id = table.Column<Guid>(type: "uuid", nullable: false), - user_id = table.Column<Guid>(type: "uuid", nullable: true), - created = table.Column<DateTime>(type: "timestamp with time zone", nullable: false) - }, - constraints: table => - { - table.PrimaryKey("pk_forgot_password_requests", x => x.id); - table.ForeignKey( - name: "fk_forgot_password_requests_users_user_id", - column: x => x.user_id, - principalTable: "users", - principalColumn: "id", - onDelete: ReferentialAction.Restrict); - }); - - migrationBuilder.CreateTable( - name: "time_entry_time_label", - columns: table => new - { - entries_id = table.Column<Guid>(type: "uuid", nullable: false), - labels_id = table.Column<Guid>(type: "uuid", nullable: false) - }, - constraints: table => - { - table.PrimaryKey("pk_time_entry_time_label", x => new { x.entries_id, x.labels_id }); - table.ForeignKey( - name: "fk_time_entry_time_label_time_entries_entries_id", - column: x => x.entries_id, - principalTable: "time_entries", - principalColumn: "id", - onDelete: ReferentialAction.Cascade); - table.ForeignKey( - name: "fk_time_entry_time_label_time_labels_labels_id", - column: x => x.labels_id, - principalTable: "time_labels", - principalColumn: "id", - onDelete: ReferentialAction.Cascade); - }); - - migrationBuilder.InsertData( - table: "users", - columns: new[] { "id", "created", "password", "username" }, - values: new object[] { new Guid("784938f0-cc0e-46ec-afa6-fc60b47b28db"), new DateTime(2021, 5, 17, 20, 21, 14, 827, DateTimeKind.Utc).AddTicks(4868), "AAAAAAEAACcQAAAAEJdtrX3pEeIbcgY+BDAr56gvfbc420ag1TllA0cK6Q6Gw3+gGDIQtYIZnisW3dmqaQ==", "admin@ivarlovlie.no" }); - - migrationBuilder.CreateIndex( - name: "ix_forgot_password_requests_user_id", - table: "forgot_password_requests", - column: "user_id"); - - migrationBuilder.CreateIndex( - name: "ix_time_entries_category_id", - table: "time_entries", - column: "category_id"); - - migrationBuilder.CreateIndex( - name: "ix_time_entry_time_label_labels_id", - table: "time_entry_time_label", - column: "labels_id"); - } - - protected override void Down(MigrationBuilder migrationBuilder) - { - migrationBuilder.DropTable( - name: "forgot_password_requests"); - - migrationBuilder.DropTable( - name: "time_entry_time_label"); - - migrationBuilder.DropTable( - name: "users"); - - migrationBuilder.DropTable( - name: "time_entries"); - - migrationBuilder.DropTable( - name: "time_labels"); - - migrationBuilder.DropTable( - name: "time_categories"); - } - } -} diff --git a/server/src/Migrations/20210522165932_RenameNoteToDescription.Designer.cs b/server/src/Migrations/20210522165932_RenameNoteToDescription.Designer.cs deleted file mode 100644 index 368e6b3..0000000 --- a/server/src/Migrations/20210522165932_RenameNoteToDescription.Designer.cs +++ /dev/null @@ -1,229 +0,0 @@ -// <auto-generated /> -using System; -using IOL.GreatOffice.Api.Data; -using Microsoft.EntityFrameworkCore; -using Microsoft.EntityFrameworkCore.Infrastructure; -using Microsoft.EntityFrameworkCore.Migrations; -using Microsoft.EntityFrameworkCore.Storage.ValueConversion; -using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata; - -namespace IOL.GreatOffice.Api.Migrations -{ - [DbContext(typeof(AppDbContext))] - [Migration("20210522165932_RenameNoteToDescription")] - partial class RenameNoteToDescription - { - protected override void BuildTargetModel(ModelBuilder modelBuilder) - { -#pragma warning disable 612, 618 - modelBuilder - .HasAnnotation("Relational:MaxIdentifierLength", 63) - .HasAnnotation("ProductVersion", "5.0.6") - .HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn); - - modelBuilder.Entity("IOL.GreatOffice.Data.Database.ForgotPasswordRequest", b => - { - b.Property<Guid>("Id") - .ValueGeneratedOnAdd() - .HasColumnType("uuid") - .HasColumnName("id"); - - b.Property<DateTime>("Created") - .HasColumnType("timestamp without time zone") - .HasColumnName("created"); - - b.Property<Guid?>("UserId") - .HasColumnType("uuid") - .HasColumnName("user_id"); - - b.HasKey("Id") - .HasName("pk_forgot_password_requests"); - - b.HasIndex("UserId") - .HasDatabaseName("ix_forgot_password_requests_user_id"); - - b.ToTable("forgot_password_requests"); - }); - - modelBuilder.Entity("IOL.GreatOffice.Data.Database.TimeCategory", b => - { - b.Property<Guid>("Id") - .ValueGeneratedOnAdd() - .HasColumnType("uuid") - .HasColumnName("id"); - - b.Property<string>("Color") - .HasColumnType("text") - .HasColumnName("color"); - - b.Property<DateTime>("Created") - .HasColumnType("timestamp without time zone") - .HasColumnName("created"); - - b.Property<string>("Name") - .HasColumnType("text") - .HasColumnName("name"); - - b.Property<Guid>("UserId") - .HasColumnType("uuid") - .HasColumnName("user_id"); - - b.HasKey("Id") - .HasName("pk_time_categories"); - - b.ToTable("time_categories"); - }); - - modelBuilder.Entity("IOL.GreatOffice.Data.Database.TimeEntry", b => - { - b.Property<Guid>("Id") - .ValueGeneratedOnAdd() - .HasColumnType("uuid") - .HasColumnName("id"); - - b.Property<Guid?>("CategoryId") - .HasColumnType("uuid") - .HasColumnName("category_id"); - - b.Property<DateTime>("Created") - .HasColumnType("timestamp without time zone") - .HasColumnName("created"); - - b.Property<string>("Description") - .HasColumnType("text") - .HasColumnName("description"); - - b.Property<DateTime>("Start") - .HasColumnType("timestamp without time zone") - .HasColumnName("start"); - - b.Property<DateTime>("Stop") - .HasColumnType("timestamp without time zone") - .HasColumnName("stop"); - - b.Property<Guid>("UserId") - .HasColumnType("uuid") - .HasColumnName("user_id"); - - b.HasKey("Id") - .HasName("pk_time_entries"); - - b.HasIndex("CategoryId") - .HasDatabaseName("ix_time_entries_category_id"); - - b.ToTable("time_entries"); - }); - - modelBuilder.Entity("IOL.GreatOffice.Data.Database.TimeLabel", b => - { - b.Property<Guid>("Id") - .ValueGeneratedOnAdd() - .HasColumnType("uuid") - .HasColumnName("id"); - - b.Property<string>("Color") - .HasColumnType("text") - .HasColumnName("color"); - - b.Property<DateTime>("Created") - .HasColumnType("timestamp without time zone") - .HasColumnName("created"); - - b.Property<string>("Name") - .HasColumnType("text") - .HasColumnName("name"); - - b.Property<Guid>("UserId") - .HasColumnType("uuid") - .HasColumnName("user_id"); - - b.HasKey("Id") - .HasName("pk_time_labels"); - - b.ToTable("time_labels"); - }); - - modelBuilder.Entity("IOL.GreatOffice.Data.Database.User", b => - { - b.Property<Guid>("Id") - .ValueGeneratedOnAdd() - .HasColumnType("uuid") - .HasColumnName("id"); - - b.Property<DateTime>("Created") - .HasColumnType("timestamp without time zone") - .HasColumnName("created"); - - b.Property<string>("Password") - .HasColumnType("text") - .HasColumnName("password"); - - b.Property<string>("Username") - .HasColumnType("text") - .HasColumnName("username"); - - b.HasKey("Id") - .HasName("pk_users"); - - b.ToTable("users"); - }); - - modelBuilder.Entity("TimeEntryTimeLabel", b => - { - b.Property<Guid>("EntriesId") - .HasColumnType("uuid") - .HasColumnName("entries_id"); - - b.Property<Guid>("LabelsId") - .HasColumnType("uuid") - .HasColumnName("labels_id"); - - b.HasKey("EntriesId", "LabelsId") - .HasName("pk_time_entry_time_label"); - - b.HasIndex("LabelsId") - .HasDatabaseName("ix_time_entry_time_label_labels_id"); - - b.ToTable("time_entry_time_label"); - }); - - modelBuilder.Entity("IOL.GreatOffice.Data.Database.ForgotPasswordRequest", b => - { - b.HasOne("IOL.GreatOffice.Data.Database.User", "User") - .WithMany() - .HasForeignKey("UserId") - .HasConstraintName("fk_forgot_password_requests_users_user_id"); - - b.Navigation("User"); - }); - - modelBuilder.Entity("IOL.GreatOffice.Data.Database.TimeEntry", b => - { - b.HasOne("IOL.GreatOffice.Data.Database.TimeCategory", "Category") - .WithMany() - .HasForeignKey("CategoryId") - .HasConstraintName("fk_time_entries_time_categories_category_id"); - - b.Navigation("Category"); - }); - - modelBuilder.Entity("TimeEntryTimeLabel", b => - { - b.HasOne("IOL.GreatOffice.Data.Database.TimeEntry", null) - .WithMany() - .HasForeignKey("EntriesId") - .HasConstraintName("fk_time_entry_time_label_time_entries_entries_id") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("IOL.GreatOffice.Data.Database.TimeLabel", null) - .WithMany() - .HasForeignKey("LabelsId") - .HasConstraintName("fk_time_entry_time_label_time_labels_labels_id") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - }); -#pragma warning restore 612, 618 - } - } -} diff --git a/server/src/Migrations/20210522165932_RenameNoteToDescription.cs b/server/src/Migrations/20210522165932_RenameNoteToDescription.cs deleted file mode 100644 index e5bae54..0000000 --- a/server/src/Migrations/20210522165932_RenameNoteToDescription.cs +++ /dev/null @@ -1,34 +0,0 @@ -using System; -using Microsoft.EntityFrameworkCore.Migrations; - -namespace IOL.GreatOffice.Api.Migrations -{ - public partial class RenameNoteToDescription : Migration - { - protected override void Up(MigrationBuilder migrationBuilder) - { - migrationBuilder.DeleteData( - table: "users", - keyColumn: "id", - keyValue: new Guid("784938f0-cc0e-46ec-afa6-fc60b47b28db")); - - migrationBuilder.RenameColumn( - name: "note", - table: "time_entries", - newName: "description"); - } - - protected override void Down(MigrationBuilder migrationBuilder) - { - migrationBuilder.RenameColumn( - name: "description", - table: "time_entries", - newName: "note"); - - migrationBuilder.InsertData( - table: "users", - columns: new[] { "id", "created", "password", "username" }, - values: new object[] { new Guid("784938f0-cc0e-46ec-afa6-fc60b47b28db"), new DateTime(2021, 5, 17, 20, 21, 14, 827, DateTimeKind.Utc).AddTicks(4868), "AAAAAAEAACcQAAAAEJdtrX3pEeIbcgY+BDAr56gvfbc420ag1TllA0cK6Q6Gw3+gGDIQtYIZnisW3dmqaQ==", "admin@ivarlovlie.no" }); - } - } -} diff --git a/server/src/Migrations/20211002113037_V6Migration.Designer.cs b/server/src/Migrations/20211002113037_V6Migration.Designer.cs deleted file mode 100644 index 59e6112..0000000 --- a/server/src/Migrations/20211002113037_V6Migration.Designer.cs +++ /dev/null @@ -1,233 +0,0 @@ -// <auto-generated /> - - -#nullable disable - -using System; -using IOL.GreatOffice.Api.Data; -using Microsoft.EntityFrameworkCore; -using Microsoft.EntityFrameworkCore.Infrastructure; -using Microsoft.EntityFrameworkCore.Migrations; -using Microsoft.EntityFrameworkCore.Storage.ValueConversion; -using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata; -namespace IOL.GreatOffice.Api.Migrations -{ - [DbContext(typeof(AppDbContext))] - [Migration("20211002113037_V6Migration")] - partial class V6Migration - { - protected override void BuildTargetModel(ModelBuilder modelBuilder) - { -#pragma warning disable 612, 618 - modelBuilder - .HasAnnotation("ProductVersion", "6.0.0-rc.1.21452.10") - .HasAnnotation("Relational:MaxIdentifierLength", 63); - - NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder); - - modelBuilder.Entity("IOL.GreatOffice.Data.Database.ForgotPasswordRequest", b => - { - b.Property<Guid>("Id") - .ValueGeneratedOnAdd() - .HasColumnType("uuid") - .HasColumnName("id"); - - b.Property<DateTime>("Created") - .HasColumnType("timestamp with time zone") - .HasColumnName("created"); - - b.Property<Guid?>("UserId") - .HasColumnType("uuid") - .HasColumnName("user_id"); - - b.HasKey("Id") - .HasName("pk_forgot_password_requests"); - - b.HasIndex("UserId") - .HasDatabaseName("ix_forgot_password_requests_user_id"); - - b.ToTable("forgot_password_requests", (string)null); - }); - - modelBuilder.Entity("IOL.GreatOffice.Data.Database.TimeCategory", b => - { - b.Property<Guid>("Id") - .ValueGeneratedOnAdd() - .HasColumnType("uuid") - .HasColumnName("id"); - - b.Property<string>("Color") - .HasColumnType("text") - .HasColumnName("color"); - - b.Property<DateTime>("Created") - .HasColumnType("timestamp with time zone") - .HasColumnName("created"); - - b.Property<string>("Name") - .HasColumnType("text") - .HasColumnName("name"); - - b.Property<Guid>("UserId") - .HasColumnType("uuid") - .HasColumnName("user_id"); - - b.HasKey("Id") - .HasName("pk_time_categories"); - - b.ToTable("time_categories", (string)null); - }); - - modelBuilder.Entity("IOL.GreatOffice.Data.Database.TimeEntry", b => - { - b.Property<Guid>("Id") - .ValueGeneratedOnAdd() - .HasColumnType("uuid") - .HasColumnName("id"); - - b.Property<Guid?>("CategoryId") - .HasColumnType("uuid") - .HasColumnName("category_id"); - - b.Property<DateTime>("Created") - .HasColumnType("timestamp with time zone") - .HasColumnName("created"); - - b.Property<string>("Description") - .HasColumnType("text") - .HasColumnName("description"); - - b.Property<DateTime>("Start") - .HasColumnType("timestamp with time zone") - .HasColumnName("start"); - - b.Property<DateTime>("Stop") - .HasColumnType("timestamp with time zone") - .HasColumnName("stop"); - - b.Property<Guid>("UserId") - .HasColumnType("uuid") - .HasColumnName("user_id"); - - b.HasKey("Id") - .HasName("pk_time_entries"); - - b.HasIndex("CategoryId") - .HasDatabaseName("ix_time_entries_category_id"); - - b.ToTable("time_entries", (string)null); - }); - - modelBuilder.Entity("IOL.GreatOffice.Data.Database.TimeLabel", b => - { - b.Property<Guid>("Id") - .ValueGeneratedOnAdd() - .HasColumnType("uuid") - .HasColumnName("id"); - - b.Property<string>("Color") - .HasColumnType("text") - .HasColumnName("color"); - - b.Property<DateTime>("Created") - .HasColumnType("timestamp with time zone") - .HasColumnName("created"); - - b.Property<string>("Name") - .HasColumnType("text") - .HasColumnName("name"); - - b.Property<Guid>("UserId") - .HasColumnType("uuid") - .HasColumnName("user_id"); - - b.HasKey("Id") - .HasName("pk_time_labels"); - - b.ToTable("time_labels", (string)null); - }); - - modelBuilder.Entity("IOL.GreatOffice.Data.Database.User", b => - { - b.Property<Guid>("Id") - .ValueGeneratedOnAdd() - .HasColumnType("uuid") - .HasColumnName("id"); - - b.Property<DateTime>("Created") - .HasColumnType("timestamp with time zone") - .HasColumnName("created"); - - b.Property<string>("Password") - .HasColumnType("text") - .HasColumnName("password"); - - b.Property<string>("Username") - .HasColumnType("text") - .HasColumnName("username"); - - b.HasKey("Id") - .HasName("pk_users"); - - b.ToTable("users", (string)null); - }); - - modelBuilder.Entity("TimeEntryTimeLabel", b => - { - b.Property<Guid>("EntriesId") - .HasColumnType("uuid") - .HasColumnName("entries_id"); - - b.Property<Guid>("LabelsId") - .HasColumnType("uuid") - .HasColumnName("labels_id"); - - b.HasKey("EntriesId", "LabelsId") - .HasName("pk_time_entry_time_label"); - - b.HasIndex("LabelsId") - .HasDatabaseName("ix_time_entry_time_label_labels_id"); - - b.ToTable("time_entry_time_label", (string)null); - }); - - modelBuilder.Entity("IOL.GreatOffice.Data.Database.ForgotPasswordRequest", b => - { - b.HasOne("IOL.GreatOffice.Data.Database.User", "User") - .WithMany() - .HasForeignKey("UserId") - .HasConstraintName("fk_forgot_password_requests_users_user_id"); - - b.Navigation("User"); - }); - - modelBuilder.Entity("IOL.GreatOffice.Data.Database.TimeEntry", b => - { - b.HasOne("IOL.GreatOffice.Data.Database.TimeCategory", "Category") - .WithMany() - .HasForeignKey("CategoryId") - .HasConstraintName("fk_time_entries_time_categories_category_id"); - - b.Navigation("Category"); - }); - - modelBuilder.Entity("TimeEntryTimeLabel", b => - { - b.HasOne("IOL.GreatOffice.Data.Database.TimeEntry", null) - .WithMany() - .HasForeignKey("EntriesId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired() - .HasConstraintName("fk_time_entry_time_label_time_entries_entries_id"); - - b.HasOne("IOL.GreatOffice.Data.Database.TimeLabel", null) - .WithMany() - .HasForeignKey("LabelsId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired() - .HasConstraintName("fk_time_entry_time_label_time_labels_labels_id"); - }); -#pragma warning restore 612, 618 - } - } -} diff --git a/server/src/Migrations/20211002113037_V6Migration.cs b/server/src/Migrations/20211002113037_V6Migration.cs deleted file mode 100644 index c7ac971..0000000 --- a/server/src/Migrations/20211002113037_V6Migration.cs +++ /dev/null @@ -1,130 +0,0 @@ -using System; -using Microsoft.EntityFrameworkCore.Migrations; - -#nullable disable - -namespace IOL.GreatOffice.Api.Migrations -{ - public partial class V6Migration : Migration - { - protected override void Up(MigrationBuilder migrationBuilder) - { - migrationBuilder.Sql("SET TimeZone='UTC'"); - migrationBuilder.AlterColumn<DateTime>( - name: "created", - table: "users", - type: "timestamp with time zone", - nullable: false, - oldClrType: typeof(DateTime), - oldType: "timestamp without time zone"); - - migrationBuilder.AlterColumn<DateTime>( - name: "created", - table: "time_labels", - type: "timestamp with time zone", - nullable: false, - oldClrType: typeof(DateTime), - oldType: "timestamp without time zone"); - - migrationBuilder.AlterColumn<DateTime>( - name: "stop", - table: "time_entries", - type: "timestamp with time zone", - nullable: false, - oldClrType: typeof(DateTime), - oldType: "timestamp without time zone"); - - migrationBuilder.AlterColumn<DateTime>( - name: "start", - table: "time_entries", - type: "timestamp with time zone", - nullable: false, - oldClrType: typeof(DateTime), - oldType: "timestamp without time zone"); - - migrationBuilder.AlterColumn<DateTime>( - name: "created", - table: "time_entries", - type: "timestamp with time zone", - nullable: false, - oldClrType: typeof(DateTime), - oldType: "timestamp without time zone"); - - migrationBuilder.AlterColumn<DateTime>( - name: "created", - table: "time_categories", - type: "timestamp with time zone", - nullable: false, - oldClrType: typeof(DateTime), - oldType: "timestamp without time zone"); - - migrationBuilder.AlterColumn<DateTime>( - name: "created", - table: "forgot_password_requests", - type: "timestamp with time zone", - nullable: false, - oldClrType: typeof(DateTime), - oldType: "timestamp without time zone"); - } - - protected override void Down(MigrationBuilder migrationBuilder) - { - migrationBuilder.Sql("SET TimeZone='UTC'"); - migrationBuilder.AlterColumn<DateTime>( - name: "created", - table: "users", - type: "timestamp without time zone", - nullable: false, - oldClrType: typeof(DateTime), - oldType: "timestamp with time zone"); - - migrationBuilder.AlterColumn<DateTime>( - name: "created", - table: "time_labels", - type: "timestamp without time zone", - nullable: false, - oldClrType: typeof(DateTime), - oldType: "timestamp with time zone"); - - migrationBuilder.AlterColumn<DateTime>( - name: "stop", - table: "time_entries", - type: "timestamp without time zone", - nullable: false, - oldClrType: typeof(DateTime), - oldType: "timestamp with time zone"); - - migrationBuilder.AlterColumn<DateTime>( - name: "start", - table: "time_entries", - type: "timestamp without time zone", - nullable: false, - oldClrType: typeof(DateTime), - oldType: "timestamp with time zone"); - - migrationBuilder.AlterColumn<DateTime>( - name: "created", - table: "time_entries", - type: "timestamp without time zone", - nullable: false, - oldClrType: typeof(DateTime), - oldType: "timestamp with time zone"); - - migrationBuilder.AlterColumn<DateTime>( - name: "created", - table: "time_categories", - type: "timestamp without time zone", - nullable: false, - oldClrType: typeof(DateTime), - oldType: "timestamp with time zone"); - - migrationBuilder.AlterColumn<DateTime>( - name: "created", - table: "forgot_password_requests", - type: "timestamp without time zone", - nullable: false, - oldClrType: typeof(DateTime), - oldType: "timestamp with time zone"); - } - } -} diff --git a/server/src/Migrations/20220225143559_GithubUserMappings.Designer.cs b/server/src/Migrations/20220225143559_GithubUserMappings.Designer.cs deleted file mode 100644 index 2b95f9d..0000000 --- a/server/src/Migrations/20220225143559_GithubUserMappings.Designer.cs +++ /dev/null @@ -1,270 +0,0 @@ -// <auto-generated /> - - -#nullable disable - -using System; -using IOL.GreatOffice.Api.Data; -using Microsoft.EntityFrameworkCore; -using Microsoft.EntityFrameworkCore.Infrastructure; -using Microsoft.EntityFrameworkCore.Migrations; -using Microsoft.EntityFrameworkCore.Storage.ValueConversion; -using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata; -namespace IOL.GreatOffice.Api.Migrations -{ - [DbContext(typeof(AppDbContext))] - [Migration("20220225143559_GithubUserMappings")] - partial class GithubUserMappings - { - protected override void BuildTargetModel(ModelBuilder modelBuilder) - { -#pragma warning disable 612, 618 - modelBuilder - .HasAnnotation("ProductVersion", "6.0.2") - .HasAnnotation("Relational:MaxIdentifierLength", 63); - - NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder); - - modelBuilder.Entity("IOL.GreatOffice.Data.Database.ForgotPasswordRequest", b => - { - b.Property<Guid>("Id") - .ValueGeneratedOnAdd() - .HasColumnType("uuid") - .HasColumnName("id"); - - b.Property<DateTime>("Created") - .HasColumnType("timestamp with time zone") - .HasColumnName("created"); - - b.Property<Guid?>("UserId") - .HasColumnType("uuid") - .HasColumnName("user_id"); - - b.HasKey("Id") - .HasName("pk_forgot_password_requests"); - - b.HasIndex("UserId") - .HasDatabaseName("ix_forgot_password_requests_user_id"); - - b.ToTable("forgot_password_requests", (string)null); - }); - - modelBuilder.Entity("IOL.GreatOffice.Data.Database.GithubUserMapping", b => - { - b.Property<string>("GithubId") - .HasColumnType("text") - .HasColumnName("github_id"); - - b.Property<string>("Email") - .HasColumnType("text") - .HasColumnName("email"); - - b.Property<string>("RefreshToken") - .HasColumnType("text") - .HasColumnName("refresh_token"); - - b.Property<Guid?>("UserId") - .HasColumnType("uuid") - .HasColumnName("user_id"); - - b.HasKey("GithubId") - .HasName("pk_github_user_mappings"); - - b.HasIndex("UserId") - .HasDatabaseName("ix_github_user_mappings_user_id"); - - b.ToTable("github_user_mappings", (string)null); - }); - - modelBuilder.Entity("IOL.GreatOffice.Data.Database.TimeCategory", b => - { - b.Property<Guid>("Id") - .ValueGeneratedOnAdd() - .HasColumnType("uuid") - .HasColumnName("id"); - - b.Property<string>("Color") - .HasColumnType("text") - .HasColumnName("color"); - - b.Property<DateTime>("Created") - .HasColumnType("timestamp with time zone") - .HasColumnName("created"); - - b.Property<string>("Name") - .HasColumnType("text") - .HasColumnName("name"); - - b.Property<Guid>("UserId") - .HasColumnType("uuid") - .HasColumnName("user_id"); - - b.HasKey("Id") - .HasName("pk_time_categories"); - - b.ToTable("time_categories", (string)null); - }); - - modelBuilder.Entity("IOL.GreatOffice.Data.Database.TimeEntry", b => - { - b.Property<Guid>("Id") - .ValueGeneratedOnAdd() - .HasColumnType("uuid") - .HasColumnName("id"); - - b.Property<Guid?>("CategoryId") - .HasColumnType("uuid") - .HasColumnName("category_id"); - - b.Property<DateTime>("Created") - .HasColumnType("timestamp with time zone") - .HasColumnName("created"); - - b.Property<string>("Description") - .HasColumnType("text") - .HasColumnName("description"); - - b.Property<DateTime>("Start") - .HasColumnType("timestamp with time zone") - .HasColumnName("start"); - - b.Property<DateTime>("Stop") - .HasColumnType("timestamp with time zone") - .HasColumnName("stop"); - - b.Property<Guid>("UserId") - .HasColumnType("uuid") - .HasColumnName("user_id"); - - b.HasKey("Id") - .HasName("pk_time_entries"); - - b.HasIndex("CategoryId") - .HasDatabaseName("ix_time_entries_category_id"); - - b.ToTable("time_entries", (string)null); - }); - - modelBuilder.Entity("IOL.GreatOffice.Data.Database.TimeLabel", b => - { - b.Property<Guid>("Id") - .ValueGeneratedOnAdd() - .HasColumnType("uuid") - .HasColumnName("id"); - - b.Property<string>("Color") - .HasColumnType("text") - .HasColumnName("color"); - - b.Property<DateTime>("Created") - .HasColumnType("timestamp with time zone") - .HasColumnName("created"); - - b.Property<string>("Name") - .HasColumnType("text") - .HasColumnName("name"); - - b.Property<Guid>("UserId") - .HasColumnType("uuid") - .HasColumnName("user_id"); - - b.HasKey("Id") - .HasName("pk_time_labels"); - - b.ToTable("time_labels", (string)null); - }); - - modelBuilder.Entity("IOL.GreatOffice.Data.Database.User", b => - { - b.Property<Guid>("Id") - .ValueGeneratedOnAdd() - .HasColumnType("uuid") - .HasColumnName("id"); - - b.Property<DateTime>("Created") - .HasColumnType("timestamp with time zone") - .HasColumnName("created"); - - b.Property<string>("Password") - .HasColumnType("text") - .HasColumnName("password"); - - b.Property<string>("Username") - .HasColumnType("text") - .HasColumnName("username"); - - b.HasKey("Id") - .HasName("pk_users"); - - b.ToTable("users", (string)null); - }); - - modelBuilder.Entity("TimeEntryTimeLabel", b => - { - b.Property<Guid>("EntriesId") - .HasColumnType("uuid") - .HasColumnName("entries_id"); - - b.Property<Guid>("LabelsId") - .HasColumnType("uuid") - .HasColumnName("labels_id"); - - b.HasKey("EntriesId", "LabelsId") - .HasName("pk_time_entry_time_label"); - - b.HasIndex("LabelsId") - .HasDatabaseName("ix_time_entry_time_label_labels_id"); - - b.ToTable("time_entry_time_label", (string)null); - }); - - modelBuilder.Entity("IOL.GreatOffice.Data.Database.ForgotPasswordRequest", b => - { - b.HasOne("IOL.GreatOffice.Data.Database.User", "User") - .WithMany() - .HasForeignKey("UserId") - .HasConstraintName("fk_forgot_password_requests_users_user_id"); - - b.Navigation("User"); - }); - - modelBuilder.Entity("IOL.GreatOffice.Data.Database.GithubUserMapping", b => - { - b.HasOne("IOL.GreatOffice.Data.Database.User", "User") - .WithMany() - .HasForeignKey("UserId") - .HasConstraintName("fk_github_user_mappings_users_user_id"); - - b.Navigation("User"); - }); - - modelBuilder.Entity("IOL.GreatOffice.Data.Database.TimeEntry", b => - { - b.HasOne("IOL.GreatOffice.Data.Database.TimeCategory", "Category") - .WithMany() - .HasForeignKey("CategoryId") - .HasConstraintName("fk_time_entries_time_categories_category_id"); - - b.Navigation("Category"); - }); - - modelBuilder.Entity("TimeEntryTimeLabel", b => - { - b.HasOne("IOL.GreatOffice.Data.Database.TimeEntry", null) - .WithMany() - .HasForeignKey("EntriesId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired() - .HasConstraintName("fk_time_entry_time_label_time_entries_entries_id"); - - b.HasOne("IOL.GreatOffice.Data.Database.TimeLabel", null) - .WithMany() - .HasForeignKey("LabelsId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired() - .HasConstraintName("fk_time_entry_time_label_time_labels_labels_id"); - }); -#pragma warning restore 612, 618 - } - } -} diff --git a/server/src/Migrations/20220225143559_GithubUserMappings.cs b/server/src/Migrations/20220225143559_GithubUserMappings.cs deleted file mode 100644 index fc30c7a..0000000 --- a/server/src/Migrations/20220225143559_GithubUserMappings.cs +++ /dev/null @@ -1,43 +0,0 @@ -using System; -using Microsoft.EntityFrameworkCore.Migrations; - -#nullable disable - -namespace IOL.GreatOffice.Api.Migrations -{ - public partial class GithubUserMappings : Migration - { - protected override void Up(MigrationBuilder migrationBuilder) - { - migrationBuilder.CreateTable( - name: "github_user_mappings", - columns: table => new - { - github_id = table.Column<string>(type: "text", nullable: false), - user_id = table.Column<Guid>(type: "uuid", nullable: true), - email = table.Column<string>(type: "text", nullable: true), - refresh_token = table.Column<string>(type: "text", nullable: true) - }, - constraints: table => - { - table.PrimaryKey("pk_github_user_mappings", x => x.github_id); - table.ForeignKey( - name: "fk_github_user_mappings_users_user_id", - column: x => x.user_id, - principalTable: "users", - principalColumn: "id"); - }); - - migrationBuilder.CreateIndex( - name: "ix_github_user_mappings_user_id", - table: "github_user_mappings", - column: "user_id"); - } - - protected override void Down(MigrationBuilder migrationBuilder) - { - migrationBuilder.DropTable( - name: "github_user_mappings"); - } - } -} diff --git a/server/src/Migrations/20220319135910_RenameCreated.Designer.cs b/server/src/Migrations/20220319135910_RenameCreated.Designer.cs deleted file mode 100644 index 3d57f1a..0000000 --- a/server/src/Migrations/20220319135910_RenameCreated.Designer.cs +++ /dev/null @@ -1,270 +0,0 @@ -// <auto-generated /> - - -#nullable disable - -using System; -using IOL.GreatOffice.Api.Data; -using Microsoft.EntityFrameworkCore; -using Microsoft.EntityFrameworkCore.Infrastructure; -using Microsoft.EntityFrameworkCore.Migrations; -using Microsoft.EntityFrameworkCore.Storage.ValueConversion; -using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata; -namespace IOL.GreatOffice.Api.Migrations -{ - [DbContext(typeof(AppDbContext))] - [Migration("20220319135910_RenameCreated")] - partial class RenameCreated - { - protected override void BuildTargetModel(ModelBuilder modelBuilder) - { -#pragma warning disable 612, 618 - modelBuilder - .HasAnnotation("ProductVersion", "6.0.3") - .HasAnnotation("Relational:MaxIdentifierLength", 63); - - NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder); - - modelBuilder.Entity("IOL.GreatOffice.Data.Database.ForgotPasswordRequest", b => - { - b.Property<Guid>("Id") - .ValueGeneratedOnAdd() - .HasColumnType("uuid") - .HasColumnName("id"); - - b.Property<DateTime>("CreatedAt") - .HasColumnType("timestamp with time zone") - .HasColumnName("created_at"); - - b.Property<Guid?>("UserId") - .HasColumnType("uuid") - .HasColumnName("user_id"); - - b.HasKey("Id") - .HasName("pk_forgot_password_requests"); - - b.HasIndex("UserId") - .HasDatabaseName("ix_forgot_password_requests_user_id"); - - b.ToTable("forgot_password_requests", (string)null); - }); - - modelBuilder.Entity("IOL.GreatOffice.Data.Database.GithubUserMapping", b => - { - b.Property<string>("GithubId") - .HasColumnType("text") - .HasColumnName("github_id"); - - b.Property<string>("Email") - .HasColumnType("text") - .HasColumnName("email"); - - b.Property<string>("RefreshToken") - .HasColumnType("text") - .HasColumnName("refresh_token"); - - b.Property<Guid?>("UserId") - .HasColumnType("uuid") - .HasColumnName("user_id"); - - b.HasKey("GithubId") - .HasName("pk_github_user_mappings"); - - b.HasIndex("UserId") - .HasDatabaseName("ix_github_user_mappings_user_id"); - - b.ToTable("github_user_mappings", (string)null); - }); - - modelBuilder.Entity("IOL.GreatOffice.Data.Database.TimeCategory", b => - { - b.Property<Guid>("Id") - .ValueGeneratedOnAdd() - .HasColumnType("uuid") - .HasColumnName("id"); - - b.Property<string>("Color") - .HasColumnType("text") - .HasColumnName("color"); - - b.Property<DateTime>("CreatedAt") - .HasColumnType("timestamp with time zone") - .HasColumnName("created_at"); - - b.Property<string>("Name") - .HasColumnType("text") - .HasColumnName("name"); - - b.Property<Guid>("UserId") - .HasColumnType("uuid") - .HasColumnName("user_id"); - - b.HasKey("Id") - .HasName("pk_time_categories"); - - b.ToTable("time_categories", (string)null); - }); - - modelBuilder.Entity("IOL.GreatOffice.Data.Database.TimeEntry", b => - { - b.Property<Guid>("Id") - .ValueGeneratedOnAdd() - .HasColumnType("uuid") - .HasColumnName("id"); - - b.Property<Guid?>("CategoryId") - .HasColumnType("uuid") - .HasColumnName("category_id"); - - b.Property<DateTime>("CreatedAt") - .HasColumnType("timestamp with time zone") - .HasColumnName("created_at"); - - b.Property<string>("Description") - .HasColumnType("text") - .HasColumnName("description"); - - b.Property<DateTime>("Start") - .HasColumnType("timestamp with time zone") - .HasColumnName("start"); - - b.Property<DateTime>("Stop") - .HasColumnType("timestamp with time zone") - .HasColumnName("stop"); - - b.Property<Guid>("UserId") - .HasColumnType("uuid") - .HasColumnName("user_id"); - - b.HasKey("Id") - .HasName("pk_time_entries"); - - b.HasIndex("CategoryId") - .HasDatabaseName("ix_time_entries_category_id"); - - b.ToTable("time_entries", (string)null); - }); - - modelBuilder.Entity("IOL.GreatOffice.Data.Database.TimeLabel", b => - { - b.Property<Guid>("Id") - .ValueGeneratedOnAdd() - .HasColumnType("uuid") - .HasColumnName("id"); - - b.Property<string>("Color") - .HasColumnType("text") - .HasColumnName("color"); - - b.Property<DateTime>("CreatedAt") - .HasColumnType("timestamp with time zone") - .HasColumnName("created_at"); - - b.Property<string>("Name") - .HasColumnType("text") - .HasColumnName("name"); - - b.Property<Guid>("UserId") - .HasColumnType("uuid") - .HasColumnName("user_id"); - - b.HasKey("Id") - .HasName("pk_time_labels"); - - b.ToTable("time_labels", (string)null); - }); - - modelBuilder.Entity("IOL.GreatOffice.Data.Database.User", b => - { - b.Property<Guid>("Id") - .ValueGeneratedOnAdd() - .HasColumnType("uuid") - .HasColumnName("id"); - - b.Property<DateTime>("CreatedAt") - .HasColumnType("timestamp with time zone") - .HasColumnName("created_at"); - - b.Property<string>("Password") - .HasColumnType("text") - .HasColumnName("password"); - - b.Property<string>("Username") - .HasColumnType("text") - .HasColumnName("username"); - - b.HasKey("Id") - .HasName("pk_users"); - - b.ToTable("users", (string)null); - }); - - modelBuilder.Entity("TimeEntryTimeLabel", b => - { - b.Property<Guid>("EntriesId") - .HasColumnType("uuid") - .HasColumnName("entries_id"); - - b.Property<Guid>("LabelsId") - .HasColumnType("uuid") - .HasColumnName("labels_id"); - - b.HasKey("EntriesId", "LabelsId") - .HasName("pk_time_entry_time_label"); - - b.HasIndex("LabelsId") - .HasDatabaseName("ix_time_entry_time_label_labels_id"); - - b.ToTable("time_entry_time_label", (string)null); - }); - - modelBuilder.Entity("IOL.GreatOffice.Data.Database.ForgotPasswordRequest", b => - { - b.HasOne("IOL.GreatOffice.Data.Database.User", "User") - .WithMany() - .HasForeignKey("UserId") - .HasConstraintName("fk_forgot_password_requests_users_user_id"); - - b.Navigation("User"); - }); - - modelBuilder.Entity("IOL.GreatOffice.Data.Database.GithubUserMapping", b => - { - b.HasOne("IOL.GreatOffice.Data.Database.User", "User") - .WithMany() - .HasForeignKey("UserId") - .HasConstraintName("fk_github_user_mappings_users_user_id"); - - b.Navigation("User"); - }); - - modelBuilder.Entity("IOL.GreatOffice.Data.Database.TimeEntry", b => - { - b.HasOne("IOL.GreatOffice.Data.Database.TimeCategory", "Category") - .WithMany() - .HasForeignKey("CategoryId") - .HasConstraintName("fk_time_entries_time_categories_category_id"); - - b.Navigation("Category"); - }); - - modelBuilder.Entity("TimeEntryTimeLabel", b => - { - b.HasOne("IOL.GreatOffice.Data.Database.TimeEntry", null) - .WithMany() - .HasForeignKey("EntriesId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired() - .HasConstraintName("fk_time_entry_time_label_time_entries_entries_id"); - - b.HasOne("IOL.GreatOffice.Data.Database.TimeLabel", null) - .WithMany() - .HasForeignKey("LabelsId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired() - .HasConstraintName("fk_time_entry_time_label_time_labels_labels_id"); - }); -#pragma warning restore 612, 618 - } - } -} diff --git a/server/src/Migrations/20220319135910_RenameCreated.cs b/server/src/Migrations/20220319135910_RenameCreated.cs deleted file mode 100644 index 6571e50..0000000 --- a/server/src/Migrations/20220319135910_RenameCreated.cs +++ /dev/null @@ -1,65 +0,0 @@ -using Microsoft.EntityFrameworkCore.Migrations; - -#nullable disable - -namespace IOL.GreatOffice.Api.Migrations -{ - public partial class RenameCreated : Migration - { - protected override void Up(MigrationBuilder migrationBuilder) - { - migrationBuilder.RenameColumn( - name: "created", - table: "users", - newName: "created_at"); - - migrationBuilder.RenameColumn( - name: "created", - table: "time_labels", - newName: "created_at"); - - migrationBuilder.RenameColumn( - name: "created", - table: "time_entries", - newName: "created_at"); - - migrationBuilder.RenameColumn( - name: "created", - table: "time_categories", - newName: "created_at"); - - migrationBuilder.RenameColumn( - name: "created", - table: "forgot_password_requests", - newName: "created_at"); - } - - protected override void Down(MigrationBuilder migrationBuilder) - { - migrationBuilder.RenameColumn( - name: "created_at", - table: "users", - newName: "created"); - - migrationBuilder.RenameColumn( - name: "created_at", - table: "time_labels", - newName: "created"); - - migrationBuilder.RenameColumn( - name: "created_at", - table: "time_entries", - newName: "created"); - - migrationBuilder.RenameColumn( - name: "created_at", - table: "time_categories", - newName: "created"); - - migrationBuilder.RenameColumn( - name: "created_at", - table: "forgot_password_requests", - newName: "created"); - } - } -} diff --git a/server/src/Migrations/20220319144958_ModifiedAt.Designer.cs b/server/src/Migrations/20220319144958_ModifiedAt.Designer.cs deleted file mode 100644 index f75400e..0000000 --- a/server/src/Migrations/20220319144958_ModifiedAt.Designer.cs +++ /dev/null @@ -1,290 +0,0 @@ -// <auto-generated /> - - -#nullable disable - -using System; -using IOL.GreatOffice.Api.Data; -using Microsoft.EntityFrameworkCore; -using Microsoft.EntityFrameworkCore.Infrastructure; -using Microsoft.EntityFrameworkCore.Migrations; -using Microsoft.EntityFrameworkCore.Storage.ValueConversion; -using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata; -namespace IOL.GreatOffice.Api.Migrations -{ - [DbContext(typeof(AppDbContext))] - [Migration("20220319144958_ModifiedAt")] - partial class ModifiedAt - { - protected override void BuildTargetModel(ModelBuilder modelBuilder) - { -#pragma warning disable 612, 618 - modelBuilder - .HasAnnotation("ProductVersion", "6.0.3") - .HasAnnotation("Relational:MaxIdentifierLength", 63); - - NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder); - - modelBuilder.Entity("IOL.GreatOffice.Data.Database.ForgotPasswordRequest", b => - { - b.Property<Guid>("Id") - .ValueGeneratedOnAdd() - .HasColumnType("uuid") - .HasColumnName("id"); - - b.Property<DateTime>("CreatedAt") - .HasColumnType("timestamp with time zone") - .HasColumnName("created_at"); - - b.Property<DateTime?>("ModifiedAt") - .HasColumnType("timestamp with time zone") - .HasColumnName("modified_at"); - - b.Property<Guid?>("UserId") - .HasColumnType("uuid") - .HasColumnName("user_id"); - - b.HasKey("Id") - .HasName("pk_forgot_password_requests"); - - b.HasIndex("UserId") - .HasDatabaseName("ix_forgot_password_requests_user_id"); - - b.ToTable("forgot_password_requests", (string)null); - }); - - modelBuilder.Entity("IOL.GreatOffice.Data.Database.GithubUserMapping", b => - { - b.Property<string>("GithubId") - .HasColumnType("text") - .HasColumnName("github_id"); - - b.Property<string>("Email") - .HasColumnType("text") - .HasColumnName("email"); - - b.Property<string>("RefreshToken") - .HasColumnType("text") - .HasColumnName("refresh_token"); - - b.Property<Guid?>("UserId") - .HasColumnType("uuid") - .HasColumnName("user_id"); - - b.HasKey("GithubId") - .HasName("pk_github_user_mappings"); - - b.HasIndex("UserId") - .HasDatabaseName("ix_github_user_mappings_user_id"); - - b.ToTable("github_user_mappings", (string)null); - }); - - modelBuilder.Entity("IOL.GreatOffice.Data.Database.TimeCategory", b => - { - b.Property<Guid>("Id") - .ValueGeneratedOnAdd() - .HasColumnType("uuid") - .HasColumnName("id"); - - b.Property<string>("Color") - .HasColumnType("text") - .HasColumnName("color"); - - b.Property<DateTime>("CreatedAt") - .HasColumnType("timestamp with time zone") - .HasColumnName("created_at"); - - b.Property<DateTime?>("ModifiedAt") - .HasColumnType("timestamp with time zone") - .HasColumnName("modified_at"); - - b.Property<string>("Name") - .HasColumnType("text") - .HasColumnName("name"); - - b.Property<Guid>("UserId") - .HasColumnType("uuid") - .HasColumnName("user_id"); - - b.HasKey("Id") - .HasName("pk_time_categories"); - - b.ToTable("time_categories", (string)null); - }); - - modelBuilder.Entity("IOL.GreatOffice.Data.Database.TimeEntry", b => - { - b.Property<Guid>("Id") - .ValueGeneratedOnAdd() - .HasColumnType("uuid") - .HasColumnName("id"); - - b.Property<Guid?>("CategoryId") - .HasColumnType("uuid") - .HasColumnName("category_id"); - - b.Property<DateTime>("CreatedAt") - .HasColumnType("timestamp with time zone") - .HasColumnName("created_at"); - - b.Property<string>("Description") - .HasColumnType("text") - .HasColumnName("description"); - - b.Property<DateTime?>("ModifiedAt") - .HasColumnType("timestamp with time zone") - .HasColumnName("modified_at"); - - b.Property<DateTime>("Start") - .HasColumnType("timestamp with time zone") - .HasColumnName("start"); - - b.Property<DateTime>("Stop") - .HasColumnType("timestamp with time zone") - .HasColumnName("stop"); - - b.Property<Guid>("UserId") - .HasColumnType("uuid") - .HasColumnName("user_id"); - - b.HasKey("Id") - .HasName("pk_time_entries"); - - b.HasIndex("CategoryId") - .HasDatabaseName("ix_time_entries_category_id"); - - b.ToTable("time_entries", (string)null); - }); - - modelBuilder.Entity("IOL.GreatOffice.Data.Database.TimeLabel", b => - { - b.Property<Guid>("Id") - .ValueGeneratedOnAdd() - .HasColumnType("uuid") - .HasColumnName("id"); - - b.Property<string>("Color") - .HasColumnType("text") - .HasColumnName("color"); - - b.Property<DateTime>("CreatedAt") - .HasColumnType("timestamp with time zone") - .HasColumnName("created_at"); - - b.Property<DateTime?>("ModifiedAt") - .HasColumnType("timestamp with time zone") - .HasColumnName("modified_at"); - - b.Property<string>("Name") - .HasColumnType("text") - .HasColumnName("name"); - - b.Property<Guid>("UserId") - .HasColumnType("uuid") - .HasColumnName("user_id"); - - b.HasKey("Id") - .HasName("pk_time_labels"); - - b.ToTable("time_labels", (string)null); - }); - - modelBuilder.Entity("IOL.GreatOffice.Data.Database.User", b => - { - b.Property<Guid>("Id") - .ValueGeneratedOnAdd() - .HasColumnType("uuid") - .HasColumnName("id"); - - b.Property<DateTime>("CreatedAt") - .HasColumnType("timestamp with time zone") - .HasColumnName("created_at"); - - b.Property<DateTime?>("ModifiedAt") - .HasColumnType("timestamp with time zone") - .HasColumnName("modified_at"); - - b.Property<string>("Password") - .HasColumnType("text") - .HasColumnName("password"); - - b.Property<string>("Username") - .HasColumnType("text") - .HasColumnName("username"); - - b.HasKey("Id") - .HasName("pk_users"); - - b.ToTable("users", (string)null); - }); - - modelBuilder.Entity("TimeEntryTimeLabel", b => - { - b.Property<Guid>("EntriesId") - .HasColumnType("uuid") - .HasColumnName("entries_id"); - - b.Property<Guid>("LabelsId") - .HasColumnType("uuid") - .HasColumnName("labels_id"); - - b.HasKey("EntriesId", "LabelsId") - .HasName("pk_time_entry_time_label"); - - b.HasIndex("LabelsId") - .HasDatabaseName("ix_time_entry_time_label_labels_id"); - - b.ToTable("time_entry_time_label", (string)null); - }); - - modelBuilder.Entity("IOL.GreatOffice.Data.Database.ForgotPasswordRequest", b => - { - b.HasOne("IOL.GreatOffice.Data.Database.User", "User") - .WithMany() - .HasForeignKey("UserId") - .HasConstraintName("fk_forgot_password_requests_users_user_id"); - - b.Navigation("User"); - }); - - modelBuilder.Entity("IOL.GreatOffice.Data.Database.GithubUserMapping", b => - { - b.HasOne("IOL.GreatOffice.Data.Database.User", "User") - .WithMany() - .HasForeignKey("UserId") - .HasConstraintName("fk_github_user_mappings_users_user_id"); - - b.Navigation("User"); - }); - - modelBuilder.Entity("IOL.GreatOffice.Data.Database.TimeEntry", b => - { - b.HasOne("IOL.GreatOffice.Data.Database.TimeCategory", "Category") - .WithMany() - .HasForeignKey("CategoryId") - .HasConstraintName("fk_time_entries_time_categories_category_id"); - - b.Navigation("Category"); - }); - - modelBuilder.Entity("TimeEntryTimeLabel", b => - { - b.HasOne("IOL.GreatOffice.Data.Database.TimeEntry", null) - .WithMany() - .HasForeignKey("EntriesId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired() - .HasConstraintName("fk_time_entry_time_label_time_entries_entries_id"); - - b.HasOne("IOL.GreatOffice.Data.Database.TimeLabel", null) - .WithMany() - .HasForeignKey("LabelsId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired() - .HasConstraintName("fk_time_entry_time_label_time_labels_labels_id"); - }); -#pragma warning restore 612, 618 - } - } -} diff --git a/server/src/Migrations/20220319144958_ModifiedAt.cs b/server/src/Migrations/20220319144958_ModifiedAt.cs deleted file mode 100644 index 028473d..0000000 --- a/server/src/Migrations/20220319144958_ModifiedAt.cs +++ /dev/null @@ -1,66 +0,0 @@ -using System; -using Microsoft.EntityFrameworkCore.Migrations; - -#nullable disable - -namespace IOL.GreatOffice.Api.Migrations -{ - public partial class ModifiedAt : Migration - { - protected override void Up(MigrationBuilder migrationBuilder) - { - migrationBuilder.AddColumn<DateTime>( - name: "modified_at", - table: "users", - type: "timestamp with time zone", - nullable: true); - - migrationBuilder.AddColumn<DateTime>( - name: "modified_at", - table: "time_labels", - type: "timestamp with time zone", - nullable: true); - - migrationBuilder.AddColumn<DateTime>( - name: "modified_at", - table: "time_entries", - type: "timestamp with time zone", - nullable: true); - - migrationBuilder.AddColumn<DateTime>( - name: "modified_at", - table: "time_categories", - type: "timestamp with time zone", - nullable: true); - - migrationBuilder.AddColumn<DateTime>( - name: "modified_at", - table: "forgot_password_requests", - type: "timestamp with time zone", - nullable: true); - } - - protected override void Down(MigrationBuilder migrationBuilder) - { - migrationBuilder.DropColumn( - name: "modified_at", - table: "users"); - - migrationBuilder.DropColumn( - name: "modified_at", - table: "time_labels"); - - migrationBuilder.DropColumn( - name: "modified_at", - table: "time_entries"); - - migrationBuilder.DropColumn( - name: "modified_at", - table: "time_categories"); - - migrationBuilder.DropColumn( - name: "modified_at", - table: "forgot_password_requests"); - } - } -} diff --git a/server/src/Migrations/20220319203018_UserBase.Designer.cs b/server/src/Migrations/20220319203018_UserBase.Designer.cs deleted file mode 100644 index 6c7a76f..0000000 --- a/server/src/Migrations/20220319203018_UserBase.Designer.cs +++ /dev/null @@ -1,322 +0,0 @@ -// <auto-generated /> - - -#nullable disable - -using System; -using IOL.GreatOffice.Api.Data; -using Microsoft.EntityFrameworkCore; -using Microsoft.EntityFrameworkCore.Infrastructure; -using Microsoft.EntityFrameworkCore.Migrations; -using Microsoft.EntityFrameworkCore.Storage.ValueConversion; -using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata; -namespace IOL.GreatOffice.Api.Migrations -{ - [DbContext(typeof(AppDbContext))] - [Migration("20220319203018_UserBase")] - partial class UserBase - { - protected override void BuildTargetModel(ModelBuilder modelBuilder) - { -#pragma warning disable 612, 618 - modelBuilder - .HasAnnotation("ProductVersion", "6.0.3") - .HasAnnotation("Relational:MaxIdentifierLength", 63); - - NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder); - - modelBuilder.Entity("IOL.GreatOffice.Data.Database.ForgotPasswordRequest", b => - { - b.Property<Guid>("Id") - .ValueGeneratedOnAdd() - .HasColumnType("uuid") - .HasColumnName("id"); - - b.Property<DateTime>("CreatedAt") - .HasColumnType("timestamp with time zone") - .HasColumnName("created_at"); - - b.Property<Guid?>("UserId") - .HasColumnType("uuid") - .HasColumnName("user_id"); - - b.HasKey("Id") - .HasName("pk_forgot_password_requests"); - - b.HasIndex("UserId") - .HasDatabaseName("ix_forgot_password_requests_user_id"); - - b.ToTable("forgot_password_requests", (string)null); - }); - - modelBuilder.Entity("IOL.GreatOffice.Data.Database.GithubUserMapping", b => - { - b.Property<string>("GithubId") - .HasColumnType("text") - .HasColumnName("github_id"); - - b.Property<string>("Email") - .HasColumnType("text") - .HasColumnName("email"); - - b.Property<string>("RefreshToken") - .HasColumnType("text") - .HasColumnName("refresh_token"); - - b.Property<Guid?>("UserId") - .HasColumnType("uuid") - .HasColumnName("user_id"); - - b.HasKey("GithubId") - .HasName("pk_github_user_mappings"); - - b.HasIndex("UserId") - .HasDatabaseName("ix_github_user_mappings_user_id"); - - b.ToTable("github_user_mappings", (string)null); - }); - - modelBuilder.Entity("IOL.GreatOffice.Data.Database.TimeCategory", b => - { - b.Property<Guid>("Id") - .ValueGeneratedOnAdd() - .HasColumnType("uuid") - .HasColumnName("id"); - - b.Property<string>("Color") - .HasColumnType("text") - .HasColumnName("color"); - - b.Property<DateTime>("CreatedAt") - .HasColumnType("timestamp with time zone") - .HasColumnName("created_at"); - - b.Property<DateTime?>("ModifiedAt") - .HasColumnType("timestamp with time zone") - .HasColumnName("modified_at"); - - b.Property<string>("Name") - .HasColumnType("text") - .HasColumnName("name"); - - b.Property<Guid?>("UserId") - .HasColumnType("uuid") - .HasColumnName("user_id"); - - b.HasKey("Id") - .HasName("pk_time_categories"); - - b.HasIndex("UserId") - .HasDatabaseName("ix_time_categories_user_id"); - - b.ToTable("time_categories", (string)null); - }); - - modelBuilder.Entity("IOL.GreatOffice.Data.Database.TimeEntry", b => - { - b.Property<Guid>("Id") - .ValueGeneratedOnAdd() - .HasColumnType("uuid") - .HasColumnName("id"); - - b.Property<Guid?>("CategoryId") - .HasColumnType("uuid") - .HasColumnName("category_id"); - - b.Property<DateTime>("CreatedAt") - .HasColumnType("timestamp with time zone") - .HasColumnName("created_at"); - - b.Property<string>("Description") - .HasColumnType("text") - .HasColumnName("description"); - - b.Property<DateTime?>("ModifiedAt") - .HasColumnType("timestamp with time zone") - .HasColumnName("modified_at"); - - b.Property<DateTime>("Start") - .HasColumnType("timestamp with time zone") - .HasColumnName("start"); - - b.Property<DateTime>("Stop") - .HasColumnType("timestamp with time zone") - .HasColumnName("stop"); - - b.Property<Guid?>("UserId") - .HasColumnType("uuid") - .HasColumnName("user_id"); - - b.HasKey("Id") - .HasName("pk_time_entries"); - - b.HasIndex("CategoryId") - .HasDatabaseName("ix_time_entries_category_id"); - - b.HasIndex("UserId") - .HasDatabaseName("ix_time_entries_user_id"); - - b.ToTable("time_entries", (string)null); - }); - - modelBuilder.Entity("IOL.GreatOffice.Data.Database.TimeLabel", b => - { - b.Property<Guid>("Id") - .ValueGeneratedOnAdd() - .HasColumnType("uuid") - .HasColumnName("id"); - - b.Property<string>("Color") - .HasColumnType("text") - .HasColumnName("color"); - - b.Property<DateTime>("CreatedAt") - .HasColumnType("timestamp with time zone") - .HasColumnName("created_at"); - - b.Property<DateTime?>("ModifiedAt") - .HasColumnType("timestamp with time zone") - .HasColumnName("modified_at"); - - b.Property<string>("Name") - .HasColumnType("text") - .HasColumnName("name"); - - b.Property<Guid?>("UserId") - .HasColumnType("uuid") - .HasColumnName("user_id"); - - b.HasKey("Id") - .HasName("pk_time_labels"); - - b.HasIndex("UserId") - .HasDatabaseName("ix_time_labels_user_id"); - - b.ToTable("time_labels", (string)null); - }); - - modelBuilder.Entity("IOL.GreatOffice.Data.Database.User", b => - { - b.Property<Guid>("Id") - .ValueGeneratedOnAdd() - .HasColumnType("uuid") - .HasColumnName("id"); - - b.Property<DateTime>("CreatedAt") - .HasColumnType("timestamp with time zone") - .HasColumnName("created_at"); - - b.Property<DateTime?>("ModifiedAt") - .HasColumnType("timestamp with time zone") - .HasColumnName("modified_at"); - - b.Property<string>("Username") - .HasColumnType("text") - .HasColumnName("username"); - - b.Property<string>("password") - .HasColumnType("text") - .HasColumnName("password"); - - b.HasKey("Id") - .HasName("pk_users"); - - b.ToTable("users", (string)null); - }); - - modelBuilder.Entity("TimeEntryTimeLabel", b => - { - b.Property<Guid>("EntriesId") - .HasColumnType("uuid") - .HasColumnName("entries_id"); - - b.Property<Guid>("LabelsId") - .HasColumnType("uuid") - .HasColumnName("labels_id"); - - b.HasKey("EntriesId", "LabelsId") - .HasName("pk_time_entry_time_label"); - - b.HasIndex("LabelsId") - .HasDatabaseName("ix_time_entry_time_label_labels_id"); - - b.ToTable("time_entry_time_label", (string)null); - }); - - modelBuilder.Entity("IOL.GreatOffice.Data.Database.ForgotPasswordRequest", b => - { - b.HasOne("IOL.GreatOffice.Data.Database.User", "User") - .WithMany() - .HasForeignKey("UserId") - .HasConstraintName("fk_forgot_password_requests_users_user_id"); - - b.Navigation("User"); - }); - - modelBuilder.Entity("IOL.GreatOffice.Data.Database.GithubUserMapping", b => - { - b.HasOne("IOL.GreatOffice.Data.Database.User", "User") - .WithMany() - .HasForeignKey("UserId") - .HasConstraintName("fk_github_user_mappings_users_user_id"); - - b.Navigation("User"); - }); - - modelBuilder.Entity("IOL.GreatOffice.Data.Database.TimeCategory", b => - { - b.HasOne("IOL.GreatOffice.Data.Database.User", "User") - .WithMany() - .HasForeignKey("UserId") - .HasConstraintName("fk_time_categories_users_user_id"); - - b.Navigation("User"); - }); - - modelBuilder.Entity("IOL.GreatOffice.Data.Database.TimeEntry", b => - { - b.HasOne("IOL.GreatOffice.Data.Database.TimeCategory", "Category") - .WithMany() - .HasForeignKey("CategoryId") - .HasConstraintName("fk_time_entries_time_categories_category_id"); - - b.HasOne("IOL.GreatOffice.Data.Database.User", "User") - .WithMany() - .HasForeignKey("UserId") - .HasConstraintName("fk_time_entries_users_user_id"); - - b.Navigation("Category"); - - b.Navigation("User"); - }); - - modelBuilder.Entity("IOL.GreatOffice.Data.Database.TimeLabel", b => - { - b.HasOne("IOL.GreatOffice.Data.Database.User", "User") - .WithMany() - .HasForeignKey("UserId") - .HasConstraintName("fk_time_labels_users_user_id"); - - b.Navigation("User"); - }); - - modelBuilder.Entity("TimeEntryTimeLabel", b => - { - b.HasOne("IOL.GreatOffice.Data.Database.TimeEntry", null) - .WithMany() - .HasForeignKey("EntriesId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired() - .HasConstraintName("fk_time_entry_time_label_time_entries_entries_id"); - - b.HasOne("IOL.GreatOffice.Data.Database.TimeLabel", null) - .WithMany() - .HasForeignKey("LabelsId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired() - .HasConstraintName("fk_time_entry_time_label_time_labels_labels_id"); - }); -#pragma warning restore 612, 618 - } - } -} diff --git a/server/src/Migrations/20220319203018_UserBase.cs b/server/src/Migrations/20220319203018_UserBase.cs deleted file mode 100644 index 14d3f4b..0000000 --- a/server/src/Migrations/20220319203018_UserBase.cs +++ /dev/null @@ -1,140 +0,0 @@ -using System; -using Microsoft.EntityFrameworkCore.Migrations; - -#nullable disable - -namespace IOL.GreatOffice.Api.Migrations -{ - public partial class UserBase : Migration - { - protected override void Up(MigrationBuilder migrationBuilder) - { - migrationBuilder.DropColumn( - name: "modified_at", - table: "forgot_password_requests"); - - migrationBuilder.AlterColumn<Guid>( - name: "user_id", - table: "time_labels", - type: "uuid", - nullable: true, - oldClrType: typeof(Guid), - oldType: "uuid"); - - migrationBuilder.AlterColumn<Guid>( - name: "user_id", - table: "time_entries", - type: "uuid", - nullable: true, - oldClrType: typeof(Guid), - oldType: "uuid"); - - migrationBuilder.AlterColumn<Guid>( - name: "user_id", - table: "time_categories", - type: "uuid", - nullable: true, - oldClrType: typeof(Guid), - oldType: "uuid"); - - migrationBuilder.CreateIndex( - name: "ix_time_labels_user_id", - table: "time_labels", - column: "user_id"); - - migrationBuilder.CreateIndex( - name: "ix_time_entries_user_id", - table: "time_entries", - column: "user_id"); - - migrationBuilder.CreateIndex( - name: "ix_time_categories_user_id", - table: "time_categories", - column: "user_id"); - - migrationBuilder.AddForeignKey( - name: "fk_time_categories_users_user_id", - table: "time_categories", - column: "user_id", - principalTable: "users", - principalColumn: "id"); - - migrationBuilder.AddForeignKey( - name: "fk_time_entries_users_user_id", - table: "time_entries", - column: "user_id", - principalTable: "users", - principalColumn: "id"); - - migrationBuilder.AddForeignKey( - name: "fk_time_labels_users_user_id", - table: "time_labels", - column: "user_id", - principalTable: "users", - principalColumn: "id"); - } - - protected override void Down(MigrationBuilder migrationBuilder) - { - migrationBuilder.DropForeignKey( - name: "fk_time_categories_users_user_id", - table: "time_categories"); - - migrationBuilder.DropForeignKey( - name: "fk_time_entries_users_user_id", - table: "time_entries"); - - migrationBuilder.DropForeignKey( - name: "fk_time_labels_users_user_id", - table: "time_labels"); - - migrationBuilder.DropIndex( - name: "ix_time_labels_user_id", - table: "time_labels"); - - migrationBuilder.DropIndex( - name: "ix_time_entries_user_id", - table: "time_entries"); - - migrationBuilder.DropIndex( - name: "ix_time_categories_user_id", - table: "time_categories"); - - migrationBuilder.AlterColumn<Guid>( - name: "user_id", - table: "time_labels", - type: "uuid", - nullable: false, - defaultValue: new Guid("00000000-0000-0000-0000-000000000000"), - oldClrType: typeof(Guid), - oldType: "uuid", - oldNullable: true); - - migrationBuilder.AlterColumn<Guid>( - name: "user_id", - table: "time_entries", - type: "uuid", - nullable: false, - defaultValue: new Guid("00000000-0000-0000-0000-000000000000"), - oldClrType: typeof(Guid), - oldType: "uuid", - oldNullable: true); - - migrationBuilder.AlterColumn<Guid>( - name: "user_id", - table: "time_categories", - type: "uuid", - nullable: false, - defaultValue: new Guid("00000000-0000-0000-0000-000000000000"), - oldClrType: typeof(Guid), - oldType: "uuid", - oldNullable: true); - - migrationBuilder.AddColumn<DateTime>( - name: "modified_at", - table: "forgot_password_requests", - type: "timestamp with time zone", - nullable: true); - } - } -} diff --git a/server/src/Migrations/20220320115601_Update1.Designer.cs b/server/src/Migrations/20220320115601_Update1.Designer.cs deleted file mode 100644 index c7463fb..0000000 --- a/server/src/Migrations/20220320115601_Update1.Designer.cs +++ /dev/null @@ -1,342 +0,0 @@ -// <auto-generated /> - - -#nullable disable - -using System; -using IOL.GreatOffice.Api.Data; -using Microsoft.EntityFrameworkCore; -using Microsoft.EntityFrameworkCore.Infrastructure; -using Microsoft.EntityFrameworkCore.Migrations; -using Microsoft.EntityFrameworkCore.Storage.ValueConversion; -using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata; -namespace IOL.GreatOffice.Api.Migrations -{ - [DbContext(typeof(AppDbContext))] - [Migration("20220320115601_Update1")] - partial class Update1 - { - protected override void BuildTargetModel(ModelBuilder modelBuilder) - { -#pragma warning disable 612, 618 - modelBuilder - .HasAnnotation("ProductVersion", "6.0.3") - .HasAnnotation("Relational:MaxIdentifierLength", 63); - - NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder); - - modelBuilder.Entity("IOL.GreatOffice.Data.Database.ForgotPasswordRequest", b => - { - b.Property<Guid>("Id") - .ValueGeneratedOnAdd() - .HasColumnType("uuid") - .HasColumnName("id"); - - b.Property<DateTime>("CreatedAt") - .HasColumnType("timestamp with time zone") - .HasColumnName("created_at"); - - b.Property<Guid?>("UserId") - .HasColumnType("uuid") - .HasColumnName("user_id"); - - b.HasKey("Id") - .HasName("pk_forgot_password_requests"); - - b.HasIndex("UserId") - .HasDatabaseName("ix_forgot_password_requests_user_id"); - - b.ToTable("forgot_password_requests", (string)null); - }); - - modelBuilder.Entity("IOL.GreatOffice.Data.Database.GithubUserMapping", b => - { - b.Property<string>("GithubId") - .HasColumnType("text") - .HasColumnName("github_id"); - - b.Property<string>("Email") - .HasColumnType("text") - .HasColumnName("email"); - - b.Property<string>("RefreshToken") - .HasColumnType("text") - .HasColumnName("refresh_token"); - - b.Property<Guid?>("UserId") - .HasColumnType("uuid") - .HasColumnName("user_id"); - - b.HasKey("GithubId") - .HasName("pk_github_user_mappings"); - - b.HasIndex("UserId") - .HasDatabaseName("ix_github_user_mappings_user_id"); - - b.ToTable("github_user_mappings", (string)null); - }); - - modelBuilder.Entity("IOL.GreatOffice.Data.Database.TimeCategory", b => - { - b.Property<Guid>("Id") - .ValueGeneratedOnAdd() - .HasColumnType("uuid") - .HasColumnName("id"); - - b.Property<string>("Color") - .HasColumnType("text") - .HasColumnName("color"); - - b.Property<DateTime>("CreatedAt") - .HasColumnType("timestamp with time zone") - .HasColumnName("created_at"); - - b.Property<DateTime?>("ModifiedAt") - .HasColumnType("timestamp with time zone") - .HasColumnName("modified_at"); - - b.Property<string>("Name") - .HasColumnType("text") - .HasColumnName("name"); - - b.Property<Guid>("UserId") - .HasColumnType("uuid") - .HasColumnName("user_id"); - - b.HasKey("Id") - .HasName("pk_time_categories"); - - b.HasIndex("UserId") - .HasDatabaseName("ix_time_categories_user_id"); - - b.ToTable("time_categories", (string)null); - }); - - modelBuilder.Entity("IOL.GreatOffice.Data.Database.TimeEntry", b => - { - b.Property<Guid>("Id") - .ValueGeneratedOnAdd() - .HasColumnType("uuid") - .HasColumnName("id"); - - b.Property<Guid?>("CategoryId") - .HasColumnType("uuid") - .HasColumnName("category_id"); - - b.Property<DateTime>("CreatedAt") - .HasColumnType("timestamp with time zone") - .HasColumnName("created_at"); - - b.Property<string>("Description") - .HasColumnType("text") - .HasColumnName("description"); - - b.Property<DateTime?>("ModifiedAt") - .HasColumnType("timestamp with time zone") - .HasColumnName("modified_at"); - - b.Property<DateTime>("Start") - .HasColumnType("timestamp with time zone") - .HasColumnName("start"); - - b.Property<DateTime>("Stop") - .HasColumnType("timestamp with time zone") - .HasColumnName("stop"); - - b.Property<Guid>("UserId") - .HasColumnType("uuid") - .HasColumnName("user_id"); - - b.HasKey("Id") - .HasName("pk_time_entries"); - - b.HasIndex("CategoryId") - .HasDatabaseName("ix_time_entries_category_id"); - - b.HasIndex("UserId") - .HasDatabaseName("ix_time_entries_user_id"); - - b.ToTable("time_entries", (string)null); - }); - - modelBuilder.Entity("IOL.GreatOffice.Data.Database.TimeLabel", b => - { - b.Property<Guid>("Id") - .ValueGeneratedOnAdd() - .HasColumnType("uuid") - .HasColumnName("id"); - - b.Property<string>("Color") - .HasColumnType("text") - .HasColumnName("color"); - - b.Property<DateTime>("CreatedAt") - .HasColumnType("timestamp with time zone") - .HasColumnName("created_at"); - - b.Property<DateTime?>("ModifiedAt") - .HasColumnType("timestamp with time zone") - .HasColumnName("modified_at"); - - b.Property<string>("Name") - .HasColumnType("text") - .HasColumnName("name"); - - b.Property<Guid>("UserId") - .HasColumnType("uuid") - .HasColumnName("user_id"); - - b.HasKey("Id") - .HasName("pk_time_labels"); - - b.HasIndex("UserId") - .HasDatabaseName("ix_time_labels_user_id"); - - b.ToTable("time_labels", (string)null); - }); - - modelBuilder.Entity("IOL.GreatOffice.Data.Database.User", b => - { - b.Property<Guid>("Id") - .ValueGeneratedOnAdd() - .HasColumnType("uuid") - .HasColumnName("id"); - - b.Property<DateTime>("CreatedAt") - .HasColumnType("timestamp with time zone") - .HasColumnName("created_at"); - - b.Property<DateTime?>("ModifiedAt") - .HasColumnType("timestamp with time zone") - .HasColumnName("modified_at"); - - b.Property<string>("Username") - .HasColumnType("text") - .HasColumnName("username"); - - b.Property<string>("password") - .HasColumnType("text") - .HasColumnName("password"); - - b.HasKey("Id") - .HasName("pk_users"); - - b.ToTable("users", (string)null); - }); - - modelBuilder.Entity("TimeEntryTimeLabel", b => - { - b.Property<Guid>("EntriesId") - .HasColumnType("uuid") - .HasColumnName("entries_id"); - - b.Property<Guid>("LabelsId") - .HasColumnType("uuid") - .HasColumnName("labels_id"); - - b.HasKey("EntriesId", "LabelsId") - .HasName("pk_time_entry_time_label"); - - b.HasIndex("LabelsId") - .HasDatabaseName("ix_time_entry_time_label_labels_id"); - - b.ToTable("time_entry_time_label", (string)null); - }); - - modelBuilder.Entity("IOL.GreatOffice.Data.Database.ForgotPasswordRequest", b => - { - b.HasOne("IOL.GreatOffice.Data.Database.User", "User") - .WithMany() - .HasForeignKey("UserId") - .HasConstraintName("fk_forgot_password_requests_users_user_id"); - - b.Navigation("User"); - }); - - modelBuilder.Entity("IOL.GreatOffice.Data.Database.GithubUserMapping", b => - { - b.HasOne("IOL.GreatOffice.Data.Database.User", "User") - .WithMany() - .HasForeignKey("UserId") - .HasConstraintName("fk_github_user_mappings_users_user_id"); - - b.Navigation("User"); - }); - - modelBuilder.Entity("IOL.GreatOffice.Data.Database.TimeCategory", b => - { - b.HasOne("IOL.GreatOffice.Data.Database.User", "User") - .WithMany("Categories") - .HasForeignKey("UserId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired() - .HasConstraintName("fk_time_categories_users_user_id"); - - b.Navigation("User"); - }); - - modelBuilder.Entity("IOL.GreatOffice.Data.Database.TimeEntry", b => - { - b.HasOne("IOL.GreatOffice.Data.Database.TimeCategory", "Category") - .WithMany("Entries") - .HasForeignKey("CategoryId") - .HasConstraintName("fk_time_entries_time_categories_category_id"); - - b.HasOne("IOL.GreatOffice.Data.Database.User", "User") - .WithMany("Entries") - .HasForeignKey("UserId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired() - .HasConstraintName("fk_time_entries_users_user_id"); - - b.Navigation("Category"); - - b.Navigation("User"); - }); - - modelBuilder.Entity("IOL.GreatOffice.Data.Database.TimeLabel", b => - { - b.HasOne("IOL.GreatOffice.Data.Database.User", "User") - .WithMany("Labels") - .HasForeignKey("UserId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired() - .HasConstraintName("fk_time_labels_users_user_id"); - - b.Navigation("User"); - }); - - modelBuilder.Entity("TimeEntryTimeLabel", b => - { - b.HasOne("IOL.GreatOffice.Data.Database.TimeEntry", null) - .WithMany() - .HasForeignKey("EntriesId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired() - .HasConstraintName("fk_time_entry_time_label_time_entries_entries_id"); - - b.HasOne("IOL.GreatOffice.Data.Database.TimeLabel", null) - .WithMany() - .HasForeignKey("LabelsId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired() - .HasConstraintName("fk_time_entry_time_label_time_labels_labels_id"); - }); - - modelBuilder.Entity("IOL.GreatOffice.Data.Database.TimeCategory", b => - { - b.Navigation("Entries"); - }); - - modelBuilder.Entity("IOL.GreatOffice.Data.Database.User", b => - { - b.Navigation("Categories"); - - b.Navigation("Entries"); - - b.Navigation("Labels"); - }); -#pragma warning restore 612, 618 - } - } -} diff --git a/server/src/Migrations/20220320115601_Update1.cs b/server/src/Migrations/20220320115601_Update1.cs deleted file mode 100644 index 8b06fb7..0000000 --- a/server/src/Migrations/20220320115601_Update1.cs +++ /dev/null @@ -1,139 +0,0 @@ -using System; -using Microsoft.EntityFrameworkCore.Migrations; - -#nullable disable - -namespace IOL.GreatOffice.Api.Migrations -{ - public partial class Update1 : Migration - { - protected override void Up(MigrationBuilder migrationBuilder) - { - migrationBuilder.DropForeignKey( - name: "fk_time_categories_users_user_id", - table: "time_categories"); - - migrationBuilder.DropForeignKey( - name: "fk_time_entries_users_user_id", - table: "time_entries"); - - migrationBuilder.DropForeignKey( - name: "fk_time_labels_users_user_id", - table: "time_labels"); - - migrationBuilder.AlterColumn<Guid>( - name: "user_id", - table: "time_labels", - type: "uuid", - nullable: false, - defaultValue: new Guid("00000000-0000-0000-0000-000000000000"), - oldClrType: typeof(Guid), - oldType: "uuid", - oldNullable: true); - - migrationBuilder.AlterColumn<Guid>( - name: "user_id", - table: "time_entries", - type: "uuid", - nullable: false, - defaultValue: new Guid("00000000-0000-0000-0000-000000000000"), - oldClrType: typeof(Guid), - oldType: "uuid", - oldNullable: true); - - migrationBuilder.AlterColumn<Guid>( - name: "user_id", - table: "time_categories", - type: "uuid", - nullable: false, - defaultValue: new Guid("00000000-0000-0000-0000-000000000000"), - oldClrType: typeof(Guid), - oldType: "uuid", - oldNullable: true); - - migrationBuilder.AddForeignKey( - name: "fk_time_categories_users_user_id", - table: "time_categories", - column: "user_id", - principalTable: "users", - principalColumn: "id", - onDelete: ReferentialAction.Cascade); - - migrationBuilder.AddForeignKey( - name: "fk_time_entries_users_user_id", - table: "time_entries", - column: "user_id", - principalTable: "users", - principalColumn: "id", - onDelete: ReferentialAction.Cascade); - - migrationBuilder.AddForeignKey( - name: "fk_time_labels_users_user_id", - table: "time_labels", - column: "user_id", - principalTable: "users", - principalColumn: "id", - onDelete: ReferentialAction.Cascade); - } - - protected override void Down(MigrationBuilder migrationBuilder) - { - migrationBuilder.DropForeignKey( - name: "fk_time_categories_users_user_id", - table: "time_categories"); - - migrationBuilder.DropForeignKey( - name: "fk_time_entries_users_user_id", - table: "time_entries"); - - migrationBuilder.DropForeignKey( - name: "fk_time_labels_users_user_id", - table: "time_labels"); - - migrationBuilder.AlterColumn<Guid>( - name: "user_id", - table: "time_labels", - type: "uuid", - nullable: true, - oldClrType: typeof(Guid), - oldType: "uuid"); - - migrationBuilder.AlterColumn<Guid>( - name: "user_id", - table: "time_entries", - type: "uuid", - nullable: true, - oldClrType: typeof(Guid), - oldType: "uuid"); - - migrationBuilder.AlterColumn<Guid>( - name: "user_id", - table: "time_categories", - type: "uuid", - nullable: true, - oldClrType: typeof(Guid), - oldType: "uuid"); - - migrationBuilder.AddForeignKey( - name: "fk_time_categories_users_user_id", - table: "time_categories", - column: "user_id", - principalTable: "users", - principalColumn: "id"); - - migrationBuilder.AddForeignKey( - name: "fk_time_entries_users_user_id", - table: "time_entries", - column: "user_id", - principalTable: "users", - principalColumn: "id"); - - migrationBuilder.AddForeignKey( - name: "fk_time_labels_users_user_id", - table: "time_labels", - column: "user_id", - principalTable: "users", - principalColumn: "id"); - } - } -} diff --git a/server/src/Migrations/20220320132220_UpdatedForgotPasswordRequests.Designer.cs b/server/src/Migrations/20220320132220_UpdatedForgotPasswordRequests.Designer.cs deleted file mode 100644 index 3a18463..0000000 --- a/server/src/Migrations/20220320132220_UpdatedForgotPasswordRequests.Designer.cs +++ /dev/null @@ -1,344 +0,0 @@ -// <auto-generated /> - - -#nullable disable - -using System; -using IOL.GreatOffice.Api.Data; -using Microsoft.EntityFrameworkCore; -using Microsoft.EntityFrameworkCore.Infrastructure; -using Microsoft.EntityFrameworkCore.Migrations; -using Microsoft.EntityFrameworkCore.Storage.ValueConversion; -using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata; -namespace IOL.GreatOffice.Api.Migrations -{ - [DbContext(typeof(AppDbContext))] - [Migration("20220320132220_UpdatedForgotPasswordRequests")] - partial class UpdatedForgotPasswordRequests - { - protected override void BuildTargetModel(ModelBuilder modelBuilder) - { -#pragma warning disable 612, 618 - modelBuilder - .HasAnnotation("ProductVersion", "6.0.3") - .HasAnnotation("Relational:MaxIdentifierLength", 63); - - NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder); - - modelBuilder.Entity("IOL.GreatOffice.Data.Database.ForgotPasswordRequest", b => - { - b.Property<Guid>("Id") - .ValueGeneratedOnAdd() - .HasColumnType("uuid") - .HasColumnName("id"); - - b.Property<DateTime>("CreatedAt") - .HasColumnType("timestamp with time zone") - .HasColumnName("created_at"); - - b.Property<Guid>("UserId") - .HasColumnType("uuid") - .HasColumnName("user_id"); - - b.HasKey("Id") - .HasName("pk_forgot_password_requests"); - - b.HasIndex("UserId") - .HasDatabaseName("ix_forgot_password_requests_user_id"); - - b.ToTable("forgot_password_requests", (string)null); - }); - - modelBuilder.Entity("IOL.GreatOffice.Data.Database.GithubUserMapping", b => - { - b.Property<string>("GithubId") - .HasColumnType("text") - .HasColumnName("github_id"); - - b.Property<string>("Email") - .HasColumnType("text") - .HasColumnName("email"); - - b.Property<string>("RefreshToken") - .HasColumnType("text") - .HasColumnName("refresh_token"); - - b.Property<Guid?>("UserId") - .HasColumnType("uuid") - .HasColumnName("user_id"); - - b.HasKey("GithubId") - .HasName("pk_github_user_mappings"); - - b.HasIndex("UserId") - .HasDatabaseName("ix_github_user_mappings_user_id"); - - b.ToTable("github_user_mappings", (string)null); - }); - - modelBuilder.Entity("IOL.GreatOffice.Data.Database.TimeCategory", b => - { - b.Property<Guid>("Id") - .ValueGeneratedOnAdd() - .HasColumnType("uuid") - .HasColumnName("id"); - - b.Property<string>("Color") - .HasColumnType("text") - .HasColumnName("color"); - - b.Property<DateTime>("CreatedAt") - .HasColumnType("timestamp with time zone") - .HasColumnName("created_at"); - - b.Property<DateTime?>("ModifiedAt") - .HasColumnType("timestamp with time zone") - .HasColumnName("modified_at"); - - b.Property<string>("Name") - .HasColumnType("text") - .HasColumnName("name"); - - b.Property<Guid>("UserId") - .HasColumnType("uuid") - .HasColumnName("user_id"); - - b.HasKey("Id") - .HasName("pk_time_categories"); - - b.HasIndex("UserId") - .HasDatabaseName("ix_time_categories_user_id"); - - b.ToTable("time_categories", (string)null); - }); - - modelBuilder.Entity("IOL.GreatOffice.Data.Database.TimeEntry", b => - { - b.Property<Guid>("Id") - .ValueGeneratedOnAdd() - .HasColumnType("uuid") - .HasColumnName("id"); - - b.Property<Guid?>("CategoryId") - .HasColumnType("uuid") - .HasColumnName("category_id"); - - b.Property<DateTime>("CreatedAt") - .HasColumnType("timestamp with time zone") - .HasColumnName("created_at"); - - b.Property<string>("Description") - .HasColumnType("text") - .HasColumnName("description"); - - b.Property<DateTime?>("ModifiedAt") - .HasColumnType("timestamp with time zone") - .HasColumnName("modified_at"); - - b.Property<DateTime>("Start") - .HasColumnType("timestamp with time zone") - .HasColumnName("start"); - - b.Property<DateTime>("Stop") - .HasColumnType("timestamp with time zone") - .HasColumnName("stop"); - - b.Property<Guid>("UserId") - .HasColumnType("uuid") - .HasColumnName("user_id"); - - b.HasKey("Id") - .HasName("pk_time_entries"); - - b.HasIndex("CategoryId") - .HasDatabaseName("ix_time_entries_category_id"); - - b.HasIndex("UserId") - .HasDatabaseName("ix_time_entries_user_id"); - - b.ToTable("time_entries", (string)null); - }); - - modelBuilder.Entity("IOL.GreatOffice.Data.Database.TimeLabel", b => - { - b.Property<Guid>("Id") - .ValueGeneratedOnAdd() - .HasColumnType("uuid") - .HasColumnName("id"); - - b.Property<string>("Color") - .HasColumnType("text") - .HasColumnName("color"); - - b.Property<DateTime>("CreatedAt") - .HasColumnType("timestamp with time zone") - .HasColumnName("created_at"); - - b.Property<DateTime?>("ModifiedAt") - .HasColumnType("timestamp with time zone") - .HasColumnName("modified_at"); - - b.Property<string>("Name") - .HasColumnType("text") - .HasColumnName("name"); - - b.Property<Guid>("UserId") - .HasColumnType("uuid") - .HasColumnName("user_id"); - - b.HasKey("Id") - .HasName("pk_time_labels"); - - b.HasIndex("UserId") - .HasDatabaseName("ix_time_labels_user_id"); - - b.ToTable("time_labels", (string)null); - }); - - modelBuilder.Entity("IOL.GreatOffice.Data.Database.User", b => - { - b.Property<Guid>("Id") - .ValueGeneratedOnAdd() - .HasColumnType("uuid") - .HasColumnName("id"); - - b.Property<DateTime>("CreatedAt") - .HasColumnType("timestamp with time zone") - .HasColumnName("created_at"); - - b.Property<DateTime?>("ModifiedAt") - .HasColumnType("timestamp with time zone") - .HasColumnName("modified_at"); - - b.Property<string>("Password") - .HasColumnType("text") - .HasColumnName("password"); - - b.Property<string>("Username") - .HasColumnType("text") - .HasColumnName("username"); - - b.HasKey("Id") - .HasName("pk_users"); - - b.ToTable("users", (string)null); - }); - - modelBuilder.Entity("TimeEntryTimeLabel", b => - { - b.Property<Guid>("EntriesId") - .HasColumnType("uuid") - .HasColumnName("entries_id"); - - b.Property<Guid>("LabelsId") - .HasColumnType("uuid") - .HasColumnName("labels_id"); - - b.HasKey("EntriesId", "LabelsId") - .HasName("pk_time_entry_time_label"); - - b.HasIndex("LabelsId") - .HasDatabaseName("ix_time_entry_time_label_labels_id"); - - b.ToTable("time_entry_time_label", (string)null); - }); - - modelBuilder.Entity("IOL.GreatOffice.Data.Database.ForgotPasswordRequest", b => - { - b.HasOne("IOL.GreatOffice.Data.Database.User", "User") - .WithMany() - .HasForeignKey("UserId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired() - .HasConstraintName("fk_forgot_password_requests_users_user_id"); - - b.Navigation("User"); - }); - - modelBuilder.Entity("IOL.GreatOffice.Data.Database.GithubUserMapping", b => - { - b.HasOne("IOL.GreatOffice.Data.Database.User", "User") - .WithMany() - .HasForeignKey("UserId") - .HasConstraintName("fk_github_user_mappings_users_user_id"); - - b.Navigation("User"); - }); - - modelBuilder.Entity("IOL.GreatOffice.Data.Database.TimeCategory", b => - { - b.HasOne("IOL.GreatOffice.Data.Database.User", "User") - .WithMany("Categories") - .HasForeignKey("UserId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired() - .HasConstraintName("fk_time_categories_users_user_id"); - - b.Navigation("User"); - }); - - modelBuilder.Entity("IOL.GreatOffice.Data.Database.TimeEntry", b => - { - b.HasOne("IOL.GreatOffice.Data.Database.TimeCategory", "Category") - .WithMany("Entries") - .HasForeignKey("CategoryId") - .HasConstraintName("fk_time_entries_time_categories_category_id"); - - b.HasOne("IOL.GreatOffice.Data.Database.User", "User") - .WithMany("Entries") - .HasForeignKey("UserId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired() - .HasConstraintName("fk_time_entries_users_user_id"); - - b.Navigation("Category"); - - b.Navigation("User"); - }); - - modelBuilder.Entity("IOL.GreatOffice.Data.Database.TimeLabel", b => - { - b.HasOne("IOL.GreatOffice.Data.Database.User", "User") - .WithMany("Labels") - .HasForeignKey("UserId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired() - .HasConstraintName("fk_time_labels_users_user_id"); - - b.Navigation("User"); - }); - - modelBuilder.Entity("TimeEntryTimeLabel", b => - { - b.HasOne("IOL.GreatOffice.Data.Database.TimeEntry", null) - .WithMany() - .HasForeignKey("EntriesId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired() - .HasConstraintName("fk_time_entry_time_label_time_entries_entries_id"); - - b.HasOne("IOL.GreatOffice.Data.Database.TimeLabel", null) - .WithMany() - .HasForeignKey("LabelsId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired() - .HasConstraintName("fk_time_entry_time_label_time_labels_labels_id"); - }); - - modelBuilder.Entity("IOL.GreatOffice.Data.Database.TimeCategory", b => - { - b.Navigation("Entries"); - }); - - modelBuilder.Entity("IOL.GreatOffice.Data.Database.User", b => - { - b.Navigation("Categories"); - - b.Navigation("Entries"); - - b.Navigation("Labels"); - }); -#pragma warning restore 612, 618 - } - } -} diff --git a/server/src/Migrations/20220320132220_UpdatedForgotPasswordRequests.cs b/server/src/Migrations/20220320132220_UpdatedForgotPasswordRequests.cs deleted file mode 100644 index df7a195..0000000 --- a/server/src/Migrations/20220320132220_UpdatedForgotPasswordRequests.cs +++ /dev/null @@ -1,57 +0,0 @@ -using System; -using Microsoft.EntityFrameworkCore.Migrations; - -#nullable disable - -namespace IOL.GreatOffice.Api.Migrations -{ - public partial class UpdatedForgotPasswordRequests : Migration - { - protected override void Up(MigrationBuilder migrationBuilder) - { - migrationBuilder.DropForeignKey( - name: "fk_forgot_password_requests_users_user_id", - table: "forgot_password_requests"); - - migrationBuilder.AlterColumn<Guid>( - name: "user_id", - table: "forgot_password_requests", - type: "uuid", - nullable: false, - defaultValue: new Guid("00000000-0000-0000-0000-000000000000"), - oldClrType: typeof(Guid), - oldType: "uuid", - oldNullable: true); - - migrationBuilder.AddForeignKey( - name: "fk_forgot_password_requests_users_user_id", - table: "forgot_password_requests", - column: "user_id", - principalTable: "users", - principalColumn: "id", - onDelete: ReferentialAction.Cascade); - } - - protected override void Down(MigrationBuilder migrationBuilder) - { - migrationBuilder.DropForeignKey( - name: "fk_forgot_password_requests_users_user_id", - table: "forgot_password_requests"); - - migrationBuilder.AlterColumn<Guid>( - name: "user_id", - table: "forgot_password_requests", - type: "uuid", - nullable: true, - oldClrType: typeof(Guid), - oldType: "uuid"); - - migrationBuilder.AddForeignKey( - name: "fk_forgot_password_requests_users_user_id", - table: "forgot_password_requests", - column: "user_id", - principalTable: "users", - principalColumn: "id"); - } - } -} diff --git a/server/src/Migrations/20220529190359_ApiAccessTokens.Designer.cs b/server/src/Migrations/20220529190359_ApiAccessTokens.Designer.cs deleted file mode 100644 index 74f9b40..0000000 --- a/server/src/Migrations/20220529190359_ApiAccessTokens.Designer.cs +++ /dev/null @@ -1,401 +0,0 @@ -// <auto-generated /> -using System; -using IOL.GreatOffice.Api.Data; -using Microsoft.EntityFrameworkCore; -using Microsoft.EntityFrameworkCore.Infrastructure; -using Microsoft.EntityFrameworkCore.Migrations; -using Microsoft.EntityFrameworkCore.Storage.ValueConversion; -using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata; - -#nullable disable - -namespace IOL.GreatOffice.Api.Migrations -{ - [DbContext(typeof(AppDbContext))] - [Migration("20220529190359_ApiAccessTokens")] - partial class ApiAccessTokens - { - protected override void BuildTargetModel(ModelBuilder modelBuilder) - { -#pragma warning disable 612, 618 - modelBuilder - .HasAnnotation("ProductVersion", "6.0.5") - .HasAnnotation("Relational:MaxIdentifierLength", 63); - - NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder); - - modelBuilder.Entity("IOL.GreatOffice.Api.Data.Database.ApiAccessToken", b => - { - b.Property<Guid>("Id") - .ValueGeneratedOnAdd() - .HasColumnType("uuid") - .HasColumnName("id"); - - b.Property<bool>("AllowCreate") - .HasColumnType("boolean") - .HasColumnName("allow_create"); - - b.Property<bool>("AllowDelete") - .HasColumnType("boolean") - .HasColumnName("allow_delete"); - - b.Property<bool>("AllowRead") - .HasColumnType("boolean") - .HasColumnName("allow_read"); - - b.Property<bool>("AllowUpdate") - .HasColumnType("boolean") - .HasColumnName("allow_update"); - - b.Property<DateTime>("CreatedAt") - .HasColumnType("timestamp with time zone") - .HasColumnName("created_at"); - - b.Property<DateTime>("ExpiryDate") - .HasColumnType("timestamp with time zone") - .HasColumnName("expiry_date"); - - b.Property<DateTime?>("ModifiedAt") - .HasColumnType("timestamp with time zone") - .HasColumnName("modified_at"); - - b.Property<Guid?>("UserId") - .HasColumnType("uuid") - .HasColumnName("user_id"); - - b.HasKey("Id") - .HasName("pk_api_access_tokens"); - - b.HasIndex("UserId") - .HasDatabaseName("ix_api_access_tokens_user_id"); - - b.ToTable("api_access_tokens", (string)null); - }); - - modelBuilder.Entity("IOL.GreatOffice.Api.Data.Database.ForgotPasswordRequest", b => - { - b.Property<Guid>("Id") - .ValueGeneratedOnAdd() - .HasColumnType("uuid") - .HasColumnName("id"); - - b.Property<DateTime>("CreatedAt") - .HasColumnType("timestamp with time zone") - .HasColumnName("created_at"); - - b.Property<Guid>("UserId") - .HasColumnType("uuid") - .HasColumnName("user_id"); - - b.HasKey("Id") - .HasName("pk_forgot_password_requests"); - - b.HasIndex("UserId") - .HasDatabaseName("ix_forgot_password_requests_user_id"); - - b.ToTable("forgot_password_requests", (string)null); - }); - - modelBuilder.Entity("IOL.GreatOffice.Api.Data.Database.GithubUserMapping", b => - { - b.Property<string>("GithubId") - .HasColumnType("text") - .HasColumnName("github_id"); - - b.Property<string>("Email") - .HasColumnType("text") - .HasColumnName("email"); - - b.Property<string>("RefreshToken") - .HasColumnType("text") - .HasColumnName("refresh_token"); - - b.Property<Guid?>("UserId") - .HasColumnType("uuid") - .HasColumnName("user_id"); - - b.HasKey("GithubId") - .HasName("pk_github_user_mappings"); - - b.HasIndex("UserId") - .HasDatabaseName("ix_github_user_mappings_user_id"); - - b.ToTable("github_user_mappings", (string)null); - }); - - modelBuilder.Entity("IOL.GreatOffice.Api.Data.Database.TimeCategory", b => - { - b.Property<Guid>("Id") - .ValueGeneratedOnAdd() - .HasColumnType("uuid") - .HasColumnName("id"); - - b.Property<string>("Color") - .HasColumnType("text") - .HasColumnName("color"); - - b.Property<DateTime>("CreatedAt") - .HasColumnType("timestamp with time zone") - .HasColumnName("created_at"); - - b.Property<DateTime?>("ModifiedAt") - .HasColumnType("timestamp with time zone") - .HasColumnName("modified_at"); - - b.Property<string>("Name") - .HasColumnType("text") - .HasColumnName("name"); - - b.Property<Guid>("UserId") - .HasColumnType("uuid") - .HasColumnName("user_id"); - - b.HasKey("Id") - .HasName("pk_time_categories"); - - b.HasIndex("UserId") - .HasDatabaseName("ix_time_categories_user_id"); - - b.ToTable("time_categories", (string)null); - }); - - modelBuilder.Entity("IOL.GreatOffice.Api.Data.Database.TimeEntry", b => - { - b.Property<Guid>("Id") - .ValueGeneratedOnAdd() - .HasColumnType("uuid") - .HasColumnName("id"); - - b.Property<Guid?>("CategoryId") - .HasColumnType("uuid") - .HasColumnName("category_id"); - - b.Property<DateTime>("CreatedAt") - .HasColumnType("timestamp with time zone") - .HasColumnName("created_at"); - - b.Property<string>("Description") - .HasColumnType("text") - .HasColumnName("description"); - - b.Property<DateTime?>("ModifiedAt") - .HasColumnType("timestamp with time zone") - .HasColumnName("modified_at"); - - b.Property<DateTime>("Start") - .HasColumnType("timestamp with time zone") - .HasColumnName("start"); - - b.Property<DateTime>("Stop") - .HasColumnType("timestamp with time zone") - .HasColumnName("stop"); - - b.Property<Guid>("UserId") - .HasColumnType("uuid") - .HasColumnName("user_id"); - - b.HasKey("Id") - .HasName("pk_time_entries"); - - b.HasIndex("CategoryId") - .HasDatabaseName("ix_time_entries_category_id"); - - b.HasIndex("UserId") - .HasDatabaseName("ix_time_entries_user_id"); - - b.ToTable("time_entries", (string)null); - }); - - modelBuilder.Entity("IOL.GreatOffice.Api.Data.Database.TimeLabel", b => - { - b.Property<Guid>("Id") - .ValueGeneratedOnAdd() - .HasColumnType("uuid") - .HasColumnName("id"); - - b.Property<string>("Color") - .HasColumnType("text") - .HasColumnName("color"); - - b.Property<DateTime>("CreatedAt") - .HasColumnType("timestamp with time zone") - .HasColumnName("created_at"); - - b.Property<DateTime?>("ModifiedAt") - .HasColumnType("timestamp with time zone") - .HasColumnName("modified_at"); - - b.Property<string>("Name") - .HasColumnType("text") - .HasColumnName("name"); - - b.Property<Guid>("UserId") - .HasColumnType("uuid") - .HasColumnName("user_id"); - - b.HasKey("Id") - .HasName("pk_time_labels"); - - b.HasIndex("UserId") - .HasDatabaseName("ix_time_labels_user_id"); - - b.ToTable("time_labels", (string)null); - }); - - modelBuilder.Entity("IOL.GreatOffice.Api.Data.Database.User", b => - { - b.Property<Guid>("Id") - .ValueGeneratedOnAdd() - .HasColumnType("uuid") - .HasColumnName("id"); - - b.Property<DateTime>("CreatedAt") - .HasColumnType("timestamp with time zone") - .HasColumnName("created_at"); - - b.Property<DateTime?>("ModifiedAt") - .HasColumnType("timestamp with time zone") - .HasColumnName("modified_at"); - - b.Property<string>("Password") - .HasColumnType("text") - .HasColumnName("password"); - - b.Property<string>("Username") - .HasColumnType("text") - .HasColumnName("username"); - - b.HasKey("Id") - .HasName("pk_users"); - - b.ToTable("users", (string)null); - }); - - modelBuilder.Entity("TimeEntryTimeLabel", b => - { - b.Property<Guid>("EntriesId") - .HasColumnType("uuid") - .HasColumnName("entries_id"); - - b.Property<Guid>("LabelsId") - .HasColumnType("uuid") - .HasColumnName("labels_id"); - - b.HasKey("EntriesId", "LabelsId") - .HasName("pk_time_entry_time_label"); - - b.HasIndex("LabelsId") - .HasDatabaseName("ix_time_entry_time_label_labels_id"); - - b.ToTable("time_entry_time_label", (string)null); - }); - - modelBuilder.Entity("IOL.GreatOffice.Api.Data.Database.ApiAccessToken", b => - { - b.HasOne("IOL.GreatOffice.Api.Data.Database.User", "User") - .WithMany() - .HasForeignKey("UserId") - .HasConstraintName("fk_api_access_tokens_users_user_id"); - - b.Navigation("User"); - }); - - modelBuilder.Entity("IOL.GreatOffice.Api.Data.Database.ForgotPasswordRequest", b => - { - b.HasOne("IOL.GreatOffice.Api.Data.Database.User", "User") - .WithMany() - .HasForeignKey("UserId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired() - .HasConstraintName("fk_forgot_password_requests_users_user_id"); - - b.Navigation("User"); - }); - - modelBuilder.Entity("IOL.GreatOffice.Api.Data.Database.GithubUserMapping", b => - { - b.HasOne("IOL.GreatOffice.Api.Data.Database.User", "User") - .WithMany() - .HasForeignKey("UserId") - .HasConstraintName("fk_github_user_mappings_users_user_id"); - - b.Navigation("User"); - }); - - modelBuilder.Entity("IOL.GreatOffice.Api.Data.Database.TimeCategory", b => - { - b.HasOne("IOL.GreatOffice.Api.Data.Database.User", "User") - .WithMany("Categories") - .HasForeignKey("UserId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired() - .HasConstraintName("fk_time_categories_users_user_id"); - - b.Navigation("User"); - }); - - modelBuilder.Entity("IOL.GreatOffice.Api.Data.Database.TimeEntry", b => - { - b.HasOne("IOL.GreatOffice.Api.Data.Database.TimeCategory", "Category") - .WithMany("Entries") - .HasForeignKey("CategoryId") - .HasConstraintName("fk_time_entries_time_categories_category_id"); - - b.HasOne("IOL.GreatOffice.Api.Data.Database.User", "User") - .WithMany("Entries") - .HasForeignKey("UserId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired() - .HasConstraintName("fk_time_entries_users_user_id"); - - b.Navigation("Category"); - - b.Navigation("User"); - }); - - modelBuilder.Entity("IOL.GreatOffice.Api.Data.Database.TimeLabel", b => - { - b.HasOne("IOL.GreatOffice.Api.Data.Database.User", "User") - .WithMany("Labels") - .HasForeignKey("UserId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired() - .HasConstraintName("fk_time_labels_users_user_id"); - - b.Navigation("User"); - }); - - modelBuilder.Entity("TimeEntryTimeLabel", b => - { - b.HasOne("IOL.GreatOffice.Api.Data.Database.TimeEntry", null) - .WithMany() - .HasForeignKey("EntriesId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired() - .HasConstraintName("fk_time_entry_time_label_time_entries_entries_id"); - - b.HasOne("IOL.GreatOffice.Api.Data.Database.TimeLabel", null) - .WithMany() - .HasForeignKey("LabelsId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired() - .HasConstraintName("fk_time_entry_time_label_time_labels_labels_id"); - }); - - modelBuilder.Entity("IOL.GreatOffice.Api.Data.Database.TimeCategory", b => - { - b.Navigation("Entries"); - }); - - modelBuilder.Entity("IOL.GreatOffice.Api.Data.Database.User", b => - { - b.Navigation("Categories"); - - b.Navigation("Entries"); - - b.Navigation("Labels"); - }); -#pragma warning restore 612, 618 - } - } -} diff --git a/server/src/Migrations/20220529190359_ApiAccessTokens.cs b/server/src/Migrations/20220529190359_ApiAccessTokens.cs deleted file mode 100644 index dc44bee..0000000 --- a/server/src/Migrations/20220529190359_ApiAccessTokens.cs +++ /dev/null @@ -1,48 +0,0 @@ -using System; -using Microsoft.EntityFrameworkCore.Migrations; - -#nullable disable - -namespace IOL.GreatOffice.Api.Migrations -{ - public partial class ApiAccessTokens : Migration - { - protected override void Up(MigrationBuilder migrationBuilder) - { - migrationBuilder.CreateTable( - name: "api_access_tokens", - columns: table => new - { - id = table.Column<Guid>(type: "uuid", nullable: false), - user_id = table.Column<Guid>(type: "uuid", nullable: true), - expiry_date = table.Column<DateTime>(type: "timestamp with time zone", nullable: false), - allow_read = table.Column<bool>(type: "boolean", nullable: false), - allow_create = table.Column<bool>(type: "boolean", nullable: false), - allow_update = table.Column<bool>(type: "boolean", nullable: false), - allow_delete = table.Column<bool>(type: "boolean", nullable: false), - created_at = table.Column<DateTime>(type: "timestamp with time zone", nullable: false), - modified_at = table.Column<DateTime>(type: "timestamp with time zone", nullable: true) - }, - constraints: table => - { - table.PrimaryKey("pk_api_access_tokens", x => x.id); - table.ForeignKey( - name: "fk_api_access_tokens_users_user_id", - column: x => x.user_id, - principalTable: "users", - principalColumn: "id"); - }); - - migrationBuilder.CreateIndex( - name: "ix_api_access_tokens_user_id", - table: "api_access_tokens", - column: "user_id"); - } - - protected override void Down(MigrationBuilder migrationBuilder) - { - migrationBuilder.DropTable( - name: "api_access_tokens"); - } - } -} diff --git a/server/src/Migrations/20220530174741_Tenants.Designer.cs b/server/src/Migrations/20220530174741_Tenants.Designer.cs deleted file mode 100644 index 678c52d..0000000 --- a/server/src/Migrations/20220530174741_Tenants.Designer.cs +++ /dev/null @@ -1,710 +0,0 @@ -// <auto-generated /> -using System; -using IOL.GreatOffice.Api.Data; -using Microsoft.EntityFrameworkCore; -using Microsoft.EntityFrameworkCore.Infrastructure; -using Microsoft.EntityFrameworkCore.Migrations; -using Microsoft.EntityFrameworkCore.Storage.ValueConversion; -using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata; - -#nullable disable - -namespace IOL.GreatOffice.Api.Migrations -{ - [DbContext(typeof(AppDbContext))] - [Migration("20220530174741_Tenants")] - partial class Tenants - { - protected override void BuildTargetModel(ModelBuilder modelBuilder) - { -#pragma warning disable 612, 618 - modelBuilder - .HasAnnotation("ProductVersion", "6.0.5") - .HasAnnotation("Relational:MaxIdentifierLength", 63); - - NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder); - - modelBuilder.Entity("IOL.GreatOffice.Api.Data.Database.ApiAccessToken", b => - { - b.Property<Guid>("Id") - .ValueGeneratedOnAdd() - .HasColumnType("uuid") - .HasColumnName("id"); - - b.Property<bool>("AllowCreate") - .HasColumnType("boolean") - .HasColumnName("allow_create"); - - b.Property<bool>("AllowDelete") - .HasColumnType("boolean") - .HasColumnName("allow_delete"); - - b.Property<bool>("AllowRead") - .HasColumnType("boolean") - .HasColumnName("allow_read"); - - b.Property<bool>("AllowUpdate") - .HasColumnType("boolean") - .HasColumnName("allow_update"); - - b.Property<DateTime>("CreatedAt") - .HasColumnType("timestamp with time zone") - .HasColumnName("created_at"); - - b.Property<DateTime>("ExpiryDate") - .HasColumnType("timestamp with time zone") - .HasColumnName("expiry_date"); - - b.Property<DateTime?>("ModifiedAt") - .HasColumnType("timestamp with time zone") - .HasColumnName("modified_at"); - - b.Property<Guid?>("UserId") - .HasColumnType("uuid") - .HasColumnName("user_id"); - - b.HasKey("Id") - .HasName("pk_api_access_tokens"); - - b.HasIndex("UserId") - .HasDatabaseName("ix_api_access_tokens_user_id"); - - b.ToTable("api_access_tokens", (string)null); - }); - - modelBuilder.Entity("IOL.GreatOffice.Api.Data.Database.ForgotPasswordRequest", b => - { - b.Property<Guid>("Id") - .ValueGeneratedOnAdd() - .HasColumnType("uuid") - .HasColumnName("id"); - - b.Property<DateTime>("CreatedAt") - .HasColumnType("timestamp with time zone") - .HasColumnName("created_at"); - - b.Property<Guid>("UserId") - .HasColumnType("uuid") - .HasColumnName("user_id"); - - b.HasKey("Id") - .HasName("pk_forgot_password_requests"); - - b.HasIndex("UserId") - .HasDatabaseName("ix_forgot_password_requests_user_id"); - - b.ToTable("forgot_password_requests", (string)null); - }); - - modelBuilder.Entity("IOL.GreatOffice.Api.Data.Database.GithubUserMapping", b => - { - b.Property<string>("GithubId") - .HasColumnType("text") - .HasColumnName("github_id"); - - b.Property<string>("Email") - .HasColumnType("text") - .HasColumnName("email"); - - b.Property<string>("RefreshToken") - .HasColumnType("text") - .HasColumnName("refresh_token"); - - b.Property<Guid?>("UserId") - .HasColumnType("uuid") - .HasColumnName("user_id"); - - b.HasKey("GithubId") - .HasName("pk_github_user_mappings"); - - b.HasIndex("UserId") - .HasDatabaseName("ix_github_user_mappings_user_id"); - - b.ToTable("github_user_mappings", (string)null); - }); - - modelBuilder.Entity("IOL.GreatOffice.Api.Data.Database.Tenant", b => - { - b.Property<Guid>("Id") - .ValueGeneratedOnAdd() - .HasColumnType("uuid") - .HasColumnName("id"); - - b.Property<string>("ContactEmail") - .HasColumnType("text") - .HasColumnName("contact_email"); - - b.Property<DateTime>("CreatedAt") - .HasColumnType("timestamp with time zone") - .HasColumnName("created_at"); - - b.Property<Guid>("CreatedById") - .HasColumnType("uuid") - .HasColumnName("created_by_id"); - - b.Property<Guid>("DeletedById") - .HasColumnType("uuid") - .HasColumnName("deleted_by_id"); - - b.Property<string>("Description") - .HasColumnType("text") - .HasColumnName("description"); - - b.Property<Guid>("MasterUserId") - .HasColumnType("uuid") - .HasColumnName("master_user_id"); - - b.Property<string>("MasterUserPassword") - .HasColumnType("text") - .HasColumnName("master_user_password"); - - b.Property<DateTime?>("ModifiedAt") - .HasColumnType("timestamp with time zone") - .HasColumnName("modified_at"); - - b.Property<Guid>("ModifiedById") - .HasColumnType("uuid") - .HasColumnName("modified_by_id"); - - b.Property<string>("Name") - .HasColumnType("text") - .HasColumnName("name"); - - b.Property<Guid>("TenantId") - .HasColumnType("uuid") - .HasColumnName("tenant_id"); - - b.Property<Guid?>("TenantId1") - .HasColumnType("uuid") - .HasColumnName("tenant_id1"); - - b.Property<Guid>("UserId") - .HasColumnType("uuid") - .HasColumnName("user_id"); - - b.HasKey("Id") - .HasName("pk_tenants"); - - b.HasIndex("CreatedById") - .HasDatabaseName("ix_tenants_created_by_id"); - - b.HasIndex("DeletedById") - .HasDatabaseName("ix_tenants_deleted_by_id"); - - b.HasIndex("ModifiedById") - .HasDatabaseName("ix_tenants_modified_by_id"); - - b.HasIndex("TenantId1") - .HasDatabaseName("ix_tenants_tenant_id1"); - - b.HasIndex("UserId") - .HasDatabaseName("ix_tenants_user_id"); - - b.ToTable("tenants", (string)null); - }); - - modelBuilder.Entity("IOL.GreatOffice.Api.Data.Database.TimeCategory", b => - { - b.Property<Guid>("Id") - .ValueGeneratedOnAdd() - .HasColumnType("uuid") - .HasColumnName("id"); - - b.Property<string>("Color") - .HasColumnType("text") - .HasColumnName("color"); - - b.Property<DateTime>("CreatedAt") - .HasColumnType("timestamp with time zone") - .HasColumnName("created_at"); - - b.Property<Guid>("CreatedById") - .HasColumnType("uuid") - .HasColumnName("created_by_id"); - - b.Property<Guid>("DeletedById") - .HasColumnType("uuid") - .HasColumnName("deleted_by_id"); - - b.Property<DateTime?>("ModifiedAt") - .HasColumnType("timestamp with time zone") - .HasColumnName("modified_at"); - - b.Property<Guid>("ModifiedById") - .HasColumnType("uuid") - .HasColumnName("modified_by_id"); - - b.Property<string>("Name") - .HasColumnType("text") - .HasColumnName("name"); - - b.Property<Guid>("TenantId") - .HasColumnType("uuid") - .HasColumnName("tenant_id"); - - b.Property<Guid>("UserId") - .HasColumnType("uuid") - .HasColumnName("user_id"); - - b.HasKey("Id") - .HasName("pk_time_categories"); - - b.HasIndex("CreatedById") - .HasDatabaseName("ix_time_categories_created_by_id"); - - b.HasIndex("DeletedById") - .HasDatabaseName("ix_time_categories_deleted_by_id"); - - b.HasIndex("ModifiedById") - .HasDatabaseName("ix_time_categories_modified_by_id"); - - b.HasIndex("TenantId") - .HasDatabaseName("ix_time_categories_tenant_id"); - - b.HasIndex("UserId") - .HasDatabaseName("ix_time_categories_user_id"); - - b.ToTable("time_categories", (string)null); - }); - - modelBuilder.Entity("IOL.GreatOffice.Api.Data.Database.TimeEntry", b => - { - b.Property<Guid>("Id") - .ValueGeneratedOnAdd() - .HasColumnType("uuid") - .HasColumnName("id"); - - b.Property<Guid?>("CategoryId") - .HasColumnType("uuid") - .HasColumnName("category_id"); - - b.Property<DateTime>("CreatedAt") - .HasColumnType("timestamp with time zone") - .HasColumnName("created_at"); - - b.Property<Guid>("CreatedById") - .HasColumnType("uuid") - .HasColumnName("created_by_id"); - - b.Property<Guid>("DeletedById") - .HasColumnType("uuid") - .HasColumnName("deleted_by_id"); - - b.Property<string>("Description") - .HasColumnType("text") - .HasColumnName("description"); - - b.Property<DateTime?>("ModifiedAt") - .HasColumnType("timestamp with time zone") - .HasColumnName("modified_at"); - - b.Property<Guid>("ModifiedById") - .HasColumnType("uuid") - .HasColumnName("modified_by_id"); - - b.Property<DateTime>("Start") - .HasColumnType("timestamp with time zone") - .HasColumnName("start"); - - b.Property<DateTime>("Stop") - .HasColumnType("timestamp with time zone") - .HasColumnName("stop"); - - b.Property<Guid>("TenantId") - .HasColumnType("uuid") - .HasColumnName("tenant_id"); - - b.Property<Guid>("UserId") - .HasColumnType("uuid") - .HasColumnName("user_id"); - - b.HasKey("Id") - .HasName("pk_time_entries"); - - b.HasIndex("CategoryId") - .HasDatabaseName("ix_time_entries_category_id"); - - b.HasIndex("CreatedById") - .HasDatabaseName("ix_time_entries_created_by_id"); - - b.HasIndex("DeletedById") - .HasDatabaseName("ix_time_entries_deleted_by_id"); - - b.HasIndex("ModifiedById") - .HasDatabaseName("ix_time_entries_modified_by_id"); - - b.HasIndex("TenantId") - .HasDatabaseName("ix_time_entries_tenant_id"); - - b.HasIndex("UserId") - .HasDatabaseName("ix_time_entries_user_id"); - - b.ToTable("time_entries", (string)null); - }); - - modelBuilder.Entity("IOL.GreatOffice.Api.Data.Database.TimeLabel", b => - { - b.Property<Guid>("Id") - .ValueGeneratedOnAdd() - .HasColumnType("uuid") - .HasColumnName("id"); - - b.Property<string>("Color") - .HasColumnType("text") - .HasColumnName("color"); - - b.Property<DateTime>("CreatedAt") - .HasColumnType("timestamp with time zone") - .HasColumnName("created_at"); - - b.Property<Guid>("CreatedById") - .HasColumnType("uuid") - .HasColumnName("created_by_id"); - - b.Property<Guid>("DeletedById") - .HasColumnType("uuid") - .HasColumnName("deleted_by_id"); - - b.Property<DateTime?>("ModifiedAt") - .HasColumnType("timestamp with time zone") - .HasColumnName("modified_at"); - - b.Property<Guid>("ModifiedById") - .HasColumnType("uuid") - .HasColumnName("modified_by_id"); - - b.Property<string>("Name") - .HasColumnType("text") - .HasColumnName("name"); - - b.Property<Guid>("TenantId") - .HasColumnType("uuid") - .HasColumnName("tenant_id"); - - b.Property<Guid>("UserId") - .HasColumnType("uuid") - .HasColumnName("user_id"); - - b.HasKey("Id") - .HasName("pk_time_labels"); - - b.HasIndex("CreatedById") - .HasDatabaseName("ix_time_labels_created_by_id"); - - b.HasIndex("DeletedById") - .HasDatabaseName("ix_time_labels_deleted_by_id"); - - b.HasIndex("ModifiedById") - .HasDatabaseName("ix_time_labels_modified_by_id"); - - b.HasIndex("TenantId") - .HasDatabaseName("ix_time_labels_tenant_id"); - - b.HasIndex("UserId") - .HasDatabaseName("ix_time_labels_user_id"); - - b.ToTable("time_labels", (string)null); - }); - - modelBuilder.Entity("IOL.GreatOffice.Api.Data.Database.User", b => - { - b.Property<Guid>("Id") - .ValueGeneratedOnAdd() - .HasColumnType("uuid") - .HasColumnName("id"); - - b.Property<DateTime>("CreatedAt") - .HasColumnType("timestamp with time zone") - .HasColumnName("created_at"); - - b.Property<DateTime?>("ModifiedAt") - .HasColumnType("timestamp with time zone") - .HasColumnName("modified_at"); - - b.Property<string>("Password") - .HasColumnType("text") - .HasColumnName("password"); - - b.Property<string>("Username") - .HasColumnType("text") - .HasColumnName("username"); - - b.HasKey("Id") - .HasName("pk_users"); - - b.ToTable("users", (string)null); - }); - - modelBuilder.Entity("TimeEntryTimeLabel", b => - { - b.Property<Guid>("EntriesId") - .HasColumnType("uuid") - .HasColumnName("entries_id"); - - b.Property<Guid>("LabelsId") - .HasColumnType("uuid") - .HasColumnName("labels_id"); - - b.HasKey("EntriesId", "LabelsId") - .HasName("pk_time_entry_time_label"); - - b.HasIndex("LabelsId") - .HasDatabaseName("ix_time_entry_time_label_labels_id"); - - b.ToTable("time_entry_time_label", (string)null); - }); - - modelBuilder.Entity("IOL.GreatOffice.Api.Data.Database.ApiAccessToken", b => - { - b.HasOne("IOL.GreatOffice.Api.Data.Database.User", "User") - .WithMany() - .HasForeignKey("UserId") - .HasConstraintName("fk_api_access_tokens_users_user_id"); - - b.Navigation("User"); - }); - - modelBuilder.Entity("IOL.GreatOffice.Api.Data.Database.ForgotPasswordRequest", b => - { - b.HasOne("IOL.GreatOffice.Api.Data.Database.User", "User") - .WithMany() - .HasForeignKey("UserId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired() - .HasConstraintName("fk_forgot_password_requests_users_user_id"); - - b.Navigation("User"); - }); - - modelBuilder.Entity("IOL.GreatOffice.Api.Data.Database.GithubUserMapping", b => - { - b.HasOne("IOL.GreatOffice.Api.Data.Database.User", "User") - .WithMany() - .HasForeignKey("UserId") - .HasConstraintName("fk_github_user_mappings_users_user_id"); - - b.Navigation("User"); - }); - - modelBuilder.Entity("IOL.GreatOffice.Api.Data.Database.Tenant", b => - { - b.HasOne("IOL.GreatOffice.Api.Data.Database.User", "CreatedBy") - .WithMany() - .HasForeignKey("CreatedById") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired() - .HasConstraintName("fk_tenants_users_created_by_id"); - - b.HasOne("IOL.GreatOffice.Api.Data.Database.User", "DeletedBy") - .WithMany() - .HasForeignKey("DeletedById") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired() - .HasConstraintName("fk_tenants_users_deleted_by_id"); - - b.HasOne("IOL.GreatOffice.Api.Data.Database.User", "ModifiedBy") - .WithMany() - .HasForeignKey("ModifiedById") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired() - .HasConstraintName("fk_tenants_users_modified_by_id"); - - b.HasOne("IOL.GreatOffice.Api.Data.Database.Tenant", "Tenant") - .WithMany() - .HasForeignKey("TenantId1") - .HasConstraintName("fk_tenants_tenants_tenant_id1"); - - b.HasOne("IOL.GreatOffice.Api.Data.Database.User", "User") - .WithMany() - .HasForeignKey("UserId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired() - .HasConstraintName("fk_tenants_users_user_id"); - - b.Navigation("CreatedBy"); - - b.Navigation("DeletedBy"); - - b.Navigation("ModifiedBy"); - - b.Navigation("Tenant"); - - b.Navigation("User"); - }); - - modelBuilder.Entity("IOL.GreatOffice.Api.Data.Database.TimeCategory", b => - { - b.HasOne("IOL.GreatOffice.Api.Data.Database.User", "CreatedBy") - .WithMany() - .HasForeignKey("CreatedById") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired() - .HasConstraintName("fk_time_categories_users_created_by_id"); - - b.HasOne("IOL.GreatOffice.Api.Data.Database.User", "DeletedBy") - .WithMany() - .HasForeignKey("DeletedById") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired() - .HasConstraintName("fk_time_categories_users_deleted_by_id"); - - b.HasOne("IOL.GreatOffice.Api.Data.Database.User", "ModifiedBy") - .WithMany() - .HasForeignKey("ModifiedById") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired() - .HasConstraintName("fk_time_categories_users_modified_by_id"); - - b.HasOne("IOL.GreatOffice.Api.Data.Database.Tenant", "Tenant") - .WithMany() - .HasForeignKey("TenantId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired() - .HasConstraintName("fk_time_categories_tenants_tenant_id"); - - b.HasOne("IOL.GreatOffice.Api.Data.Database.User", "User") - .WithMany() - .HasForeignKey("UserId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired() - .HasConstraintName("fk_time_categories_users_user_id"); - - b.Navigation("CreatedBy"); - - b.Navigation("DeletedBy"); - - b.Navigation("ModifiedBy"); - - b.Navigation("Tenant"); - - b.Navigation("User"); - }); - - modelBuilder.Entity("IOL.GreatOffice.Api.Data.Database.TimeEntry", b => - { - b.HasOne("IOL.GreatOffice.Api.Data.Database.TimeCategory", "Category") - .WithMany("Entries") - .HasForeignKey("CategoryId") - .HasConstraintName("fk_time_entries_time_categories_category_id"); - - b.HasOne("IOL.GreatOffice.Api.Data.Database.User", "CreatedBy") - .WithMany() - .HasForeignKey("CreatedById") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired() - .HasConstraintName("fk_time_entries_users_created_by_id"); - - b.HasOne("IOL.GreatOffice.Api.Data.Database.User", "DeletedBy") - .WithMany() - .HasForeignKey("DeletedById") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired() - .HasConstraintName("fk_time_entries_users_deleted_by_id"); - - b.HasOne("IOL.GreatOffice.Api.Data.Database.User", "ModifiedBy") - .WithMany() - .HasForeignKey("ModifiedById") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired() - .HasConstraintName("fk_time_entries_users_modified_by_id"); - - b.HasOne("IOL.GreatOffice.Api.Data.Database.Tenant", "Tenant") - .WithMany() - .HasForeignKey("TenantId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired() - .HasConstraintName("fk_time_entries_tenants_tenant_id"); - - b.HasOne("IOL.GreatOffice.Api.Data.Database.User", "User") - .WithMany() - .HasForeignKey("UserId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired() - .HasConstraintName("fk_time_entries_users_user_id"); - - b.Navigation("Category"); - - b.Navigation("CreatedBy"); - - b.Navigation("DeletedBy"); - - b.Navigation("ModifiedBy"); - - b.Navigation("Tenant"); - - b.Navigation("User"); - }); - - modelBuilder.Entity("IOL.GreatOffice.Api.Data.Database.TimeLabel", b => - { - b.HasOne("IOL.GreatOffice.Api.Data.Database.User", "CreatedBy") - .WithMany() - .HasForeignKey("CreatedById") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired() - .HasConstraintName("fk_time_labels_users_created_by_id"); - - b.HasOne("IOL.GreatOffice.Api.Data.Database.User", "DeletedBy") - .WithMany() - .HasForeignKey("DeletedById") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired() - .HasConstraintName("fk_time_labels_users_deleted_by_id"); - - b.HasOne("IOL.GreatOffice.Api.Data.Database.User", "ModifiedBy") - .WithMany() - .HasForeignKey("ModifiedById") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired() - .HasConstraintName("fk_time_labels_users_modified_by_id"); - - b.HasOne("IOL.GreatOffice.Api.Data.Database.Tenant", "Tenant") - .WithMany() - .HasForeignKey("TenantId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired() - .HasConstraintName("fk_time_labels_tenants_tenant_id"); - - b.HasOne("IOL.GreatOffice.Api.Data.Database.User", "User") - .WithMany() - .HasForeignKey("UserId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired() - .HasConstraintName("fk_time_labels_users_user_id"); - - b.Navigation("CreatedBy"); - - b.Navigation("DeletedBy"); - - b.Navigation("ModifiedBy"); - - b.Navigation("Tenant"); - - b.Navigation("User"); - }); - - modelBuilder.Entity("TimeEntryTimeLabel", b => - { - b.HasOne("IOL.GreatOffice.Api.Data.Database.TimeEntry", null) - .WithMany() - .HasForeignKey("EntriesId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired() - .HasConstraintName("fk_time_entry_time_label_time_entries_entries_id"); - - b.HasOne("IOL.GreatOffice.Api.Data.Database.TimeLabel", null) - .WithMany() - .HasForeignKey("LabelsId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired() - .HasConstraintName("fk_time_entry_time_label_time_labels_labels_id"); - }); - - modelBuilder.Entity("IOL.GreatOffice.Api.Data.Database.TimeCategory", b => - { - b.Navigation("Entries"); - }); -#pragma warning restore 612, 618 - } - } -} diff --git a/server/src/Migrations/20220530174741_Tenants.cs b/server/src/Migrations/20220530174741_Tenants.cs deleted file mode 100644 index ea02ddd..0000000 --- a/server/src/Migrations/20220530174741_Tenants.cs +++ /dev/null @@ -1,481 +0,0 @@ -using System; -using Microsoft.EntityFrameworkCore.Migrations; - -#nullable disable - -namespace IOL.GreatOffice.Api.Migrations -{ - public partial class Tenants : Migration - { - protected override void Up(MigrationBuilder migrationBuilder) - { - migrationBuilder.AddColumn<Guid>( - name: "created_by_id", - table: "time_labels", - type: "uuid", - nullable: false, - defaultValue: new Guid("00000000-0000-0000-0000-000000000000")); - - migrationBuilder.AddColumn<Guid>( - name: "deleted_by_id", - table: "time_labels", - type: "uuid", - nullable: false, - defaultValue: new Guid("00000000-0000-0000-0000-000000000000")); - - migrationBuilder.AddColumn<Guid>( - name: "modified_by_id", - table: "time_labels", - type: "uuid", - nullable: false, - defaultValue: new Guid("00000000-0000-0000-0000-000000000000")); - - migrationBuilder.AddColumn<Guid>( - name: "tenant_id", - table: "time_labels", - type: "uuid", - nullable: false, - defaultValue: new Guid("00000000-0000-0000-0000-000000000000")); - - migrationBuilder.AddColumn<Guid>( - name: "created_by_id", - table: "time_entries", - type: "uuid", - nullable: false, - defaultValue: new Guid("00000000-0000-0000-0000-000000000000")); - - migrationBuilder.AddColumn<Guid>( - name: "deleted_by_id", - table: "time_entries", - type: "uuid", - nullable: false, - defaultValue: new Guid("00000000-0000-0000-0000-000000000000")); - - migrationBuilder.AddColumn<Guid>( - name: "modified_by_id", - table: "time_entries", - type: "uuid", - nullable: false, - defaultValue: new Guid("00000000-0000-0000-0000-000000000000")); - - migrationBuilder.AddColumn<Guid>( - name: "tenant_id", - table: "time_entries", - type: "uuid", - nullable: false, - defaultValue: new Guid("00000000-0000-0000-0000-000000000000")); - - migrationBuilder.AddColumn<Guid>( - name: "created_by_id", - table: "time_categories", - type: "uuid", - nullable: false, - defaultValue: new Guid("00000000-0000-0000-0000-000000000000")); - - migrationBuilder.AddColumn<Guid>( - name: "deleted_by_id", - table: "time_categories", - type: "uuid", - nullable: false, - defaultValue: new Guid("00000000-0000-0000-0000-000000000000")); - - migrationBuilder.AddColumn<Guid>( - name: "modified_by_id", - table: "time_categories", - type: "uuid", - nullable: false, - defaultValue: new Guid("00000000-0000-0000-0000-000000000000")); - - migrationBuilder.AddColumn<Guid>( - name: "tenant_id", - table: "time_categories", - type: "uuid", - nullable: false, - defaultValue: new Guid("00000000-0000-0000-0000-000000000000")); - - migrationBuilder.CreateTable( - name: "tenants", - columns: table => new - { - id = table.Column<Guid>(type: "uuid", nullable: false), - name = table.Column<string>(type: "text", nullable: true), - description = table.Column<string>(type: "text", nullable: true), - contact_email = table.Column<string>(type: "text", nullable: true), - master_user_id = table.Column<Guid>(type: "uuid", nullable: false), - master_user_password = table.Column<string>(type: "text", nullable: true), - created_at = table.Column<DateTime>(type: "timestamp with time zone", nullable: false), - modified_at = table.Column<DateTime>(type: "timestamp with time zone", nullable: true), - user_id = table.Column<Guid>(type: "uuid", nullable: false), - tenant_id = table.Column<Guid>(type: "uuid", nullable: false), - tenant_id1 = table.Column<Guid>(type: "uuid", nullable: true), - modified_by_id = table.Column<Guid>(type: "uuid", nullable: false), - created_by_id = table.Column<Guid>(type: "uuid", nullable: false), - deleted_by_id = table.Column<Guid>(type: "uuid", nullable: false) - }, - constraints: table => - { - table.PrimaryKey("pk_tenants", x => x.id); - table.ForeignKey( - name: "fk_tenants_tenants_tenant_id1", - column: x => x.tenant_id1, - principalTable: "tenants", - principalColumn: "id"); - table.ForeignKey( - name: "fk_tenants_users_created_by_id", - column: x => x.created_by_id, - principalTable: "users", - principalColumn: "id", - onDelete: ReferentialAction.Cascade); - table.ForeignKey( - name: "fk_tenants_users_deleted_by_id", - column: x => x.deleted_by_id, - principalTable: "users", - principalColumn: "id", - onDelete: ReferentialAction.Cascade); - table.ForeignKey( - name: "fk_tenants_users_modified_by_id", - column: x => x.modified_by_id, - principalTable: "users", - principalColumn: "id", - onDelete: ReferentialAction.Cascade); - table.ForeignKey( - name: "fk_tenants_users_user_id", - column: x => x.user_id, - principalTable: "users", - principalColumn: "id", - onDelete: ReferentialAction.Cascade); - }); - - migrationBuilder.CreateIndex( - name: "ix_time_labels_created_by_id", - table: "time_labels", - column: "created_by_id"); - - migrationBuilder.CreateIndex( - name: "ix_time_labels_deleted_by_id", - table: "time_labels", - column: "deleted_by_id"); - - migrationBuilder.CreateIndex( - name: "ix_time_labels_modified_by_id", - table: "time_labels", - column: "modified_by_id"); - - migrationBuilder.CreateIndex( - name: "ix_time_labels_tenant_id", - table: "time_labels", - column: "tenant_id"); - - migrationBuilder.CreateIndex( - name: "ix_time_entries_created_by_id", - table: "time_entries", - column: "created_by_id"); - - migrationBuilder.CreateIndex( - name: "ix_time_entries_deleted_by_id", - table: "time_entries", - column: "deleted_by_id"); - - migrationBuilder.CreateIndex( - name: "ix_time_entries_modified_by_id", - table: "time_entries", - column: "modified_by_id"); - - migrationBuilder.CreateIndex( - name: "ix_time_entries_tenant_id", - table: "time_entries", - column: "tenant_id"); - - migrationBuilder.CreateIndex( - name: "ix_time_categories_created_by_id", - table: "time_categories", - column: "created_by_id"); - - migrationBuilder.CreateIndex( - name: "ix_time_categories_deleted_by_id", - table: "time_categories", - column: "deleted_by_id"); - - migrationBuilder.CreateIndex( - name: "ix_time_categories_modified_by_id", - table: "time_categories", - column: "modified_by_id"); - - migrationBuilder.CreateIndex( - name: "ix_time_categories_tenant_id", - table: "time_categories", - column: "tenant_id"); - - migrationBuilder.CreateIndex( - name: "ix_tenants_created_by_id", - table: "tenants", - column: "created_by_id"); - - migrationBuilder.CreateIndex( - name: "ix_tenants_deleted_by_id", - table: "tenants", - column: "deleted_by_id"); - - migrationBuilder.CreateIndex( - name: "ix_tenants_modified_by_id", - table: "tenants", - column: "modified_by_id"); - - migrationBuilder.CreateIndex( - name: "ix_tenants_tenant_id1", - table: "tenants", - column: "tenant_id1"); - - migrationBuilder.CreateIndex( - name: "ix_tenants_user_id", - table: "tenants", - column: "user_id"); - - migrationBuilder.AddForeignKey( - name: "fk_time_categories_tenants_tenant_id", - table: "time_categories", - column: "tenant_id", - principalTable: "tenants", - principalColumn: "id", - onDelete: ReferentialAction.Cascade); - - migrationBuilder.AddForeignKey( - name: "fk_time_categories_users_created_by_id", - table: "time_categories", - column: "created_by_id", - principalTable: "users", - principalColumn: "id", - onDelete: ReferentialAction.Cascade); - - migrationBuilder.AddForeignKey( - name: "fk_time_categories_users_deleted_by_id", - table: "time_categories", - column: "deleted_by_id", - principalTable: "users", - principalColumn: "id", - onDelete: ReferentialAction.Cascade); - - migrationBuilder.AddForeignKey( - name: "fk_time_categories_users_modified_by_id", - table: "time_categories", - column: "modified_by_id", - principalTable: "users", - principalColumn: "id", - onDelete: ReferentialAction.Cascade); - - migrationBuilder.AddForeignKey( - name: "fk_time_entries_tenants_tenant_id", - table: "time_entries", - column: "tenant_id", - principalTable: "tenants", - principalColumn: "id", - onDelete: ReferentialAction.Cascade); - - migrationBuilder.AddForeignKey( - name: "fk_time_entries_users_created_by_id", - table: "time_entries", - column: "created_by_id", - principalTable: "users", - principalColumn: "id", - onDelete: ReferentialAction.Cascade); - - migrationBuilder.AddForeignKey( - name: "fk_time_entries_users_deleted_by_id", - table: "time_entries", - column: "deleted_by_id", - principalTable: "users", - principalColumn: "id", - onDelete: ReferentialAction.Cascade); - - migrationBuilder.AddForeignKey( - name: "fk_time_entries_users_modified_by_id", - table: "time_entries", - column: "modified_by_id", - principalTable: "users", - principalColumn: "id", - onDelete: ReferentialAction.Cascade); - - migrationBuilder.AddForeignKey( - name: "fk_time_labels_tenants_tenant_id", - table: "time_labels", - column: "tenant_id", - principalTable: "tenants", - principalColumn: "id", - onDelete: ReferentialAction.Cascade); - - migrationBuilder.AddForeignKey( - name: "fk_time_labels_users_created_by_id", - table: "time_labels", - column: "created_by_id", - principalTable: "users", - principalColumn: "id", - onDelete: ReferentialAction.Cascade); - - migrationBuilder.AddForeignKey( - name: "fk_time_labels_users_deleted_by_id", - table: "time_labels", - column: "deleted_by_id", - principalTable: "users", - principalColumn: "id", - onDelete: ReferentialAction.Cascade); - - migrationBuilder.AddForeignKey( - name: "fk_time_labels_users_modified_by_id", - table: "time_labels", - column: "modified_by_id", - principalTable: "users", - principalColumn: "id", - onDelete: ReferentialAction.Cascade); - } - - protected override void Down(MigrationBuilder migrationBuilder) - { - migrationBuilder.DropForeignKey( - name: "fk_time_categories_tenants_tenant_id", - table: "time_categories"); - - migrationBuilder.DropForeignKey( - name: "fk_time_categories_users_created_by_id", - table: "time_categories"); - - migrationBuilder.DropForeignKey( - name: "fk_time_categories_users_deleted_by_id", - table: "time_categories"); - - migrationBuilder.DropForeignKey( - name: "fk_time_categories_users_modified_by_id", - table: "time_categories"); - - migrationBuilder.DropForeignKey( - name: "fk_time_entries_tenants_tenant_id", - table: "time_entries"); - - migrationBuilder.DropForeignKey( - name: "fk_time_entries_users_created_by_id", - table: "time_entries"); - - migrationBuilder.DropForeignKey( - name: "fk_time_entries_users_deleted_by_id", - table: "time_entries"); - - migrationBuilder.DropForeignKey( - name: "fk_time_entries_users_modified_by_id", - table: "time_entries"); - - migrationBuilder.DropForeignKey( - name: "fk_time_labels_tenants_tenant_id", - table: "time_labels"); - - migrationBuilder.DropForeignKey( - name: "fk_time_labels_users_created_by_id", - table: "time_labels"); - - migrationBuilder.DropForeignKey( - name: "fk_time_labels_users_deleted_by_id", - table: "time_labels"); - - migrationBuilder.DropForeignKey( - name: "fk_time_labels_users_modified_by_id", - table: "time_labels"); - - migrationBuilder.DropTable( - name: "tenants"); - - migrationBuilder.DropIndex( - name: "ix_time_labels_created_by_id", - table: "time_labels"); - - migrationBuilder.DropIndex( - name: "ix_time_labels_deleted_by_id", - table: "time_labels"); - - migrationBuilder.DropIndex( - name: "ix_time_labels_modified_by_id", - table: "time_labels"); - - migrationBuilder.DropIndex( - name: "ix_time_labels_tenant_id", - table: "time_labels"); - - migrationBuilder.DropIndex( - name: "ix_time_entries_created_by_id", - table: "time_entries"); - - migrationBuilder.DropIndex( - name: "ix_time_entries_deleted_by_id", - table: "time_entries"); - - migrationBuilder.DropIndex( - name: "ix_time_entries_modified_by_id", - table: "time_entries"); - - migrationBuilder.DropIndex( - name: "ix_time_entries_tenant_id", - table: "time_entries"); - - migrationBuilder.DropIndex( - name: "ix_time_categories_created_by_id", - table: "time_categories"); - - migrationBuilder.DropIndex( - name: "ix_time_categories_deleted_by_id", - table: "time_categories"); - - migrationBuilder.DropIndex( - name: "ix_time_categories_modified_by_id", - table: "time_categories"); - - migrationBuilder.DropIndex( - name: "ix_time_categories_tenant_id", - table: "time_categories"); - - migrationBuilder.DropColumn( - name: "created_by_id", - table: "time_labels"); - - migrationBuilder.DropColumn( - name: "deleted_by_id", - table: "time_labels"); - - migrationBuilder.DropColumn( - name: "modified_by_id", - table: "time_labels"); - - migrationBuilder.DropColumn( - name: "tenant_id", - table: "time_labels"); - - migrationBuilder.DropColumn( - name: "created_by_id", - table: "time_entries"); - - migrationBuilder.DropColumn( - name: "deleted_by_id", - table: "time_entries"); - - migrationBuilder.DropColumn( - name: "modified_by_id", - table: "time_entries"); - - migrationBuilder.DropColumn( - name: "tenant_id", - table: "time_entries"); - - migrationBuilder.DropColumn( - name: "created_by_id", - table: "time_categories"); - - migrationBuilder.DropColumn( - name: "deleted_by_id", - table: "time_categories"); - - migrationBuilder.DropColumn( - name: "modified_by_id", - table: "time_categories"); - - migrationBuilder.DropColumn( - name: "tenant_id", - table: "time_categories"); - } - } -} diff --git a/server/src/Migrations/20220530175322_RemoveUnusedNavs.Designer.cs b/server/src/Migrations/20220530175322_RemoveUnusedNavs.Designer.cs deleted file mode 100644 index 8fd6b40..0000000 --- a/server/src/Migrations/20220530175322_RemoveUnusedNavs.Designer.cs +++ /dev/null @@ -1,686 +0,0 @@ -// <auto-generated /> -using System; -using IOL.GreatOffice.Api.Data; -using Microsoft.EntityFrameworkCore; -using Microsoft.EntityFrameworkCore.Infrastructure; -using Microsoft.EntityFrameworkCore.Migrations; -using Microsoft.EntityFrameworkCore.Storage.ValueConversion; -using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata; - -#nullable disable - -namespace IOL.GreatOffice.Api.Migrations -{ - [DbContext(typeof(AppDbContext))] - [Migration("20220530175322_RemoveUnusedNavs")] - partial class RemoveUnusedNavs - { - protected override void BuildTargetModel(ModelBuilder modelBuilder) - { -#pragma warning disable 612, 618 - modelBuilder - .HasAnnotation("ProductVersion", "6.0.5") - .HasAnnotation("Relational:MaxIdentifierLength", 63); - - NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder); - - modelBuilder.Entity("IOL.GreatOffice.Api.Data.Database.ApiAccessToken", b => - { - b.Property<Guid>("Id") - .ValueGeneratedOnAdd() - .HasColumnType("uuid") - .HasColumnName("id"); - - b.Property<bool>("AllowCreate") - .HasColumnType("boolean") - .HasColumnName("allow_create"); - - b.Property<bool>("AllowDelete") - .HasColumnType("boolean") - .HasColumnName("allow_delete"); - - b.Property<bool>("AllowRead") - .HasColumnType("boolean") - .HasColumnName("allow_read"); - - b.Property<bool>("AllowUpdate") - .HasColumnType("boolean") - .HasColumnName("allow_update"); - - b.Property<DateTime>("CreatedAt") - .HasColumnType("timestamp with time zone") - .HasColumnName("created_at"); - - b.Property<DateTime>("ExpiryDate") - .HasColumnType("timestamp with time zone") - .HasColumnName("expiry_date"); - - b.Property<DateTime?>("ModifiedAt") - .HasColumnType("timestamp with time zone") - .HasColumnName("modified_at"); - - b.Property<Guid?>("UserId") - .HasColumnType("uuid") - .HasColumnName("user_id"); - - b.HasKey("Id") - .HasName("pk_api_access_tokens"); - - b.HasIndex("UserId") - .HasDatabaseName("ix_api_access_tokens_user_id"); - - b.ToTable("api_access_tokens", (string)null); - }); - - modelBuilder.Entity("IOL.GreatOffice.Api.Data.Database.ForgotPasswordRequest", b => - { - b.Property<Guid>("Id") - .ValueGeneratedOnAdd() - .HasColumnType("uuid") - .HasColumnName("id"); - - b.Property<DateTime>("CreatedAt") - .HasColumnType("timestamp with time zone") - .HasColumnName("created_at"); - - b.Property<Guid>("UserId") - .HasColumnType("uuid") - .HasColumnName("user_id"); - - b.HasKey("Id") - .HasName("pk_forgot_password_requests"); - - b.HasIndex("UserId") - .HasDatabaseName("ix_forgot_password_requests_user_id"); - - b.ToTable("forgot_password_requests", (string)null); - }); - - modelBuilder.Entity("IOL.GreatOffice.Api.Data.Database.GithubUserMapping", b => - { - b.Property<string>("GithubId") - .HasColumnType("text") - .HasColumnName("github_id"); - - b.Property<string>("Email") - .HasColumnType("text") - .HasColumnName("email"); - - b.Property<string>("RefreshToken") - .HasColumnType("text") - .HasColumnName("refresh_token"); - - b.Property<Guid?>("UserId") - .HasColumnType("uuid") - .HasColumnName("user_id"); - - b.HasKey("GithubId") - .HasName("pk_github_user_mappings"); - - b.HasIndex("UserId") - .HasDatabaseName("ix_github_user_mappings_user_id"); - - b.ToTable("github_user_mappings", (string)null); - }); - - modelBuilder.Entity("IOL.GreatOffice.Api.Data.Database.Tenant", b => - { - b.Property<Guid>("Id") - .ValueGeneratedOnAdd() - .HasColumnType("uuid") - .HasColumnName("id"); - - b.Property<string>("ContactEmail") - .HasColumnType("text") - .HasColumnName("contact_email"); - - b.Property<DateTime>("CreatedAt") - .HasColumnType("timestamp with time zone") - .HasColumnName("created_at"); - - b.Property<Guid>("CreatedById") - .HasColumnType("uuid") - .HasColumnName("created_by_id"); - - b.Property<Guid>("DeletedById") - .HasColumnType("uuid") - .HasColumnName("deleted_by_id"); - - b.Property<string>("Description") - .HasColumnType("text") - .HasColumnName("description"); - - b.Property<Guid>("MasterUserId") - .HasColumnType("uuid") - .HasColumnName("master_user_id"); - - b.Property<string>("MasterUserPassword") - .HasColumnType("text") - .HasColumnName("master_user_password"); - - b.Property<DateTime?>("ModifiedAt") - .HasColumnType("timestamp with time zone") - .HasColumnName("modified_at"); - - b.Property<Guid>("ModifiedById") - .HasColumnType("uuid") - .HasColumnName("modified_by_id"); - - b.Property<string>("Name") - .HasColumnType("text") - .HasColumnName("name"); - - b.Property<Guid>("TenantId") - .HasColumnType("uuid") - .HasColumnName("tenant_id"); - - b.Property<Guid?>("TenantId1") - .HasColumnType("uuid") - .HasColumnName("tenant_id1"); - - b.Property<Guid>("UserId") - .HasColumnType("uuid") - .HasColumnName("user_id"); - - b.HasKey("Id") - .HasName("pk_tenants"); - - b.HasIndex("CreatedById") - .HasDatabaseName("ix_tenants_created_by_id"); - - b.HasIndex("DeletedById") - .HasDatabaseName("ix_tenants_deleted_by_id"); - - b.HasIndex("ModifiedById") - .HasDatabaseName("ix_tenants_modified_by_id"); - - b.HasIndex("TenantId1") - .HasDatabaseName("ix_tenants_tenant_id1"); - - b.HasIndex("UserId") - .HasDatabaseName("ix_tenants_user_id"); - - b.ToTable("tenants", (string)null); - }); - - modelBuilder.Entity("IOL.GreatOffice.Api.Data.Database.TimeCategory", b => - { - b.Property<Guid>("Id") - .ValueGeneratedOnAdd() - .HasColumnType("uuid") - .HasColumnName("id"); - - b.Property<string>("Color") - .HasColumnType("text") - .HasColumnName("color"); - - b.Property<DateTime>("CreatedAt") - .HasColumnType("timestamp with time zone") - .HasColumnName("created_at"); - - b.Property<Guid>("CreatedById") - .HasColumnType("uuid") - .HasColumnName("created_by_id"); - - b.Property<Guid>("DeletedById") - .HasColumnType("uuid") - .HasColumnName("deleted_by_id"); - - b.Property<DateTime?>("ModifiedAt") - .HasColumnType("timestamp with time zone") - .HasColumnName("modified_at"); - - b.Property<Guid>("ModifiedById") - .HasColumnType("uuid") - .HasColumnName("modified_by_id"); - - b.Property<string>("Name") - .HasColumnType("text") - .HasColumnName("name"); - - b.Property<Guid>("TenantId") - .HasColumnType("uuid") - .HasColumnName("tenant_id"); - - b.Property<Guid>("UserId") - .HasColumnType("uuid") - .HasColumnName("user_id"); - - b.HasKey("Id") - .HasName("pk_time_categories"); - - b.HasIndex("CreatedById") - .HasDatabaseName("ix_time_categories_created_by_id"); - - b.HasIndex("DeletedById") - .HasDatabaseName("ix_time_categories_deleted_by_id"); - - b.HasIndex("ModifiedById") - .HasDatabaseName("ix_time_categories_modified_by_id"); - - b.HasIndex("TenantId") - .HasDatabaseName("ix_time_categories_tenant_id"); - - b.HasIndex("UserId") - .HasDatabaseName("ix_time_categories_user_id"); - - b.ToTable("time_categories", (string)null); - }); - - modelBuilder.Entity("IOL.GreatOffice.Api.Data.Database.TimeEntry", b => - { - b.Property<Guid>("Id") - .ValueGeneratedOnAdd() - .HasColumnType("uuid") - .HasColumnName("id"); - - b.Property<Guid?>("CategoryId") - .HasColumnType("uuid") - .HasColumnName("category_id"); - - b.Property<DateTime>("CreatedAt") - .HasColumnType("timestamp with time zone") - .HasColumnName("created_at"); - - b.Property<Guid>("CreatedById") - .HasColumnType("uuid") - .HasColumnName("created_by_id"); - - b.Property<Guid>("DeletedById") - .HasColumnType("uuid") - .HasColumnName("deleted_by_id"); - - b.Property<string>("Description") - .HasColumnType("text") - .HasColumnName("description"); - - b.Property<DateTime?>("ModifiedAt") - .HasColumnType("timestamp with time zone") - .HasColumnName("modified_at"); - - b.Property<Guid>("ModifiedById") - .HasColumnType("uuid") - .HasColumnName("modified_by_id"); - - b.Property<DateTime>("Start") - .HasColumnType("timestamp with time zone") - .HasColumnName("start"); - - b.Property<DateTime>("Stop") - .HasColumnType("timestamp with time zone") - .HasColumnName("stop"); - - b.Property<Guid>("TenantId") - .HasColumnType("uuid") - .HasColumnName("tenant_id"); - - b.Property<Guid>("UserId") - .HasColumnType("uuid") - .HasColumnName("user_id"); - - b.HasKey("Id") - .HasName("pk_time_entries"); - - b.HasIndex("CategoryId") - .HasDatabaseName("ix_time_entries_category_id"); - - b.HasIndex("CreatedById") - .HasDatabaseName("ix_time_entries_created_by_id"); - - b.HasIndex("DeletedById") - .HasDatabaseName("ix_time_entries_deleted_by_id"); - - b.HasIndex("ModifiedById") - .HasDatabaseName("ix_time_entries_modified_by_id"); - - b.HasIndex("TenantId") - .HasDatabaseName("ix_time_entries_tenant_id"); - - b.HasIndex("UserId") - .HasDatabaseName("ix_time_entries_user_id"); - - b.ToTable("time_entries", (string)null); - }); - - modelBuilder.Entity("IOL.GreatOffice.Api.Data.Database.TimeLabel", b => - { - b.Property<Guid>("Id") - .ValueGeneratedOnAdd() - .HasColumnType("uuid") - .HasColumnName("id"); - - b.Property<string>("Color") - .HasColumnType("text") - .HasColumnName("color"); - - b.Property<DateTime>("CreatedAt") - .HasColumnType("timestamp with time zone") - .HasColumnName("created_at"); - - b.Property<Guid>("CreatedById") - .HasColumnType("uuid") - .HasColumnName("created_by_id"); - - b.Property<Guid>("DeletedById") - .HasColumnType("uuid") - .HasColumnName("deleted_by_id"); - - b.Property<DateTime?>("ModifiedAt") - .HasColumnType("timestamp with time zone") - .HasColumnName("modified_at"); - - b.Property<Guid>("ModifiedById") - .HasColumnType("uuid") - .HasColumnName("modified_by_id"); - - b.Property<string>("Name") - .HasColumnType("text") - .HasColumnName("name"); - - b.Property<Guid>("TenantId") - .HasColumnType("uuid") - .HasColumnName("tenant_id"); - - b.Property<Guid?>("TimeEntryId") - .HasColumnType("uuid") - .HasColumnName("time_entry_id"); - - b.Property<Guid>("UserId") - .HasColumnType("uuid") - .HasColumnName("user_id"); - - b.HasKey("Id") - .HasName("pk_time_labels"); - - b.HasIndex("CreatedById") - .HasDatabaseName("ix_time_labels_created_by_id"); - - b.HasIndex("DeletedById") - .HasDatabaseName("ix_time_labels_deleted_by_id"); - - b.HasIndex("ModifiedById") - .HasDatabaseName("ix_time_labels_modified_by_id"); - - b.HasIndex("TenantId") - .HasDatabaseName("ix_time_labels_tenant_id"); - - b.HasIndex("TimeEntryId") - .HasDatabaseName("ix_time_labels_time_entry_id"); - - b.HasIndex("UserId") - .HasDatabaseName("ix_time_labels_user_id"); - - b.ToTable("time_labels", (string)null); - }); - - modelBuilder.Entity("IOL.GreatOffice.Api.Data.Database.User", b => - { - b.Property<Guid>("Id") - .ValueGeneratedOnAdd() - .HasColumnType("uuid") - .HasColumnName("id"); - - b.Property<DateTime>("CreatedAt") - .HasColumnType("timestamp with time zone") - .HasColumnName("created_at"); - - b.Property<DateTime?>("ModifiedAt") - .HasColumnType("timestamp with time zone") - .HasColumnName("modified_at"); - - b.Property<string>("Password") - .HasColumnType("text") - .HasColumnName("password"); - - b.Property<string>("Username") - .HasColumnType("text") - .HasColumnName("username"); - - b.HasKey("Id") - .HasName("pk_users"); - - b.ToTable("users", (string)null); - }); - - modelBuilder.Entity("IOL.GreatOffice.Api.Data.Database.ApiAccessToken", b => - { - b.HasOne("IOL.GreatOffice.Api.Data.Database.User", "User") - .WithMany() - .HasForeignKey("UserId") - .HasConstraintName("fk_api_access_tokens_users_user_id"); - - b.Navigation("User"); - }); - - modelBuilder.Entity("IOL.GreatOffice.Api.Data.Database.ForgotPasswordRequest", b => - { - b.HasOne("IOL.GreatOffice.Api.Data.Database.User", "User") - .WithMany() - .HasForeignKey("UserId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired() - .HasConstraintName("fk_forgot_password_requests_users_user_id"); - - b.Navigation("User"); - }); - - modelBuilder.Entity("IOL.GreatOffice.Api.Data.Database.GithubUserMapping", b => - { - b.HasOne("IOL.GreatOffice.Api.Data.Database.User", "User") - .WithMany() - .HasForeignKey("UserId") - .HasConstraintName("fk_github_user_mappings_users_user_id"); - - b.Navigation("User"); - }); - - modelBuilder.Entity("IOL.GreatOffice.Api.Data.Database.Tenant", b => - { - b.HasOne("IOL.GreatOffice.Api.Data.Database.User", "CreatedBy") - .WithMany() - .HasForeignKey("CreatedById") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired() - .HasConstraintName("fk_tenants_users_created_by_id"); - - b.HasOne("IOL.GreatOffice.Api.Data.Database.User", "DeletedBy") - .WithMany() - .HasForeignKey("DeletedById") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired() - .HasConstraintName("fk_tenants_users_deleted_by_id"); - - b.HasOne("IOL.GreatOffice.Api.Data.Database.User", "ModifiedBy") - .WithMany() - .HasForeignKey("ModifiedById") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired() - .HasConstraintName("fk_tenants_users_modified_by_id"); - - b.HasOne("IOL.GreatOffice.Api.Data.Database.Tenant", "Tenant") - .WithMany() - .HasForeignKey("TenantId1") - .HasConstraintName("fk_tenants_tenants_tenant_id1"); - - b.HasOne("IOL.GreatOffice.Api.Data.Database.User", "User") - .WithMany() - .HasForeignKey("UserId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired() - .HasConstraintName("fk_tenants_users_user_id"); - - b.Navigation("CreatedBy"); - - b.Navigation("DeletedBy"); - - b.Navigation("ModifiedBy"); - - b.Navigation("Tenant"); - - b.Navigation("User"); - }); - - modelBuilder.Entity("IOL.GreatOffice.Api.Data.Database.TimeCategory", b => - { - b.HasOne("IOL.GreatOffice.Api.Data.Database.User", "CreatedBy") - .WithMany() - .HasForeignKey("CreatedById") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired() - .HasConstraintName("fk_time_categories_users_created_by_id"); - - b.HasOne("IOL.GreatOffice.Api.Data.Database.User", "DeletedBy") - .WithMany() - .HasForeignKey("DeletedById") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired() - .HasConstraintName("fk_time_categories_users_deleted_by_id"); - - b.HasOne("IOL.GreatOffice.Api.Data.Database.User", "ModifiedBy") - .WithMany() - .HasForeignKey("ModifiedById") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired() - .HasConstraintName("fk_time_categories_users_modified_by_id"); - - b.HasOne("IOL.GreatOffice.Api.Data.Database.Tenant", "Tenant") - .WithMany() - .HasForeignKey("TenantId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired() - .HasConstraintName("fk_time_categories_tenants_tenant_id"); - - b.HasOne("IOL.GreatOffice.Api.Data.Database.User", "User") - .WithMany() - .HasForeignKey("UserId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired() - .HasConstraintName("fk_time_categories_users_user_id"); - - b.Navigation("CreatedBy"); - - b.Navigation("DeletedBy"); - - b.Navigation("ModifiedBy"); - - b.Navigation("Tenant"); - - b.Navigation("User"); - }); - - modelBuilder.Entity("IOL.GreatOffice.Api.Data.Database.TimeEntry", b => - { - b.HasOne("IOL.GreatOffice.Api.Data.Database.TimeCategory", "Category") - .WithMany() - .HasForeignKey("CategoryId") - .HasConstraintName("fk_time_entries_time_categories_category_id"); - - b.HasOne("IOL.GreatOffice.Api.Data.Database.User", "CreatedBy") - .WithMany() - .HasForeignKey("CreatedById") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired() - .HasConstraintName("fk_time_entries_users_created_by_id"); - - b.HasOne("IOL.GreatOffice.Api.Data.Database.User", "DeletedBy") - .WithMany() - .HasForeignKey("DeletedById") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired() - .HasConstraintName("fk_time_entries_users_deleted_by_id"); - - b.HasOne("IOL.GreatOffice.Api.Data.Database.User", "ModifiedBy") - .WithMany() - .HasForeignKey("ModifiedById") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired() - .HasConstraintName("fk_time_entries_users_modified_by_id"); - - b.HasOne("IOL.GreatOffice.Api.Data.Database.Tenant", "Tenant") - .WithMany() - .HasForeignKey("TenantId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired() - .HasConstraintName("fk_time_entries_tenants_tenant_id"); - - b.HasOne("IOL.GreatOffice.Api.Data.Database.User", "User") - .WithMany() - .HasForeignKey("UserId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired() - .HasConstraintName("fk_time_entries_users_user_id"); - - b.Navigation("Category"); - - b.Navigation("CreatedBy"); - - b.Navigation("DeletedBy"); - - b.Navigation("ModifiedBy"); - - b.Navigation("Tenant"); - - b.Navigation("User"); - }); - - modelBuilder.Entity("IOL.GreatOffice.Api.Data.Database.TimeLabel", b => - { - b.HasOne("IOL.GreatOffice.Api.Data.Database.User", "CreatedBy") - .WithMany() - .HasForeignKey("CreatedById") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired() - .HasConstraintName("fk_time_labels_users_created_by_id"); - - b.HasOne("IOL.GreatOffice.Api.Data.Database.User", "DeletedBy") - .WithMany() - .HasForeignKey("DeletedById") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired() - .HasConstraintName("fk_time_labels_users_deleted_by_id"); - - b.HasOne("IOL.GreatOffice.Api.Data.Database.User", "ModifiedBy") - .WithMany() - .HasForeignKey("ModifiedById") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired() - .HasConstraintName("fk_time_labels_users_modified_by_id"); - - b.HasOne("IOL.GreatOffice.Api.Data.Database.Tenant", "Tenant") - .WithMany() - .HasForeignKey("TenantId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired() - .HasConstraintName("fk_time_labels_tenants_tenant_id"); - - b.HasOne("IOL.GreatOffice.Api.Data.Database.TimeEntry", null) - .WithMany("Labels") - .HasForeignKey("TimeEntryId") - .HasConstraintName("fk_time_labels_time_entries_time_entry_id"); - - b.HasOne("IOL.GreatOffice.Api.Data.Database.User", "User") - .WithMany() - .HasForeignKey("UserId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired() - .HasConstraintName("fk_time_labels_users_user_id"); - - b.Navigation("CreatedBy"); - - b.Navigation("DeletedBy"); - - b.Navigation("ModifiedBy"); - - b.Navigation("Tenant"); - - b.Navigation("User"); - }); - - modelBuilder.Entity("IOL.GreatOffice.Api.Data.Database.TimeEntry", b => - { - b.Navigation("Labels"); - }); -#pragma warning restore 612, 618 - } - } -} diff --git a/server/src/Migrations/20220530175322_RemoveUnusedNavs.cs b/server/src/Migrations/20220530175322_RemoveUnusedNavs.cs deleted file mode 100644 index 36b3cf1..0000000 --- a/server/src/Migrations/20220530175322_RemoveUnusedNavs.cs +++ /dev/null @@ -1,78 +0,0 @@ -using System; -using Microsoft.EntityFrameworkCore.Migrations; - -#nullable disable - -namespace IOL.GreatOffice.Api.Migrations -{ - public partial class RemoveUnusedNavs : Migration - { - protected override void Up(MigrationBuilder migrationBuilder) - { - migrationBuilder.DropTable( - name: "time_entry_time_label"); - - migrationBuilder.AddColumn<Guid>( - name: "time_entry_id", - table: "time_labels", - type: "uuid", - nullable: true); - - migrationBuilder.CreateIndex( - name: "ix_time_labels_time_entry_id", - table: "time_labels", - column: "time_entry_id"); - - migrationBuilder.AddForeignKey( - name: "fk_time_labels_time_entries_time_entry_id", - table: "time_labels", - column: "time_entry_id", - principalTable: "time_entries", - principalColumn: "id"); - } - - protected override void Down(MigrationBuilder migrationBuilder) - { - migrationBuilder.DropForeignKey( - name: "fk_time_labels_time_entries_time_entry_id", - table: "time_labels"); - - migrationBuilder.DropIndex( - name: "ix_time_labels_time_entry_id", - table: "time_labels"); - - migrationBuilder.DropColumn( - name: "time_entry_id", - table: "time_labels"); - - migrationBuilder.CreateTable( - name: "time_entry_time_label", - columns: table => new - { - entries_id = table.Column<Guid>(type: "uuid", nullable: false), - labels_id = table.Column<Guid>(type: "uuid", nullable: false) - }, - constraints: table => - { - table.PrimaryKey("pk_time_entry_time_label", x => new { x.entries_id, x.labels_id }); - table.ForeignKey( - name: "fk_time_entry_time_label_time_entries_entries_id", - column: x => x.entries_id, - principalTable: "time_entries", - principalColumn: "id", - onDelete: ReferentialAction.Cascade); - table.ForeignKey( - name: "fk_time_entry_time_label_time_labels_labels_id", - column: x => x.labels_id, - principalTable: "time_labels", - principalColumn: "id", - onDelete: ReferentialAction.Cascade); - }); - - migrationBuilder.CreateIndex( - name: "ix_time_entry_time_label_labels_id", - table: "time_entry_time_label", - column: "labels_id"); - } - } -} diff --git a/server/src/Migrations/20220602214238_NullableOptionalBaseFields.Designer.cs b/server/src/Migrations/20220602214238_NullableOptionalBaseFields.Designer.cs deleted file mode 100644 index a05b0e4..0000000 --- a/server/src/Migrations/20220602214238_NullableOptionalBaseFields.Designer.cs +++ /dev/null @@ -1,656 +0,0 @@ -// <auto-generated /> -using System; -using IOL.GreatOffice.Api.Data; -using Microsoft.EntityFrameworkCore; -using Microsoft.EntityFrameworkCore.Infrastructure; -using Microsoft.EntityFrameworkCore.Migrations; -using Microsoft.EntityFrameworkCore.Storage.ValueConversion; -using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata; - -#nullable disable - -namespace IOL.GreatOffice.Api.Migrations -{ - [DbContext(typeof(AppDbContext))] - [Migration("20220602214238_NullableOptionalBaseFields")] - partial class NullableOptionalBaseFields - { - protected override void BuildTargetModel(ModelBuilder modelBuilder) - { -#pragma warning disable 612, 618 - modelBuilder - .HasAnnotation("ProductVersion", "6.0.5") - .HasAnnotation("Relational:MaxIdentifierLength", 63); - - NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder); - - modelBuilder.Entity("IOL.GreatOffice.Api.Data.Database.ApiAccessToken", b => - { - b.Property<Guid>("Id") - .ValueGeneratedOnAdd() - .HasColumnType("uuid") - .HasColumnName("id"); - - b.Property<bool>("AllowCreate") - .HasColumnType("boolean") - .HasColumnName("allow_create"); - - b.Property<bool>("AllowDelete") - .HasColumnType("boolean") - .HasColumnName("allow_delete"); - - b.Property<bool>("AllowRead") - .HasColumnType("boolean") - .HasColumnName("allow_read"); - - b.Property<bool>("AllowUpdate") - .HasColumnType("boolean") - .HasColumnName("allow_update"); - - b.Property<DateTime>("CreatedAt") - .HasColumnType("timestamp with time zone") - .HasColumnName("created_at"); - - b.Property<DateTime>("ExpiryDate") - .HasColumnType("timestamp with time zone") - .HasColumnName("expiry_date"); - - b.Property<DateTime?>("ModifiedAt") - .HasColumnType("timestamp with time zone") - .HasColumnName("modified_at"); - - b.Property<Guid?>("UserId") - .HasColumnType("uuid") - .HasColumnName("user_id"); - - b.HasKey("Id") - .HasName("pk_api_access_tokens"); - - b.HasIndex("UserId") - .HasDatabaseName("ix_api_access_tokens_user_id"); - - b.ToTable("api_access_tokens", (string)null); - }); - - modelBuilder.Entity("IOL.GreatOffice.Api.Data.Database.ForgotPasswordRequest", b => - { - b.Property<Guid>("Id") - .ValueGeneratedOnAdd() - .HasColumnType("uuid") - .HasColumnName("id"); - - b.Property<DateTime>("CreatedAt") - .HasColumnType("timestamp with time zone") - .HasColumnName("created_at"); - - b.Property<Guid>("UserId") - .HasColumnType("uuid") - .HasColumnName("user_id"); - - b.HasKey("Id") - .HasName("pk_forgot_password_requests"); - - b.HasIndex("UserId") - .HasDatabaseName("ix_forgot_password_requests_user_id"); - - b.ToTable("forgot_password_requests", (string)null); - }); - - modelBuilder.Entity("IOL.GreatOffice.Api.Data.Database.GithubUserMapping", b => - { - b.Property<string>("GithubId") - .HasColumnType("text") - .HasColumnName("github_id"); - - b.Property<string>("Email") - .HasColumnType("text") - .HasColumnName("email"); - - b.Property<string>("RefreshToken") - .HasColumnType("text") - .HasColumnName("refresh_token"); - - b.Property<Guid?>("UserId") - .HasColumnType("uuid") - .HasColumnName("user_id"); - - b.HasKey("GithubId") - .HasName("pk_github_user_mappings"); - - b.HasIndex("UserId") - .HasDatabaseName("ix_github_user_mappings_user_id"); - - b.ToTable("github_user_mappings", (string)null); - }); - - modelBuilder.Entity("IOL.GreatOffice.Api.Data.Database.Tenant", b => - { - b.Property<Guid>("Id") - .ValueGeneratedOnAdd() - .HasColumnType("uuid") - .HasColumnName("id"); - - b.Property<string>("ContactEmail") - .HasColumnType("text") - .HasColumnName("contact_email"); - - b.Property<DateTime>("CreatedAt") - .HasColumnType("timestamp with time zone") - .HasColumnName("created_at"); - - b.Property<Guid?>("CreatedById") - .HasColumnType("uuid") - .HasColumnName("created_by_id"); - - b.Property<Guid?>("DeletedById") - .HasColumnType("uuid") - .HasColumnName("deleted_by_id"); - - b.Property<string>("Description") - .HasColumnType("text") - .HasColumnName("description"); - - b.Property<Guid>("MasterUserId") - .HasColumnType("uuid") - .HasColumnName("master_user_id"); - - b.Property<string>("MasterUserPassword") - .HasColumnType("text") - .HasColumnName("master_user_password"); - - b.Property<DateTime?>("ModifiedAt") - .HasColumnType("timestamp with time zone") - .HasColumnName("modified_at"); - - b.Property<Guid?>("ModifiedById") - .HasColumnType("uuid") - .HasColumnName("modified_by_id"); - - b.Property<string>("Name") - .HasColumnType("text") - .HasColumnName("name"); - - b.Property<Guid?>("TenantId") - .HasColumnType("uuid") - .HasColumnName("tenant_id"); - - b.Property<Guid?>("TenantId1") - .HasColumnType("uuid") - .HasColumnName("tenant_id1"); - - b.Property<Guid>("UserId") - .HasColumnType("uuid") - .HasColumnName("user_id"); - - b.HasKey("Id") - .HasName("pk_tenants"); - - b.HasIndex("CreatedById") - .HasDatabaseName("ix_tenants_created_by_id"); - - b.HasIndex("DeletedById") - .HasDatabaseName("ix_tenants_deleted_by_id"); - - b.HasIndex("ModifiedById") - .HasDatabaseName("ix_tenants_modified_by_id"); - - b.HasIndex("TenantId1") - .HasDatabaseName("ix_tenants_tenant_id1"); - - b.HasIndex("UserId") - .HasDatabaseName("ix_tenants_user_id"); - - b.ToTable("tenants", (string)null); - }); - - modelBuilder.Entity("IOL.GreatOffice.Api.Data.Database.TimeCategory", b => - { - b.Property<Guid>("Id") - .ValueGeneratedOnAdd() - .HasColumnType("uuid") - .HasColumnName("id"); - - b.Property<string>("Color") - .HasColumnType("text") - .HasColumnName("color"); - - b.Property<DateTime>("CreatedAt") - .HasColumnType("timestamp with time zone") - .HasColumnName("created_at"); - - b.Property<Guid?>("CreatedById") - .HasColumnType("uuid") - .HasColumnName("created_by_id"); - - b.Property<Guid?>("DeletedById") - .HasColumnType("uuid") - .HasColumnName("deleted_by_id"); - - b.Property<DateTime?>("ModifiedAt") - .HasColumnType("timestamp with time zone") - .HasColumnName("modified_at"); - - b.Property<Guid?>("ModifiedById") - .HasColumnType("uuid") - .HasColumnName("modified_by_id"); - - b.Property<string>("Name") - .HasColumnType("text") - .HasColumnName("name"); - - b.Property<Guid?>("TenantId") - .HasColumnType("uuid") - .HasColumnName("tenant_id"); - - b.Property<Guid>("UserId") - .HasColumnType("uuid") - .HasColumnName("user_id"); - - b.HasKey("Id") - .HasName("pk_time_categories"); - - b.HasIndex("CreatedById") - .HasDatabaseName("ix_time_categories_created_by_id"); - - b.HasIndex("DeletedById") - .HasDatabaseName("ix_time_categories_deleted_by_id"); - - b.HasIndex("ModifiedById") - .HasDatabaseName("ix_time_categories_modified_by_id"); - - b.HasIndex("TenantId") - .HasDatabaseName("ix_time_categories_tenant_id"); - - b.HasIndex("UserId") - .HasDatabaseName("ix_time_categories_user_id"); - - b.ToTable("time_categories", (string)null); - }); - - modelBuilder.Entity("IOL.GreatOffice.Api.Data.Database.TimeEntry", b => - { - b.Property<Guid>("Id") - .ValueGeneratedOnAdd() - .HasColumnType("uuid") - .HasColumnName("id"); - - b.Property<Guid?>("CategoryId") - .HasColumnType("uuid") - .HasColumnName("category_id"); - - b.Property<DateTime>("CreatedAt") - .HasColumnType("timestamp with time zone") - .HasColumnName("created_at"); - - b.Property<Guid?>("CreatedById") - .HasColumnType("uuid") - .HasColumnName("created_by_id"); - - b.Property<Guid?>("DeletedById") - .HasColumnType("uuid") - .HasColumnName("deleted_by_id"); - - b.Property<string>("Description") - .HasColumnType("text") - .HasColumnName("description"); - - b.Property<DateTime?>("ModifiedAt") - .HasColumnType("timestamp with time zone") - .HasColumnName("modified_at"); - - b.Property<Guid?>("ModifiedById") - .HasColumnType("uuid") - .HasColumnName("modified_by_id"); - - b.Property<DateTime>("Start") - .HasColumnType("timestamp with time zone") - .HasColumnName("start"); - - b.Property<DateTime>("Stop") - .HasColumnType("timestamp with time zone") - .HasColumnName("stop"); - - b.Property<Guid?>("TenantId") - .HasColumnType("uuid") - .HasColumnName("tenant_id"); - - b.Property<Guid>("UserId") - .HasColumnType("uuid") - .HasColumnName("user_id"); - - b.HasKey("Id") - .HasName("pk_time_entries"); - - b.HasIndex("CategoryId") - .HasDatabaseName("ix_time_entries_category_id"); - - b.HasIndex("CreatedById") - .HasDatabaseName("ix_time_entries_created_by_id"); - - b.HasIndex("DeletedById") - .HasDatabaseName("ix_time_entries_deleted_by_id"); - - b.HasIndex("ModifiedById") - .HasDatabaseName("ix_time_entries_modified_by_id"); - - b.HasIndex("TenantId") - .HasDatabaseName("ix_time_entries_tenant_id"); - - b.HasIndex("UserId") - .HasDatabaseName("ix_time_entries_user_id"); - - b.ToTable("time_entries", (string)null); - }); - - modelBuilder.Entity("IOL.GreatOffice.Api.Data.Database.TimeLabel", b => - { - b.Property<Guid>("Id") - .ValueGeneratedOnAdd() - .HasColumnType("uuid") - .HasColumnName("id"); - - b.Property<string>("Color") - .HasColumnType("text") - .HasColumnName("color"); - - b.Property<DateTime>("CreatedAt") - .HasColumnType("timestamp with time zone") - .HasColumnName("created_at"); - - b.Property<Guid?>("CreatedById") - .HasColumnType("uuid") - .HasColumnName("created_by_id"); - - b.Property<Guid?>("DeletedById") - .HasColumnType("uuid") - .HasColumnName("deleted_by_id"); - - b.Property<DateTime?>("ModifiedAt") - .HasColumnType("timestamp with time zone") - .HasColumnName("modified_at"); - - b.Property<Guid?>("ModifiedById") - .HasColumnType("uuid") - .HasColumnName("modified_by_id"); - - b.Property<string>("Name") - .HasColumnType("text") - .HasColumnName("name"); - - b.Property<Guid?>("TenantId") - .HasColumnType("uuid") - .HasColumnName("tenant_id"); - - b.Property<Guid?>("TimeEntryId") - .HasColumnType("uuid") - .HasColumnName("time_entry_id"); - - b.Property<Guid>("UserId") - .HasColumnType("uuid") - .HasColumnName("user_id"); - - b.HasKey("Id") - .HasName("pk_time_labels"); - - b.HasIndex("CreatedById") - .HasDatabaseName("ix_time_labels_created_by_id"); - - b.HasIndex("DeletedById") - .HasDatabaseName("ix_time_labels_deleted_by_id"); - - b.HasIndex("ModifiedById") - .HasDatabaseName("ix_time_labels_modified_by_id"); - - b.HasIndex("TenantId") - .HasDatabaseName("ix_time_labels_tenant_id"); - - b.HasIndex("TimeEntryId") - .HasDatabaseName("ix_time_labels_time_entry_id"); - - b.HasIndex("UserId") - .HasDatabaseName("ix_time_labels_user_id"); - - b.ToTable("time_labels", (string)null); - }); - - modelBuilder.Entity("IOL.GreatOffice.Api.Data.Database.User", b => - { - b.Property<Guid>("Id") - .ValueGeneratedOnAdd() - .HasColumnType("uuid") - .HasColumnName("id"); - - b.Property<DateTime>("CreatedAt") - .HasColumnType("timestamp with time zone") - .HasColumnName("created_at"); - - b.Property<DateTime?>("ModifiedAt") - .HasColumnType("timestamp with time zone") - .HasColumnName("modified_at"); - - b.Property<string>("Password") - .HasColumnType("text") - .HasColumnName("password"); - - b.Property<string>("Username") - .HasColumnType("text") - .HasColumnName("username"); - - b.HasKey("Id") - .HasName("pk_users"); - - b.ToTable("users", (string)null); - }); - - modelBuilder.Entity("IOL.GreatOffice.Api.Data.Database.ApiAccessToken", b => - { - b.HasOne("IOL.GreatOffice.Api.Data.Database.User", "User") - .WithMany() - .HasForeignKey("UserId") - .HasConstraintName("fk_api_access_tokens_users_user_id"); - - b.Navigation("User"); - }); - - modelBuilder.Entity("IOL.GreatOffice.Api.Data.Database.ForgotPasswordRequest", b => - { - b.HasOne("IOL.GreatOffice.Api.Data.Database.User", "User") - .WithMany() - .HasForeignKey("UserId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired() - .HasConstraintName("fk_forgot_password_requests_users_user_id"); - - b.Navigation("User"); - }); - - modelBuilder.Entity("IOL.GreatOffice.Api.Data.Database.GithubUserMapping", b => - { - b.HasOne("IOL.GreatOffice.Api.Data.Database.User", "User") - .WithMany() - .HasForeignKey("UserId") - .HasConstraintName("fk_github_user_mappings_users_user_id"); - - b.Navigation("User"); - }); - - modelBuilder.Entity("IOL.GreatOffice.Api.Data.Database.Tenant", b => - { - b.HasOne("IOL.GreatOffice.Api.Data.Database.User", "CreatedBy") - .WithMany() - .HasForeignKey("CreatedById") - .HasConstraintName("fk_tenants_users_created_by_id"); - - b.HasOne("IOL.GreatOffice.Api.Data.Database.User", "DeletedBy") - .WithMany() - .HasForeignKey("DeletedById") - .HasConstraintName("fk_tenants_users_deleted_by_id"); - - b.HasOne("IOL.GreatOffice.Api.Data.Database.User", "ModifiedBy") - .WithMany() - .HasForeignKey("ModifiedById") - .HasConstraintName("fk_tenants_users_modified_by_id"); - - b.HasOne("IOL.GreatOffice.Api.Data.Database.Tenant", "Tenant") - .WithMany() - .HasForeignKey("TenantId1") - .HasConstraintName("fk_tenants_tenants_tenant_id1"); - - b.HasOne("IOL.GreatOffice.Api.Data.Database.User", "User") - .WithMany() - .HasForeignKey("UserId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired() - .HasConstraintName("fk_tenants_users_user_id"); - - b.Navigation("CreatedBy"); - - b.Navigation("DeletedBy"); - - b.Navigation("ModifiedBy"); - - b.Navigation("Tenant"); - - b.Navigation("User"); - }); - - modelBuilder.Entity("IOL.GreatOffice.Api.Data.Database.TimeCategory", b => - { - b.HasOne("IOL.GreatOffice.Api.Data.Database.User", "CreatedBy") - .WithMany() - .HasForeignKey("CreatedById") - .HasConstraintName("fk_time_categories_users_created_by_id"); - - b.HasOne("IOL.GreatOffice.Api.Data.Database.User", "DeletedBy") - .WithMany() - .HasForeignKey("DeletedById") - .HasConstraintName("fk_time_categories_users_deleted_by_id"); - - b.HasOne("IOL.GreatOffice.Api.Data.Database.User", "ModifiedBy") - .WithMany() - .HasForeignKey("ModifiedById") - .HasConstraintName("fk_time_categories_users_modified_by_id"); - - b.HasOne("IOL.GreatOffice.Api.Data.Database.Tenant", "Tenant") - .WithMany() - .HasForeignKey("TenantId") - .HasConstraintName("fk_time_categories_tenants_tenant_id"); - - b.HasOne("IOL.GreatOffice.Api.Data.Database.User", "User") - .WithMany() - .HasForeignKey("UserId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired() - .HasConstraintName("fk_time_categories_users_user_id"); - - b.Navigation("CreatedBy"); - - b.Navigation("DeletedBy"); - - b.Navigation("ModifiedBy"); - - b.Navigation("Tenant"); - - b.Navigation("User"); - }); - - modelBuilder.Entity("IOL.GreatOffice.Api.Data.Database.TimeEntry", b => - { - b.HasOne("IOL.GreatOffice.Api.Data.Database.TimeCategory", "Category") - .WithMany() - .HasForeignKey("CategoryId") - .HasConstraintName("fk_time_entries_time_categories_category_id"); - - b.HasOne("IOL.GreatOffice.Api.Data.Database.User", "CreatedBy") - .WithMany() - .HasForeignKey("CreatedById") - .HasConstraintName("fk_time_entries_users_created_by_id"); - - b.HasOne("IOL.GreatOffice.Api.Data.Database.User", "DeletedBy") - .WithMany() - .HasForeignKey("DeletedById") - .HasConstraintName("fk_time_entries_users_deleted_by_id"); - - b.HasOne("IOL.GreatOffice.Api.Data.Database.User", "ModifiedBy") - .WithMany() - .HasForeignKey("ModifiedById") - .HasConstraintName("fk_time_entries_users_modified_by_id"); - - b.HasOne("IOL.GreatOffice.Api.Data.Database.Tenant", "Tenant") - .WithMany() - .HasForeignKey("TenantId") - .HasConstraintName("fk_time_entries_tenants_tenant_id"); - - b.HasOne("IOL.GreatOffice.Api.Data.Database.User", "User") - .WithMany() - .HasForeignKey("UserId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired() - .HasConstraintName("fk_time_entries_users_user_id"); - - b.Navigation("Category"); - - b.Navigation("CreatedBy"); - - b.Navigation("DeletedBy"); - - b.Navigation("ModifiedBy"); - - b.Navigation("Tenant"); - - b.Navigation("User"); - }); - - modelBuilder.Entity("IOL.GreatOffice.Api.Data.Database.TimeLabel", b => - { - b.HasOne("IOL.GreatOffice.Api.Data.Database.User", "CreatedBy") - .WithMany() - .HasForeignKey("CreatedById") - .HasConstraintName("fk_time_labels_users_created_by_id"); - - b.HasOne("IOL.GreatOffice.Api.Data.Database.User", "DeletedBy") - .WithMany() - .HasForeignKey("DeletedById") - .HasConstraintName("fk_time_labels_users_deleted_by_id"); - - b.HasOne("IOL.GreatOffice.Api.Data.Database.User", "ModifiedBy") - .WithMany() - .HasForeignKey("ModifiedById") - .HasConstraintName("fk_time_labels_users_modified_by_id"); - - b.HasOne("IOL.GreatOffice.Api.Data.Database.Tenant", "Tenant") - .WithMany() - .HasForeignKey("TenantId") - .HasConstraintName("fk_time_labels_tenants_tenant_id"); - - b.HasOne("IOL.GreatOffice.Api.Data.Database.TimeEntry", null) - .WithMany("Labels") - .HasForeignKey("TimeEntryId") - .HasConstraintName("fk_time_labels_time_entries_time_entry_id"); - - b.HasOne("IOL.GreatOffice.Api.Data.Database.User", "User") - .WithMany() - .HasForeignKey("UserId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired() - .HasConstraintName("fk_time_labels_users_user_id"); - - b.Navigation("CreatedBy"); - - b.Navigation("DeletedBy"); - - b.Navigation("ModifiedBy"); - - b.Navigation("Tenant"); - - b.Navigation("User"); - }); - - modelBuilder.Entity("IOL.GreatOffice.Api.Data.Database.TimeEntry", b => - { - b.Navigation("Labels"); - }); -#pragma warning restore 612, 618 - } - } -} diff --git a/server/src/Migrations/20220602214238_NullableOptionalBaseFields.cs b/server/src/Migrations/20220602214238_NullableOptionalBaseFields.cs deleted file mode 100644 index eebab5c..0000000 --- a/server/src/Migrations/20220602214238_NullableOptionalBaseFields.cs +++ /dev/null @@ -1,649 +0,0 @@ -using System; -using Microsoft.EntityFrameworkCore.Migrations; - -#nullable disable - -namespace IOL.GreatOffice.Api.Migrations -{ - public partial class NullableOptionalBaseFields : Migration - { - protected override void Up(MigrationBuilder migrationBuilder) - { - migrationBuilder.DropForeignKey( - name: "fk_tenants_users_created_by_id", - table: "tenants"); - - migrationBuilder.DropForeignKey( - name: "fk_tenants_users_deleted_by_id", - table: "tenants"); - - migrationBuilder.DropForeignKey( - name: "fk_tenants_users_modified_by_id", - table: "tenants"); - - migrationBuilder.DropForeignKey( - name: "fk_time_categories_tenants_tenant_id", - table: "time_categories"); - - migrationBuilder.DropForeignKey( - name: "fk_time_categories_users_created_by_id", - table: "time_categories"); - - migrationBuilder.DropForeignKey( - name: "fk_time_categories_users_deleted_by_id", - table: "time_categories"); - - migrationBuilder.DropForeignKey( - name: "fk_time_categories_users_modified_by_id", - table: "time_categories"); - - migrationBuilder.DropForeignKey( - name: "fk_time_entries_tenants_tenant_id", - table: "time_entries"); - - migrationBuilder.DropForeignKey( - name: "fk_time_entries_users_created_by_id", - table: "time_entries"); - - migrationBuilder.DropForeignKey( - name: "fk_time_entries_users_deleted_by_id", - table: "time_entries"); - - migrationBuilder.DropForeignKey( - name: "fk_time_entries_users_modified_by_id", - table: "time_entries"); - - migrationBuilder.DropForeignKey( - name: "fk_time_labels_tenants_tenant_id", - table: "time_labels"); - - migrationBuilder.DropForeignKey( - name: "fk_time_labels_users_created_by_id", - table: "time_labels"); - - migrationBuilder.DropForeignKey( - name: "fk_time_labels_users_deleted_by_id", - table: "time_labels"); - - migrationBuilder.DropForeignKey( - name: "fk_time_labels_users_modified_by_id", - table: "time_labels"); - - migrationBuilder.AlterColumn<Guid>( - name: "tenant_id", - table: "time_labels", - type: "uuid", - nullable: true, - oldClrType: typeof(Guid), - oldType: "uuid"); - - migrationBuilder.AlterColumn<Guid>( - name: "modified_by_id", - table: "time_labels", - type: "uuid", - nullable: true, - oldClrType: typeof(Guid), - oldType: "uuid"); - - migrationBuilder.AlterColumn<Guid>( - name: "deleted_by_id", - table: "time_labels", - type: "uuid", - nullable: true, - oldClrType: typeof(Guid), - oldType: "uuid"); - - migrationBuilder.AlterColumn<Guid>( - name: "created_by_id", - table: "time_labels", - type: "uuid", - nullable: true, - oldClrType: typeof(Guid), - oldType: "uuid"); - - migrationBuilder.AlterColumn<Guid>( - name: "tenant_id", - table: "time_entries", - type: "uuid", - nullable: true, - oldClrType: typeof(Guid), - oldType: "uuid"); - - migrationBuilder.AlterColumn<Guid>( - name: "modified_by_id", - table: "time_entries", - type: "uuid", - nullable: true, - oldClrType: typeof(Guid), - oldType: "uuid"); - - migrationBuilder.AlterColumn<Guid>( - name: "deleted_by_id", - table: "time_entries", - type: "uuid", - nullable: true, - oldClrType: typeof(Guid), - oldType: "uuid"); - - migrationBuilder.AlterColumn<Guid>( - name: "created_by_id", - table: "time_entries", - type: "uuid", - nullable: true, - oldClrType: typeof(Guid), - oldType: "uuid"); - - migrationBuilder.AlterColumn<Guid>( - name: "tenant_id", - table: "time_categories", - type: "uuid", - nullable: true, - oldClrType: typeof(Guid), - oldType: "uuid"); - - migrationBuilder.AlterColumn<Guid>( - name: "modified_by_id", - table: "time_categories", - type: "uuid", - nullable: true, - oldClrType: typeof(Guid), - oldType: "uuid"); - - migrationBuilder.AlterColumn<Guid>( - name: "deleted_by_id", - table: "time_categories", - type: "uuid", - nullable: true, - oldClrType: typeof(Guid), - oldType: "uuid"); - - migrationBuilder.AlterColumn<Guid>( - name: "created_by_id", - table: "time_categories", - type: "uuid", - nullable: true, - oldClrType: typeof(Guid), - oldType: "uuid"); - - migrationBuilder.AlterColumn<Guid>( - name: "tenant_id", - table: "tenants", - type: "uuid", - nullable: true, - oldClrType: typeof(Guid), - oldType: "uuid"); - - migrationBuilder.AlterColumn<Guid>( - name: "modified_by_id", - table: "tenants", - type: "uuid", - nullable: true, - oldClrType: typeof(Guid), - oldType: "uuid"); - - migrationBuilder.AlterColumn<Guid>( - name: "deleted_by_id", - table: "tenants", - type: "uuid", - nullable: true, - oldClrType: typeof(Guid), - oldType: "uuid"); - - migrationBuilder.AlterColumn<Guid>( - name: "created_by_id", - table: "tenants", - type: "uuid", - nullable: true, - oldClrType: typeof(Guid), - oldType: "uuid"); - - migrationBuilder.AddForeignKey( - name: "fk_tenants_users_created_by_id", - table: "tenants", - column: "created_by_id", - principalTable: "users", - principalColumn: "id"); - - migrationBuilder.AddForeignKey( - name: "fk_tenants_users_deleted_by_id", - table: "tenants", - column: "deleted_by_id", - principalTable: "users", - principalColumn: "id"); - - migrationBuilder.AddForeignKey( - name: "fk_tenants_users_modified_by_id", - table: "tenants", - column: "modified_by_id", - principalTable: "users", - principalColumn: "id"); - - migrationBuilder.AddForeignKey( - name: "fk_time_categories_tenants_tenant_id", - table: "time_categories", - column: "tenant_id", - principalTable: "tenants", - principalColumn: "id"); - - migrationBuilder.AddForeignKey( - name: "fk_time_categories_users_created_by_id", - table: "time_categories", - column: "created_by_id", - principalTable: "users", - principalColumn: "id"); - - migrationBuilder.AddForeignKey( - name: "fk_time_categories_users_deleted_by_id", - table: "time_categories", - column: "deleted_by_id", - principalTable: "users", - principalColumn: "id"); - - migrationBuilder.AddForeignKey( - name: "fk_time_categories_users_modified_by_id", - table: "time_categories", - column: "modified_by_id", - principalTable: "users", - principalColumn: "id"); - - migrationBuilder.AddForeignKey( - name: "fk_time_entries_tenants_tenant_id", - table: "time_entries", - column: "tenant_id", - principalTable: "tenants", - principalColumn: "id"); - - migrationBuilder.AddForeignKey( - name: "fk_time_entries_users_created_by_id", - table: "time_entries", - column: "created_by_id", - principalTable: "users", - principalColumn: "id"); - - migrationBuilder.AddForeignKey( - name: "fk_time_entries_users_deleted_by_id", - table: "time_entries", - column: "deleted_by_id", - principalTable: "users", - principalColumn: "id"); - - migrationBuilder.AddForeignKey( - name: "fk_time_entries_users_modified_by_id", - table: "time_entries", - column: "modified_by_id", - principalTable: "users", - principalColumn: "id"); - - migrationBuilder.AddForeignKey( - name: "fk_time_labels_tenants_tenant_id", - table: "time_labels", - column: "tenant_id", - principalTable: "tenants", - principalColumn: "id"); - - migrationBuilder.AddForeignKey( - name: "fk_time_labels_users_created_by_id", - table: "time_labels", - column: "created_by_id", - principalTable: "users", - principalColumn: "id"); - - migrationBuilder.AddForeignKey( - name: "fk_time_labels_users_deleted_by_id", - table: "time_labels", - column: "deleted_by_id", - principalTable: "users", - principalColumn: "id"); - - migrationBuilder.AddForeignKey( - name: "fk_time_labels_users_modified_by_id", - table: "time_labels", - column: "modified_by_id", - principalTable: "users", - principalColumn: "id"); - } - - protected override void Down(MigrationBuilder migrationBuilder) - { - migrationBuilder.DropForeignKey( - name: "fk_tenants_users_created_by_id", - table: "tenants"); - - migrationBuilder.DropForeignKey( - name: "fk_tenants_users_deleted_by_id", - table: "tenants"); - - migrationBuilder.DropForeignKey( - name: "fk_tenants_users_modified_by_id", - table: "tenants"); - - migrationBuilder.DropForeignKey( - name: "fk_time_categories_tenants_tenant_id", - table: "time_categories"); - - migrationBuilder.DropForeignKey( - name: "fk_time_categories_users_created_by_id", - table: "time_categories"); - - migrationBuilder.DropForeignKey( - name: "fk_time_categories_users_deleted_by_id", - table: "time_categories"); - - migrationBuilder.DropForeignKey( - name: "fk_time_categories_users_modified_by_id", - table: "time_categories"); - - migrationBuilder.DropForeignKey( - name: "fk_time_entries_tenants_tenant_id", - table: "time_entries"); - - migrationBuilder.DropForeignKey( - name: "fk_time_entries_users_created_by_id", - table: "time_entries"); - - migrationBuilder.DropForeignKey( - name: "fk_time_entries_users_deleted_by_id", - table: "time_entries"); - - migrationBuilder.DropForeignKey( - name: "fk_time_entries_users_modified_by_id", - table: "time_entries"); - - migrationBuilder.DropForeignKey( - name: "fk_time_labels_tenants_tenant_id", - table: "time_labels"); - - migrationBuilder.DropForeignKey( - name: "fk_time_labels_users_created_by_id", - table: "time_labels"); - - migrationBuilder.DropForeignKey( - name: "fk_time_labels_users_deleted_by_id", - table: "time_labels"); - - migrationBuilder.DropForeignKey( - name: "fk_time_labels_users_modified_by_id", - table: "time_labels"); - - migrationBuilder.AlterColumn<Guid>( - name: "tenant_id", - table: "time_labels", - type: "uuid", - nullable: false, - defaultValue: new Guid("00000000-0000-0000-0000-000000000000"), - oldClrType: typeof(Guid), - oldType: "uuid", - oldNullable: true); - - migrationBuilder.AlterColumn<Guid>( - name: "modified_by_id", - table: "time_labels", - type: "uuid", - nullable: false, - defaultValue: new Guid("00000000-0000-0000-0000-000000000000"), - oldClrType: typeof(Guid), - oldType: "uuid", - oldNullable: true); - - migrationBuilder.AlterColumn<Guid>( - name: "deleted_by_id", - table: "time_labels", - type: "uuid", - nullable: false, - defaultValue: new Guid("00000000-0000-0000-0000-000000000000"), - oldClrType: typeof(Guid), - oldType: "uuid", - oldNullable: true); - - migrationBuilder.AlterColumn<Guid>( - name: "created_by_id", - table: "time_labels", - type: "uuid", - nullable: false, - defaultValue: new Guid("00000000-0000-0000-0000-000000000000"), - oldClrType: typeof(Guid), - oldType: "uuid", - oldNullable: true); - - migrationBuilder.AlterColumn<Guid>( - name: "tenant_id", - table: "time_entries", - type: "uuid", - nullable: false, - defaultValue: new Guid("00000000-0000-0000-0000-000000000000"), - oldClrType: typeof(Guid), - oldType: "uuid", - oldNullable: true); - - migrationBuilder.AlterColumn<Guid>( - name: "modified_by_id", - table: "time_entries", - type: "uuid", - nullable: false, - defaultValue: new Guid("00000000-0000-0000-0000-000000000000"), - oldClrType: typeof(Guid), - oldType: "uuid", - oldNullable: true); - - migrationBuilder.AlterColumn<Guid>( - name: "deleted_by_id", - table: "time_entries", - type: "uuid", - nullable: false, - defaultValue: new Guid("00000000-0000-0000-0000-000000000000"), - oldClrType: typeof(Guid), - oldType: "uuid", - oldNullable: true); - - migrationBuilder.AlterColumn<Guid>( - name: "created_by_id", - table: "time_entries", - type: "uuid", - nullable: false, - defaultValue: new Guid("00000000-0000-0000-0000-000000000000"), - oldClrType: typeof(Guid), - oldType: "uuid", - oldNullable: true); - - migrationBuilder.AlterColumn<Guid>( - name: "tenant_id", - table: "time_categories", - type: "uuid", - nullable: false, - defaultValue: new Guid("00000000-0000-0000-0000-000000000000"), - oldClrType: typeof(Guid), - oldType: "uuid", - oldNullable: true); - - migrationBuilder.AlterColumn<Guid>( - name: "modified_by_id", - table: "time_categories", - type: "uuid", - nullable: false, - defaultValue: new Guid("00000000-0000-0000-0000-000000000000"), - oldClrType: typeof(Guid), - oldType: "uuid", - oldNullable: true); - - migrationBuilder.AlterColumn<Guid>( - name: "deleted_by_id", - table: "time_categories", - type: "uuid", - nullable: false, - defaultValue: new Guid("00000000-0000-0000-0000-000000000000"), - oldClrType: typeof(Guid), - oldType: "uuid", - oldNullable: true); - - migrationBuilder.AlterColumn<Guid>( - name: "created_by_id", - table: "time_categories", - type: "uuid", - nullable: false, - defaultValue: new Guid("00000000-0000-0000-0000-000000000000"), - oldClrType: typeof(Guid), - oldType: "uuid", - oldNullable: true); - - migrationBuilder.AlterColumn<Guid>( - name: "tenant_id", - table: "tenants", - type: "uuid", - nullable: false, - defaultValue: new Guid("00000000-0000-0000-0000-000000000000"), - oldClrType: typeof(Guid), - oldType: "uuid", - oldNullable: true); - - migrationBuilder.AlterColumn<Guid>( - name: "modified_by_id", - table: "tenants", - type: "uuid", - nullable: false, - defaultValue: new Guid("00000000-0000-0000-0000-000000000000"), - oldClrType: typeof(Guid), - oldType: "uuid", - oldNullable: true); - - migrationBuilder.AlterColumn<Guid>( - name: "deleted_by_id", - table: "tenants", - type: "uuid", - nullable: false, - defaultValue: new Guid("00000000-0000-0000-0000-000000000000"), - oldClrType: typeof(Guid), - oldType: "uuid", - oldNullable: true); - - migrationBuilder.AlterColumn<Guid>( - name: "created_by_id", - table: "tenants", - type: "uuid", - nullable: false, - defaultValue: new Guid("00000000-0000-0000-0000-000000000000"), - oldClrType: typeof(Guid), - oldType: "uuid", - oldNullable: true); - - migrationBuilder.AddForeignKey( - name: "fk_tenants_users_created_by_id", - table: "tenants", - column: "created_by_id", - principalTable: "users", - principalColumn: "id", - onDelete: ReferentialAction.Cascade); - - migrationBuilder.AddForeignKey( - name: "fk_tenants_users_deleted_by_id", - table: "tenants", - column: "deleted_by_id", - principalTable: "users", - principalColumn: "id", - onDelete: ReferentialAction.Cascade); - - migrationBuilder.AddForeignKey( - name: "fk_tenants_users_modified_by_id", - table: "tenants", - column: "modified_by_id", - principalTable: "users", - principalColumn: "id", - onDelete: ReferentialAction.Cascade); - - migrationBuilder.AddForeignKey( - name: "fk_time_categories_tenants_tenant_id", - table: "time_categories", - column: "tenant_id", - principalTable: "tenants", - principalColumn: "id", - onDelete: ReferentialAction.Cascade); - - migrationBuilder.AddForeignKey( - name: "fk_time_categories_users_created_by_id", - table: "time_categories", - column: "created_by_id", - principalTable: "users", - principalColumn: "id", - onDelete: ReferentialAction.Cascade); - - migrationBuilder.AddForeignKey( - name: "fk_time_categories_users_deleted_by_id", - table: "time_categories", - column: "deleted_by_id", - principalTable: "users", - principalColumn: "id", - onDelete: ReferentialAction.Cascade); - - migrationBuilder.AddForeignKey( - name: "fk_time_categories_users_modified_by_id", - table: "time_categories", - column: "modified_by_id", - principalTable: "users", - principalColumn: "id", - onDelete: ReferentialAction.Cascade); - - migrationBuilder.AddForeignKey( - name: "fk_time_entries_tenants_tenant_id", - table: "time_entries", - column: "tenant_id", - principalTable: "tenants", - principalColumn: "id", - onDelete: ReferentialAction.Cascade); - - migrationBuilder.AddForeignKey( - name: "fk_time_entries_users_created_by_id", - table: "time_entries", - column: "created_by_id", - principalTable: "users", - principalColumn: "id", - onDelete: ReferentialAction.Cascade); - - migrationBuilder.AddForeignKey( - name: "fk_time_entries_users_deleted_by_id", - table: "time_entries", - column: "deleted_by_id", - principalTable: "users", - principalColumn: "id", - onDelete: ReferentialAction.Cascade); - - migrationBuilder.AddForeignKey( - name: "fk_time_entries_users_modified_by_id", - table: "time_entries", - column: "modified_by_id", - principalTable: "users", - principalColumn: "id", - onDelete: ReferentialAction.Cascade); - - migrationBuilder.AddForeignKey( - name: "fk_time_labels_tenants_tenant_id", - table: "time_labels", - column: "tenant_id", - principalTable: "tenants", - principalColumn: "id", - onDelete: ReferentialAction.Cascade); - - migrationBuilder.AddForeignKey( - name: "fk_time_labels_users_created_by_id", - table: "time_labels", - column: "created_by_id", - principalTable: "users", - principalColumn: "id", - onDelete: ReferentialAction.Cascade); - - migrationBuilder.AddForeignKey( - name: "fk_time_labels_users_deleted_by_id", - table: "time_labels", - column: "deleted_by_id", - principalTable: "users", - principalColumn: "id", - onDelete: ReferentialAction.Cascade); - - migrationBuilder.AddForeignKey( - name: "fk_time_labels_users_modified_by_id", - table: "time_labels", - column: "modified_by_id", - principalTable: "users", - principalColumn: "id", - onDelete: ReferentialAction.Cascade); - } - } -} diff --git a/server/src/Migrations/20220606232346_FleshOutNewModules.Designer.cs b/server/src/Migrations/20220606232346_FleshOutNewModules.Designer.cs deleted file mode 100644 index 69d4f7e..0000000 --- a/server/src/Migrations/20220606232346_FleshOutNewModules.Designer.cs +++ /dev/null @@ -1,510 +0,0 @@ -// <auto-generated /> -using System; -using IOL.GreatOffice.Api.Data; -using Microsoft.EntityFrameworkCore; -using Microsoft.EntityFrameworkCore.Infrastructure; -using Microsoft.EntityFrameworkCore.Migrations; -using Microsoft.EntityFrameworkCore.Storage.ValueConversion; -using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata; - -#nullable disable - -namespace IOL.GreatOffice.Api.Migrations -{ - [DbContext(typeof(AppDbContext))] - [Migration("20220606232346_FleshOutNewModules")] - partial class FleshOutNewModules - { - protected override void BuildTargetModel(ModelBuilder modelBuilder) - { -#pragma warning disable 612, 618 - modelBuilder - .HasAnnotation("ProductVersion", "6.0.5") - .HasAnnotation("Relational:MaxIdentifierLength", 63); - - NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder); - - modelBuilder.Entity("IOL.GreatOffice.Api.Data.Database.ApiAccessToken", b => - { - b.Property<Guid>("Id") - .ValueGeneratedOnAdd() - .HasColumnType("uuid") - .HasColumnName("id"); - - b.Property<bool>("AllowCreate") - .HasColumnType("boolean") - .HasColumnName("allow_create"); - - b.Property<bool>("AllowDelete") - .HasColumnType("boolean") - .HasColumnName("allow_delete"); - - b.Property<bool>("AllowRead") - .HasColumnType("boolean") - .HasColumnName("allow_read"); - - b.Property<bool>("AllowUpdate") - .HasColumnType("boolean") - .HasColumnName("allow_update"); - - b.Property<DateTime>("CreatedAt") - .HasColumnType("timestamp with time zone") - .HasColumnName("created_at"); - - b.Property<bool>("Deleted") - .HasColumnType("boolean") - .HasColumnName("deleted"); - - b.Property<DateTime>("ExpiryDate") - .HasColumnType("timestamp with time zone") - .HasColumnName("expiry_date"); - - b.Property<DateTime?>("ModifiedAt") - .HasColumnType("timestamp with time zone") - .HasColumnName("modified_at"); - - b.Property<Guid?>("UserId") - .HasColumnType("uuid") - .HasColumnName("user_id"); - - b.HasKey("Id") - .HasName("pk_api_access_tokens"); - - b.HasIndex("UserId") - .HasDatabaseName("ix_api_access_tokens_user_id"); - - b.ToTable("api_access_tokens", (string)null); - }); - - modelBuilder.Entity("IOL.GreatOffice.Api.Data.Database.ForgotPasswordRequest", b => - { - b.Property<Guid>("Id") - .ValueGeneratedOnAdd() - .HasColumnType("uuid") - .HasColumnName("id"); - - b.Property<DateTime>("CreatedAt") - .HasColumnType("timestamp with time zone") - .HasColumnName("created_at"); - - b.Property<Guid>("UserId") - .HasColumnType("uuid") - .HasColumnName("user_id"); - - b.HasKey("Id") - .HasName("pk_forgot_password_requests"); - - b.HasIndex("UserId") - .HasDatabaseName("ix_forgot_password_requests_user_id"); - - b.ToTable("forgot_password_requests", (string)null); - }); - - modelBuilder.Entity("IOL.GreatOffice.Api.Data.Database.GithubUserMapping", b => - { - b.Property<string>("GithubId") - .HasColumnType("text") - .HasColumnName("github_id"); - - b.Property<string>("Email") - .HasColumnType("text") - .HasColumnName("email"); - - b.Property<string>("RefreshToken") - .HasColumnType("text") - .HasColumnName("refresh_token"); - - b.Property<Guid?>("UserId") - .HasColumnType("uuid") - .HasColumnName("user_id"); - - b.HasKey("GithubId") - .HasName("pk_github_user_mappings"); - - b.HasIndex("UserId") - .HasDatabaseName("ix_github_user_mappings_user_id"); - - b.ToTable("github_user_mappings", (string)null); - }); - - modelBuilder.Entity("IOL.GreatOffice.Api.Data.Database.Tenant", b => - { - b.Property<Guid>("Id") - .ValueGeneratedOnAdd() - .HasColumnType("uuid") - .HasColumnName("id"); - - b.Property<string>("ContactEmail") - .HasColumnType("text") - .HasColumnName("contact_email"); - - b.Property<DateTime>("CreatedAt") - .HasColumnType("timestamp with time zone") - .HasColumnName("created_at"); - - b.Property<Guid?>("CreatedById") - .HasColumnType("uuid") - .HasColumnName("created_by_id"); - - b.Property<bool>("Deleted") - .HasColumnType("boolean") - .HasColumnName("deleted"); - - b.Property<Guid?>("DeletedById") - .HasColumnType("uuid") - .HasColumnName("deleted_by_id"); - - b.Property<string>("Description") - .HasColumnType("text") - .HasColumnName("description"); - - b.Property<Guid>("MasterUserId") - .HasColumnType("uuid") - .HasColumnName("master_user_id"); - - b.Property<string>("MasterUserPassword") - .HasColumnType("text") - .HasColumnName("master_user_password"); - - b.Property<DateTime?>("ModifiedAt") - .HasColumnType("timestamp with time zone") - .HasColumnName("modified_at"); - - b.Property<Guid?>("ModifiedById") - .HasColumnType("uuid") - .HasColumnName("modified_by_id"); - - b.Property<string>("Name") - .HasColumnType("text") - .HasColumnName("name"); - - b.Property<Guid?>("TenantId") - .HasColumnType("uuid") - .HasColumnName("tenant_id"); - - b.Property<Guid?>("UserId") - .HasColumnType("uuid") - .HasColumnName("user_id"); - - b.HasKey("Id") - .HasName("pk_tenants"); - - b.ToTable("tenants", (string)null); - }); - - modelBuilder.Entity("IOL.GreatOffice.Api.Data.Database.TimeCategory", b => - { - b.Property<Guid>("Id") - .ValueGeneratedOnAdd() - .HasColumnType("uuid") - .HasColumnName("id"); - - b.Property<string>("Color") - .HasColumnType("text") - .HasColumnName("color"); - - b.Property<DateTime>("CreatedAt") - .HasColumnType("timestamp with time zone") - .HasColumnName("created_at"); - - b.Property<Guid?>("CreatedById") - .HasColumnType("uuid") - .HasColumnName("created_by_id"); - - b.Property<bool>("Deleted") - .HasColumnType("boolean") - .HasColumnName("deleted"); - - b.Property<Guid?>("DeletedById") - .HasColumnType("uuid") - .HasColumnName("deleted_by_id"); - - b.Property<DateTime?>("ModifiedAt") - .HasColumnType("timestamp with time zone") - .HasColumnName("modified_at"); - - b.Property<Guid?>("ModifiedById") - .HasColumnType("uuid") - .HasColumnName("modified_by_id"); - - b.Property<string>("Name") - .HasColumnType("text") - .HasColumnName("name"); - - b.Property<Guid?>("TenantId") - .HasColumnType("uuid") - .HasColumnName("tenant_id"); - - b.Property<Guid?>("UserId") - .HasColumnType("uuid") - .HasColumnName("user_id"); - - b.HasKey("Id") - .HasName("pk_time_categories"); - - b.ToTable("time_categories", (string)null); - }); - - modelBuilder.Entity("IOL.GreatOffice.Api.Data.Database.TimeEntry", b => - { - b.Property<Guid>("Id") - .ValueGeneratedOnAdd() - .HasColumnType("uuid") - .HasColumnName("id"); - - b.Property<Guid?>("CategoryId") - .HasColumnType("uuid") - .HasColumnName("category_id"); - - b.Property<DateTime>("CreatedAt") - .HasColumnType("timestamp with time zone") - .HasColumnName("created_at"); - - b.Property<Guid?>("CreatedById") - .HasColumnType("uuid") - .HasColumnName("created_by_id"); - - b.Property<bool>("Deleted") - .HasColumnType("boolean") - .HasColumnName("deleted"); - - b.Property<Guid?>("DeletedById") - .HasColumnType("uuid") - .HasColumnName("deleted_by_id"); - - b.Property<string>("Description") - .HasColumnType("text") - .HasColumnName("description"); - - b.Property<DateTime?>("ModifiedAt") - .HasColumnType("timestamp with time zone") - .HasColumnName("modified_at"); - - b.Property<Guid?>("ModifiedById") - .HasColumnType("uuid") - .HasColumnName("modified_by_id"); - - b.Property<DateTime>("Start") - .HasColumnType("timestamp with time zone") - .HasColumnName("start"); - - b.Property<DateTime>("Stop") - .HasColumnType("timestamp with time zone") - .HasColumnName("stop"); - - b.Property<Guid?>("TenantId") - .HasColumnType("uuid") - .HasColumnName("tenant_id"); - - b.Property<Guid?>("UserId") - .HasColumnType("uuid") - .HasColumnName("user_id"); - - b.HasKey("Id") - .HasName("pk_time_entries"); - - b.HasIndex("CategoryId") - .HasDatabaseName("ix_time_entries_category_id"); - - b.ToTable("time_entries", (string)null); - }); - - modelBuilder.Entity("IOL.GreatOffice.Api.Data.Database.TimeLabel", b => - { - b.Property<Guid>("Id") - .ValueGeneratedOnAdd() - .HasColumnType("uuid") - .HasColumnName("id"); - - b.Property<string>("Color") - .HasColumnType("text") - .HasColumnName("color"); - - b.Property<DateTime>("CreatedAt") - .HasColumnType("timestamp with time zone") - .HasColumnName("created_at"); - - b.Property<Guid?>("CreatedById") - .HasColumnType("uuid") - .HasColumnName("created_by_id"); - - b.Property<bool>("Deleted") - .HasColumnType("boolean") - .HasColumnName("deleted"); - - b.Property<Guid?>("DeletedById") - .HasColumnType("uuid") - .HasColumnName("deleted_by_id"); - - b.Property<DateTime?>("ModifiedAt") - .HasColumnType("timestamp with time zone") - .HasColumnName("modified_at"); - - b.Property<Guid?>("ModifiedById") - .HasColumnType("uuid") - .HasColumnName("modified_by_id"); - - b.Property<string>("Name") - .HasColumnType("text") - .HasColumnName("name"); - - b.Property<Guid?>("TenantId") - .HasColumnType("uuid") - .HasColumnName("tenant_id"); - - b.Property<Guid?>("TimeEntryId") - .HasColumnType("uuid") - .HasColumnName("time_entry_id"); - - b.Property<Guid?>("UserId") - .HasColumnType("uuid") - .HasColumnName("user_id"); - - b.HasKey("Id") - .HasName("pk_time_labels"); - - b.HasIndex("TimeEntryId") - .HasDatabaseName("ix_time_labels_time_entry_id"); - - b.ToTable("time_labels", (string)null); - }); - - modelBuilder.Entity("IOL.GreatOffice.Api.Data.Database.User", b => - { - b.Property<Guid>("Id") - .ValueGeneratedOnAdd() - .HasColumnType("uuid") - .HasColumnName("id"); - - b.Property<DateTime>("CreatedAt") - .HasColumnType("timestamp with time zone") - .HasColumnName("created_at"); - - b.Property<bool>("Deleted") - .HasColumnType("boolean") - .HasColumnName("deleted"); - - b.Property<string>("Email") - .HasColumnType("text") - .HasColumnName("email"); - - b.Property<string>("FirstName") - .HasColumnType("text") - .HasColumnName("first_name"); - - b.Property<string>("LastName") - .HasColumnType("text") - .HasColumnName("last_name"); - - b.Property<DateTime?>("ModifiedAt") - .HasColumnType("timestamp with time zone") - .HasColumnName("modified_at"); - - b.Property<string>("Password") - .HasColumnType("text") - .HasColumnName("password"); - - b.Property<string>("Username") - .HasColumnType("text") - .HasColumnName("username"); - - b.HasKey("Id") - .HasName("pk_users"); - - b.ToTable("users", (string)null); - }); - - modelBuilder.Entity("TenantUser", b => - { - b.Property<Guid>("TenantsId") - .HasColumnType("uuid") - .HasColumnName("tenants_id"); - - b.Property<Guid>("UsersId") - .HasColumnType("uuid") - .HasColumnName("users_id"); - - b.HasKey("TenantsId", "UsersId") - .HasName("pk_tenant_user"); - - b.HasIndex("UsersId") - .HasDatabaseName("ix_tenant_user_users_id"); - - b.ToTable("tenant_user", (string)null); - }); - - modelBuilder.Entity("IOL.GreatOffice.Api.Data.Database.ApiAccessToken", b => - { - b.HasOne("IOL.GreatOffice.Api.Data.Database.User", "User") - .WithMany() - .HasForeignKey("UserId") - .HasConstraintName("fk_api_access_tokens_users_user_id"); - - b.Navigation("User"); - }); - - modelBuilder.Entity("IOL.GreatOffice.Api.Data.Database.ForgotPasswordRequest", b => - { - b.HasOne("IOL.GreatOffice.Api.Data.Database.User", "User") - .WithMany() - .HasForeignKey("UserId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired() - .HasConstraintName("fk_forgot_password_requests_users_user_id"); - - b.Navigation("User"); - }); - - modelBuilder.Entity("IOL.GreatOffice.Api.Data.Database.GithubUserMapping", b => - { - b.HasOne("IOL.GreatOffice.Api.Data.Database.User", "User") - .WithMany() - .HasForeignKey("UserId") - .HasConstraintName("fk_github_user_mappings_users_user_id"); - - b.Navigation("User"); - }); - - modelBuilder.Entity("IOL.GreatOffice.Api.Data.Database.TimeEntry", b => - { - b.HasOne("IOL.GreatOffice.Api.Data.Database.TimeCategory", "Category") - .WithMany() - .HasForeignKey("CategoryId") - .HasConstraintName("fk_time_entries_time_categories_category_id"); - - b.Navigation("Category"); - }); - - modelBuilder.Entity("IOL.GreatOffice.Api.Data.Database.TimeLabel", b => - { - b.HasOne("IOL.GreatOffice.Api.Data.Database.TimeEntry", null) - .WithMany("Labels") - .HasForeignKey("TimeEntryId") - .HasConstraintName("fk_time_labels_time_entries_time_entry_id"); - }); - - modelBuilder.Entity("TenantUser", b => - { - b.HasOne("IOL.GreatOffice.Api.Data.Database.Tenant", null) - .WithMany() - .HasForeignKey("TenantsId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired() - .HasConstraintName("fk_tenant_user_tenants_tenants_id"); - - b.HasOne("IOL.GreatOffice.Api.Data.Database.User", null) - .WithMany() - .HasForeignKey("UsersId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired() - .HasConstraintName("fk_tenant_user_users_users_id"); - }); - - modelBuilder.Entity("IOL.GreatOffice.Api.Data.Database.TimeEntry", b => - { - b.Navigation("Labels"); - }); -#pragma warning restore 612, 618 - } - } -} diff --git a/server/src/Migrations/20220606232346_FleshOutNewModules.cs b/server/src/Migrations/20220606232346_FleshOutNewModules.cs deleted file mode 100644 index 49a36b8..0000000 --- a/server/src/Migrations/20220606232346_FleshOutNewModules.cs +++ /dev/null @@ -1,630 +0,0 @@ -using System; -using Microsoft.EntityFrameworkCore.Migrations; - -#nullable disable - -namespace IOL.GreatOffice.Api.Migrations -{ - public partial class FleshOutNewModules : Migration - { - protected override void Up(MigrationBuilder migrationBuilder) - { - migrationBuilder.DropForeignKey( - name: "fk_tenants_tenants_tenant_id1", - table: "tenants"); - - migrationBuilder.DropForeignKey( - name: "fk_tenants_users_created_by_id", - table: "tenants"); - - migrationBuilder.DropForeignKey( - name: "fk_tenants_users_deleted_by_id", - table: "tenants"); - - migrationBuilder.DropForeignKey( - name: "fk_tenants_users_modified_by_id", - table: "tenants"); - - migrationBuilder.DropForeignKey( - name: "fk_tenants_users_user_id", - table: "tenants"); - - migrationBuilder.DropForeignKey( - name: "fk_time_categories_tenants_tenant_id", - table: "time_categories"); - - migrationBuilder.DropForeignKey( - name: "fk_time_categories_users_created_by_id", - table: "time_categories"); - - migrationBuilder.DropForeignKey( - name: "fk_time_categories_users_deleted_by_id", - table: "time_categories"); - - migrationBuilder.DropForeignKey( - name: "fk_time_categories_users_modified_by_id", - table: "time_categories"); - - migrationBuilder.DropForeignKey( - name: "fk_time_categories_users_user_id", - table: "time_categories"); - - migrationBuilder.DropForeignKey( - name: "fk_time_entries_tenants_tenant_id", - table: "time_entries"); - - migrationBuilder.DropForeignKey( - name: "fk_time_entries_users_created_by_id", - table: "time_entries"); - - migrationBuilder.DropForeignKey( - name: "fk_time_entries_users_deleted_by_id", - table: "time_entries"); - - migrationBuilder.DropForeignKey( - name: "fk_time_entries_users_modified_by_id", - table: "time_entries"); - - migrationBuilder.DropForeignKey( - name: "fk_time_entries_users_user_id", - table: "time_entries"); - - migrationBuilder.DropForeignKey( - name: "fk_time_labels_tenants_tenant_id", - table: "time_labels"); - - migrationBuilder.DropForeignKey( - name: "fk_time_labels_users_created_by_id", - table: "time_labels"); - - migrationBuilder.DropForeignKey( - name: "fk_time_labels_users_deleted_by_id", - table: "time_labels"); - - migrationBuilder.DropForeignKey( - name: "fk_time_labels_users_modified_by_id", - table: "time_labels"); - - migrationBuilder.DropForeignKey( - name: "fk_time_labels_users_user_id", - table: "time_labels"); - - migrationBuilder.DropIndex( - name: "ix_time_labels_created_by_id", - table: "time_labels"); - - migrationBuilder.DropIndex( - name: "ix_time_labels_deleted_by_id", - table: "time_labels"); - - migrationBuilder.DropIndex( - name: "ix_time_labels_modified_by_id", - table: "time_labels"); - - migrationBuilder.DropIndex( - name: "ix_time_labels_tenant_id", - table: "time_labels"); - - migrationBuilder.DropIndex( - name: "ix_time_labels_user_id", - table: "time_labels"); - - migrationBuilder.DropIndex( - name: "ix_time_entries_created_by_id", - table: "time_entries"); - - migrationBuilder.DropIndex( - name: "ix_time_entries_deleted_by_id", - table: "time_entries"); - - migrationBuilder.DropIndex( - name: "ix_time_entries_modified_by_id", - table: "time_entries"); - - migrationBuilder.DropIndex( - name: "ix_time_entries_tenant_id", - table: "time_entries"); - - migrationBuilder.DropIndex( - name: "ix_time_entries_user_id", - table: "time_entries"); - - migrationBuilder.DropIndex( - name: "ix_time_categories_created_by_id", - table: "time_categories"); - - migrationBuilder.DropIndex( - name: "ix_time_categories_deleted_by_id", - table: "time_categories"); - - migrationBuilder.DropIndex( - name: "ix_time_categories_modified_by_id", - table: "time_categories"); - - migrationBuilder.DropIndex( - name: "ix_time_categories_tenant_id", - table: "time_categories"); - - migrationBuilder.DropIndex( - name: "ix_time_categories_user_id", - table: "time_categories"); - - migrationBuilder.DropIndex( - name: "ix_tenants_created_by_id", - table: "tenants"); - - migrationBuilder.DropIndex( - name: "ix_tenants_deleted_by_id", - table: "tenants"); - - migrationBuilder.DropIndex( - name: "ix_tenants_modified_by_id", - table: "tenants"); - - migrationBuilder.DropIndex( - name: "ix_tenants_tenant_id1", - table: "tenants"); - - migrationBuilder.DropIndex( - name: "ix_tenants_user_id", - table: "tenants"); - - migrationBuilder.DropColumn( - name: "tenant_id1", - table: "tenants"); - - migrationBuilder.AddColumn<bool>( - name: "deleted", - table: "users", - type: "boolean", - nullable: false, - defaultValue: false); - - migrationBuilder.AddColumn<string>( - name: "email", - table: "users", - type: "text", - nullable: true); - - migrationBuilder.AddColumn<string>( - name: "first_name", - table: "users", - type: "text", - nullable: true); - - migrationBuilder.AddColumn<string>( - name: "last_name", - table: "users", - type: "text", - nullable: true); - - migrationBuilder.AlterColumn<Guid>( - name: "user_id", - table: "time_labels", - type: "uuid", - nullable: true, - oldClrType: typeof(Guid), - oldType: "uuid"); - - migrationBuilder.AddColumn<bool>( - name: "deleted", - table: "time_labels", - type: "boolean", - nullable: false, - defaultValue: false); - - migrationBuilder.AlterColumn<Guid>( - name: "user_id", - table: "time_entries", - type: "uuid", - nullable: true, - oldClrType: typeof(Guid), - oldType: "uuid"); - - migrationBuilder.AddColumn<bool>( - name: "deleted", - table: "time_entries", - type: "boolean", - nullable: false, - defaultValue: false); - - migrationBuilder.AlterColumn<Guid>( - name: "user_id", - table: "time_categories", - type: "uuid", - nullable: true, - oldClrType: typeof(Guid), - oldType: "uuid"); - - migrationBuilder.AddColumn<bool>( - name: "deleted", - table: "time_categories", - type: "boolean", - nullable: false, - defaultValue: false); - - migrationBuilder.AlterColumn<Guid>( - name: "user_id", - table: "tenants", - type: "uuid", - nullable: true, - oldClrType: typeof(Guid), - oldType: "uuid"); - - migrationBuilder.AddColumn<bool>( - name: "deleted", - table: "tenants", - type: "boolean", - nullable: false, - defaultValue: false); - - migrationBuilder.AddColumn<bool>( - name: "deleted", - table: "api_access_tokens", - type: "boolean", - nullable: false, - defaultValue: false); - - migrationBuilder.CreateTable( - name: "tenant_user", - columns: table => new - { - tenants_id = table.Column<Guid>(type: "uuid", nullable: false), - users_id = table.Column<Guid>(type: "uuid", nullable: false) - }, - constraints: table => - { - table.PrimaryKey("pk_tenant_user", x => new { x.tenants_id, x.users_id }); - table.ForeignKey( - name: "fk_tenant_user_tenants_tenants_id", - column: x => x.tenants_id, - principalTable: "tenants", - principalColumn: "id", - onDelete: ReferentialAction.Cascade); - table.ForeignKey( - name: "fk_tenant_user_users_users_id", - column: x => x.users_id, - principalTable: "users", - principalColumn: "id", - onDelete: ReferentialAction.Cascade); - }); - - migrationBuilder.CreateIndex( - name: "ix_tenant_user_users_id", - table: "tenant_user", - column: "users_id"); - } - - protected override void Down(MigrationBuilder migrationBuilder) - { - migrationBuilder.DropTable( - name: "tenant_user"); - - migrationBuilder.DropColumn( - name: "deleted", - table: "users"); - - migrationBuilder.DropColumn( - name: "email", - table: "users"); - - migrationBuilder.DropColumn( - name: "first_name", - table: "users"); - - migrationBuilder.DropColumn( - name: "last_name", - table: "users"); - - migrationBuilder.DropColumn( - name: "deleted", - table: "time_labels"); - - migrationBuilder.DropColumn( - name: "deleted", - table: "time_entries"); - - migrationBuilder.DropColumn( - name: "deleted", - table: "time_categories"); - - migrationBuilder.DropColumn( - name: "deleted", - table: "tenants"); - - migrationBuilder.DropColumn( - name: "deleted", - table: "api_access_tokens"); - - migrationBuilder.AlterColumn<Guid>( - name: "user_id", - table: "time_labels", - type: "uuid", - nullable: false, - defaultValue: new Guid("00000000-0000-0000-0000-000000000000"), - oldClrType: typeof(Guid), - oldType: "uuid", - oldNullable: true); - - migrationBuilder.AlterColumn<Guid>( - name: "user_id", - table: "time_entries", - type: "uuid", - nullable: false, - defaultValue: new Guid("00000000-0000-0000-0000-000000000000"), - oldClrType: typeof(Guid), - oldType: "uuid", - oldNullable: true); - - migrationBuilder.AlterColumn<Guid>( - name: "user_id", - table: "time_categories", - type: "uuid", - nullable: false, - defaultValue: new Guid("00000000-0000-0000-0000-000000000000"), - oldClrType: typeof(Guid), - oldType: "uuid", - oldNullable: true); - - migrationBuilder.AlterColumn<Guid>( - name: "user_id", - table: "tenants", - type: "uuid", - nullable: false, - defaultValue: new Guid("00000000-0000-0000-0000-000000000000"), - oldClrType: typeof(Guid), - oldType: "uuid", - oldNullable: true); - - migrationBuilder.AddColumn<Guid>( - name: "tenant_id1", - table: "tenants", - type: "uuid", - nullable: true); - - migrationBuilder.CreateIndex( - name: "ix_time_labels_created_by_id", - table: "time_labels", - column: "created_by_id"); - - migrationBuilder.CreateIndex( - name: "ix_time_labels_deleted_by_id", - table: "time_labels", - column: "deleted_by_id"); - - migrationBuilder.CreateIndex( - name: "ix_time_labels_modified_by_id", - table: "time_labels", - column: "modified_by_id"); - - migrationBuilder.CreateIndex( - name: "ix_time_labels_tenant_id", - table: "time_labels", - column: "tenant_id"); - - migrationBuilder.CreateIndex( - name: "ix_time_labels_user_id", - table: "time_labels", - column: "user_id"); - - migrationBuilder.CreateIndex( - name: "ix_time_entries_created_by_id", - table: "time_entries", - column: "created_by_id"); - - migrationBuilder.CreateIndex( - name: "ix_time_entries_deleted_by_id", - table: "time_entries", - column: "deleted_by_id"); - - migrationBuilder.CreateIndex( - name: "ix_time_entries_modified_by_id", - table: "time_entries", - column: "modified_by_id"); - - migrationBuilder.CreateIndex( - name: "ix_time_entries_tenant_id", - table: "time_entries", - column: "tenant_id"); - - migrationBuilder.CreateIndex( - name: "ix_time_entries_user_id", - table: "time_entries", - column: "user_id"); - - migrationBuilder.CreateIndex( - name: "ix_time_categories_created_by_id", - table: "time_categories", - column: "created_by_id"); - - migrationBuilder.CreateIndex( - name: "ix_time_categories_deleted_by_id", - table: "time_categories", - column: "deleted_by_id"); - - migrationBuilder.CreateIndex( - name: "ix_time_categories_modified_by_id", - table: "time_categories", - column: "modified_by_id"); - - migrationBuilder.CreateIndex( - name: "ix_time_categories_tenant_id", - table: "time_categories", - column: "tenant_id"); - - migrationBuilder.CreateIndex( - name: "ix_time_categories_user_id", - table: "time_categories", - column: "user_id"); - - migrationBuilder.CreateIndex( - name: "ix_tenants_created_by_id", - table: "tenants", - column: "created_by_id"); - - migrationBuilder.CreateIndex( - name: "ix_tenants_deleted_by_id", - table: "tenants", - column: "deleted_by_id"); - - migrationBuilder.CreateIndex( - name: "ix_tenants_modified_by_id", - table: "tenants", - column: "modified_by_id"); - - migrationBuilder.CreateIndex( - name: "ix_tenants_tenant_id1", - table: "tenants", - column: "tenant_id1"); - - migrationBuilder.CreateIndex( - name: "ix_tenants_user_id", - table: "tenants", - column: "user_id"); - - migrationBuilder.AddForeignKey( - name: "fk_tenants_tenants_tenant_id1", - table: "tenants", - column: "tenant_id1", - principalTable: "tenants", - principalColumn: "id"); - - migrationBuilder.AddForeignKey( - name: "fk_tenants_users_created_by_id", - table: "tenants", - column: "created_by_id", - principalTable: "users", - principalColumn: "id"); - - migrationBuilder.AddForeignKey( - name: "fk_tenants_users_deleted_by_id", - table: "tenants", - column: "deleted_by_id", - principalTable: "users", - principalColumn: "id"); - - migrationBuilder.AddForeignKey( - name: "fk_tenants_users_modified_by_id", - table: "tenants", - column: "modified_by_id", - principalTable: "users", - principalColumn: "id"); - - migrationBuilder.AddForeignKey( - name: "fk_tenants_users_user_id", - table: "tenants", - column: "user_id", - principalTable: "users", - principalColumn: "id", - onDelete: ReferentialAction.Cascade); - - migrationBuilder.AddForeignKey( - name: "fk_time_categories_tenants_tenant_id", - table: "time_categories", - column: "tenant_id", - principalTable: "tenants", - principalColumn: "id"); - - migrationBuilder.AddForeignKey( - name: "fk_time_categories_users_created_by_id", - table: "time_categories", - column: "created_by_id", - principalTable: "users", - principalColumn: "id"); - - migrationBuilder.AddForeignKey( - name: "fk_time_categories_users_deleted_by_id", - table: "time_categories", - column: "deleted_by_id", - principalTable: "users", - principalColumn: "id"); - - migrationBuilder.AddForeignKey( - name: "fk_time_categories_users_modified_by_id", - table: "time_categories", - column: "modified_by_id", - principalTable: "users", - principalColumn: "id"); - - migrationBuilder.AddForeignKey( - name: "fk_time_categories_users_user_id", - table: "time_categories", - column: "user_id", - principalTable: "users", - principalColumn: "id", - onDelete: ReferentialAction.Cascade); - - migrationBuilder.AddForeignKey( - name: "fk_time_entries_tenants_tenant_id", - table: "time_entries", - column: "tenant_id", - principalTable: "tenants", - principalColumn: "id"); - - migrationBuilder.AddForeignKey( - name: "fk_time_entries_users_created_by_id", - table: "time_entries", - column: "created_by_id", - principalTable: "users", - principalColumn: "id"); - - migrationBuilder.AddForeignKey( - name: "fk_time_entries_users_deleted_by_id", - table: "time_entries", - column: "deleted_by_id", - principalTable: "users", - principalColumn: "id"); - - migrationBuilder.AddForeignKey( - name: "fk_time_entries_users_modified_by_id", - table: "time_entries", - column: "modified_by_id", - principalTable: "users", - principalColumn: "id"); - - migrationBuilder.AddForeignKey( - name: "fk_time_entries_users_user_id", - table: "time_entries", - column: "user_id", - principalTable: "users", - principalColumn: "id", - onDelete: ReferentialAction.Cascade); - - migrationBuilder.AddForeignKey( - name: "fk_time_labels_tenants_tenant_id", - table: "time_labels", - column: "tenant_id", - principalTable: "tenants", - principalColumn: "id"); - - migrationBuilder.AddForeignKey( - name: "fk_time_labels_users_created_by_id", - table: "time_labels", - column: "created_by_id", - principalTable: "users", - principalColumn: "id"); - - migrationBuilder.AddForeignKey( - name: "fk_time_labels_users_deleted_by_id", - table: "time_labels", - column: "deleted_by_id", - principalTable: "users", - principalColumn: "id"); - - migrationBuilder.AddForeignKey( - name: "fk_time_labels_users_modified_by_id", - table: "time_labels", - column: "modified_by_id", - principalTable: "users", - principalColumn: "id"); - - migrationBuilder.AddForeignKey( - name: "fk_time_labels_users_user_id", - table: "time_labels", - column: "user_id", - principalTable: "users", - principalColumn: "id", - onDelete: ReferentialAction.Cascade); - } - } -} diff --git a/server/src/Migrations/20220616170311_DataProtectionKeys.Designer.cs b/server/src/Migrations/20220616170311_DataProtectionKeys.Designer.cs deleted file mode 100644 index b333f23..0000000 --- a/server/src/Migrations/20220616170311_DataProtectionKeys.Designer.cs +++ /dev/null @@ -1,533 +0,0 @@ -// <auto-generated /> -using System; -using IOL.GreatOffice.Api.Data; -using Microsoft.EntityFrameworkCore; -using Microsoft.EntityFrameworkCore.Infrastructure; -using Microsoft.EntityFrameworkCore.Migrations; -using Microsoft.EntityFrameworkCore.Storage.ValueConversion; -using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata; - -#nullable disable - -namespace IOL.GreatOffice.Api.Migrations -{ - [DbContext(typeof(AppDbContext))] - [Migration("20220616170311_DataProtectionKeys")] - partial class DataProtectionKeys - { - protected override void BuildTargetModel(ModelBuilder modelBuilder) - { -#pragma warning disable 612, 618 - modelBuilder - .HasAnnotation("ProductVersion", "6.0.6") - .HasAnnotation("Relational:MaxIdentifierLength", 63); - - NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder); - - modelBuilder.Entity("IOL.GreatOffice.Api.Data.Database.ApiAccessToken", b => - { - b.Property<Guid>("Id") - .ValueGeneratedOnAdd() - .HasColumnType("uuid") - .HasColumnName("id"); - - b.Property<bool>("AllowCreate") - .HasColumnType("boolean") - .HasColumnName("allow_create"); - - b.Property<bool>("AllowDelete") - .HasColumnType("boolean") - .HasColumnName("allow_delete"); - - b.Property<bool>("AllowRead") - .HasColumnType("boolean") - .HasColumnName("allow_read"); - - b.Property<bool>("AllowUpdate") - .HasColumnType("boolean") - .HasColumnName("allow_update"); - - b.Property<DateTime>("CreatedAt") - .HasColumnType("timestamp with time zone") - .HasColumnName("created_at"); - - b.Property<bool>("Deleted") - .HasColumnType("boolean") - .HasColumnName("deleted"); - - b.Property<DateTime>("ExpiryDate") - .HasColumnType("timestamp with time zone") - .HasColumnName("expiry_date"); - - b.Property<DateTime?>("ModifiedAt") - .HasColumnType("timestamp with time zone") - .HasColumnName("modified_at"); - - b.Property<Guid?>("UserId") - .HasColumnType("uuid") - .HasColumnName("user_id"); - - b.HasKey("Id") - .HasName("pk_api_access_tokens"); - - b.HasIndex("UserId") - .HasDatabaseName("ix_api_access_tokens_user_id"); - - b.ToTable("api_access_tokens", (string)null); - }); - - modelBuilder.Entity("IOL.GreatOffice.Api.Data.Database.ForgotPasswordRequest", b => - { - b.Property<Guid>("Id") - .ValueGeneratedOnAdd() - .HasColumnType("uuid") - .HasColumnName("id"); - - b.Property<DateTime>("CreatedAt") - .HasColumnType("timestamp with time zone") - .HasColumnName("created_at"); - - b.Property<Guid>("UserId") - .HasColumnType("uuid") - .HasColumnName("user_id"); - - b.HasKey("Id") - .HasName("pk_forgot_password_requests"); - - b.HasIndex("UserId") - .HasDatabaseName("ix_forgot_password_requests_user_id"); - - b.ToTable("forgot_password_requests", (string)null); - }); - - modelBuilder.Entity("IOL.GreatOffice.Api.Data.Database.GithubUserMapping", b => - { - b.Property<string>("GithubId") - .HasColumnType("text") - .HasColumnName("github_id"); - - b.Property<string>("Email") - .HasColumnType("text") - .HasColumnName("email"); - - b.Property<string>("RefreshToken") - .HasColumnType("text") - .HasColumnName("refresh_token"); - - b.Property<Guid?>("UserId") - .HasColumnType("uuid") - .HasColumnName("user_id"); - - b.HasKey("GithubId") - .HasName("pk_github_user_mappings"); - - b.HasIndex("UserId") - .HasDatabaseName("ix_github_user_mappings_user_id"); - - b.ToTable("github_user_mappings", (string)null); - }); - - modelBuilder.Entity("IOL.GreatOffice.Api.Data.Database.Tenant", b => - { - b.Property<Guid>("Id") - .ValueGeneratedOnAdd() - .HasColumnType("uuid") - .HasColumnName("id"); - - b.Property<string>("ContactEmail") - .HasColumnType("text") - .HasColumnName("contact_email"); - - b.Property<DateTime>("CreatedAt") - .HasColumnType("timestamp with time zone") - .HasColumnName("created_at"); - - b.Property<Guid?>("CreatedById") - .HasColumnType("uuid") - .HasColumnName("created_by_id"); - - b.Property<bool>("Deleted") - .HasColumnType("boolean") - .HasColumnName("deleted"); - - b.Property<Guid?>("DeletedById") - .HasColumnType("uuid") - .HasColumnName("deleted_by_id"); - - b.Property<string>("Description") - .HasColumnType("text") - .HasColumnName("description"); - - b.Property<Guid>("MasterUserId") - .HasColumnType("uuid") - .HasColumnName("master_user_id"); - - b.Property<string>("MasterUserPassword") - .HasColumnType("text") - .HasColumnName("master_user_password"); - - b.Property<DateTime?>("ModifiedAt") - .HasColumnType("timestamp with time zone") - .HasColumnName("modified_at"); - - b.Property<Guid?>("ModifiedById") - .HasColumnType("uuid") - .HasColumnName("modified_by_id"); - - b.Property<string>("Name") - .HasColumnType("text") - .HasColumnName("name"); - - b.Property<Guid?>("TenantId") - .HasColumnType("uuid") - .HasColumnName("tenant_id"); - - b.Property<Guid?>("UserId") - .HasColumnType("uuid") - .HasColumnName("user_id"); - - b.HasKey("Id") - .HasName("pk_tenants"); - - b.ToTable("tenants", (string)null); - }); - - modelBuilder.Entity("IOL.GreatOffice.Api.Data.Database.TimeCategory", b => - { - b.Property<Guid>("Id") - .ValueGeneratedOnAdd() - .HasColumnType("uuid") - .HasColumnName("id"); - - b.Property<string>("Color") - .HasColumnType("text") - .HasColumnName("color"); - - b.Property<DateTime>("CreatedAt") - .HasColumnType("timestamp with time zone") - .HasColumnName("created_at"); - - b.Property<Guid?>("CreatedById") - .HasColumnType("uuid") - .HasColumnName("created_by_id"); - - b.Property<bool>("Deleted") - .HasColumnType("boolean") - .HasColumnName("deleted"); - - b.Property<Guid?>("DeletedById") - .HasColumnType("uuid") - .HasColumnName("deleted_by_id"); - - b.Property<DateTime?>("ModifiedAt") - .HasColumnType("timestamp with time zone") - .HasColumnName("modified_at"); - - b.Property<Guid?>("ModifiedById") - .HasColumnType("uuid") - .HasColumnName("modified_by_id"); - - b.Property<string>("Name") - .HasColumnType("text") - .HasColumnName("name"); - - b.Property<Guid?>("TenantId") - .HasColumnType("uuid") - .HasColumnName("tenant_id"); - - b.Property<Guid?>("UserId") - .HasColumnType("uuid") - .HasColumnName("user_id"); - - b.HasKey("Id") - .HasName("pk_time_categories"); - - b.ToTable("time_categories", (string)null); - }); - - modelBuilder.Entity("IOL.GreatOffice.Api.Data.Database.TimeEntry", b => - { - b.Property<Guid>("Id") - .ValueGeneratedOnAdd() - .HasColumnType("uuid") - .HasColumnName("id"); - - b.Property<Guid?>("CategoryId") - .HasColumnType("uuid") - .HasColumnName("category_id"); - - b.Property<DateTime>("CreatedAt") - .HasColumnType("timestamp with time zone") - .HasColumnName("created_at"); - - b.Property<Guid?>("CreatedById") - .HasColumnType("uuid") - .HasColumnName("created_by_id"); - - b.Property<bool>("Deleted") - .HasColumnType("boolean") - .HasColumnName("deleted"); - - b.Property<Guid?>("DeletedById") - .HasColumnType("uuid") - .HasColumnName("deleted_by_id"); - - b.Property<string>("Description") - .HasColumnType("text") - .HasColumnName("description"); - - b.Property<DateTime?>("ModifiedAt") - .HasColumnType("timestamp with time zone") - .HasColumnName("modified_at"); - - b.Property<Guid?>("ModifiedById") - .HasColumnType("uuid") - .HasColumnName("modified_by_id"); - - b.Property<DateTime>("Start") - .HasColumnType("timestamp with time zone") - .HasColumnName("start"); - - b.Property<DateTime>("Stop") - .HasColumnType("timestamp with time zone") - .HasColumnName("stop"); - - b.Property<Guid?>("TenantId") - .HasColumnType("uuid") - .HasColumnName("tenant_id"); - - b.Property<Guid?>("UserId") - .HasColumnType("uuid") - .HasColumnName("user_id"); - - b.HasKey("Id") - .HasName("pk_time_entries"); - - b.HasIndex("CategoryId") - .HasDatabaseName("ix_time_entries_category_id"); - - b.ToTable("time_entries", (string)null); - }); - - modelBuilder.Entity("IOL.GreatOffice.Api.Data.Database.TimeLabel", b => - { - b.Property<Guid>("Id") - .ValueGeneratedOnAdd() - .HasColumnType("uuid") - .HasColumnName("id"); - - b.Property<string>("Color") - .HasColumnType("text") - .HasColumnName("color"); - - b.Property<DateTime>("CreatedAt") - .HasColumnType("timestamp with time zone") - .HasColumnName("created_at"); - - b.Property<Guid?>("CreatedById") - .HasColumnType("uuid") - .HasColumnName("created_by_id"); - - b.Property<bool>("Deleted") - .HasColumnType("boolean") - .HasColumnName("deleted"); - - b.Property<Guid?>("DeletedById") - .HasColumnType("uuid") - .HasColumnName("deleted_by_id"); - - b.Property<DateTime?>("ModifiedAt") - .HasColumnType("timestamp with time zone") - .HasColumnName("modified_at"); - - b.Property<Guid?>("ModifiedById") - .HasColumnType("uuid") - .HasColumnName("modified_by_id"); - - b.Property<string>("Name") - .HasColumnType("text") - .HasColumnName("name"); - - b.Property<Guid?>("TenantId") - .HasColumnType("uuid") - .HasColumnName("tenant_id"); - - b.Property<Guid?>("TimeEntryId") - .HasColumnType("uuid") - .HasColumnName("time_entry_id"); - - b.Property<Guid?>("UserId") - .HasColumnType("uuid") - .HasColumnName("user_id"); - - b.HasKey("Id") - .HasName("pk_time_labels"); - - b.HasIndex("TimeEntryId") - .HasDatabaseName("ix_time_labels_time_entry_id"); - - b.ToTable("time_labels", (string)null); - }); - - modelBuilder.Entity("IOL.GreatOffice.Api.Data.Database.User", b => - { - b.Property<Guid>("Id") - .ValueGeneratedOnAdd() - .HasColumnType("uuid") - .HasColumnName("id"); - - b.Property<DateTime>("CreatedAt") - .HasColumnType("timestamp with time zone") - .HasColumnName("created_at"); - - b.Property<bool>("Deleted") - .HasColumnType("boolean") - .HasColumnName("deleted"); - - b.Property<string>("Email") - .HasColumnType("text") - .HasColumnName("email"); - - b.Property<string>("FirstName") - .HasColumnType("text") - .HasColumnName("first_name"); - - b.Property<string>("LastName") - .HasColumnType("text") - .HasColumnName("last_name"); - - b.Property<DateTime?>("ModifiedAt") - .HasColumnType("timestamp with time zone") - .HasColumnName("modified_at"); - - b.Property<string>("Password") - .HasColumnType("text") - .HasColumnName("password"); - - b.Property<string>("Username") - .HasColumnType("text") - .HasColumnName("username"); - - b.HasKey("Id") - .HasName("pk_users"); - - b.ToTable("users", (string)null); - }); - - modelBuilder.Entity("Microsoft.AspNetCore.DataProtection.EntityFrameworkCore.DataProtectionKey", b => - { - b.Property<int>("Id") - .ValueGeneratedOnAdd() - .HasColumnType("integer") - .HasColumnName("id"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id")); - - b.Property<string>("FriendlyName") - .HasColumnType("text") - .HasColumnName("friendly_name"); - - b.Property<string>("Xml") - .HasColumnType("text") - .HasColumnName("xml"); - - b.HasKey("Id") - .HasName("pk_data_protection_keys"); - - b.ToTable("data_protection_keys", (string)null); - }); - - modelBuilder.Entity("TenantUser", b => - { - b.Property<Guid>("TenantsId") - .HasColumnType("uuid") - .HasColumnName("tenants_id"); - - b.Property<Guid>("UsersId") - .HasColumnType("uuid") - .HasColumnName("users_id"); - - b.HasKey("TenantsId", "UsersId") - .HasName("pk_tenant_user"); - - b.HasIndex("UsersId") - .HasDatabaseName("ix_tenant_user_users_id"); - - b.ToTable("tenant_user", (string)null); - }); - - modelBuilder.Entity("IOL.GreatOffice.Api.Data.Database.ApiAccessToken", b => - { - b.HasOne("IOL.GreatOffice.Api.Data.Database.User", "User") - .WithMany() - .HasForeignKey("UserId") - .HasConstraintName("fk_api_access_tokens_users_user_id"); - - b.Navigation("User"); - }); - - modelBuilder.Entity("IOL.GreatOffice.Api.Data.Database.ForgotPasswordRequest", b => - { - b.HasOne("IOL.GreatOffice.Api.Data.Database.User", "User") - .WithMany() - .HasForeignKey("UserId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired() - .HasConstraintName("fk_forgot_password_requests_users_user_id"); - - b.Navigation("User"); - }); - - modelBuilder.Entity("IOL.GreatOffice.Api.Data.Database.GithubUserMapping", b => - { - b.HasOne("IOL.GreatOffice.Api.Data.Database.User", "User") - .WithMany() - .HasForeignKey("UserId") - .HasConstraintName("fk_github_user_mappings_users_user_id"); - - b.Navigation("User"); - }); - - modelBuilder.Entity("IOL.GreatOffice.Api.Data.Database.TimeEntry", b => - { - b.HasOne("IOL.GreatOffice.Api.Data.Database.TimeCategory", "Category") - .WithMany() - .HasForeignKey("CategoryId") - .HasConstraintName("fk_time_entries_time_categories_category_id"); - - b.Navigation("Category"); - }); - - modelBuilder.Entity("IOL.GreatOffice.Api.Data.Database.TimeLabel", b => - { - b.HasOne("IOL.GreatOffice.Api.Data.Database.TimeEntry", null) - .WithMany("Labels") - .HasForeignKey("TimeEntryId") - .HasConstraintName("fk_time_labels_time_entries_time_entry_id"); - }); - - modelBuilder.Entity("TenantUser", b => - { - b.HasOne("IOL.GreatOffice.Api.Data.Database.Tenant", null) - .WithMany() - .HasForeignKey("TenantsId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired() - .HasConstraintName("fk_tenant_user_tenants_tenants_id"); - - b.HasOne("IOL.GreatOffice.Api.Data.Database.User", null) - .WithMany() - .HasForeignKey("UsersId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired() - .HasConstraintName("fk_tenant_user_users_users_id"); - }); - - modelBuilder.Entity("IOL.GreatOffice.Api.Data.Database.TimeEntry", b => - { - b.Navigation("Labels"); - }); -#pragma warning restore 612, 618 - } - } -} diff --git a/server/src/Migrations/20220616170311_DataProtectionKeys.cs b/server/src/Migrations/20220616170311_DataProtectionKeys.cs deleted file mode 100644 index bc3c673..0000000 --- a/server/src/Migrations/20220616170311_DataProtectionKeys.cs +++ /dev/null @@ -1,33 +0,0 @@ -using Microsoft.EntityFrameworkCore.Migrations; -using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata; - -#nullable disable - -namespace IOL.GreatOffice.Api.Migrations -{ - public partial class DataProtectionKeys : Migration - { - protected override void Up(MigrationBuilder migrationBuilder) - { - migrationBuilder.CreateTable( - name: "data_protection_keys", - columns: table => new - { - id = table.Column<int>(type: "integer", nullable: false) - .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), - friendly_name = table.Column<string>(type: "text", nullable: true), - xml = table.Column<string>(type: "text", nullable: true) - }, - constraints: table => - { - table.PrimaryKey("pk_data_protection_keys", x => x.id); - }); - } - - protected override void Down(MigrationBuilder migrationBuilder) - { - migrationBuilder.DropTable( - name: "data_protection_keys"); - } - } -} diff --git a/server/src/Migrations/20220819203816_RemoveGithubUsers.Designer.cs b/server/src/Migrations/20220819203816_RemoveGithubUsers.Designer.cs deleted file mode 100644 index 33b5cfd..0000000 --- a/server/src/Migrations/20220819203816_RemoveGithubUsers.Designer.cs +++ /dev/null @@ -1,496 +0,0 @@ -// <auto-generated /> -using System; -using IOL.GreatOffice.Api.Data; -using Microsoft.EntityFrameworkCore; -using Microsoft.EntityFrameworkCore.Infrastructure; -using Microsoft.EntityFrameworkCore.Migrations; -using Microsoft.EntityFrameworkCore.Storage.ValueConversion; -using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata; - -#nullable disable - -namespace IOL.GreatOffice.Api.Migrations -{ - [DbContext(typeof(AppDbContext))] - [Migration("20220819203816_RemoveGithubUsers")] - partial class RemoveGithubUsers - { - protected override void BuildTargetModel(ModelBuilder modelBuilder) - { -#pragma warning disable 612, 618 - modelBuilder - .HasAnnotation("ProductVersion", "6.0.7") - .HasAnnotation("Relational:MaxIdentifierLength", 63); - - NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder); - - modelBuilder.Entity("IOL.GreatOffice.Api.Data.Database.ApiAccessToken", b => - { - b.Property<Guid>("Id") - .ValueGeneratedOnAdd() - .HasColumnType("uuid") - .HasColumnName("id"); - - b.Property<bool>("AllowCreate") - .HasColumnType("boolean") - .HasColumnName("allow_create"); - - b.Property<bool>("AllowDelete") - .HasColumnType("boolean") - .HasColumnName("allow_delete"); - - b.Property<bool>("AllowRead") - .HasColumnType("boolean") - .HasColumnName("allow_read"); - - b.Property<bool>("AllowUpdate") - .HasColumnType("boolean") - .HasColumnName("allow_update"); - - b.Property<DateTime>("CreatedAt") - .HasColumnType("timestamp with time zone") - .HasColumnName("created_at"); - - b.Property<bool>("Deleted") - .HasColumnType("boolean") - .HasColumnName("deleted"); - - b.Property<DateTime>("ExpiryDate") - .HasColumnType("timestamp with time zone") - .HasColumnName("expiry_date"); - - b.Property<DateTime?>("ModifiedAt") - .HasColumnType("timestamp with time zone") - .HasColumnName("modified_at"); - - b.Property<Guid?>("UserId") - .HasColumnType("uuid") - .HasColumnName("user_id"); - - b.HasKey("Id") - .HasName("pk_api_access_tokens"); - - b.HasIndex("UserId") - .HasDatabaseName("ix_api_access_tokens_user_id"); - - b.ToTable("api_access_tokens", (string)null); - }); - - modelBuilder.Entity("IOL.GreatOffice.Api.Data.Database.ForgotPasswordRequest", b => - { - b.Property<Guid>("Id") - .ValueGeneratedOnAdd() - .HasColumnType("uuid") - .HasColumnName("id"); - - b.Property<DateTime>("CreatedAt") - .HasColumnType("timestamp with time zone") - .HasColumnName("created_at"); - - b.Property<Guid>("UserId") - .HasColumnType("uuid") - .HasColumnName("user_id"); - - b.HasKey("Id") - .HasName("pk_forgot_password_requests"); - - b.HasIndex("UserId") - .HasDatabaseName("ix_forgot_password_requests_user_id"); - - b.ToTable("forgot_password_requests", (string)null); - }); - - modelBuilder.Entity("IOL.GreatOffice.Api.Data.Database.Tenant", b => - { - b.Property<Guid>("Id") - .ValueGeneratedOnAdd() - .HasColumnType("uuid") - .HasColumnName("id"); - - b.Property<string>("ContactEmail") - .HasColumnType("text") - .HasColumnName("contact_email"); - - b.Property<DateTime>("CreatedAt") - .HasColumnType("timestamp with time zone") - .HasColumnName("created_at"); - - b.Property<Guid?>("CreatedById") - .HasColumnType("uuid") - .HasColumnName("created_by_id"); - - b.Property<bool>("Deleted") - .HasColumnType("boolean") - .HasColumnName("deleted"); - - b.Property<Guid?>("DeletedById") - .HasColumnType("uuid") - .HasColumnName("deleted_by_id"); - - b.Property<string>("Description") - .HasColumnType("text") - .HasColumnName("description"); - - b.Property<Guid>("MasterUserId") - .HasColumnType("uuid") - .HasColumnName("master_user_id"); - - b.Property<string>("MasterUserPassword") - .HasColumnType("text") - .HasColumnName("master_user_password"); - - b.Property<DateTime?>("ModifiedAt") - .HasColumnType("timestamp with time zone") - .HasColumnName("modified_at"); - - b.Property<Guid?>("ModifiedById") - .HasColumnType("uuid") - .HasColumnName("modified_by_id"); - - b.Property<string>("Name") - .HasColumnType("text") - .HasColumnName("name"); - - b.Property<Guid?>("TenantId") - .HasColumnType("uuid") - .HasColumnName("tenant_id"); - - b.Property<Guid?>("UserId") - .HasColumnType("uuid") - .HasColumnName("user_id"); - - b.HasKey("Id") - .HasName("pk_tenants"); - - b.ToTable("tenants", (string)null); - }); - - modelBuilder.Entity("IOL.GreatOffice.Api.Data.Database.TimeCategory", b => - { - b.Property<Guid>("Id") - .ValueGeneratedOnAdd() - .HasColumnType("uuid") - .HasColumnName("id"); - - b.Property<string>("Color") - .HasColumnType("text") - .HasColumnName("color"); - - b.Property<DateTime>("CreatedAt") - .HasColumnType("timestamp with time zone") - .HasColumnName("created_at"); - - b.Property<Guid?>("CreatedById") - .HasColumnType("uuid") - .HasColumnName("created_by_id"); - - b.Property<bool>("Deleted") - .HasColumnType("boolean") - .HasColumnName("deleted"); - - b.Property<Guid?>("DeletedById") - .HasColumnType("uuid") - .HasColumnName("deleted_by_id"); - - b.Property<DateTime?>("ModifiedAt") - .HasColumnType("timestamp with time zone") - .HasColumnName("modified_at"); - - b.Property<Guid?>("ModifiedById") - .HasColumnType("uuid") - .HasColumnName("modified_by_id"); - - b.Property<string>("Name") - .HasColumnType("text") - .HasColumnName("name"); - - b.Property<Guid?>("TenantId") - .HasColumnType("uuid") - .HasColumnName("tenant_id"); - - b.Property<Guid?>("UserId") - .HasColumnType("uuid") - .HasColumnName("user_id"); - - b.HasKey("Id") - .HasName("pk_time_categories"); - - b.ToTable("time_categories", (string)null); - }); - - modelBuilder.Entity("IOL.GreatOffice.Api.Data.Database.TimeEntry", b => - { - b.Property<Guid>("Id") - .ValueGeneratedOnAdd() - .HasColumnType("uuid") - .HasColumnName("id"); - - b.Property<Guid?>("CategoryId") - .HasColumnType("uuid") - .HasColumnName("category_id"); - - b.Property<DateTime>("CreatedAt") - .HasColumnType("timestamp with time zone") - .HasColumnName("created_at"); - - b.Property<Guid?>("CreatedById") - .HasColumnType("uuid") - .HasColumnName("created_by_id"); - - b.Property<bool>("Deleted") - .HasColumnType("boolean") - .HasColumnName("deleted"); - - b.Property<Guid?>("DeletedById") - .HasColumnType("uuid") - .HasColumnName("deleted_by_id"); - - b.Property<string>("Description") - .HasColumnType("text") - .HasColumnName("description"); - - b.Property<DateTime?>("ModifiedAt") - .HasColumnType("timestamp with time zone") - .HasColumnName("modified_at"); - - b.Property<Guid?>("ModifiedById") - .HasColumnType("uuid") - .HasColumnName("modified_by_id"); - - b.Property<DateTime>("Start") - .HasColumnType("timestamp with time zone") - .HasColumnName("start"); - - b.Property<DateTime>("Stop") - .HasColumnType("timestamp with time zone") - .HasColumnName("stop"); - - b.Property<Guid?>("TenantId") - .HasColumnType("uuid") - .HasColumnName("tenant_id"); - - b.Property<Guid?>("UserId") - .HasColumnType("uuid") - .HasColumnName("user_id"); - - b.HasKey("Id") - .HasName("pk_time_entries"); - - b.HasIndex("CategoryId") - .HasDatabaseName("ix_time_entries_category_id"); - - b.ToTable("time_entries", (string)null); - }); - - modelBuilder.Entity("IOL.GreatOffice.Api.Data.Database.TimeLabel", b => - { - b.Property<Guid>("Id") - .ValueGeneratedOnAdd() - .HasColumnType("uuid") - .HasColumnName("id"); - - b.Property<string>("Color") - .HasColumnType("text") - .HasColumnName("color"); - - b.Property<DateTime>("CreatedAt") - .HasColumnType("timestamp with time zone") - .HasColumnName("created_at"); - - b.Property<Guid?>("CreatedById") - .HasColumnType("uuid") - .HasColumnName("created_by_id"); - - b.Property<bool>("Deleted") - .HasColumnType("boolean") - .HasColumnName("deleted"); - - b.Property<Guid?>("DeletedById") - .HasColumnType("uuid") - .HasColumnName("deleted_by_id"); - - b.Property<DateTime?>("ModifiedAt") - .HasColumnType("timestamp with time zone") - .HasColumnName("modified_at"); - - b.Property<Guid?>("ModifiedById") - .HasColumnType("uuid") - .HasColumnName("modified_by_id"); - - b.Property<string>("Name") - .HasColumnType("text") - .HasColumnName("name"); - - b.Property<Guid?>("TenantId") - .HasColumnType("uuid") - .HasColumnName("tenant_id"); - - b.Property<Guid?>("TimeEntryId") - .HasColumnType("uuid") - .HasColumnName("time_entry_id"); - - b.Property<Guid?>("UserId") - .HasColumnType("uuid") - .HasColumnName("user_id"); - - b.HasKey("Id") - .HasName("pk_time_labels"); - - b.HasIndex("TimeEntryId") - .HasDatabaseName("ix_time_labels_time_entry_id"); - - b.ToTable("time_labels", (string)null); - }); - - modelBuilder.Entity("IOL.GreatOffice.Api.Data.Database.User", b => - { - b.Property<Guid>("Id") - .ValueGeneratedOnAdd() - .HasColumnType("uuid") - .HasColumnName("id"); - - b.Property<DateTime>("CreatedAt") - .HasColumnType("timestamp with time zone") - .HasColumnName("created_at"); - - b.Property<bool>("Deleted") - .HasColumnType("boolean") - .HasColumnName("deleted"); - - b.Property<string>("Email") - .HasColumnType("text") - .HasColumnName("email"); - - b.Property<string>("FirstName") - .HasColumnType("text") - .HasColumnName("first_name"); - - b.Property<string>("LastName") - .HasColumnType("text") - .HasColumnName("last_name"); - - b.Property<DateTime?>("ModifiedAt") - .HasColumnType("timestamp with time zone") - .HasColumnName("modified_at"); - - b.Property<string>("Password") - .HasColumnType("text") - .HasColumnName("password"); - - b.Property<string>("Username") - .HasColumnType("text") - .HasColumnName("username"); - - b.HasKey("Id") - .HasName("pk_users"); - - b.ToTable("users", (string)null); - }); - - modelBuilder.Entity("Microsoft.AspNetCore.DataProtection.EntityFrameworkCore.DataProtectionKey", b => - { - b.Property<int>("Id") - .ValueGeneratedOnAdd() - .HasColumnType("integer") - .HasColumnName("id"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id")); - - b.Property<string>("FriendlyName") - .HasColumnType("text") - .HasColumnName("friendly_name"); - - b.Property<string>("Xml") - .HasColumnType("text") - .HasColumnName("xml"); - - b.HasKey("Id") - .HasName("pk_data_protection_keys"); - - b.ToTable("data_protection_keys", (string)null); - }); - - modelBuilder.Entity("TenantUser", b => - { - b.Property<Guid>("TenantsId") - .HasColumnType("uuid") - .HasColumnName("tenants_id"); - - b.Property<Guid>("UsersId") - .HasColumnType("uuid") - .HasColumnName("users_id"); - - b.HasKey("TenantsId", "UsersId") - .HasName("pk_tenant_user"); - - b.HasIndex("UsersId") - .HasDatabaseName("ix_tenant_user_users_id"); - - b.ToTable("tenant_user", (string)null); - }); - - modelBuilder.Entity("IOL.GreatOffice.Api.Data.Database.ApiAccessToken", b => - { - b.HasOne("IOL.GreatOffice.Api.Data.Database.User", "User") - .WithMany() - .HasForeignKey("UserId") - .HasConstraintName("fk_api_access_tokens_users_user_id"); - - b.Navigation("User"); - }); - - modelBuilder.Entity("IOL.GreatOffice.Api.Data.Database.ForgotPasswordRequest", b => - { - b.HasOne("IOL.GreatOffice.Api.Data.Database.User", "User") - .WithMany() - .HasForeignKey("UserId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired() - .HasConstraintName("fk_forgot_password_requests_users_user_id"); - - b.Navigation("User"); - }); - - modelBuilder.Entity("IOL.GreatOffice.Api.Data.Database.TimeEntry", b => - { - b.HasOne("IOL.GreatOffice.Api.Data.Database.TimeCategory", "Category") - .WithMany() - .HasForeignKey("CategoryId") - .HasConstraintName("fk_time_entries_time_categories_category_id"); - - b.Navigation("Category"); - }); - - modelBuilder.Entity("IOL.GreatOffice.Api.Data.Database.TimeLabel", b => - { - b.HasOne("IOL.GreatOffice.Api.Data.Database.TimeEntry", null) - .WithMany("Labels") - .HasForeignKey("TimeEntryId") - .HasConstraintName("fk_time_labels_time_entries_time_entry_id"); - }); - - modelBuilder.Entity("TenantUser", b => - { - b.HasOne("IOL.GreatOffice.Api.Data.Database.Tenant", null) - .WithMany() - .HasForeignKey("TenantsId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired() - .HasConstraintName("fk_tenant_user_tenants_tenants_id"); - - b.HasOne("IOL.GreatOffice.Api.Data.Database.User", null) - .WithMany() - .HasForeignKey("UsersId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired() - .HasConstraintName("fk_tenant_user_users_users_id"); - }); - - modelBuilder.Entity("IOL.GreatOffice.Api.Data.Database.TimeEntry", b => - { - b.Navigation("Labels"); - }); -#pragma warning restore 612, 618 - } - } -} diff --git a/server/src/Migrations/20220819203816_RemoveGithubUsers.cs b/server/src/Migrations/20220819203816_RemoveGithubUsers.cs deleted file mode 100644 index d301f67..0000000 --- a/server/src/Migrations/20220819203816_RemoveGithubUsers.cs +++ /dev/null @@ -1,43 +0,0 @@ -using System; -using Microsoft.EntityFrameworkCore.Migrations; - -#nullable disable - -namespace IOL.GreatOffice.Api.Migrations -{ - public partial class RemoveGithubUsers : Migration - { - protected override void Up(MigrationBuilder migrationBuilder) - { - migrationBuilder.DropTable( - name: "github_user_mappings"); - } - - protected override void Down(MigrationBuilder migrationBuilder) - { - migrationBuilder.CreateTable( - name: "github_user_mappings", - columns: table => new - { - github_id = table.Column<string>(type: "text", nullable: false), - user_id = table.Column<Guid>(type: "uuid", nullable: true), - email = table.Column<string>(type: "text", nullable: true), - refresh_token = table.Column<string>(type: "text", nullable: true) - }, - constraints: table => - { - table.PrimaryKey("pk_github_user_mappings", x => x.github_id); - table.ForeignKey( - name: "fk_github_user_mappings_users_user_id", - column: x => x.user_id, - principalTable: "users", - principalColumn: "id"); - }); - - migrationBuilder.CreateIndex( - name: "ix_github_user_mappings_user_id", - table: "github_user_mappings", - column: "user_id"); - } - } -} diff --git a/server/src/Migrations/AppDbContextModelSnapshot.cs b/server/src/Migrations/AppDbContextModelSnapshot.cs deleted file mode 100644 index cc4bf72..0000000 --- a/server/src/Migrations/AppDbContextModelSnapshot.cs +++ /dev/null @@ -1,494 +0,0 @@ -// <auto-generated /> -using System; -using IOL.GreatOffice.Api.Data; -using Microsoft.EntityFrameworkCore; -using Microsoft.EntityFrameworkCore.Infrastructure; -using Microsoft.EntityFrameworkCore.Storage.ValueConversion; -using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata; - -#nullable disable - -namespace IOL.GreatOffice.Api.Migrations -{ - [DbContext(typeof(AppDbContext))] - partial class AppDbContextModelSnapshot : ModelSnapshot - { - protected override void BuildModel(ModelBuilder modelBuilder) - { -#pragma warning disable 612, 618 - modelBuilder - .HasAnnotation("ProductVersion", "6.0.7") - .HasAnnotation("Relational:MaxIdentifierLength", 63); - - NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder); - - modelBuilder.Entity("IOL.GreatOffice.Api.Data.Database.ApiAccessToken", b => - { - b.Property<Guid>("Id") - .ValueGeneratedOnAdd() - .HasColumnType("uuid") - .HasColumnName("id"); - - b.Property<bool>("AllowCreate") - .HasColumnType("boolean") - .HasColumnName("allow_create"); - - b.Property<bool>("AllowDelete") - .HasColumnType("boolean") - .HasColumnName("allow_delete"); - - b.Property<bool>("AllowRead") - .HasColumnType("boolean") - .HasColumnName("allow_read"); - - b.Property<bool>("AllowUpdate") - .HasColumnType("boolean") - .HasColumnName("allow_update"); - - b.Property<DateTime>("CreatedAt") - .HasColumnType("timestamp with time zone") - .HasColumnName("created_at"); - - b.Property<bool>("Deleted") - .HasColumnType("boolean") - .HasColumnName("deleted"); - - b.Property<DateTime>("ExpiryDate") - .HasColumnType("timestamp with time zone") - .HasColumnName("expiry_date"); - - b.Property<DateTime?>("ModifiedAt") - .HasColumnType("timestamp with time zone") - .HasColumnName("modified_at"); - - b.Property<Guid?>("UserId") - .HasColumnType("uuid") - .HasColumnName("user_id"); - - b.HasKey("Id") - .HasName("pk_api_access_tokens"); - - b.HasIndex("UserId") - .HasDatabaseName("ix_api_access_tokens_user_id"); - - b.ToTable("api_access_tokens", (string)null); - }); - - modelBuilder.Entity("IOL.GreatOffice.Api.Data.Database.ForgotPasswordRequest", b => - { - b.Property<Guid>("Id") - .ValueGeneratedOnAdd() - .HasColumnType("uuid") - .HasColumnName("id"); - - b.Property<DateTime>("CreatedAt") - .HasColumnType("timestamp with time zone") - .HasColumnName("created_at"); - - b.Property<Guid>("UserId") - .HasColumnType("uuid") - .HasColumnName("user_id"); - - b.HasKey("Id") - .HasName("pk_forgot_password_requests"); - - b.HasIndex("UserId") - .HasDatabaseName("ix_forgot_password_requests_user_id"); - - b.ToTable("forgot_password_requests", (string)null); - }); - - modelBuilder.Entity("IOL.GreatOffice.Api.Data.Database.Tenant", b => - { - b.Property<Guid>("Id") - .ValueGeneratedOnAdd() - .HasColumnType("uuid") - .HasColumnName("id"); - - b.Property<string>("ContactEmail") - .HasColumnType("text") - .HasColumnName("contact_email"); - - b.Property<DateTime>("CreatedAt") - .HasColumnType("timestamp with time zone") - .HasColumnName("created_at"); - - b.Property<Guid?>("CreatedById") - .HasColumnType("uuid") - .HasColumnName("created_by_id"); - - b.Property<bool>("Deleted") - .HasColumnType("boolean") - .HasColumnName("deleted"); - - b.Property<Guid?>("DeletedById") - .HasColumnType("uuid") - .HasColumnName("deleted_by_id"); - - b.Property<string>("Description") - .HasColumnType("text") - .HasColumnName("description"); - - b.Property<Guid>("MasterUserId") - .HasColumnType("uuid") - .HasColumnName("master_user_id"); - - b.Property<string>("MasterUserPassword") - .HasColumnType("text") - .HasColumnName("master_user_password"); - - b.Property<DateTime?>("ModifiedAt") - .HasColumnType("timestamp with time zone") - .HasColumnName("modified_at"); - - b.Property<Guid?>("ModifiedById") - .HasColumnType("uuid") - .HasColumnName("modified_by_id"); - - b.Property<string>("Name") - .HasColumnType("text") - .HasColumnName("name"); - - b.Property<Guid?>("TenantId") - .HasColumnType("uuid") - .HasColumnName("tenant_id"); - - b.Property<Guid?>("UserId") - .HasColumnType("uuid") - .HasColumnName("user_id"); - - b.HasKey("Id") - .HasName("pk_tenants"); - - b.ToTable("tenants", (string)null); - }); - - modelBuilder.Entity("IOL.GreatOffice.Api.Data.Database.TimeCategory", b => - { - b.Property<Guid>("Id") - .ValueGeneratedOnAdd() - .HasColumnType("uuid") - .HasColumnName("id"); - - b.Property<string>("Color") - .HasColumnType("text") - .HasColumnName("color"); - - b.Property<DateTime>("CreatedAt") - .HasColumnType("timestamp with time zone") - .HasColumnName("created_at"); - - b.Property<Guid?>("CreatedById") - .HasColumnType("uuid") - .HasColumnName("created_by_id"); - - b.Property<bool>("Deleted") - .HasColumnType("boolean") - .HasColumnName("deleted"); - - b.Property<Guid?>("DeletedById") - .HasColumnType("uuid") - .HasColumnName("deleted_by_id"); - - b.Property<DateTime?>("ModifiedAt") - .HasColumnType("timestamp with time zone") - .HasColumnName("modified_at"); - - b.Property<Guid?>("ModifiedById") - .HasColumnType("uuid") - .HasColumnName("modified_by_id"); - - b.Property<string>("Name") - .HasColumnType("text") - .HasColumnName("name"); - - b.Property<Guid?>("TenantId") - .HasColumnType("uuid") - .HasColumnName("tenant_id"); - - b.Property<Guid?>("UserId") - .HasColumnType("uuid") - .HasColumnName("user_id"); - - b.HasKey("Id") - .HasName("pk_time_categories"); - - b.ToTable("time_categories", (string)null); - }); - - modelBuilder.Entity("IOL.GreatOffice.Api.Data.Database.TimeEntry", b => - { - b.Property<Guid>("Id") - .ValueGeneratedOnAdd() - .HasColumnType("uuid") - .HasColumnName("id"); - - b.Property<Guid?>("CategoryId") - .HasColumnType("uuid") - .HasColumnName("category_id"); - - b.Property<DateTime>("CreatedAt") - .HasColumnType("timestamp with time zone") - .HasColumnName("created_at"); - - b.Property<Guid?>("CreatedById") - .HasColumnType("uuid") - .HasColumnName("created_by_id"); - - b.Property<bool>("Deleted") - .HasColumnType("boolean") - .HasColumnName("deleted"); - - b.Property<Guid?>("DeletedById") - .HasColumnType("uuid") - .HasColumnName("deleted_by_id"); - - b.Property<string>("Description") - .HasColumnType("text") - .HasColumnName("description"); - - b.Property<DateTime?>("ModifiedAt") - .HasColumnType("timestamp with time zone") - .HasColumnName("modified_at"); - - b.Property<Guid?>("ModifiedById") - .HasColumnType("uuid") - .HasColumnName("modified_by_id"); - - b.Property<DateTime>("Start") - .HasColumnType("timestamp with time zone") - .HasColumnName("start"); - - b.Property<DateTime>("Stop") - .HasColumnType("timestamp with time zone") - .HasColumnName("stop"); - - b.Property<Guid?>("TenantId") - .HasColumnType("uuid") - .HasColumnName("tenant_id"); - - b.Property<Guid?>("UserId") - .HasColumnType("uuid") - .HasColumnName("user_id"); - - b.HasKey("Id") - .HasName("pk_time_entries"); - - b.HasIndex("CategoryId") - .HasDatabaseName("ix_time_entries_category_id"); - - b.ToTable("time_entries", (string)null); - }); - - modelBuilder.Entity("IOL.GreatOffice.Api.Data.Database.TimeLabel", b => - { - b.Property<Guid>("Id") - .ValueGeneratedOnAdd() - .HasColumnType("uuid") - .HasColumnName("id"); - - b.Property<string>("Color") - .HasColumnType("text") - .HasColumnName("color"); - - b.Property<DateTime>("CreatedAt") - .HasColumnType("timestamp with time zone") - .HasColumnName("created_at"); - - b.Property<Guid?>("CreatedById") - .HasColumnType("uuid") - .HasColumnName("created_by_id"); - - b.Property<bool>("Deleted") - .HasColumnType("boolean") - .HasColumnName("deleted"); - - b.Property<Guid?>("DeletedById") - .HasColumnType("uuid") - .HasColumnName("deleted_by_id"); - - b.Property<DateTime?>("ModifiedAt") - .HasColumnType("timestamp with time zone") - .HasColumnName("modified_at"); - - b.Property<Guid?>("ModifiedById") - .HasColumnType("uuid") - .HasColumnName("modified_by_id"); - - b.Property<string>("Name") - .HasColumnType("text") - .HasColumnName("name"); - - b.Property<Guid?>("TenantId") - .HasColumnType("uuid") - .HasColumnName("tenant_id"); - - b.Property<Guid?>("TimeEntryId") - .HasColumnType("uuid") - .HasColumnName("time_entry_id"); - - b.Property<Guid?>("UserId") - .HasColumnType("uuid") - .HasColumnName("user_id"); - - b.HasKey("Id") - .HasName("pk_time_labels"); - - b.HasIndex("TimeEntryId") - .HasDatabaseName("ix_time_labels_time_entry_id"); - - b.ToTable("time_labels", (string)null); - }); - - modelBuilder.Entity("IOL.GreatOffice.Api.Data.Database.User", b => - { - b.Property<Guid>("Id") - .ValueGeneratedOnAdd() - .HasColumnType("uuid") - .HasColumnName("id"); - - b.Property<DateTime>("CreatedAt") - .HasColumnType("timestamp with time zone") - .HasColumnName("created_at"); - - b.Property<bool>("Deleted") - .HasColumnType("boolean") - .HasColumnName("deleted"); - - b.Property<string>("Email") - .HasColumnType("text") - .HasColumnName("email"); - - b.Property<string>("FirstName") - .HasColumnType("text") - .HasColumnName("first_name"); - - b.Property<string>("LastName") - .HasColumnType("text") - .HasColumnName("last_name"); - - b.Property<DateTime?>("ModifiedAt") - .HasColumnType("timestamp with time zone") - .HasColumnName("modified_at"); - - b.Property<string>("Password") - .HasColumnType("text") - .HasColumnName("password"); - - b.Property<string>("Username") - .HasColumnType("text") - .HasColumnName("username"); - - b.HasKey("Id") - .HasName("pk_users"); - - b.ToTable("users", (string)null); - }); - - modelBuilder.Entity("Microsoft.AspNetCore.DataProtection.EntityFrameworkCore.DataProtectionKey", b => - { - b.Property<int>("Id") - .ValueGeneratedOnAdd() - .HasColumnType("integer") - .HasColumnName("id"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id")); - - b.Property<string>("FriendlyName") - .HasColumnType("text") - .HasColumnName("friendly_name"); - - b.Property<string>("Xml") - .HasColumnType("text") - .HasColumnName("xml"); - - b.HasKey("Id") - .HasName("pk_data_protection_keys"); - - b.ToTable("data_protection_keys", (string)null); - }); - - modelBuilder.Entity("TenantUser", b => - { - b.Property<Guid>("TenantsId") - .HasColumnType("uuid") - .HasColumnName("tenants_id"); - - b.Property<Guid>("UsersId") - .HasColumnType("uuid") - .HasColumnName("users_id"); - - b.HasKey("TenantsId", "UsersId") - .HasName("pk_tenant_user"); - - b.HasIndex("UsersId") - .HasDatabaseName("ix_tenant_user_users_id"); - - b.ToTable("tenant_user", (string)null); - }); - - modelBuilder.Entity("IOL.GreatOffice.Api.Data.Database.ApiAccessToken", b => - { - b.HasOne("IOL.GreatOffice.Api.Data.Database.User", "User") - .WithMany() - .HasForeignKey("UserId") - .HasConstraintName("fk_api_access_tokens_users_user_id"); - - b.Navigation("User"); - }); - - modelBuilder.Entity("IOL.GreatOffice.Api.Data.Database.ForgotPasswordRequest", b => - { - b.HasOne("IOL.GreatOffice.Api.Data.Database.User", "User") - .WithMany() - .HasForeignKey("UserId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired() - .HasConstraintName("fk_forgot_password_requests_users_user_id"); - - b.Navigation("User"); - }); - - modelBuilder.Entity("IOL.GreatOffice.Api.Data.Database.TimeEntry", b => - { - b.HasOne("IOL.GreatOffice.Api.Data.Database.TimeCategory", "Category") - .WithMany() - .HasForeignKey("CategoryId") - .HasConstraintName("fk_time_entries_time_categories_category_id"); - - b.Navigation("Category"); - }); - - modelBuilder.Entity("IOL.GreatOffice.Api.Data.Database.TimeLabel", b => - { - b.HasOne("IOL.GreatOffice.Api.Data.Database.TimeEntry", null) - .WithMany("Labels") - .HasForeignKey("TimeEntryId") - .HasConstraintName("fk_time_labels_time_entries_time_entry_id"); - }); - - modelBuilder.Entity("TenantUser", b => - { - b.HasOne("IOL.GreatOffice.Api.Data.Database.Tenant", null) - .WithMany() - .HasForeignKey("TenantsId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired() - .HasConstraintName("fk_tenant_user_tenants_tenants_id"); - - b.HasOne("IOL.GreatOffice.Api.Data.Database.User", null) - .WithMany() - .HasForeignKey("UsersId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired() - .HasConstraintName("fk_tenant_user_users_users_id"); - }); - - modelBuilder.Entity("IOL.GreatOffice.Api.Data.Database.TimeEntry", b => - { - b.Navigation("Labels"); - }); -#pragma warning restore 612, 618 - } - } -} diff --git a/server/src/Program.cs b/server/src/Program.cs deleted file mode 100644 index 9a6bc3f..0000000 --- a/server/src/Program.cs +++ /dev/null @@ -1,236 +0,0 @@ -global using System; -global using System.Linq; -global using System.IO; -global using System.Net.Mail; -global using System.Net; -global using System.Threading; -global using System.Threading.Tasks; -global using System.Collections.Generic; -global using System.Runtime.Serialization; -global using System.ComponentModel.DataAnnotations.Schema; -global using System.Security.Claims; -global using System.Text.Json; -global using System.Text.Json.Serialization; -global using IOL.GreatOffice.Api.Data.Database; -global using IOL.GreatOffice.Api.Data.Exceptions; -global using IOL.GreatOffice.Api.Data.Dtos; -global using IOL.GreatOffice.Api.Data.Enums; -global using IOL.GreatOffice.Api.Data.Models; -global using IOL.GreatOffice.Api.Data.Results; -global using IOL.Helpers; -global using Microsoft.OpenApi.Models; -global using Microsoft.AspNetCore.Authentication.Cookies; -global using Microsoft.AspNetCore.Builder; -global using Microsoft.AspNetCore.DataProtection; -global using Microsoft.AspNetCore.Hosting; -global using Microsoft.AspNetCore.Authorization; -global using Microsoft.AspNetCore.Http; -global using Microsoft.AspNetCore.Authentication; -global using Microsoft.AspNetCore.Mvc; -global using Microsoft.EntityFrameworkCore; -global using Microsoft.Extensions.Configuration; -global using Microsoft.Extensions.DependencyInjection; -global using Microsoft.Extensions.Hosting; -global using Microsoft.Extensions.Logging; -global using Serilog; -global using IOL.GreatOffice.Api.Data; -global using IOL.GreatOffice.Api.Data.Static; -global using IOL.GreatOffice.Api.Services; -global using IOL.GreatOffice.Api.Utilities; -using System.Reflection; -using IOL.GreatOffice.Api.Endpoints.V1; -using IOL.GreatOffice.Api.Jobs; -using Microsoft.AspNetCore.HttpOverrides; -using Microsoft.AspNetCore.Mvc.Versioning; -using Quartz; - -namespace IOL.GreatOffice.Api; - -public static class Program -{ - public static WebApplicationBuilder CreateAppBuilder(string[] args) { - var builder = WebApplication.CreateBuilder(args); - builder.Services.AddLogging(); - builder.Services.AddHttpClient(); - builder.Services.AddMemoryCache(); - builder.Services.AddScoped<MailService>(); - builder.Services.AddScoped<PasswordResetService>(); - builder.Services.AddScoped<UserService>(); - builder.Services.AddTransient<VaultService>(); - var vaultService = builder.Services.BuildServiceProvider().GetRequiredService<VaultService>(); - var configuration = vaultService.GetCurrentAppConfiguration(); - var logger = new LoggerConfiguration() - .Enrich.FromLogContext() - .ReadFrom.Configuration(builder.Configuration) - .WriteTo.Console(); - - if (!builder.Environment.IsDevelopment() && configuration.SEQ_API_KEY.HasValue() && configuration.SEQ_API_URL.HasValue()) { - logger.WriteTo.Seq(configuration.SEQ_API_URL, apiKey: configuration.SEQ_API_KEY); - } - - Log.Logger = logger.CreateLogger(); - Log.Information("Starting web host, " - + JsonSerializer.Serialize(configuration.GetPublicVersion(), - new JsonSerializerOptions() { - WriteIndented = true - })); - builder.Host.UseSerilog(Log.Logger); - builder.WebHost.ConfigureKestrel(kestrel => { - kestrel.AddServerHeader = false; - }); - - if (builder.Environment.IsDevelopment()) { - builder.Services.AddCors(); - } - - if (builder.Environment.IsProduction()) { - builder.Services.Configure<ForwardedHeadersOptions>(options => { - options.ForwardedHeaders = ForwardedHeaders.XForwardedProto; - }); - } - - builder.Services - .AddDataProtection() - .ProtectKeysWithCertificate(configuration.CERT1()) - .PersistKeysToDbContext<AppDbContext>(); - - builder.Services.Configure(JsonSettings.Default); - builder.Services.AddQuartz(options => { - options.UsePersistentStore(o => { - o.UsePostgres(builder.Configuration.GetQuartzDatabaseConnectionString(vaultService.GetCurrentAppConfiguration)); - o.UseSerializer<QuartzJsonSerializer>(); - }); - options.UseMicrosoftDependencyInjectionJobFactory(); - options.RegisterJobs(); - }); - - builder.Services.AddQuartzHostedService(options => { - options.WaitForJobsToComplete = true; - }); - - builder.Services.AddAuthentication(options => { - options.DefaultScheme = CookieAuthenticationDefaults.AuthenticationScheme; - options.DefaultChallengeScheme = CookieAuthenticationDefaults.AuthenticationScheme; - }) - .AddCookie(options => { - options.Cookie.Name = "go_session"; - options.Cookie.HttpOnly = true; - options.Cookie.IsEssential = true; - options.SlidingExpiration = true; - options.Events.OnRedirectToAccessDenied = - options.Events.OnRedirectToLogin = c => { - c.Response.StatusCode = StatusCodes.Status401Unauthorized; - return Task.FromResult<object>(null); - }; - }) - .AddScheme<AuthenticationSchemeOptions, BasicAuthenticationHandler>(AppConstants.BASIC_AUTH_SCHEME, default); - - builder.Services.AddDbContext<AppDbContext>(options => { - options.UseNpgsql(builder.Configuration.GetAppDatabaseConnectionString(vaultService.GetCurrentAppConfiguration), - npgsqlDbContextOptionsBuilder => { - npgsqlDbContextOptionsBuilder.UseQuerySplittingBehavior(QuerySplittingBehavior.SplitQuery); - npgsqlDbContextOptionsBuilder.EnableRetryOnFailure(5, TimeSpan.FromSeconds(10), default); - }) - .UseSnakeCaseNamingConvention(); - if (builder.Environment.IsDevelopment()) { - options.EnableSensitiveDataLogging(); - } - }); - - builder.Services.AddApiVersioning(options => { - options.ApiVersionReader = new UrlSegmentApiVersionReader(); - options.ReportApiVersions = true; - options.AssumeDefaultVersionWhenUnspecified = false; - }); - builder.Services.AddVersionedApiExplorer(options => { - options.SubstituteApiVersionInUrl = true; - }); - builder.Services.AddSwaggerGen(options => { - options.IncludeXmlComments(Path.Combine(AppContext.BaseDirectory, Assembly.GetExecutingAssembly().GetName().Name + ".xml")); - options.UseApiEndpoints(); - options.OperationFilter<SwaggerDefaultValues>(); - options.SwaggerDoc(ApiSpecV1.Document.VersionName, ApiSpecV1.Document.OpenApiInfo); - options.AddSecurityDefinition("Basic", - new OpenApiSecurityScheme { - Name = "Authorization", - Type = SecuritySchemeType.ApiKey, - Scheme = "Basic", - BearerFormat = "Basic", - In = ParameterLocation.Header, - Description = - "Enter your token in the text input below.\r\n\r\nExample: \"Basic 12345abcdef\"", - }); - - options.AddSecurityRequirement(new OpenApiSecurityRequirement { - { - new OpenApiSecurityScheme { - Reference = new OpenApiReference { - Type = ReferenceType.SecurityScheme, - Id = "Basic" - } - }, - Array.Empty<string>() - } - }); - }); - - builder.Services - .AddControllers() - .AddJsonOptions(JsonSettings.Default); - - return builder; - } - - public static WebApplication CreateWebApplication(WebApplicationBuilder builder) { - var app = builder.Build(); - - if (app.Environment.IsDevelopment()) { - app.UseDeveloperExceptionPage(); - app.UseCors(cors => { - cors.AllowAnyMethod(); - cors.AllowAnyHeader(); - cors.SetIsOriginAllowed((origin) => true); - cors.AllowCredentials(); - }); - } - - if (app.Environment.IsProduction()) { - app.UseForwardedHeaders(); - } - - app.UseDefaultFiles() - .UseStaticFiles() - .UseRouting() - .UseSerilogRequestLogging() - .UseStatusCodePages() - .UseAuthentication() - .UseAuthorization() - .UseSwagger() - .UseSwaggerUI(options => { - options.SwaggerEndpoint(ApiSpecV1.Document.SwaggerPath, ApiSpecV1.Document.VersionName); - options.DocumentTitle = AppConstants.API_NAME; - }) - .UseEndpoints(endpoints => { - endpoints.MapControllers(); - }); - return app; - } - - public static int Main(string[] args) { - try { - CreateWebApplication(CreateAppBuilder(args)).Run(); - return 0; - } catch (Exception ex) { - // This is subject to change in future .net versions, see https://github.com/dotnet/runtime/issues/60600. - if (ex.GetType().Name.Equals("StopTheHostException", StringComparison.Ordinal)) { - throw; - } - - Log.Fatal(ex, "Unhandled exception"); - return 1; - } finally { - Log.Information("Shut down complete, flusing logs..."); - Log.CloseAndFlush(); - } - } -} diff --git a/server/src/Properties/launchSettings.json b/server/src/Properties/launchSettings.json deleted file mode 100644 index ebd333b..0000000 --- a/server/src/Properties/launchSettings.json +++ /dev/null @@ -1,14 +0,0 @@ -{ - "$schema": "http://json.schemastore.org/launchsettings.json", - "profiles": { - "IOL.GreatOffice": { - "commandName": "Project", - "dotnetRunMessages": "true", - "launchBrowser": false, - "applicationUrl": "http://localhost:5000", - "environmentVariables": { - "ASPNETCORE_ENVIRONMENT": "Development" - } - } - } -} diff --git a/server/src/Services/MailService.cs b/server/src/Services/MailService.cs deleted file mode 100644 index c08cb84..0000000 --- a/server/src/Services/MailService.cs +++ /dev/null @@ -1,49 +0,0 @@ -namespace IOL.GreatOffice.Api.Services; - -public class MailService -{ - private readonly ILogger<MailService> _logger; - private static string _emailHost; - private static int _emailPort; - private static string _emailUser; - private static string _emailPassword; - - public MailService(VaultService vaultService, ILogger<MailService> logger) { - var configuration = vaultService.GetCurrentAppConfiguration(); - _logger = logger; - _emailHost = configuration.SMTP_HOST; - _emailPort = Convert.ToInt32(configuration.SMTP_PORT); - _emailUser = configuration.SMTP_USER; - _emailPassword = configuration.SMTP_PASSWORD; - } - - /// <summary> - /// Send an email. - /// </summary> - /// <param name="message"></param> - public void SendMail(MailMessage message) { - using var smtpClient = new SmtpClient { - Host = _emailHost, - EnableSsl = _emailPort == 587, - Port = _emailPort, - Credentials = new NetworkCredential { - UserName = _emailUser, - Password = _emailPassword, - } - }; - var configurationString = JsonSerializer.Serialize(new { - smtpClient.Host, - smtpClient.EnableSsl, - smtpClient.Port, - UserName = _emailUser.HasValue() ? "**REDACTED**" : "**MISSING**", - Password = _emailPassword.HasValue() ? "**REDACTED**" : "**MISSING**", - }, - new JsonSerializerOptions { - WriteIndented = true - }); - - _logger.LogDebug("SmtpClient was instansiated with the following configuration\n" + configurationString); - - smtpClient.Send(message); - } -}
\ No newline at end of file diff --git a/server/src/Services/PasswordResetService.cs b/server/src/Services/PasswordResetService.cs deleted file mode 100644 index 1b4f147..0000000 --- a/server/src/Services/PasswordResetService.cs +++ /dev/null @@ -1,115 +0,0 @@ -namespace IOL.GreatOffice.Api.Services; - -public class PasswordResetService -{ - private readonly AppDbContext _context; - private readonly MailService _mailService; - private readonly AppConfiguration _configuration; - private readonly ILogger<PasswordResetService> _logger; - - - public PasswordResetService( - AppDbContext context, - VaultService vaultService, - ILogger<PasswordResetService> logger, - MailService mailService - ) { - _context = context; - _configuration = vaultService.GetCurrentAppConfiguration(); - _logger = logger; - _mailService = mailService; - } - - public async Task<ForgotPasswordRequest> GetRequestAsync(Guid id, CancellationToken cancellationToken = default) { - var request = await _context.ForgotPasswordRequests - .Include(c => c.User) - .SingleOrDefaultAsync(c => c.Id == id, cancellationToken); - if (request == default) { - return default; - } - - _logger.LogInformation($"Found password reset request for user: {request.User.Username}, expires at {request.ExpirationDate} (in {request.ExpirationDate.Subtract(AppDateTime.UtcNow).Minutes} minutes)."); - return request; - } - - public async Task<bool> FullFillRequestAsync(Guid id, string newPassword, CancellationToken cancellationToken = default) { - var request = await GetRequestAsync(id, cancellationToken); - if (request == default) { - throw new ForgotPasswordRequestNotFoundException("Request with id: " + id + " was not found"); - } - - var user = _context.Users.SingleOrDefault(c => c.Id == request.User.Id); - if (user == default) { - throw new UserNotFoundException("User with id: " + request.User.Id + " was not found"); - } - - user.HashAndSetPassword(newPassword); - _context.Users.Update(user); - await _context.SaveChangesAsync(cancellationToken); - _logger.LogInformation($"Fullfilled password reset request for user: {request.User.Username}"); - await DeleteRequestsForUserAsync(user.Id, cancellationToken); - return true; - } - - - public async Task AddRequestAsync(User user, TimeZoneInfo requestTz, CancellationToken cancellationToken = default) { - await DeleteRequestsForUserAsync(user.Id, cancellationToken); - var request = new ForgotPasswordRequest(user); - _context.ForgotPasswordRequests.Add(request); - await _context.SaveChangesAsync(cancellationToken); - var portalUrl = _configuration.PORTAL_URL; - var emailFromAddress = _configuration.EMAIL_FROM_ADDRESS; - var emailFromDisplayName = _configuration.EMAIL_FROM_DISPLAY_NAME; - var zonedExpirationDate = TimeZoneInfo.ConvertTimeBySystemTimeZoneId(request.ExpirationDate, requestTz.Id); - var message = new MailMessage { - From = new MailAddress(emailFromAddress, emailFromDisplayName), - To = { - new MailAddress(user.Username) - }, - Subject = "Reset password - Greatoffice", - Body = @$" -Hi {user.Username} - -Go to the following link to set a new password. - -{portalUrl}/reset-password/{request.Id} - -The link expires at {zonedExpirationDate:yyyy-MM-dd hh:mm}. -If you did not request a password reset, no action is required. -" - }; - -#pragma warning disable 4014 - Task.Run(() => { -#pragma warning restore 4014 - _mailService.SendMail(message); - _logger.LogInformation($"Added password reset request for user: {request.User.Username}, expires in {request.ExpirationDate.Subtract(AppDateTime.UtcNow)}."); - }, - cancellationToken); - } - - public async Task DeleteRequestsForUserAsync(Guid userId, CancellationToken cancellationToken = default) { - var requestsToRemove = _context.ForgotPasswordRequests.Where(c => c.UserId == userId).ToList(); - if (!requestsToRemove.Any()) return; - _context.ForgotPasswordRequests.RemoveRange(requestsToRemove); - await _context.SaveChangesAsync(cancellationToken); - _logger.LogInformation($"Deleted {requestsToRemove.Count} password reset requests for user: {userId}."); - } - - - public async Task DeleteStaleRequestsAsync(CancellationToken cancellationToken = default) { - var deleteCount = 0; - foreach (var request in _context.ForgotPasswordRequests.Where(c => c.IsExpired)) { - if (!request.IsExpired) { - continue; - } - - _context.ForgotPasswordRequests.Remove(request); - deleteCount++; - _logger.LogInformation($"Marking password reset request with id: {request.Id} for deletion, expiration date was {request.ExpirationDate}."); - } - - await _context.SaveChangesAsync(cancellationToken); - _logger.LogInformation($"Deleted {deleteCount} stale password reset requests."); - } -}
\ No newline at end of file diff --git a/server/src/Services/UserService.cs b/server/src/Services/UserService.cs deleted file mode 100644 index 6db663a..0000000 --- a/server/src/Services/UserService.cs +++ /dev/null @@ -1,50 +0,0 @@ -namespace IOL.GreatOffice.Api.Services; - -public class UserService -{ - private readonly PasswordResetService _passwordResetService; - - /// <summary> - /// Provides methods to perform common operations on user data. - /// </summary> - /// <param name="passwordResetService"></param> - public UserService(PasswordResetService passwordResetService) { - _passwordResetService = passwordResetService; - } - - /// <summary> - /// Log in a user. - /// </summary> - /// <param name="httpContext"></param> - /// <param name="user"></param> - /// <param name="persist"></param> - public async Task LogInUser(HttpContext httpContext, User user, bool persist = false) { - var claims = new List<Claim> { - new(AppClaims.USER_ID, user.Id.ToString()), - new(AppClaims.NAME, user.Username), - }; - - var identity = new ClaimsIdentity(claims, CookieAuthenticationDefaults.AuthenticationScheme); - var principal = new ClaimsPrincipal(identity); - var authenticationProperties = new AuthenticationProperties { - AllowRefresh = true, - IssuedUtc = DateTimeOffset.UtcNow, - }; - - if (persist) { - authenticationProperties.ExpiresUtc = DateTimeOffset.UtcNow.AddMonths(6); - authenticationProperties.IsPersistent = true; - } - - await httpContext.SignInAsync(principal, authenticationProperties); - await _passwordResetService.DeleteRequestsForUserAsync(user.Id); - } - - /// <summary> - /// Log out a user. - /// </summary> - /// <param name="httpContext"></param> - public async Task LogOutUser(HttpContext httpContext) { - await httpContext.SignOutAsync(); - } -} diff --git a/server/src/Services/VaultService.cs b/server/src/Services/VaultService.cs deleted file mode 100644 index 732911a..0000000 --- a/server/src/Services/VaultService.cs +++ /dev/null @@ -1,158 +0,0 @@ -using Microsoft.Extensions.Caching.Memory; - -namespace IOL.GreatOffice.Api.Services; - -public class VaultService -{ - private readonly HttpClient _client; - private readonly IMemoryCache _cache; - private readonly IConfiguration _configuration; - private readonly ILogger<VaultService> _logger; - private int CACHE_TTL { get; set; } - - public VaultService(HttpClient client, IConfiguration configuration, IMemoryCache cache, ILogger<VaultService> logger) { - var token = configuration.GetValue<string>(AppEnvironmentVariables.VAULT_TOKEN); - var vaultUrl = configuration.GetValue<string>(AppEnvironmentVariables.VAULT_URL); - CACHE_TTL = configuration.GetValue(AppEnvironmentVariables.VAULT_CACHE_TTL, 60 * 60 * 12); - if (token.IsNullOrWhiteSpace()) throw new ApplicationException("VAULT_TOKEN is empty"); - if (vaultUrl.IsNullOrWhiteSpace()) throw new ApplicationException("VAULT_URL is empty"); - client.DefaultRequestHeaders.Add("X-Vault-Token", token); - client.BaseAddress = new Uri(vaultUrl); - _client = client; - _cache = cache; - _configuration = configuration; - _logger = logger; - } - - public static object Data { get; set; } - - public T Get<T>(string path) { - var result = _cache.GetOrCreate(AppConstants.VAULT_CACHE_KEY, - cacheEntry => { - cacheEntry.AbsoluteExpirationRelativeToNow = TimeSpan.FromSeconds(CACHE_TTL); - var getSecretResponse = _client.GetFromJsonAsync<GetSecretResponse<T>>("/v1/kv/data/" + path).Result; - - if (getSecretResponse == null) { - return default; - } - - Log.Debug("Setting new Vault cache, " - + new { - PATH = path, - CACHE_TTL, - Data = JsonSerializer.Serialize(getSecretResponse.Data.Data) - }); - return getSecretResponse.Data.Data ?? default; - }); - return result; - } - - public T Refresh<T>(string path) { - _cache.Remove(AppConstants.VAULT_CACHE_KEY); - CACHE_TTL = _configuration.GetValue(AppEnvironmentVariables.VAULT_CACHE_TTL, 60 * 60 * 12); - return Get<T>(path); - } - - public async Task<RenewTokenResponse> RenewTokenAsync<T>(string token) { - var response = await _client.PostAsJsonAsync("v1/auth/token/renew", - new { - Token = token - }); - if (response.IsSuccessStatusCode) { - return await response.Content.ReadFromJsonAsync<RenewTokenResponse>(); - } - - return default; - } - - public AppConfiguration GetCurrentAppConfiguration() { - var path = _configuration.GetValue<string>(AppEnvironmentVariables.MAIN_CONFIG_SHEET); - var result = Get<AppConfiguration>(path); - var overwrites = new { - DB_HOST = _configuration.GetValue("OVERWRITE_DB_HOST", string.Empty), - DB_PORT = _configuration.GetValue("OVERWRITE_DB_PORT", string.Empty), - DB_USER = _configuration.GetValue("OVERWRITE_DB_USER", string.Empty), - DB_PASSWORD = _configuration.GetValue("OVERWRITE_DB_PASSWORD", string.Empty), - DB_NAME = _configuration.GetValue("OVERWRITE_DB_NAME", string.Empty), - }; - if (overwrites.DB_HOST.HasValue()) { - _logger.LogInformation("OVERWRITE_DB_HOST is specified, using it's value: " + overwrites.DB_HOST); - result.DB_HOST = overwrites.DB_HOST; - } - - if (overwrites.DB_PORT.HasValue()) { - _logger.LogInformation("OVERWRITE_DB_PORT is specified, using it's value: " + overwrites.DB_PORT); - result.DB_PORT = overwrites.DB_PORT; - } - - if (overwrites.DB_USER.HasValue()) { - _logger.LogInformation("OVERWRITE_DB_USER is specified, using it's value: " + overwrites.DB_USER); - result.DB_USER = overwrites.DB_USER; - } - - if (overwrites.DB_PASSWORD.HasValue()) { - _logger.LogInformation("OVERWRITE_DB_PASSWORD is specified, using it's value: " + "(redacted)"); - result.DB_PASSWORD = overwrites.DB_PASSWORD; - } - - if (overwrites.DB_NAME.HasValue()) { - _logger.LogInformation("OVERWRITE_DB_NAME is specified, using it's value: " + overwrites.DB_NAME); - result.DB_NAME = overwrites.DB_NAME; - } - - return result; - } - - public AppConfiguration RefreshCurrentAppConfiguration() { - var path = _configuration.GetValue<string>(AppEnvironmentVariables.MAIN_CONFIG_SHEET); - return Refresh<AppConfiguration>(path); - } - - public class RenewTokenResponse - { - public Guid RequestId { get; set; } - public string LeaseId { get; set; } - public bool Renewable { get; set; } - public long LeaseDuration { get; set; } - public object Data { get; set; } - public object WrapInfo { get; set; } - public List<string> Warnings { get; set; } - public Auth Auth { get; set; } - } - - public class Auth - { - public string ClientToken { get; set; } - public string Accessor { get; set; } - public List<string> Policies { get; set; } - public List<string> TokenPolicies { get; set; } - public object Metadata { get; set; } - public long LeaseDuration { get; set; } - public bool Renewable { get; set; } - public string EntityId { get; set; } - public string TokenType { get; set; } - public bool Orphan { get; set; } - public object MfaRequirement { get; set; } - public long NumUses { get; set; } - } - - public class GetSecretResponse<T> - { - public VaultSecret<T> Data { get; set; } - } - - public class VaultSecret<T> - { - public T Data { get; set; } - public VaultSecretMetadata Metadata { get; set; } - } - - public class VaultSecretMetadata - { - public DateTimeOffset CreatedTime { get; set; } - public object CustomMetadata { get; set; } - public string DeletionTime { get; set; } - public bool Destroyed { get; set; } - public long Version { get; set; } - } -} diff --git a/server/src/Utilities/BasicAuthenticationAttribute.cs b/server/src/Utilities/BasicAuthenticationAttribute.cs deleted file mode 100644 index 0bfd007..0000000 --- a/server/src/Utilities/BasicAuthenticationAttribute.cs +++ /dev/null @@ -1,39 +0,0 @@ -using System.Net.Http.Headers; -using Microsoft.AspNetCore.Mvc.Filters; - -namespace IOL.GreatOffice.Api.Utilities; - -public class BasicAuthenticationAttribute : TypeFilterAttribute -{ - public BasicAuthenticationAttribute(string claimPermission) : base(typeof(BasicAuthenticationFilter)) { - Arguments = new object[] { - new Claim(claimPermission, "True") - }; - } -} - -public class BasicAuthenticationFilter : IAuthorizationFilter -{ - private readonly Claim _claim; - - public BasicAuthenticationFilter(Claim claim) { - _claim = claim; - } - - public void OnAuthorization(AuthorizationFilterContext context) { - if (!context.HttpContext.Request.Headers.ContainsKey("Authorization")) return; - try { - var authHeader = AuthenticationHeaderValue.Parse(context.HttpContext.Request.Headers["Authorization"]); - if (authHeader.Parameter is null) { - context.Result = new ForbidResult(AppConstants.BASIC_AUTH_SCHEME); - } - - var hasClaim = context.HttpContext.User.Claims.Any(c => c.Type == _claim.Type && c.Value == _claim.Value); - if (!hasClaim) { - context.Result = new ForbidResult(AppConstants.BASIC_AUTH_SCHEME); - } - } catch { - // ignore - } - } -} diff --git a/server/src/Utilities/BasicAuthenticationHandler.cs b/server/src/Utilities/BasicAuthenticationHandler.cs deleted file mode 100644 index 6138193..0000000 --- a/server/src/Utilities/BasicAuthenticationHandler.cs +++ /dev/null @@ -1,79 +0,0 @@ -using System.Net.Http.Headers; -using System.Text; -using System.Text.Encodings.Web; -using Microsoft.Extensions.Options; - -namespace IOL.GreatOffice.Api.Utilities; - -public class BasicAuthenticationHandler : AuthenticationHandler<AuthenticationSchemeOptions> -{ - private readonly AppDbContext _context; - private readonly AppConfiguration _configuration; - private readonly ILogger<BasicAuthenticationHandler> _logger; - - public BasicAuthenticationHandler( - IOptionsMonitor<AuthenticationSchemeOptions> options, - ILoggerFactory logger, - UrlEncoder encoder, - ISystemClock clock, - AppDbContext context, - VaultService vaultService - ) : - base(options, logger, encoder, clock) { - _context = context; - _configuration = vaultService.GetCurrentAppConfiguration(); - _logger = logger.CreateLogger<BasicAuthenticationHandler>(); - } - - protected override Task<AuthenticateResult> HandleAuthenticateAsync() { - var endpoint = Context.GetEndpoint(); - if (endpoint?.Metadata.GetMetadata<IAllowAnonymous>() != null) - return Task.FromResult(AuthenticateResult.NoResult()); - - if (!Request.Headers.ContainsKey("Authorization")) - return Task.FromResult(AuthenticateResult.Fail("Missing Authorization Header")); - - try { - var tokenEntropy = _configuration.APP_AES_KEY; - if (tokenEntropy.IsNullOrWhiteSpace()) { - _logger.LogWarning("No token entropy is available in env:TOKEN_ENTROPY, Basic auth is disabled"); - return Task.FromResult(AuthenticateResult.Fail("Invalid Authorization Header")); - } - - var authHeader = AuthenticationHeaderValue.Parse(Request.Headers["Authorization"]); - if (authHeader.Parameter == null) return Task.FromResult(AuthenticateResult.Fail("Invalid Authorization Header")); - var credentialBytes = Convert.FromBase64String(authHeader.Parameter); - var decryptedString = Encoding.UTF8.GetString(credentialBytes).DecryptWithAes(tokenEntropy); - var tokenIsGuid = Guid.TryParse(decryptedString, out var tokenId); - - if (!tokenIsGuid) { - return Task.FromResult(AuthenticateResult.Fail("Invalid Authorization Header")); - } - - var token = _context.AccessTokens.Include(c => c.User).SingleOrDefault(c => c.Id == tokenId); - if (token == default) { - return Task.FromResult(AuthenticateResult.Fail("Invalid Authorization Header: Not Found")); - } - - if (token.HasExpired) { - return Task.FromResult(AuthenticateResult.Fail("Invalid Authorization Header: Expired")); - } - - var permissions = new List<Claim>() { - new(AppConstants.TOKEN_ALLOW_READ, token.AllowRead.ToString()), - new(AppConstants.TOKEN_ALLOW_UPDATE, token.AllowUpdate.ToString()), - new(AppConstants.TOKEN_ALLOW_CREATE, token.AllowCreate.ToString()), - new(AppConstants.TOKEN_ALLOW_DELETE, token.AllowDelete.ToString()), - }; - var claims = token.User.DefaultClaims().Concat(permissions); - var identity = new ClaimsIdentity(claims, AppConstants.BASIC_AUTH_SCHEME); - var principal = new ClaimsPrincipal(identity); - var ticket = new AuthenticationTicket(principal, AppConstants.BASIC_AUTH_SCHEME); - - return Task.FromResult(AuthenticateResult.Success(ticket)); - } catch (Exception e) { - _logger.LogError(e, $"An exception occured when challenging {AppConstants.BASIC_AUTH_SCHEME}"); - return Task.FromResult(AuthenticateResult.Fail("Invalid Authorization Header")); - } - } -} diff --git a/server/src/Utilities/ConfigurationExtensions.cs b/server/src/Utilities/ConfigurationExtensions.cs deleted file mode 100644 index 405c702..0000000 --- a/server/src/Utilities/ConfigurationExtensions.cs +++ /dev/null @@ -1,88 +0,0 @@ -namespace IOL.GreatOffice.Api.Utilities; - -public static class ConfigurationExtensions -{ - public static string GetAppDatabaseConnectionString(this IConfiguration config, AppConfiguration configuration) { - var host = configuration.DB_HOST; - var port = configuration.DB_PORT; - var database = configuration.DB_NAME; - var user = configuration.DB_USER; - var password = configuration.DB_PASSWORD; - - var res = ""; - if (config.GetValue<string>("ASPNETCORE_ENVIRONMENT") == "Development") { - res = $"Server={host};Port={port};Database={database};User Id={user};Password={password};Include Error Detail=true"; - } else { - res = $"Server={host};Port={port};Database={database};User Id={user};Password={password}"; - } - - Log.Debug("Using app database connection string: " + res); - return res; - } - - public static string GetAppDatabaseConnectionString(this IConfiguration config, Func<AppConfiguration> configuration) { - var _configuration = configuration(); - var host = _configuration.DB_HOST; - var port = _configuration.DB_PORT; - var database = _configuration.DB_NAME; - var user = _configuration.DB_USER; - var password = _configuration.DB_PASSWORD; - - var res = ""; - if (config.GetValue<string>("ASPNETCORE_ENVIRONMENT") == "Development") { - res = $"Server={host};Port={port};Database={database};User Id={user};Password={password};Include Error Detail=true"; - } else { - res = $"Server={host};Port={port};Database={database};User Id={user};Password={password}"; - } - - Log.Debug("Using app database connection string: " + res); - return res; - } - - public static string GetQuartzDatabaseConnectionString(this IConfiguration config, AppConfiguration configuration) { - var host = configuration.QUARTZ_DB_HOST; - var port = configuration.QUARTZ_DB_PORT; - var database = configuration.QUARTZ_DB_NAME; - var user = configuration.QUARTZ_DB_USER; - var password = configuration.QUARTZ_DB_PASSWORD; - - var res = ""; - if (config.GetValue<string>("ASPNETCORE_ENVIRONMENT") == "Development") { - res = $"Server={host};Port={port};Database={database};User Id={user};Password={password};Include Error Detail=true"; - } else { - res = $"Server={host};Port={port};Database={database};User Id={user};Password={password}"; - } - - Log.Debug("Using quartz database connection string: " + res); - return res; - } - - public static string GetQuartzDatabaseConnectionString(this IConfiguration config, Func<AppConfiguration> configuration) { - var _configuration = configuration(); - var host = _configuration.QUARTZ_DB_HOST; - var port = _configuration.QUARTZ_DB_PORT; - var database = _configuration.QUARTZ_DB_NAME; - var user = _configuration.QUARTZ_DB_USER; - var password = _configuration.QUARTZ_DB_PASSWORD; - - var res = ""; - if (config.GetValue<string>("ASPNETCORE_ENVIRONMENT") == "Development") { - res = $"Server={host};Port={port};Database={database};User Id={user};Password={password};Include Error Detail=true"; - } else { - res = $"Server={host};Port={port};Database={database};User Id={user};Password={password}"; - } - - Log.Debug("Using quartz database connection string: " + res); - return res; - } - - public static string GetVersion(this IConfiguration configuration) { - var versionFilePath = Path.Combine(AppPaths.AppData.HostPath, "version.txt"); - if (File.Exists(versionFilePath)) { - var versionText = File.ReadAllText(versionFilePath); - return versionText + "-" + configuration.GetValue<string>("ASPNETCORE_ENVIRONMENT"); - } - - return "unknown-" + configuration.GetValue<string>("ASPNETCORE_ENVIRONMENT"); - } -} diff --git a/server/src/Utilities/GithubAuthenticationHelpers.cs b/server/src/Utilities/GithubAuthenticationHelpers.cs deleted file mode 100644 index a4461d2..0000000 --- a/server/src/Utilities/GithubAuthenticationHelpers.cs +++ /dev/null @@ -1,84 +0,0 @@ -using Microsoft.AspNetCore.Authentication.OAuth; -using Npgsql; - -namespace IOL.GreatOffice.Api.Utilities; - -public static class GithubAuthenticationHelpers -{ - public static async Task HandleGithubTicketCreation(OAuthCreatingTicketContext context, IConfiguration configuration, AppConfiguration options) { - var githubId = context.Identity?.FindFirst(p => p.Type == ClaimTypes.NameIdentifier)?.Value; - var githubUsername = context.Identity?.FindFirst(p => p.Type == ClaimTypes.Name)?.Value; - var githubEmail = context.Identity?.FindFirst(p => p.Type == ClaimTypes.Email)?.Value; - - if (githubId.IsNullOrWhiteSpace() || githubUsername.IsNullOrWhiteSpace() || context.Identity == default) { - return; - } - - var claims = context.Identity.Claims.ToList(); - foreach (var claim in claims) { - context.Identity.RemoveClaim(claim); - } - - var connstring = configuration.GetAppDatabaseConnectionString(options); - var connection = new NpgsqlConnection(connstring); - - Log.Information($"Getting user mappings for github user: {githubId}"); - var getMappedUserQuery = @$"SELECT u.id,u.username FROM github_user_mappings INNER JOIN users u on u.id = github_user_mappings.user_id WHERE github_id='{githubId}'"; - await connection.OpenAsync(); - await using var getMappedUserCommand = new NpgsqlCommand(getMappedUserQuery, connection); - await using var reader = await getMappedUserCommand.ExecuteReaderAsync(); - var handled = false; - while (await reader.ReadAsync()) { - try { - var userId = reader.GetGuid(0); - var username = reader.GetString(1); - context.Identity.AddClaim(new Claim(AppClaims.USER_ID, userId.ToString())); - context.Identity.AddClaim(new Claim(AppClaims.NAME, username)); - if (context.AccessToken != default) { - context.Identity.AddClaim(new Claim(AppClaims.GITHUB_ACCESS_TOKEN, context.AccessToken ?? "")); - } - - Log.Information($"Found mapping for github id {githubId} mapped to user id {userId}"); - handled = true; - } catch (Exception e) { - Log.Error(e, "An exception occured when handling github user mappings"); - handled = false; - } - } - - await connection.CloseAsync(); - - if (!handled) { - var userId = Guid.NewGuid(); - - var insertUserQuery = $@"INSERT INTO users VALUES ('{userId}', '{githubUsername}', '', '{AppDateTime.UtcNow}')"; - await connection.OpenAsync(); - await using var insertUserCommand = new NpgsqlCommand(insertUserQuery, connection); - await insertUserCommand.ExecuteNonQueryAsync(); - await connection.CloseAsync(); - - var refreshTokenEncryptionKey = options.APP_AES_KEY; - string insertMappingQuery; - - if (context.RefreshToken.HasValue() && refreshTokenEncryptionKey.HasValue()) { - var encryptedRefreshToken = context.RefreshToken.EncryptWithAes(refreshTokenEncryptionKey); - insertMappingQuery = $@"INSERT INTO github_user_mappings VALUES ('{githubId}', '{userId}', '{githubEmail}', '{encryptedRefreshToken}')"; - } else { - insertMappingQuery = $@"INSERT INTO github_user_mappings VALUES ('{githubId}', '{userId}', '{githubEmail}', '')"; - } - - await connection.OpenAsync(); - await using var insertMappingCommand = new NpgsqlCommand(insertMappingQuery, connection); - await insertMappingCommand.ExecuteNonQueryAsync(); - await connection.CloseAsync(); - - context.Identity.AddClaim(new Claim(AppClaims.USER_ID, userId.ToString())); - context.Identity.AddClaim(new Claim(AppClaims.NAME, githubUsername)); - if (context.AccessToken != default) { - context.Identity.AddClaim(new Claim(AppClaims.GITHUB_ACCESS_TOKEN, context.AccessToken ?? "")); - } - - Log.Information($"Created mapping for github id {githubId} mapped to user id {userId}"); - } - } -} diff --git a/server/src/Utilities/QuartzJsonSerializer.cs b/server/src/Utilities/QuartzJsonSerializer.cs deleted file mode 100644 index 164a189..0000000 --- a/server/src/Utilities/QuartzJsonSerializer.cs +++ /dev/null @@ -1,16 +0,0 @@ -using Quartz.Spi; - -namespace IOL.GreatOffice.Api.Utilities; - -public class QuartzJsonSerializer : IObjectSerializer -{ - public void Initialize() { } - - public byte[] Serialize<T>(T obj) where T : class { - return JsonSerializer.SerializeToUtf8Bytes(obj); - } - - public T DeSerialize<T>(byte[] data) where T : class { - return JsonSerializer.Deserialize<T>(data); - } -} diff --git a/server/src/Utilities/SwaggerDefaultValues.cs b/server/src/Utilities/SwaggerDefaultValues.cs deleted file mode 100644 index 4b5c764..0000000 --- a/server/src/Utilities/SwaggerDefaultValues.cs +++ /dev/null @@ -1,58 +0,0 @@ -using Microsoft.AspNetCore.Mvc.ApiExplorer; -using Swashbuckle.AspNetCore.SwaggerGen; - -namespace IOL.GreatOffice.Api.Utilities; - -/// <summary> -/// Represents the Swagger/Swashbuckle operation filter used to document the implicit API version parameter. -/// </summary> -/// <remarks>This <see cref="IOperationFilter"/> is only required due to bugs in the <see cref="SwaggerGenerator"/>. -/// Once they are fixed and published, this class can be removed.</remarks> -public class SwaggerDefaultValues : IOperationFilter -{ - /// <summary> - /// Applies the filter to the specified operation using the given context. - /// </summary> - /// <param name="operation">The operation to apply the filter to.</param> - /// <param name="context">The current operation filter context.</param> - public void Apply(OpenApiOperation operation, OperationFilterContext context) { - var apiDescription = context.ApiDescription; - - operation.Deprecated |= apiDescription.IsDeprecated(); - - // REF: https://github.com/domaindrivendev/Swashbuckle.AspNetCore/issues/1752#issue-663991077 - foreach (var responseType in context.ApiDescription.SupportedResponseTypes) { - // REF: https://github.com/domaindrivendev/Swashbuckle.AspNetCore/blob/b7cf75e7905050305b115dd96640ddd6e74c7ac9/src/Swashbuckle.AspNetCore.SwaggerGen/SwaggerGenerator/SwaggerGenerator.cs#L383-L387 - var responseKey = responseType.IsDefaultResponse ? "default" : responseType.StatusCode.ToString(); - var response = operation.Responses[responseKey]; - - foreach (var contentType in response.Content.Keys) { - if (!responseType.ApiResponseFormats.Any(x => x.MediaType == contentType)) { - response.Content.Remove(contentType); - } - } - } - - if (operation.Parameters == null) { - return; - } - - // REF: https://github.com/domaindrivendev/Swashbuckle.AspNetCore/issues/412 - // REF: https://github.com/domaindrivendev/Swashbuckle.AspNetCore/pull/413 - foreach (var parameter in operation.Parameters) { - var description = apiDescription.ParameterDescriptions.First(p => p.Name == parameter.Name); - - if (parameter.Description == null) { - parameter.Description = description.ModelMetadata.Description; - } - - if (parameter.Schema.Default == null && description.DefaultValue != null) { - // REF: https://github.com/Microsoft/aspnet-api-versioning/issues/429#issuecomment-605402330 - var json = JsonSerializer.Serialize(description.DefaultValue, description.ModelMetadata.ModelType); - parameter.Schema.Default = OpenApiAnyFactory.CreateFromJson(json); - } - - parameter.Required |= description.IsRequired; - } - } -} diff --git a/server/src/Utilities/SwaggerGenOptionsExtensions.cs b/server/src/Utilities/SwaggerGenOptionsExtensions.cs deleted file mode 100644 index a2dcf7a..0000000 --- a/server/src/Utilities/SwaggerGenOptionsExtensions.cs +++ /dev/null @@ -1,43 +0,0 @@ -#nullable enable -using Microsoft.AspNetCore.Mvc.ApiExplorer; -using Microsoft.AspNetCore.Mvc.Controllers; -using Swashbuckle.AspNetCore.SwaggerGen; -using BaseRoute = IOL.GreatOffice.Api.Endpoints.V1.BaseRoute; - -namespace IOL.GreatOffice.Api.Utilities; - -public static class SwaggerGenOptionsExtensions -{ - /// <summary> - /// Updates Swagger document to support ApiEndpoints.<br/><br/> - /// For controllers inherited from <see cref="BaseRoute"/>:<br/> - /// - Replaces action Tag with <c>[namespace]</c><br/> - /// </summary> - public static void UseApiEndpoints(this SwaggerGenOptions options) { - options.TagActionsBy(EndpointNamespaceOrDefault); - } - - private static IList<string?> EndpointNamespaceOrDefault(ApiDescription api) { - if (api.ActionDescriptor is not ControllerActionDescriptor actionDescriptor) { - throw new InvalidOperationException($"Unable to determine tag for endpoint: {api.ActionDescriptor.DisplayName}"); - } - - if (actionDescriptor.ControllerTypeInfo.GetBaseTypesAndThis().Any(t => t == typeof(BaseRoute))) { - return new[] { - actionDescriptor.ControllerTypeInfo.Namespace?.Split('.').Last() - }; - } - - return new[] { - actionDescriptor.ControllerName - }; - } - - public static IEnumerable<Type> GetBaseTypesAndThis(this Type type) { - Type? current = type; - while (current != null) { - yield return current; - current = current.BaseType; - } - } -} diff --git a/server/src/appsettings.json b/server/src/appsettings.json deleted file mode 100644 index 8727fd7..0000000 --- a/server/src/appsettings.json +++ /dev/null @@ -1,22 +0,0 @@ -{ - "AllowedHosts": "*", - "Serilog": { - "MinimumLevel": { - "Default": "Information", - "Override": { - "Microsoft": "Warning", - "Microsoft.Hosting.Lifetime": "Information", - "Microsoft.EntityFrameworkCore": "Information", - "Microsoft.AspNetCore": "Warning" - } - }, - "Filter": [ - { - "Name": "ByExcluding", - "Args": { - "expression": "@mt = 'An unhandled exception has occurred while executing the request.'" - } - } - ] - } -} diff --git a/server/src/wwwroot/version.txt b/server/src/wwwroot/version.txt deleted file mode 100644 index 9cf68da..0000000 --- a/server/src/wwwroot/version.txt +++ /dev/null @@ -1 +0,0 @@ -v47-server-dev |
