Skip to content

Commit

Permalink
Add branch models to database
Browse files Browse the repository at this point in the history
  • Loading branch information
vicr123 committed Jul 5, 2024
1 parent e065248 commit 088bff8
Show file tree
Hide file tree
Showing 6 changed files with 26 additions and 1 deletion.
1 change: 1 addition & 0 deletions Parlance.Database/Models/EditsPending.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ public class EditsPending

public ulong UserId { get; set; }
public string Project { get; set; } = null!;
public string Branch { get; set; } = null!;
public string Subproject { get; set; } = null!;
public string Language { get; set; } = null!;
}
1 change: 1 addition & 0 deletions Parlance.Database/Models/IndexItem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ public class IndexItem
public Guid Id { get; set; }

public string Project { get; set; } = null!;
public string Branch { get; set; } = null!;
public string Subproject { get; set; } = null!;
public string Language { get; set; } = null!;
public string ItemIdentifier { get; set; } = null!;
Expand Down
20 changes: 20 additions & 0 deletions Parlance.Database/Models/ProjectBranch.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;

namespace Parlance.Database.Models;

public class ProjectBranch
{
[DatabaseGenerated(DatabaseGeneratedOption.Identity)]
[Key]
public Guid Id { get; set; }

public Guid? ProjectId { get; set; }
public Project? Project { get; set; }

public string BranchName { get; set; }

public string Worktree { get; set; }

public bool DefaultBranch { get; set; }
}
1 change: 1 addition & 0 deletions Parlance.Database/Models/SourceStrings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ public class SourceStrings
public Guid Id { get; set; }

public string Project { get; set; }
public string Branch { get; set; }
public string Subproject { get; set; }
public string Language { get; set; }
public string Key { get; set; }
Expand Down
2 changes: 2 additions & 0 deletions Parlance.Database/ParlanceContext.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ public class ParlanceContext(DbContextOptions options) : DbContext(options)
public DbSet<SshTrustedServer> SshTrustedServers { get; set; } = null!;
public DbSet<Superuser> Superusers { get; set; } = null!;
public DbSet<Project> Projects { get; set; } = null!;
public DbSet<ProjectBranch> ProjectBranches { get; set; } = null!;
public DbSet<Permission> Permissions { get; set; } = null!;
public DbSet<IndexItem> Index { get; set; } = null!;
public DbSet<Alert> Alerts { get; set; } = null!;
Expand All @@ -32,6 +33,7 @@ protected override void OnModelCreating(ModelBuilder modelBuilder)
modelBuilder.Entity<Superuser>().ToTable("Superusers");
modelBuilder.Entity<Project>().ToTable("Projects")
.HasIndex(p => p.Name).IsUnique();
modelBuilder.Entity<ProjectBranch>().ToTable("ProjectBranches");
modelBuilder.Entity<Permission>().ToTable("Permissions");
modelBuilder.Entity<IndexItem>().ToTable("Index");
modelBuilder.Entity<Alert>().ToTable("Alerts");
Expand Down
2 changes: 1 addition & 1 deletion Parlance.Project/ParlanceProject.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ public class ParlanceProject : IParlanceProject

private readonly Database.Models.Project _project;

public ParlanceProject(Database.Models.Project project)
public ParlanceProject(Database.Models.Project project, string branch)
{
_project = project;
using var file = File.OpenRead(Path.Combine(project.VcsDirectory, ".parlance.json"));
Expand Down

0 comments on commit 088bff8

Please sign in to comment.