From 89d1b964009e5d6ded39817ed5f17a6fda35aa44 Mon Sep 17 00:00:00 2001 From: Maximilian Date: Fri, 17 Feb 2023 18:55:27 -0600 Subject: [PATCH] Change CreatedAt and UpdatedAt to type Time and update migrations.go accordingly --- models/migrations.go | 11 ++++++++--- models/user.go | 4 ++-- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/models/migrations.go b/models/migrations.go index c76fce4..262e600 100644 --- a/models/migrations.go +++ b/models/migrations.go @@ -3,6 +3,7 @@ package models import ( "GoWeb/app" "GoWeb/database" + "time" ) // RunAllMigrations defines the structs that should be represented in the database @@ -13,9 +14,13 @@ func RunAllMigrations(app *app.App) error { Username: "migrate", Password: "migrate", AuthToken: "migrate", - CreatedAt: "2021-01-01 00:00:00", - UpdatedAt: "2021-01-01 00:00:00", + CreatedAt: time.Now(), + UpdatedAt: time.Now(), + } + err := database.Migrate(app, user) + if err != nil { + return err } - return database.Migrate(app, user) + return nil } diff --git a/models/user.go b/models/user.go index e7ac8b9..dbb7ae2 100644 --- a/models/user.go +++ b/models/user.go @@ -19,8 +19,8 @@ type User struct { Username string Password string AuthToken string - CreatedAt string - UpdatedAt string + CreatedAt time.Time + UpdatedAt time.Time } // GetCurrentUser finds the currently logged-in user by session cookie