mirror of
https://github.com/nicotsx/ironmount.git
synced 2025-12-10 12:10:51 +01:00
chore: move to go folder
This commit is contained in:
22
go/internal/db/db.go
Normal file
22
go/internal/db/db.go
Normal file
@@ -0,0 +1,22 @@
|
||||
// Package db provides database access for the Ironmount application
|
||||
package db
|
||||
|
||||
import (
|
||||
"github.com/glebarez/sqlite"
|
||||
"gorm.io/gorm"
|
||||
)
|
||||
|
||||
var DB, err = gorm.Open(sqlite.Open("file:ironmount.db"), &gorm.Config{})
|
||||
|
||||
// InitDB initializes the database and creates the volumes table if it doesn't exist
|
||||
func InitDB() {
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
err = DB.AutoMigrate(&Volume{})
|
||||
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
}
|
||||
13
go/internal/db/schema.go
Normal file
13
go/internal/db/schema.go
Normal file
@@ -0,0 +1,13 @@
|
||||
package db
|
||||
|
||||
import (
|
||||
"gorm.io/gorm"
|
||||
)
|
||||
|
||||
type Volume struct {
|
||||
gorm.Model
|
||||
Name string `json:"name"`
|
||||
Path string `json:"path"`
|
||||
Type string `json:"type"`
|
||||
Config string `json:"config"`
|
||||
}
|
||||
Reference in New Issue
Block a user