Rename BaseTable to BaseModel

This commit is contained in:
Nicolas Duhamel 2016-02-20 19:42:56 +01:00
parent bb9a5789d7
commit 7b32887840
3 changed files with 8 additions and 7 deletions

View File

@ -42,12 +42,12 @@ const (
) )
var ( var (
// NotFound error returned when show not found in database // ErrNotFound error returned when show not found in database
ErrNotFound = fmt.Errorf("Not found") ErrNotFound = fmt.Errorf("Not found")
) )
type Show struct { type Show struct {
sqly.BaseTable sqly.BaseModel
polochon.Show polochon.Show
Episodes []*Episode Episodes []*Episode
TrackedSeason int TrackedSeason int
@ -213,7 +213,7 @@ func (s *Show) GetEpisodes(db *sqlx.DB) error {
} }
type Episode struct { type Episode struct {
sqly.BaseTable sqly.BaseModel
polochon.ShowEpisode polochon.ShowEpisode
} }

View File

@ -9,13 +9,14 @@ import (
"github.com/mattes/migrate/migrate" "github.com/mattes/migrate/migrate"
) )
// BaseTable have to be embeded in all your struct which reflect a table // BaseModel have to be embeded in all your struct which reflect a table
type BaseTable struct { type BaseModel struct {
ID string ID string
Updated time.Time Updated time.Time
Created time.Time Created time.Time
} }
// RunWithLastestMigration runs your test with database migration set to the lastest
func RunWithLastestMigration(db *sqlx.DB, pgdsn string, t *testing.T, test func(db *sqlx.DB, t *testing.T)) { func RunWithLastestMigration(db *sqlx.DB, pgdsn string, t *testing.T, test func(db *sqlx.DB, t *testing.T)) {
defer func() { defer func() {
allErrors, ok := migrate.DownSync(pgdsn, "../sql") allErrors, ok := migrate.DownSync(pgdsn, "../sql")

View File

@ -22,14 +22,14 @@ const (
// User represents an user // User represents an user
type User struct { type User struct {
sqly.BaseTable sqly.BaseModel
Name string Name string
Hash string Hash string
} }
// Token represents a token // Token represents a token
type Token struct { type Token struct {
sqly.BaseTable sqly.BaseModel
Value string Value string
} }