Remove postgres and references to it

This commit is contained in:
Michael Hohn
2024-06-16 19:43:29 -07:00
committed by =Michael Hohn
parent b756668e70
commit 6229c08900
8 changed files with 29 additions and 418 deletions

View File

@@ -1,32 +0,0 @@
package main
import (
"gorm.io/driver/postgres"
"gorm.io/gorm"
"mrvacommander/pkg/common"
)
// TODO migrate this to test/
// TODO add a reader test
// Minimal gorm example that takes a go struct, creates a postgres table,
// and writes the struct to the table.
func main() {
// Set up the database connection string
dsn := "host=postgres user=exampleuser dbname=exampledb sslmode=disable password=examplepass"
// Open the database connection
db, err := gorm.Open(postgres.Open(dsn), &gorm.Config{})
if err != nil {
panic("failed to connect database")
}
// Migrate the schema: create the 'owner_repo' table from the struct
err = db.AutoMigrate(&common.NameWithOwner{})
if err != nil {
panic("failed to migrate database")
}
// Create an entry in the database
db.Create(&common.NameWithOwner{Owner: "foo", Repo: "foo/bar"})
}