@@ -15,6 +15,7 @@ type Repository struct {
1515 Description string `db:"description"`
1616 CreatedAt time.Time `db:"created_at"`
1717 UpdatedAt time.Time `db:"updated_at"`
18+ GithubURL string `db:"github_url"`
1819}
1920
2021type RepositoryStore struct {
@@ -35,7 +36,7 @@ func (store *RepositoryStore) GetByKey(ctx context.Context, key string) (*Reposi
3536
3637 var r Repository
3738 err := store .database .QueryRowContext (ctx , `
38- SELECT id, owner, name, description, created_at, updated_at
39+ SELECT id, owner, name, description, created_at, updated_at, github_url
3940 FROM repositories
4041 WHERE owner = ? AND name = ?
4142 ` , owner , name ).Scan (
@@ -45,6 +46,7 @@ func (store *RepositoryStore) GetByKey(ctx context.Context, key string) (*Reposi
4546 & r .Description ,
4647 & r .CreatedAt ,
4748 & r .UpdatedAt ,
49+ & r .GithubURL ,
4850 )
4951
5052 if err != nil {
@@ -59,27 +61,29 @@ func (store *RepositoryStore) GetByKey(ctx context.Context, key string) (*Reposi
5961
6062func (store * RepositoryStore ) Upsert (ctx context.Context , r Repository ) error {
6163 _ , err := store .database .ExecContext (ctx , `
62- INSERT INTO repositories (id, owner, name, description, created_at, updated_at)
63- VALUES (?, ?, ?, ?, ?, ?)
64+ INSERT INTO repositories (id, owner, name, description, created_at, updated_at, github_url )
65+ VALUES (?, ?, ?, ?, ?, ?, ? )
6466 ON CONFLICT(id) DO UPDATE SET
6567 owner = excluded.owner,
6668 name = excluded.name,
6769 description = excluded.description,
68- updated_at = excluded.updated_at;
70+ updated_at = excluded.updated_at,
71+ github_url = excluded.github_url;
6972 ` ,
7073 r .ID ,
7174 r .Owner ,
7275 r .Name ,
7376 r .Description ,
7477 r .CreatedAt ,
7578 r .UpdatedAt ,
79+ r .GithubURL ,
7680 )
7781 return err
7882}
7983
8084func (store * RepositoryStore ) GetAll () []Repository {
8185 rows , err := store .database .Query (`
82- SELECT id, owner, name, description, created_at, updated_at
86+ SELECT id, owner, name, description, created_at, updated_at, github_url
8387 FROM repositories
8488 ` )
8589 if err != nil {
@@ -97,6 +101,7 @@ func (store *RepositoryStore) GetAll() []Repository {
97101 & r .Description ,
98102 & r .CreatedAt ,
99103 & r .UpdatedAt ,
104+ & r .GithubURL ,
100105 ); err != nil {
101106 panic (err )
102107 }
0 commit comments