satellite/metabase: change versions column to INT8

This will allow further progress towards S3-compatible object
versioning.

Refs: https://github.com/storj/storj/issues/6352
Change-Id: I0b3aa93fcacd1f9d91a667d619d6cb41fba602a9
This commit is contained in:
paul cannon 2023-10-03 16:23:43 -05:00 committed by Storj Robot
parent 67bd36ae4d
commit b2c6ec0091

View File

@ -172,13 +172,13 @@ func (db *DB) TestMigrateToLatest(ctx context.Context) error {
{ {
DB: &db.db, DB: &db.db,
Description: "Test snapshot", Description: "Test snapshot",
Version: 17, Version: 18,
Action: migrate.SQL{ Action: migrate.SQL{
`CREATE TABLE objects ( `CREATE TABLE objects (
project_id BYTEA NOT NULL, project_id BYTEA NOT NULL,
bucket_name BYTEA NOT NULL, -- we're using bucket_name here to avoid a lookup into buckets table 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 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, stream_id BYTEA NOT NULL,
created_at TIMESTAMPTZ NOT NULL default now(), created_at TIMESTAMPTZ NOT NULL default now(),
@ -349,7 +349,7 @@ func (db *DB) TestMigrateToLatest(ctx context.Context) error {
migration.Steps = append(migration.Steps, &migrate.Step{ migration.Steps = append(migration.Steps, &migrate.Step{
DB: &db.db, DB: &db.db,
Description: "Constraint for ensuring our metabase correctness.", Description: "Constraint for ensuring our metabase correctness.",
Version: 18, Version: 19,
Action: migrate.SQL{ Action: migrate.SQL{
`CREATE UNIQUE INDEX objects_one_unversioned_per_location ON objects (project_id, bucket_name, object_key) WHERE status IN ` + statusesUnversioned + `;`, `CREATE UNIQUE INDEX objects_one_unversioned_per_location ON objects (project_id, bucket_name, object_key) WHERE status IN ` + statusesUnversioned + `;`,
}, },
@ -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.'; 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;
`},
},
}, },
} }
} }