Skip to content

Enable FTS5 in SQLite migrations #582

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Oct 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@ OUTPUT ?= dbmate
GOOS := $(shell go env GOOS)
ifeq ($(GOOS),linux)
# statically link binaries to support alpine linux
override FLAGS := -tags netgo,osusergo,sqlite_omit_load_extension,sqlite_json -ldflags '-s -extldflags "-static"' $(FLAGS)
override FLAGS := -tags netgo,osusergo,sqlite_omit_load_extension,sqlite_fts5,sqlite_json -ldflags '-s -extldflags "-static"' $(FLAGS)
else
# strip binaries
override FLAGS := -tags sqlite_omit_load_extension,sqlite_json -ldflags '-s' $(FLAGS)
override FLAGS := -tags sqlite_omit_load_extension,sqlite_fts5,sqlite_json -ldflags '-s' $(FLAGS)
endif
ifeq ($(GOOS),darwin)
export SDKROOT ?= $(shell xcrun --sdk macosx --show-sdk-path)
Expand Down
9 changes: 9 additions & 0 deletions pkg/driver/sqlite/sqlite_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -405,3 +405,12 @@ func TestSQLiteQuotedMigrationsTableName(t *testing.T) {
require.Equal(t, `"fooMigrations"`, name)
})
}

func TestSQLiteFTS5Available(t *testing.T) {
db := prepTestSQLiteDB(t)
defer dbutil.MustClose(db)

// this only passes if the FTS5 module is statically compiled in to the SQLite driver
_, err := db.Exec("CREATE VIRTUAL TABLE a USING fts5(b, c)")
require.NoError(t, err)
}
Loading