Skip to content

Commit

Permalink
feat: add entities
Browse files Browse the repository at this point in the history
  • Loading branch information
Angular2Guy committed Mar 23, 2024
1 parent f9369b3 commit aa6e0db
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 1 deletion.
1 change: 0 additions & 1 deletion backend/pkd/controller/client/gsclient.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,6 @@ type gsStations struct {
}

func UpdateGasStations(c *gin.Context) {
time.Now().Year()
year := time.Now().Year()
month := time.Now().Month()
day := time.Now().Day()
Expand Down
3 changes: 3 additions & 0 deletions backend/pkd/database/dbmigrate/dbmigrate.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,9 @@ func MigrateDB() {
if !database.DB.Migrator().HasColumn(&pcmodel.CountyData{}, "GsNumDiesel") {
database.DB.Migrator().AddColumn(&pcmodel.CountyData{}, "GsNumDiesel")
}
if !database.DB.Migrator().HasTable(&pcmodel.CountyTimeSlot{}) {
database.DB.Migrator().AutoMigrate(&pcmodel.CountyTimeSlot{})
}

log.Printf("DB Migration Done.")
}
1 change: 1 addition & 0 deletions backend/pkd/postcode/pcmodel/countydata.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,5 @@ type CountyData struct {
County string `gorm:"size:256"`
GsAvgValues
PostCodeLocations []PostCodeLocation `gorm:"foreignKey:CountyDataID"`
CountyTimeSlots []CountyTimeSlot `gorm:"foreignKey:CountyDataID"`
}
27 changes: 27 additions & 0 deletions backend/pkd/postcode/pcmodel/countytimeslot.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
/*
- Copyright 2022 Sven Loesekann
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
package pcmodel

import (
"time"

"gorm.io/gorm"
)

type CountyTimeSlot struct {
gorm.Model
StartDate time.Time
GsAvgValues
CountyDataID uint
CountyData CountyData
}

0 comments on commit aa6e0db

Please sign in to comment.