-
Notifications
You must be signed in to change notification settings - Fork 37
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Also add notion of valid bucket. A bucket that can be used as baseline.
- Loading branch information
Showing
13 changed files
with
261 additions
and
32 deletions.
There are no files selected for viewing
55 changes: 55 additions & 0 deletions
55
apps/backend/db/migrations/20240707121753_build-metadata.js
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,55 @@ | ||
/** | ||
* @param {import('knex').Knex} knex | ||
*/ | ||
export const up = async (knex) => { | ||
await knex.schema.alterTable("builds", async (table) => { | ||
table.jsonb("metadata"); | ||
}); | ||
|
||
await knex.schema.alterTable("build_shards", async (table) => { | ||
table.jsonb("metadata"); | ||
}); | ||
|
||
await knex.schema.alterTable("screenshot_buckets", (table) => { | ||
table.boolean("valid"); | ||
}); | ||
|
||
await knex.raw( | ||
`UPDATE screenshot_buckets SET valid = true WHERE valid IS NULL`, | ||
); | ||
|
||
await knex.raw(` | ||
ALTER TABLE screenshot_buckets ADD CONSTRAINT screenshot_buckets_valid_not_null_constraint CHECK (valid IS NOT NULL) NOT VALID; | ||
`); | ||
|
||
await knex.raw(` | ||
ALTER TABLE screenshot_buckets VALIDATE CONSTRAINT screenshot_buckets_valid_not_null_constraint; | ||
`); | ||
|
||
await knex.raw(` | ||
ALTER TABLE screenshot_buckets ALTER column valid SET NOT NULL; | ||
`); | ||
|
||
await knex.raw(` | ||
ALTER TABLE screenshot_buckets DROP CONSTRAINT screenshot_buckets_valid_not_null_constraint; | ||
`); | ||
}; | ||
|
||
/** | ||
* @param {import('knex').Knex} knex | ||
*/ | ||
export const down = async (knex) => { | ||
await knex.schema.alterTable("builds", async (table) => { | ||
table.dropColumn("metadata"); | ||
}); | ||
|
||
await knex.schema.alterTable("build_shards", async (table) => { | ||
table.dropColumn("metadata"); | ||
}); | ||
|
||
await knex.schema.alterTable("screenshot_buckets", async (table) => { | ||
table.dropColumn("valid"); | ||
}); | ||
}; | ||
|
||
export const config = { transaction: false }; |
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
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
Oops, something went wrong.