Skip to content

The only tool you need to know what is happening and how to fix it.

fixes: invalid created/updated at

ddux3d5f279a18cb
diff --git a/backend/app/repositories/invitation.repository.go b/backend/app/repositories/invitation.repository.go
index 0f597e96..4eb896fc 100644
--- a/backend/app/repositories/invitation.repository.go
+++ b/backend/app/repositories/invitation.repository.go
@@ -22,6 +22,7 @@ func (r *invitationRepository) Create(tx *sql.Tx, organizationId int, email stri
InvitedBy: invitedBy,
Status: "pending",
ExpiresAt: expiresAt,
+ CreatedAt: time.Now().UTC(),
}
id, err := lit.Insert(tx, invitation)
diff --git a/backend/app/repositories/organization.repository.go b/backend/app/repositories/organization.repository.go
index 0071cbfd..d2ab20c9 100644
--- a/backend/app/repositories/organization.repository.go
+++ b/backend/app/repositories/organization.repository.go
@@ -3,6 +3,7 @@ package repositories
import (
"backend/app/models"
"database/sql"
+ "time"
"github.com/tracewayapp/go-lightning/lit"
)
@@ -11,7 +12,8 @@ type organizationRepository struct{}
func (r *organizationRepository) Create(tx *sql.Tx, name string) (*models.Organization, error) {
org := &models.Organization{
- Name: name,
+ Name: name,
+ CreatedAt: time.Now().UTC(),
}
id, err := lit.Insert(tx, org)
@@ -64,6 +66,7 @@ func (r *organizationRepository) AddUser(tx *sql.Tx, organizationId int, userId
UserId: userId,
OrganizationId: organizationId,
Role: role,
+ CreatedAt: time.Now().UTC(),
}
id, err := lit.Insert(tx, orgUser)
diff --git a/backend/app/repositories/project.repository.go b/backend/app/repositories/project.repository.go
index b0531167..b496d3eb 100644
--- a/backend/app/repositories/project.repository.go
+++ b/backend/app/repositories/project.repository.go
@@ -4,6 +4,7 @@ import (
"backend/app/models"
"database/sql"
"strings"
+ "time"
"github.com/google/uuid"
"github.com/tracewayapp/go-lightning/lit"
@@ -56,6 +57,7 @@ func (p *projectRepository) Create(tx *sql.Tx, name string, framework string) (*
Name: name,
Token: generateSecureToken(),
Framework: framework,
+ CreatedAt: time.Now().UTC(),
}
err := lit.InsertExistingUuid(tx, project)
@@ -73,6 +75,7 @@ func (p *projectRepository) CreateWithOrganization(tx *sql.Tx, name string, fram
Token: generateSecureToken(),
Framework: framework,
OrganizationId: &organizationId,
+ CreatedAt: time.Now().UTC(),
}
err := lit.InsertExistingUuid(tx, project)
diff --git a/backend/app/repositories/user.repository.go b/backend/app/repositories/user.repository.go
index 3a00b826..4b68cd56 100644
--- a/backend/app/repositories/user.repository.go
+++ b/backend/app/repositories/user.repository.go
@@ -28,9 +28,10 @@ func (r *userRepository) FindById(tx *sql.Tx, id int) (*models.User, error) {
func (r *userRepository) Create(tx *sql.Tx, email string, name string, hashedPassword string) (*models.User, error) {
user := &models.User{
- Email: email,
- Name: name,
- Password: hashedPassword,
+ Email: email,
+ Name: name,
+ Password: hashedPassword,
+ CreatedAt: time.Now().UTC(),
}
id, err := lit.Insert(tx, user)
@@ -59,7 +60,7 @@ func (r *userRepository) SetPasswordResetToken(tx *sql.Tx, userId int, token str
PasswordResetExpiresAt: &expiresAt,
PasswordResetRequestedAt: &now,
},
- "WHERE id = $1",
+ "id = $1",
userId,
)
}
@@ -84,7 +85,7 @@ func (r *userRepository) UpdatePassword(tx *sql.Tx, userId int, hashedPassword s
return lit.Update[models.User](
tx,
&models.User{Password: hashedPassword},
- "WHERE id = $1",
+ "id = $1",
userId,
)
}