Skip to content

Commit

Permalink
satellite/metabase: change versions column to INT8
Browse files Browse the repository at this point in the history
This will allow further progress towards S3-compatible object
versioning.

Refs: #6352
Change-Id: I0b3aa93fcacd1f9d91a667d619d6cb41fba602a9
  • Loading branch information
thepaul authored and Storj Robot committed Oct 20, 2023
1 parent 67bd36a commit b2c6ec0
Showing 1 changed file with 13 additions and 3 deletions.
16 changes: 13 additions & 3 deletions satellite/metabase/db.go
Expand Up @@ -172,13 +172,13 @@ func (db *DB) TestMigrateToLatest(ctx context.Context) error {
{
DB: &db.db,
Description: "Test snapshot",
Version: 17,
Version: 18,
Action: migrate.SQL{
`CREATE TABLE objects (
project_id BYTEA NOT NULL,
bucket_name BYTEA NOT NULL, -- we're using bucket_name here to avoid a lookup into buckets table
object_key BYTEA NOT NULL, -- using 'object_key' instead of 'key' to avoid reserved word
version INT4 NOT NULL,
version INT8 NOT NULL,
stream_id BYTEA NOT NULL,
created_at TIMESTAMPTZ NOT NULL default now(),
Expand Down Expand Up @@ -349,7 +349,7 @@ func (db *DB) TestMigrateToLatest(ctx context.Context) error {
migration.Steps = append(migration.Steps, &migrate.Step{
DB: &db.db,
Description: "Constraint for ensuring our metabase correctness.",
Version: 18,
Version: 19,
Action: migrate.SQL{
`CREATE UNIQUE INDEX objects_one_unversioned_per_location ON objects (project_id, bucket_name, object_key) WHERE status IN ` + statusesUnversioned + `;`,
},
Expand Down Expand Up @@ -691,6 +691,16 @@ func (db *DB) PostgresMigration() *migrate.Migration {
COMMENT ON COLUMN objects.zombie_deletion_deadline is 'zombie_deletion_deadline defines when a pending object can be deleted due to a failed upload.';
`},
},
{
DB: &db.db,
Description: "change objects.version from INT4 to INT8",
Version: 18,
Action: migrate.SQL{`
-- change type from INT4 to INT8; this is practically instant on cockroachdb because
-- it uses INT8 storage for INT4 values already.
ALTER TABLE objects ALTER COLUMN version TYPE INT8;
`},
},
},
}
}
Expand Down

0 comments on commit b2c6ec0

Please sign in to comment.