Change CreatedAt and UpdatedAt to type Time and update migrations.go accordingly

This commit is contained in:
Maximilian 2023-02-17 18:55:27 -06:00
parent 2b46385126
commit 89d1b96400
2 changed files with 10 additions and 5 deletions

View File

@ -3,6 +3,7 @@ package models
import ( import (
"GoWeb/app" "GoWeb/app"
"GoWeb/database" "GoWeb/database"
"time"
) )
// RunAllMigrations defines the structs that should be represented in the database // RunAllMigrations defines the structs that should be represented in the database
@ -13,9 +14,13 @@ func RunAllMigrations(app *app.App) error {
Username: "migrate", Username: "migrate",
Password: "migrate", Password: "migrate",
AuthToken: "migrate", AuthToken: "migrate",
CreatedAt: "2021-01-01 00:00:00", CreatedAt: time.Now(),
UpdatedAt: "2021-01-01 00:00:00", UpdatedAt: time.Now(),
}
err := database.Migrate(app, user)
if err != nil {
return err
} }
return database.Migrate(app, user) return nil
} }

View File

@ -19,8 +19,8 @@ type User struct {
Username string Username string
Password string Password string
AuthToken string AuthToken string
CreatedAt string CreatedAt time.Time
UpdatedAt string UpdatedAt time.Time
} }
// GetCurrentUser finds the currently logged-in user by session cookie // GetCurrentUser finds the currently logged-in user by session cookie