- commit
- 2b4cefb
- parent
- 5a19fa8
- author
- Eric Bower
- date
- 2024-04-28 21:31:01 -0400 EDT
chore: working on db models
1 files changed,
+43,
-7
M
db.go
M
db.go
+43,
-7
1@@ -1,14 +1,50 @@
2 package git
3
4-import "time"
5+import (
6+ "database/sql"
7+ "time"
8+)
9
10-type Patch struct {
11- ID string
12- Owner string
13- Contents string
14- CreatedAt *time.Time
15+// User is the entity repesenting a pubkey authenticated user
16+// A user and a single ssh key-pair are synonymous in this context
17+type User struct {
18+ ID int64 `db:"id"`
19+ Name string `db:"name"`
20+ Pubkey string `db:"pubkey"`
21+ CreatedAt time.Time `db:"created_at"`
22+ UpdatedAt time.Time `db:"updated_at"`
23+}
24+
25+// PatchRequest is a database model for patches submitted to a Repo
26+type PatchRequest struct {
27+ ID int64 `db:"id"`
28+ UserID int64 `db:"user_id"`
29+ RepoID int64 `db:"repo_id"`
30+ Name string `db:"name"`
31+ CreatedAt time.Time `db:"created_at"`
32+ UpdatedAt time.Time `db:"updated_at"`
33+}
34+
35+// Comment is a database model for a reply to a PatchRequest
36+type Comment struct {
37+ ID int64 `db:"id"`
38+ UserID int64 `db:"user_id"`
39+ PatchRequestID int64 `db:"comment"`
40+ CreatedAt time.Time `db:"created_at"`
41+ UpdatedAt time.Time `db:"updated_at"`
42+}
43+
44+// Repo is a database model for a repository.
45+type Repo struct {
46+ ID int64 `db:"id"`
47+ Name string `db:"name"`
48+ ProjectName string `db:"project_name"`
49+ Description string `db:"description"`
50+ Private bool `db:"private"`
51+ UserID sql.NullInt64 `db:"user_id"`
52+ CreatedAt time.Time `db:"created_at"`
53+ UpdatedAt time.Time `db:"updated_at"`
54 }
55
56 type GitDB interface {
57- InsertPatch(patch *Patch) (*Patch, error)
58 }