satellite/metainfo/metabase: add created_at and repaired_at to segments

The created_at columns is first added without a default value to avoid
setting the current time to existing segments.

Change-Id: Ic2fe3da238422e2949e6f3016fbac04eb89ba037
This commit is contained in:
Kaloyan Raev 2021-03-10 16:31:22 +02:00 committed by Michal Niewrzal
parent e0f07ef04e
commit bdb33b381b

View File

@ -282,6 +282,23 @@ func (db *DB) PostgresMigration() *migrate.Migration {
`ALTER TABLE segments DROP COLUMN remote_pieces`,
},
},
{
DB: &db.db,
Description: "add created_at and repaired_at columns to segments table",
Version: 7,
Action: migrate.SQL{
`ALTER TABLE segments ADD COLUMN created_at TIMESTAMPTZ`,
`ALTER TABLE segments ADD COLUMN repaired_at TIMESTAMPTZ`,
},
},
{
DB: &db.db,
Description: "change default of created_at column in segments table to now()",
Version: 8,
Action: migrate.SQL{
`ALTER TABLE segments ALTER COLUMN created_at SET DEFAULT now()`,
},
},
},
}
}