29 lines
854 B
Go
29 lines
854 B
Go
package sense
|
|
|
|
import (
|
|
"os"
|
|
"yovision.local/sense/app/sense/device"
|
|
"yovision.local/sense/internal/platform"
|
|
)
|
|
|
|
func init() {
|
|
registerModule(func(app *platform.App) error {
|
|
memory := app.Config().DatabaseMode == platform.DatabaseModeMemory
|
|
vault, err := device.NewCredentialVault(os.Getenv("SENSE_CREDENTIAL_KEY"), memory)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
var store device.Store
|
|
if memory {
|
|
store = device.NewMemoryStore()
|
|
} else {
|
|
store = device.NewPostgresStore(app.Database())
|
|
}
|
|
app.RegisterMigration(platform.Migration{Version: 2026081202, Name: "sense_device", SQL: device.MigrationSQL})
|
|
app.RegisterMigration(platform.Migration{Version: 2026081301, Name: "sense_device_split_credentials", SQL: device.SplitCredentialMigrationSQL})
|
|
device.NewModule(device.NewService(store, vault)).Register(app)
|
|
return nil
|
|
})
|
|
}
|
|
|