Skip to content

Commit

Permalink
move migrations to after table creation (#255)
Browse files Browse the repository at this point in the history
  • Loading branch information
danielchalef authored Nov 1, 2023
1 parent 44b1725 commit da58ee1
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions pkg/store/postgres/schema.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,13 @@ import (
"strings"
"time"

"github.com/getzep/zep/pkg/store/postgres/migrations"

"github.com/Masterminds/semver/v3"
_ "github.com/jackc/pgx/v5/stdlib" // required for pgx to work
"github.com/uptrace/bun/driver/pgdriver"

"github.com/getzep/zep/pkg/llms"
"github.com/getzep/zep/pkg/store/postgres/migrations"
"github.com/uptrace/bun/dialect/pgdialect"

"github.com/getzep/zep/pkg/models"
Expand Down Expand Up @@ -444,6 +445,11 @@ func CreateSchema(
}
}

// apply migrations
if err := migrations.Migrate(ctx, db); err != nil {
return fmt.Errorf("failed to apply migrations: %w", err)
}

// check that the message and summary embedding dimensions match the configured model
if err := checkEmbeddingDims(ctx, appState, db, "message", "message_embedding"); err != nil {
return fmt.Errorf("error checking message embedding dimensions: %w", err)
Expand All @@ -464,11 +470,6 @@ func CreateSchema(
}
}

// apply migrations
if err := migrations.Migrate(ctx, db); err != nil {
return fmt.Errorf("failed to apply migrations: %w", err)
}

return nil
}

Expand Down

0 comments on commit da58ee1

Please sign in to comment.