moved db indices to uint

This commit is contained in:
Alex
2024-09-29 20:58:42 +02:00
parent e0cc893493
commit 1ded8bee33
22 changed files with 90 additions and 85 deletions

View File

@@ -5,12 +5,11 @@ import "time"
type BankAccount struct {
CreatedAt time.Time
UpdatedAt time.Time
MandateDateSigned time.Time `gorm:"not null"` // json:"mandate_date_signed"`
Bank string //`json:"bank_name" validate:"omitempty,alphanumunicode,safe_content"`
AccountHolderName string //`json:"account_holder_name" validate:"omitempty,alphaunicode,safe_content"`
IBAN string `gorm:"not null" json:"iban" validate:"required,iban"`
BIC string //`json:"bic" validate:"omitempty,bic"`
MandateReference string `gorm:"not null"` //json:"mandate_reference"`
ID int64 `gorm:"primaryKey"`
UserID int64 //`json:"user_id"`
MandateDateSigned time.Time `gorm:"not null" json:"mandate_date_signed"`
Bank string `json:"bank_name" validate:"omitempty,alphanumunicode,safe_content"`
AccountHolderName string `json:"account_holder_name" validate:"omitempty,alphaunicode,safe_content"`
IBAN string `gorm:"not null" json:"iban" validate:"iban"`
BIC string `json:"bic" validate:"omitempty,bic"`
MandateReference string `gorm:"not null" json:"mandate_reference"`
ID uint `gorm:"primaryKey"`
}

View File

@@ -1,6 +1,8 @@
package models
import "time"
import (
"time"
)
type Consent struct {
CreatedAt time.Time
@@ -9,6 +11,7 @@ type Consent struct {
LastName string `gorm:"not null" json:"last_name" validate:"safe_content"`
Email string `json:"email" validate:"email,safe_content"`
ConsentType string `gorm:"not null" json:"consent_type" validate:"safe_content"`
ID int64 `gorm:"primaryKey"`
UserID int64 `gorm:"not null" json:"user_id"`
ID uint `gorm:"primaryKey"`
User User
UserID uint
}

View File

@@ -9,8 +9,7 @@ type Membership struct {
EndDate time.Time `json:"end_date"`
Status string `json:"status" validate:"safe_content"`
SubscriptionModel SubscriptionModel `gorm:"foreignKey:SubscriptionModelID" json:"subscription_model"`
ParentMembershipID int64 `json:"parent_member_id" validate:"omitempty,omitnil,number"`
SubscriptionModelID int64 `json:"subsription_model_id"`
ID int64 `json:"id"`
UserID int64 `json:"user_id"`
SubscriptionModelID uint `json:"subsription_model_id"`
ParentMembershipID uint `json:"parent_member_id" validate:"omitempty,omitnil,number"`
ID uint `json:"id"`
}

View File

@@ -11,9 +11,9 @@ type SubscriptionModel struct {
Details string `json:"details" validate:"required"`
Conditions string `json:"conditions"`
RequiredMembershipField string `json:"required_membership_field" validate:"membershipField"`
ID int64 `gorm:"primaryKey"`
MonthlyFee float32 `json:"monthly_fee" validate:"required,number,gte=0"`
HourlyRate float32 `json:"hourly_rate" validate:"required,number,gte=0"`
ID uint `json:"id" gorm:"primaryKey"`
MonthlyFee float32 `json:"monthly_fee" validate:"number,gte=0"`
HourlyRate float32 `json:"hourly_rate" validate:"number,gte=0"`
IncludedPerYear int16 `json:"included_hours_per_year" validate:"omitempty,number,gte=0"`
IncludedPerMonth int16 `json:"included_hours_per_month" validate:"omitempty,number,gte=0"`
}

View File

@@ -9,9 +9,7 @@ import (
)
type User struct {
UpdatedAt time.Time
DateOfBirth time.Time `gorm:"not null" json:"date_of_birth" validate:"required,age"`
CreatedAt time.Time
Company string `json:"company" validate:"omitempty,omitnil,safe_content"`
Phone string `json:"phone" validate:"omitempty,omitnil,safe_content"`
Notes *string `json:"notes,safe_content"`
@@ -31,6 +29,7 @@ type User struct {
PaymentStatus int8 `json:"payment_status"`
Status int8 `json:"status"`
RoleID int8 `json:"role_id"`
gorm.Model
}
// BeforeCreate sets the default value for Status

View File

@@ -8,6 +8,6 @@ type Verification struct {
EmailVerifiedAt *time.Time `gorm:"Default:NULL" json:"email_verified_at"`
IDVerifiedAt *time.Time `gorm:"Default:NULL" json:"id_verified_at"`
VerificationToken string `json:"token"`
ID int64 `gorm:"primaryKey"`
UserID int64 `gorm:"unique;" json:"user_id"`
ID uint `gorm:"primaryKey"`
UserID uint `gorm:"unique;" json:"user_id"`
}