The commit that makes you yell :I GIVE UP!"
This commit is contained in:
parent
f82bd15873
commit
7ab3687614
44 changed files with 15012 additions and 0 deletions
19
backend/db/db.go
Normal file
19
backend/db/db.go
Normal file
|
@ -0,0 +1,19 @@
|
|||
package db
|
||||
|
||||
import (
|
||||
"gorm.io/driver/sqlite"
|
||||
"gorm.io/gorm"
|
||||
"blue-backend/models"
|
||||
)
|
||||
|
||||
var DB *gorm.DB
|
||||
|
||||
func InitDB() {
|
||||
var err error
|
||||
DB, err = gorm.Open(sqlite.Open("blueddit.db"), &gorm.Config{})
|
||||
if err != nil {
|
||||
panic("Failed to connect to database!")
|
||||
}
|
||||
|
||||
DB.AutoMigrate(&models.Post{}, &models.Comment{})
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue