Spanner: support for lastInsertId (#101770)

* Support for returning inserted ID in Spanner.
* Convert bytes to string when storing them into text column.
This commit is contained in:
Peter Štibraný
2025-03-10 15:59:06 +01:00
committed by GitHub
parent d5451f2e13
commit 0ce67dad74
8 changed files with 124 additions and 59 deletions
+3 -3
View File
@@ -240,19 +240,19 @@ func (mg *Migrator) run(ctx context.Context) (err error) {
migrationLogExists, err := mg.DBEngine.IsTableExist(mg.tableName)
if err != nil {
return fmt.Errorf("%v: %w", "failed to check table existence", err)
return fmt.Errorf("failed to check table existence: %w", err)
}
if !migrationLogExists {
// Check if dialect can initialize database from a snapshot.
err := mg.Dialect.CreateDatabaseFromSnapshot(ctx, mg.DBEngine, mg.tableName)
if err != nil {
return fmt.Errorf("%v: %w", "failed to create database from snapshot", err)
return fmt.Errorf("failed to create database from snapshot: %w", err)
}
migrationLogExists, err = mg.DBEngine.IsTableExist(mg.tableName)
if err != nil {
return fmt.Errorf("%v: %w", "failed to check table existence after applying snapshot", err)
return fmt.Errorf("failed to check table existence after applying snapshot: %w", err)
}
}