github.com/authzed/spicedb@v1.32.1-0.20240520085336-ebda56537386/internal/datastore/mysql/migrations/zz_migration.0003_add_ns_config_id.go (about)

     1  package migrations
     2  
     3  import "fmt"
     4  
     5  func dropNSConfigPK(t *tables) string {
     6  	return fmt.Sprintf(
     7  		`ALTER TABLE %s DROP PRIMARY KEY;`,
     8  		t.tableNamespace,
     9  	)
    10  }
    11  
    12  func createNSConfigID(t *tables) string {
    13  	return fmt.Sprintf(
    14  		`ALTER TABLE %s ADD COLUMN id BIGINT UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY FIRST;`,
    15  		t.tableNamespace,
    16  	)
    17  }
    18  
    19  func init() {
    20  	mustRegisterMigration("add_ns_config_id", "add_unique_datastore_id", noNonatomicMigration,
    21  		newStatementBatch(
    22  			dropNSConfigPK,
    23  			createNSConfigID,
    24  		).execute,
    25  	)
    26  }