File tree Expand file tree Collapse file tree 4 files changed +31
-1
lines changed Expand file tree Collapse file tree 4 files changed +31
-1
lines changed Original file line number Diff line number Diff line change @@ -53,7 +53,6 @@ type gsStations struct {
53
53
}
54
54
55
55
func UpdateGasStations (c * gin.Context ) {
56
- time .Now ().Year ()
57
56
year := time .Now ().Year ()
58
57
month := time .Now ().Month ()
59
58
day := time .Now ().Day ()
Original file line number Diff line number Diff line change @@ -70,6 +70,9 @@ func MigrateDB() {
70
70
if ! database .DB .Migrator ().HasColumn (& pcmodel.CountyData {}, "GsNumDiesel" ) {
71
71
database .DB .Migrator ().AddColumn (& pcmodel.CountyData {}, "GsNumDiesel" )
72
72
}
73
+ if ! database .DB .Migrator ().HasTable (& pcmodel.CountyTimeSlot {}) {
74
+ database .DB .Migrator ().AutoMigrate (& pcmodel.CountyTimeSlot {})
75
+ }
73
76
74
77
log .Printf ("DB Migration Done." )
75
78
}
Original file line number Diff line number Diff line change @@ -21,4 +21,5 @@ type CountyData struct {
21
21
County string `gorm:"size:256"`
22
22
GsAvgValues
23
23
PostCodeLocations []PostCodeLocation `gorm:"foreignKey:CountyDataID"`
24
+ CountyTimeSlots []CountyTimeSlot `gorm:"foreignKey:CountyDataID"`
24
25
}
Original file line number Diff line number Diff line change
1
+ /*
2
+ - Copyright 2022 Sven Loesekann
3
+ Licensed under the Apache License, Version 2.0 (the "License");
4
+ you may not use this file except in compliance with the License.
5
+ You may obtain a copy of the License at
6
+ http://www.apache.org/licenses/LICENSE-2.0
7
+ Unless required by applicable law or agreed to in writing, software
8
+ distributed under the License is distributed on an "AS IS" BASIS,
9
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
10
+ See the License for the specific language governing permissions and
11
+ limitations under the License.
12
+ */
13
+ package pcmodel
14
+
15
+ import (
16
+ "time"
17
+
18
+ "gorm.io/gorm"
19
+ )
20
+
21
+ type CountyTimeSlot struct {
22
+ gorm.Model
23
+ StartDate time.Time
24
+ GsAvgValues
25
+ CountyDataID uint
26
+ CountyData CountyData
27
+ }
You can’t perform that action at this time.
0 commit comments