modified: yalarba/serv_golang_rest_api/internal/models/o_auth_provider.go
deleted: yalarba/serv_golang_rest_api/main.exe modified: yalarba/serv_golang_rest_api/pkg/database/postgres.go check auth, login, register on golang rest api
This commit is contained in:
@@ -2,15 +2,19 @@ package models
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
"gorm.io/gorm"
|
||||||
)
|
)
|
||||||
|
|
||||||
type OAuthProvider struct {
|
type OAuthProvider struct {
|
||||||
ID uint `json:"id" gorm:"primaryKey"`
|
ID uint `json:"id" gorm:"primaryKey"`
|
||||||
UserID uint `json:"user_id" gorm:"not null;index"`
|
UserID uint `json:"user_id" gorm:"not null;index:idx_user_provider"` // Уникальный индекс с провайдером
|
||||||
Provider string `json:"provider" gorm:"not null;index"` // google, yandex, vk
|
Provider string `json:"provider" gorm:"not null;index:idx_user_provider;size:50"` // Ограничение длины
|
||||||
ProviderID string `json:"provider_id" gorm:"not null"` // ID пользователя в провайдере
|
ProviderID string `json:"provider_id" gorm:"not null;uniqueIndex:uix_provider_id"` // Уникальный идентификатор
|
||||||
AccessToken string `json:"access_token"`
|
AccessToken string `json:"access_token"`
|
||||||
RefreshToken string `json:"refresh_token"`
|
RefreshToken string `json:"refresh_token"`
|
||||||
ExpiresAt time.Time `json:"expires_at"`
|
ExpiresAt time.Time `json:"expires_at"`
|
||||||
CreatedAt time.Time `json:"created_at"`
|
CreatedAt time.Time `json:"created_at"`
|
||||||
|
UpdatedAt time.Time `json:"updated_at"` // Добавлено для отслеживания изменений
|
||||||
|
DeletedAt gorm.DeletedAt `json:"deleted_at" gorm:"index"`
|
||||||
}
|
}
|
||||||
Binary file not shown.
@@ -47,6 +47,7 @@ func autoMigrate(db *gorm.DB) error {
|
|||||||
// Или используйте автоматические миграции GORM
|
// Или используйте автоматические миграции GORM
|
||||||
return db.AutoMigrate(
|
return db.AutoMigrate(
|
||||||
&models.User{},
|
&models.User{},
|
||||||
|
&models.OAuthProvider{},
|
||||||
// другие модели...
|
// другие модели...
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user