-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Implement simple database access layer (#19)
* feat: Implement Repository CreateItem function * feat: Inject a repository into the Server * feat: Implement Repository functions * feat: Implement delete function in repository
- Loading branch information
1 parent
433a728
commit f585ee8
Showing
10 changed files
with
661 additions
and
22 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
output: ./out/ | ||
output: './out' | ||
database: | ||
driver: sqlite3 | ||
dsn: ':memory:' | ||
driver: 'sqlite3' | ||
|
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,21 @@ | ||
package database | ||
|
||
import ( | ||
"database/sql" | ||
"embed" | ||
|
||
"github.com/pressly/goose/v3" | ||
) | ||
|
||
//go:embed migrations/*.sql | ||
var embedMigrations embed.FS | ||
|
||
// MigrateDatabase migrates the database to the latest version. | ||
func MigrateDatabase(db *sql.DB, cfg Config) error { | ||
if err := goose.SetDialect(cfg.Driver); err != nil { | ||
return err | ||
} | ||
goose.SetBaseFS(embedMigrations) | ||
|
||
return goose.Up(db, "migrations") | ||
} |
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
Oops, something went wrong.