Skip to content

Commit

Permalink
ref
Browse files Browse the repository at this point in the history
  • Loading branch information
Olegsuus committed Jun 19, 2024
1 parent 13fed01 commit 697c513
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 13 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
.idea
7 changes: 3 additions & 4 deletions internal/database/storage.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,12 @@ package database
import (
"database/sql"
"fmt"
"log"
"news-api/internal/config"
"news-api/internal/models"

_ "github.com/lib/pq"
"gopkg.in/reform.v1"
"gopkg.in/reform.v1/dialects/postgresql"
"log"
"news-api/internal/config"
"news-api/internal/models"
)

type DB struct {
Expand Down
3 changes: 2 additions & 1 deletion internal/migrations/migrations.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,13 @@ import (
"embed"
"github.com/pressly/goose/v3"
"log"
"news-api/internal/config"
)

//go:embed *.sql
var embedMigrations embed.FS

func MigrateUp(db *sql.DB) {
func Migrations(cfg *config.Config, db *sql.DB) {
goose.SetBaseFS(embedMigrations)

if err := goose.SetDialect("postgres"); err != nil {
Expand Down
8 changes: 0 additions & 8 deletions internal/models/models.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,6 @@ func (*News) String() string {
}

// Implementing reform.Record interface
func (n *News) String() string {
return "News"
}

func (n *News) Values() []interface{} {
return []interface{}{n.ID, n.Title, n.Content}
}
Expand All @@ -45,10 +41,6 @@ func (*NewsCategory) String() string {
}

// Implementing reform.Record interface
func (nc *NewsCategory) String() string {
return "NewsCategory"
}

func (nc *NewsCategory) Values() []interface{} {
return []interface{}{nc.NewsID, nc.CategoryID}
}
Expand Down

0 comments on commit 697c513

Please sign in to comment.