build/sqlc: remove bindata machinery for migrations
This wasn't great to use, mostly because of the amount of symbols that
go-bindata generates. Instead, for now expect downstream users to use
go:embed.
The mentioned example will come in a follow-up CL.
Change-Id: I74c0cef691af54a87a5170f63b57356999841379
Reviewed-on: https://review.monogon.dev/c/monogon/+/911
Tested-by: Jenkins CI
Reviewed-by: Leopold Schabel <leo@monogon.tech>
diff --git a/build/sqlc/README.md b/build/sqlc/README.md
index 72d9a86..570e024 100644
--- a/build/sqlc/README.md
+++ b/build/sqlc/README.md
@@ -3,8 +3,6 @@
This is a set of rules which uses [sqlc](https://github.com/kyleconroy/sqlc) to generate Go code (types and functions) based on a SQL schema/migrations and a list of queries to be turned into functions.
-It also embeds the migrations using [bindata](https://github.com/kevinburke/go-bindata).
-
Usage
---
@@ -47,4 +45,7 @@
To list the generated files for inspection/debugging, `bazel aquery //foo/bar:sqlc_model` and find files named `db.go`, `model.go` and `queries.sql.go` (or similar, depending on how your query file(s) are named).
-TODO(q3k): document migrations (and probably move them to a subpackage).
\ No newline at end of file
+Migrations
+---
+
+Currently, you need to manually embed the same migrations files using standard //go:embed directives, then you can used them with golang-migrate via en embed.FS/io.FS/iofs-source. See //cloud/apigw/model for an example.
diff --git a/build/sqlc/sqlc.bzl b/build/sqlc/sqlc.bzl
index 3083fd3..71d2fc3 100644
--- a/build/sqlc/sqlc.bzl
+++ b/build/sqlc/sqlc.bzl
@@ -77,8 +77,6 @@
for basename in query_basenames:
sqlc_go_sources.append(ctx.actions.declare_file(basename + ".go"))
- migrations_source = ctx.actions.declare_file("migrations.go")
-
# Cockroachdb is PostgreSQL with some extra overrides to fix Go/SQL type
# mappings.
overrides = []
@@ -127,20 +125,7 @@
outputs = sqlc_go_sources,
)
- # Generate migrations bindata.
- ctx.actions.run(
- mnemonic = "MigrationsEmbed",
- executable = ctx.executable._bindata,
- arguments = [
- "-pkg", package_name,
- "-prefix", ctx.label.workspace_root,
- "-o", migrations_source.path,
- ] + [up.path for up in uppers.values()] + [down.path for down in downers.values()],
- inputs = uppers.values() + downers.values(),
- outputs = [migrations_source],
- )
-
- library = go.new_library(go, srcs = sqlc_go_sources + [migrations_source], importparth = ctx.attr.importpath)
+ library = go.new_library(go, srcs = sqlc_go_sources, importparth = ctx.attr.importpath)
source = go.library_to_source(go, ctx.attr, library, ctx.coverage_instrumented())
return [
library,