github.com/authzed/spicedb@v1.32.1-0.20240520085336-ebda56537386/internal/datastore/spanner/migrations/zz_migration.0008_delete_older_changestreams.go (about)

     1  package migrations
     2  
     3  import (
     4  	"context"
     5  
     6  	"cloud.google.com/go/spanner/admin/database/apiv1/databasepb"
     7  )
     8  
     9  const (
    10  	deleteTupleChangeStream  = `DROP CHANGE STREAM relation_tuple_stream`
    11  	deleteSchemaChangeStream = `DROP CHANGE STREAM schema_change_stream`
    12  )
    13  
    14  func init() {
    15  	if err := SpannerMigrations.Register("delete-older-changestreams", "register-combined-change-stream", func(ctx context.Context, w Wrapper) error {
    16  		updateOp, err := w.adminClient.UpdateDatabaseDdl(ctx, &databasepb.UpdateDatabaseDdlRequest{
    17  			Database: w.client.DatabaseName(),
    18  			Statements: []string{
    19  				deleteTupleChangeStream,
    20  				deleteSchemaChangeStream,
    21  			},
    22  		})
    23  		if err != nil {
    24  			return err
    25  		}
    26  		return updateOp.Wait(ctx)
    27  	}, nil); err != nil {
    28  		panic("failed to register migration: " + err.Error())
    29  	}
    30  }