package main import ( "gorm.io/gorm" "gorm.io/driver/sqlite" ) type ArtistInfo struct { gorm.Model Name string Popularity string SpotifyID string ArtistGenre ArtistGenre } // Stores an association between several Genres and an individual artist type ArtistGenre struct { gorm.Model Genres []Genre ArtistInfoID uint } type Genre struct { gorm.Model Genre string ArtistGenreID uint } func setupDatabase() *gorm.DB { db, err := gorm.Open(sqlite.Open("gomusic.db"), &gorm.Config{}) if err != nil { panic("Failed to open database") } // Run model migrations here to keep DB consistent db.AutoMigrate(&ArtistInfo{}, &ArtistGenre{}, &Genre{}) return db }