sourcegraph/migrations/codeinsights
Keegan Carruthers-Smith 9981c14e40
migrations: avoid duplicate foreign key constraints when tenant_id re-run (#64465)
ALTER TABLE with a foreign key constraint will _always_ add the
constraint, which means we always require a table lock even if this
migration has run. So we check if the column exists first.

The motivation for this change was me noticing slow migrations against
S2, even though it had been migrated already. This speeds it up since it
avoids a bunch of locks.

In testing I kept running into issues with the lsif_* tables. We agreed
we will only migrate them later.

Test Plan: ran against my local instance and S2 multiple times and CI.
Also manually ran the down and up migration against dotcom
2024-08-14 16:57:32 +02:00
..
1000000027_squashed_migrations_privileged chore: Squash migrations (#38563) 2022-07-11 16:26:57 -05:00
1646761143_squashed_migrations_unprivileged migrations: Update migration directory names (#38599) 2022-07-11 23:20:32 +00:00
1647894746_dashboard_type migrations: Update migration directory names (#38599) 2022-07-11 23:20:32 +00:00
1649801281_context_filters migrations: Update migration directory names (#38599) 2022-07-11 23:20:32 +00:00
1651021000_sort_series migrations: Update migration directory names (#38599) 2022-07-11 23:20:32 +00:00
1652289966_deprecate-search-stream-generation-method migrations: Update migration directory names (#38599) 2022-07-11 23:20:32 +00:00
1656517037_group_by migrations: Update migration directory names (#38599) 2022-07-11 23:20:32 +00:00
1656608833_track_backfill_attempts migrations: Update migration directory names (#38599) 2022-07-11 23:20:32 +00:00
1659572248_refresh_scoped_insights migrations: Add CI check detecting drift on downgrade (#52098) 2023-05-17 15:44:19 -05:00
1663626068_backfill_completed_at insights: Background process to stamp backfill_completed_at (#41832) 2022-09-23 18:48:36 -04:00
1664984848_insights_scheduler_table insights: skeleton queue for new scheduler (#42581) 2022-10-05 13:41:31 -07:00
1665003565_insights_backfill_scheduler_state insights: add durable repo iterator (#42676) 2022-10-10 14:13:04 -07:00
1665053848_add_insight_series_recording_times insights: save insight series recording times on creation and job runs (#42801) 2022-10-24 08:44:23 -04:00
1665616961_backfill_table insights: maintain state about backfills throughout the entire series lifecycle (#42912) 2022-10-14 12:39:38 -04:00
1666632478_add_supports_augmentation_column insights: augment series points with zero values (#43166) 2022-10-25 07:46:04 -04:00
1666729025_incomplete_points insights: extend insight series API for timeout alerts (#43452) 2022-11-09 10:56:02 -07:00
1667309737_backfill_priority_groups insights: bin backfill costs and use to prioritize backfill runs #43757 (#43758) 2022-11-01 14:20:17 -04:00
1670253074_insight_series_repo_criteria insights: db and store changes for strat scoped insights (#45624) 2022-12-13 12:45:27 -05:00
1672740238_add_insights_data_retention_jobs insights: add base for data retention worker (#46082) 2023-01-04 14:07:25 +00:00
1672917501_add_retention_tables insights: archive points for a series beyond a set sample size (#46164) 2023-01-12 10:29:40 +00:00
1672921606_data_retention_jobs_series_metadata migrations: Add CI check detecting drift on downgrade (#52098) 2023-05-17 15:44:19 -05:00
1674474174_remove_dirty_queries_table insights: remove deprecated dirty_queries table (#45714) 2023-01-23 15:58:08 +00:00
1675113463_backfill_repo_query_selector insights: add migration for code insights repo criteria query (#47133) 2023-01-30 23:11:02 +00:00
1675347548_add_insight_view_series_num_samples insights: allow to save the default number of series samples (#47329) 2023-02-08 12:24:08 +00:00
1679051112_remove_commit_index_tables insights: remove deprecated commit_index tables (#49578) 2023-03-28 09:48:45 +01:00
1719914228_insight_series_modify_query insights: persist patternType in db (#63579) 2024-07-03 09:51:48 +02:00
1723117231_add_tenants_table tenant: Ensure tenant table also exists in codeintel and codeinsights DBs (#64359) 2024-08-08 15:33:49 +02:00
1723127349_add_tenant_id_to_most_tables migrations: avoid duplicate foreign key constraints when tenant_id re-run (#64465) 2024-08-14 16:57:32 +02:00
BUILD.bazel bzl: rework migration schemas generation (#57511) 2023-10-10 17:19:47 +02:00
squashed.sql database: run tenant_id migration outside of a transaction (#64410) 2024-08-13 07:08:19 +02:00