Initial lookbook implementation
Pinterest-style visual bookmarking app with: - URL metadata extraction (OG/Twitter meta, oEmbed fallback) - Image caching in Postgres with 480px thumbnails - Multi-tag filtering with Ctrl/Cmd for OR mode - Fuzzy tag suggestions and inline tag editing - Browser console auth() with first-use password setup - Brutalist UI with Commit Mono font and Pico CSS - Light/dark mode via browser preference
This commit is contained in:
commit
fc625fb9cf
486 changed files with 195373 additions and 0 deletions
64
vendor/github.com/pressly/goose/v3/reset.go
generated
vendored
Normal file
64
vendor/github.com/pressly/goose/v3/reset.go
generated
vendored
Normal file
|
|
@ -0,0 +1,64 @@
|
|||
package goose
|
||||
|
||||
import (
|
||||
"context"
|
||||
"database/sql"
|
||||
"fmt"
|
||||
"sort"
|
||||
)
|
||||
|
||||
// Reset rolls back all migrations
|
||||
func Reset(db *sql.DB, dir string, opts ...OptionsFunc) error {
|
||||
ctx := context.Background()
|
||||
return ResetContext(ctx, db, dir, opts...)
|
||||
}
|
||||
|
||||
// ResetContext rolls back all migrations
|
||||
func ResetContext(ctx context.Context, db *sql.DB, dir string, opts ...OptionsFunc) error {
|
||||
option := &options{}
|
||||
for _, f := range opts {
|
||||
f(option)
|
||||
}
|
||||
migrations, err := CollectMigrations(dir, minVersion, maxVersion)
|
||||
if err != nil {
|
||||
return fmt.Errorf("failed to collect migrations: %w", err)
|
||||
}
|
||||
if option.noVersioning {
|
||||
return DownToContext(ctx, db, dir, minVersion, opts...)
|
||||
}
|
||||
|
||||
statuses, err := dbMigrationsStatus(ctx, db)
|
||||
if err != nil {
|
||||
return fmt.Errorf("failed to get status of migrations: %w", err)
|
||||
}
|
||||
sort.Sort(sort.Reverse(migrations))
|
||||
|
||||
for _, migration := range migrations {
|
||||
if !statuses[migration.Version] {
|
||||
continue
|
||||
}
|
||||
if err = migration.DownContext(ctx, db); err != nil {
|
||||
return fmt.Errorf("failed to db-down: %w", err)
|
||||
}
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func dbMigrationsStatus(ctx context.Context, db *sql.DB) (map[int64]bool, error) {
|
||||
dbMigrations, err := store.ListMigrations(ctx, db, TableName())
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
// The most recent record for each migration specifies
|
||||
// whether it has been applied or rolled back.
|
||||
results := make(map[int64]bool)
|
||||
|
||||
for _, m := range dbMigrations {
|
||||
if _, ok := results[m.VersionID]; ok {
|
||||
continue
|
||||
}
|
||||
results[m.VersionID] = m.IsApplied
|
||||
}
|
||||
return results, nil
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue