-
Notifications
You must be signed in to change notification settings - Fork 286
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
datastore/postgres: write only xid, drop support for ids
- Loading branch information
Showing
5 changed files
with
47 additions
and
28 deletions.
There are no files selected for viewing
36 changes: 36 additions & 0 deletions
36
internal/datastore/postgres/migrations/zz_migration.0013_drop_bigserial_ids.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
package migrations | ||
|
||
import ( | ||
"context" | ||
|
||
"github.com/jackc/pgx/v4" | ||
) | ||
|
||
var dropIDStmts = []string{ | ||
`ALTER TABLE relation_tuple_transaction | ||
DROP COLUMN id;`, | ||
`ALTER TABLE namespace_config | ||
DROP COLUMN id, | ||
DROP COLUMN created_transaction, | ||
DROP COLUMN deleted_transaction;`, | ||
`ALTER TABLE relation_tuple | ||
DROP COLUMN id, | ||
DROP COLUMN created_transaction, | ||
DROP COLUMN deleted_transaction;`, | ||
} | ||
|
||
func init() { | ||
if err := DatabaseMigrations.Register("drop-bigserial-ids", "add-xid-constraints", | ||
noNonatomicMigration, | ||
func(ctx context.Context, tx pgx.Tx) error { | ||
for _, stmt := range dropIDStmts { | ||
if _, err := tx.Exec(ctx, stmt); err != nil { | ||
return err | ||
} | ||
} | ||
|
||
return nil | ||
}); err != nil { | ||
panic("failed to register migration: " + err.Error()) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters