Skip to content

Commit

Permalink
fixed usages of sql instead of the null shortcuts
Browse files Browse the repository at this point in the history
  • Loading branch information
CommanderStorm committed Sep 19, 2023
1 parent ba654dd commit d6817da
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 22 deletions.
3 changes: 2 additions & 1 deletion server/backend/cron/movies.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,14 @@ import (
"encoding/json"
"encoding/xml"
"errors"
"github.com/guregu/null"
"io"
"net/http"
"os"
"strings"
"time"

"github.com/guregu/null"

"github.com/PuerkitoBio/goquery"
"github.com/TUM-Dev/Campus-Backend/server/model"
log "github.com/sirupsen/logrus"
Expand Down
8 changes: 3 additions & 5 deletions server/backend/migration/2023090410000000.go
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
package migration

import (
"database/sql"

"github.com/TUM-Dev/Campus-Backend/server/model"
"github.com/go-gormigrate/gormigrate/v2"
"github.com/guregu/null"
Expand All @@ -27,8 +25,8 @@ func (m TumDBMigrator) migrate2023090410000000() *gormigrate.Migration {
}
if err := tx.Create(&model.Crontab{
Interval: 60 * 60 * 24, // daily
Type: null.String{NullString: sql.NullString{String: "movie", Valid: true}},
ID: null.Int{NullInt64: sql.NullInt64{Int64: 2, Valid: true}},
Type: null.StringFrom("movie"),
ID: null.IntFrom(2),
}).Error; err != nil {
return err
}
Expand All @@ -48,7 +46,7 @@ func (m TumDBMigrator) migrate2023090410000000() *gormigrate.Migration {
}
if err := tx.Create(&model.Crontab{
Interval: 24 * 60 * 60, // daily
Type: null.String{NullString: sql.NullString{String: "kino", Valid: true}},
Type: null.StringFrom("kino"),
}).Error; err != nil {
return err
}
Expand Down
33 changes: 17 additions & 16 deletions server/model/kino.go
Original file line number Diff line number Diff line change
@@ -1,27 +1,28 @@
package model

import (
"database/sql"
"time"

"github.com/guregu/null"
)

// Kino stores all movies
type Kino struct {
Id int32 `gorm:"primary_key;AUTO_INCREMENT;column:kino;type:int;not null;"`
Date time.Time `gorm:"column:date;type:datetime;not null;"`
Created time.Time `gorm:"column:created;type:timestamp;not null;default:CURRENT_TIMESTAMP"`
Title string `gorm:"column:title;type:text;not null;"`
Year string `gorm:"column:year;type:varchar(4);not null;"`
Runtime string `gorm:"column:runtime;type:varchar(40);not null;"`
Genre string `gorm:"column:genre;type:varchar(100);not null;"`
Director string `gorm:"column:director;type:text;not null;"`
Actors string `gorm:"column:actors;type:text;not null;"`
ImdbRating string `gorm:"column:rating;type:varchar(4);not null;"`
Description string `gorm:"column:description;type:text;not null;"`
Trailer sql.NullString `gorm:"column:trailer"`
FilesID int32 `gorm:"column:cover"`
Files Files `gorm:"foreignKey:FilesID;references:file"`
Link string `gorm:"column:link;type:varchar(190);not null;unique;"`
Id int32 `gorm:"primary_key;AUTO_INCREMENT;column:kino;type:int;not null;"`
Date time.Time `gorm:"column:date;type:datetime;not null;"`
Created time.Time `gorm:"column:created;type:timestamp;not null;default:CURRENT_TIMESTAMP"`
Title string `gorm:"column:title;type:text;not null;"`
Year string `gorm:"column:year;type:varchar(4);not null;"`
Runtime string `gorm:"column:runtime;type:varchar(40);not null;"`
Genre string `gorm:"column:genre;type:varchar(100);not null;"`
Director string `gorm:"column:director;type:text;not null;"`
Actors string `gorm:"column:actors;type:text;not null;"`
ImdbRating string `gorm:"column:rating;type:varchar(4);not null;"`
Description string `gorm:"column:description;type:text;not null;"`
Trailer null.String `gorm:"column:trailer"`
FilesID int32 `gorm:"column:cover"`
Files Files `gorm:"foreignKey:FilesID;references:file"`
Link string `gorm:"column:link;type:varchar(190);not null;unique;"`
}

// TableName sets the insert table name for this struct type
Expand Down

0 comments on commit d6817da

Please sign in to comment.