-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(main): Reworked database instrumentation
- Loading branch information
Showing
33 changed files
with
753 additions
and
984 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
-- +goose Up | ||
CREATE TABLE gophers ( | ||
id INTEGER NOT NULL PRIMARY KEY /*!40101 AUTO_INCREMENT */, | ||
name VARCHAR(255) NOT NULL, | ||
job VARCHAR(255) | ||
); | ||
|
||
-- +goose Down | ||
DROP TABLE IF EXISTS gophers; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
-- name: ListGophers :many | ||
SELECT g.* FROM gophers AS g | ||
ORDER BY g.name; | ||
|
||
-- name: GetGopher :one | ||
SELECT g.* FROM gophers AS g | ||
WHERE g.id = ? | ||
LIMIT 1; | ||
|
||
-- name: CreateGopher :execresult | ||
INSERT INTO gophers ( | ||
name, job | ||
) VALUES ( | ||
?, ? | ||
); | ||
|
||
-- name: DeleteGopher :exec | ||
DELETE FROM gophers | ||
WHERE id = ?; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
package seeds | ||
|
||
import ( | ||
"context" | ||
"database/sql" | ||
|
||
"github.com/ankorstore/yokai/config" | ||
) | ||
|
||
type GophersSeed struct { | ||
config *config.Config | ||
} | ||
|
||
func NewGophersSeed(config *config.Config) *GophersSeed { | ||
return &GophersSeed{ | ||
config: config, | ||
} | ||
} | ||
|
||
func (s *GophersSeed) Name() string { | ||
return "gophers" | ||
} | ||
|
||
func (s *GophersSeed) Run(ctx context.Context, db *sql.DB) error { | ||
for name, job := range s.config.GetStringMapString("config.seed.gophers") { | ||
_, err := db.ExecContext(ctx, "INSERT INTO gophers (name, job) VALUES (?, ?)", name, job) | ||
if err != nil { | ||
return err | ||
} | ||
} | ||
|
||
return nil | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.