todo sqlite and inmemory repo

This commit is contained in:
2025-02-06 16:33:49 -05:00
parent 21747e0f72
commit bb3d9abb7e
7 changed files with 233 additions and 12 deletions

View File

@@ -14,21 +14,14 @@ type Migration struct {
Name string
}
func Migrate() {
db, err := sql.Open("sqlite3", "./habits.db")
if err != nil {
log.Fatal("Failed to open db pool")
}
defer db.Close()
func Migrate(db *sql.DB) {
migrationTableSql := `
CREATE TABLE IF NOT EXISTS migrations(
version INTEGER PRIMARY KEY,
name VARCHAR(50)
);`
_, err = db.Exec(migrationTableSql)
_, err := db.Exec(migrationTableSql)
if err != nil {
log.Fatal(err)
}