Files
Trackeep/backend/models/models.go
T
Tomas Dvorak 954a1a1080 feat: migrate to DragonflyDB and clean up environment configuration
- Replace Redis with DragonflyDB for better performance and memory efficiency
- Remove redundant environment variables (POSTGRES_*, ENCRYPTION_KEY, OAUTH_SERVICE_URL)
- Consolidate database configuration to use single DB_* variables
- Use JWT_SECRET for both JWT tokens and encryption
- Remove PORT variable redundancy, use BACKEND_PORT consistently
- Clean up docker-compose configurations for dev/prod consistency
- Add DragonflyDB configuration with optimized memory usage
- Remove redis.conf as it's no longer needed
- Update health checks to use Redis-compatible CLI for DragonflyDB
- Add missing VITE_API_URL to production frontend
- Fix GitHub Actions to use correct go.sum path
- Clean up development directories and unused files
2026-03-05 23:51:34 +01:00

133 lines
2.6 KiB
Go

package models
import (
"github.com/trackeep/backend/config"
"gorm.io/gorm"
)
// DB is the global database instance
var DB *gorm.DB
// InitDB initializes the global database variable
func InitDB() {
DB = config.GetDB()
}
// AutoMigrate runs database migrations for all models
func AutoMigrate() {
db := config.GetDB()
// Auto migrate all models
db.AutoMigrate(
&User{},
&Tag{},
&Bookmark{},
&Task{},
&File{},
&Note{},
&TimeEntry{},
&FileAnalysis{},
&ChatSession{},
&ChatMessage{},
&LearningPath{},
&LearningModule{},
&ModuleResource{},
&Enrollment{},
&Progress{},
&Course{},
&LearningPathCourse{},
&CalendarEvent{},
&RecurrenceRule{},
&CalendarSettings{},
// Search models
&ContentEmbedding{},
&SavedSearch{},
&SavedSearchTag{},
&SearchAnalytics{},
&SearchSuggestion{},
// AI Feature models
&AISummary{},
&AITaskSuggestion{},
&UserAISettings{},
&UserSearchSettings{},
&UserUpdateSettings{},
&AITagSuggestion{},
&AIContentGeneration{},
&AICodeReview{},
&AILearningRecommendation{},
// Advanced AI Recommendation models
&AIRecommendation{},
&UserPreference{},
&RecommendationInteraction{},
// Integration models
&Integration{},
&SyncLog{},
&WebhookEvent{},
&GitHubAppInstallState{},
&GitHubAppInstallation{},
&GitHubRepoBackup{},
// Analytics models
&Analytics{},
&ProductivityMetrics{},
&LearningAnalytics{},
&ContentAnalytics{},
&GitHubAnalytics{},
&HabitAnalytics{},
&Goal{},
&Milestone{},
&AnalyticsReport{},
// Social features models
&Skill{},
&Project{},
&ProjectTag{},
&SocialLink{},
&Follow{},
// Team workspace models
&Team{},
&TeamMember{},
&TeamInvitation{},
&TeamProject{},
&TeamProjectTag{},
&TeamBookmark{},
&TeamNote{},
&TeamTask{},
&TeamFile{},
&TeamActivity{},
// Security models
&AuditLog{},
// Marketplace models
&MarketplaceItem{},
&MarketplaceTag{},
&MarketplaceReview{},
&MarketplacePurchase{},
&ContentShare{},
// Community models
&Challenge{},
&ChallengeParticipant{},
&ChallengeTeam{},
&ChallengeMilestone{},
&ChallengeMilestoneCompletion{},
&ChallengeResource{},
&ChallengeTag{},
&Mentorship{},
&MentorshipSession{},
&MentorshipReview{},
&MentorshipMilestone{},
&MentorshipRequest{},
// YouTube cache models
&YouTubeChannelCache{},
// Video bookmark models
&VideoBookmark{},
// Messaging models
&Conversation{},
&ConversationMember{},
&Message{},
&MessageAttachment{},
&MessageReference{},
&MessageSuggestion{},
&MessageReaction{},
&PasswordVaultItem{},
&PasswordVaultShare{},
)
}