From ea9fb80eff6dcfcf89d990e4caccdf96637e57bb Mon Sep 17 00:00:00 2001 From: ziggie Date: Wed, 13 Aug 2025 22:26:03 +0200 Subject: [PATCH] sqldb: use the new schema We put this new schema update into the main line and change the versions of the schema updates which are currently only available in dev builds. The schemas need to be chronological therefore we also need to rename the file numbers. --- config_test_native_sql.go | 2 +- sqldb/migrations.go | 5 +++++ sqldb/migrations_dev.go | 10 +++++----- sqldb/migrations_prod.go | 5 +++++ ...n.sql => 000007_invoice_add_settled_index.down.sql} | 0 ....up.sql => 000007_invoice_add_settled_index.up.sql} | 0 .../{000007_graph.down.sql => 000008_graph.down.sql} | 0 .../{000007_graph.up.sql => 000008_graph.up.sql} | 0 8 files changed, 16 insertions(+), 6 deletions(-) rename sqldb/sqlc/migrations/{000008_invoice_add_settled_index.down.sql => 000007_invoice_add_settled_index.down.sql} (100%) rename sqldb/sqlc/migrations/{000008_invoice_add_settled_index.up.sql => 000007_invoice_add_settled_index.up.sql} (100%) rename sqldb/sqlc/migrations/{000007_graph.down.sql => 000008_graph.down.sql} (100%) rename sqldb/sqlc/migrations/{000007_graph.up.sql => 000008_graph.up.sql} (100%) diff --git a/config_test_native_sql.go b/config_test_native_sql.go index 01baacfae..2994e9e08 100644 --- a/config_test_native_sql.go +++ b/config_test_native_sql.go @@ -46,7 +46,7 @@ func (d *DefaultDatabaseBuilder) getGraphStore(baseDB *sqldb.BaseDB, // graphSQLMigration is the version number for the graph migration // that migrates the KV graph to the native SQL schema. -const graphSQLMigration = 9 +const graphSQLMigration = 10 // getSQLMigration returns a migration function for the given version. func (d *DefaultDatabaseBuilder) getSQLMigration(ctx context.Context, diff --git a/sqldb/migrations.go b/sqldb/migrations.go index 98c63734d..0f293d22a 100644 --- a/sqldb/migrations.go +++ b/sqldb/migrations.go @@ -73,6 +73,11 @@ var ( // schema. This is optional and can be disabled by the // user if necessary. }, + { + Name: "000007_invoice_add_settled_index", + Version: 8, + SchemaVersion: 7, + }, }, migrationAdditions...) // ErrMigrationMismatch is returned when a migrated record does not diff --git a/sqldb/migrations_dev.go b/sqldb/migrations_dev.go index 38501b58b..a9b753696 100644 --- a/sqldb/migrations_dev.go +++ b/sqldb/migrations_dev.go @@ -4,14 +4,14 @@ package sqldb var migrationAdditions = []MigrationConfig{ { - Name: "000007_graph", - Version: 8, - SchemaVersion: 7, + Name: "000008_graph", + Version: 9, + SchemaVersion: 8, }, { Name: "kv_graph_migration", - Version: 9, - SchemaVersion: 7, + Version: 10, + SchemaVersion: 8, // A migration function may be attached to this // migration to migrate KV graph to the native SQL // schema. This is optional and can be disabled by the diff --git a/sqldb/migrations_prod.go b/sqldb/migrations_prod.go index faa41f419..15f5f5844 100644 --- a/sqldb/migrations_prod.go +++ b/sqldb/migrations_prod.go @@ -2,4 +2,9 @@ package sqldb +// migrationAdditions is a list of migrations that are added to the +// migrationConfig slice. +// +// NOTE: This should always be empty and instead migrations for production +// should be added into the main line (see migrations.go). var migrationAdditions []MigrationConfig diff --git a/sqldb/sqlc/migrations/000008_invoice_add_settled_index.down.sql b/sqldb/sqlc/migrations/000007_invoice_add_settled_index.down.sql similarity index 100% rename from sqldb/sqlc/migrations/000008_invoice_add_settled_index.down.sql rename to sqldb/sqlc/migrations/000007_invoice_add_settled_index.down.sql diff --git a/sqldb/sqlc/migrations/000008_invoice_add_settled_index.up.sql b/sqldb/sqlc/migrations/000007_invoice_add_settled_index.up.sql similarity index 100% rename from sqldb/sqlc/migrations/000008_invoice_add_settled_index.up.sql rename to sqldb/sqlc/migrations/000007_invoice_add_settled_index.up.sql diff --git a/sqldb/sqlc/migrations/000007_graph.down.sql b/sqldb/sqlc/migrations/000008_graph.down.sql similarity index 100% rename from sqldb/sqlc/migrations/000007_graph.down.sql rename to sqldb/sqlc/migrations/000008_graph.down.sql diff --git a/sqldb/sqlc/migrations/000007_graph.up.sql b/sqldb/sqlc/migrations/000008_graph.up.sql similarity index 100% rename from sqldb/sqlc/migrations/000007_graph.up.sql rename to sqldb/sqlc/migrations/000008_graph.up.sql