Add asset metadata, sharing, and MinIO-backed signed links.
CI / test (pull_request) Successful in 4s
CI / test (pull_request) Successful in 4s
This introduces deduplicated per-user image/3D asset records linked into feature properties, adds visibility-controlled download routing, and wires local S3-compatible storage with automatic bucket bootstrap in Docker Compose. Made-with: Cursor
This commit is contained in:
@@ -3,7 +3,11 @@ package store
|
||||
import (
|
||||
"database/sql"
|
||||
"embed"
|
||||
"fmt"
|
||||
"io/fs"
|
||||
"log"
|
||||
"path/filepath"
|
||||
"sort"
|
||||
|
||||
_ "github.com/jackc/pgx/v5/stdlib"
|
||||
)
|
||||
@@ -17,12 +21,27 @@ func Migrate(databaseURL string) error {
|
||||
return err
|
||||
}
|
||||
defer db.Close()
|
||||
sql, err := migrationsFS.ReadFile("migrations/0001_init.sql")
|
||||
|
||||
files, err := fs.ReadDir(migrationsFS, "migrations")
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if _, err := db.Exec(string(sql)); err != nil {
|
||||
return err
|
||||
paths := make([]string, 0, len(files))
|
||||
for _, entry := range files {
|
||||
if entry.IsDir() || filepath.Ext(entry.Name()) != ".sql" {
|
||||
continue
|
||||
}
|
||||
paths = append(paths, "migrations/"+entry.Name())
|
||||
}
|
||||
sort.Strings(paths)
|
||||
for _, path := range paths {
|
||||
sqlBytes, readErr := migrationsFS.ReadFile(path)
|
||||
if readErr != nil {
|
||||
return readErr
|
||||
}
|
||||
if _, execErr := db.Exec(string(sqlBytes)); execErr != nil {
|
||||
return fmt.Errorf("%s: %w", path, execErr)
|
||||
}
|
||||
}
|
||||
log.Printf("migrations applied")
|
||||
return nil
|
||||
|
||||
Reference in New Issue
Block a user