sourcegraph/migrations/codeintel
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
..
1000000033_squashed_migrations_privileged chore: Squash migrations (#38563) 2022-07-11 16:26:57 -05:00
1000000034_squashed_migrations_unprivileged migrations: Update migration directory names (#38599) 2022-07-11 23:20:32 +00:00
1665531314_remove_api_docs_tables migrations: Add CI check detecting drift on downgrade (#52098) 2023-05-17 15:44:19 -05:00
1666727108_add_codeintel_last_reconcile_table codeintel: Create background job to reconcile abandoned uploads (#43443) 2022-10-31 13:21:28 -05:00
1669075922_add_scip_tables codeintel: Fix asymmetric down migration (#45025) 2022-12-01 17:48:04 -06:00
1669842405_add_additional_metadata_fields codeintel: Add additional metadata fields to SCIP tables (#44971) 2022-11-30 23:42:42 +00:00
1669934289_add_scip_document_schema_versions_table codeintel: Fix migration comment and add missing function (#45031) 2022-12-01 17:25:13 -06:00
1670001463_add_missing_index_for_cascading_deletes codeintel: Add index on SCIP table to speed up cascading deletes (#45092) 2022-12-02 19:13:48 +00:00
1670363942_fix_scip_schema_version_triggers codeintel: Fix bad SCIP schema version triggers (#45300) 2022-12-06 22:47:40 +00:00
1670365552_fix_scip_document_schema_counting migrations: Add CI check detecting drift on downgrade (#52098) 2023-05-17 15:44:19 -05:00
1670370058_process_unreferenced_documents codeintel: Tombstone SCIP documents after last use (#45308) 2022-12-09 12:22:32 -06:00
1670881409_fix_scip_document_schema_counting_again codeintel: Improve document schema version tracking (#45587) 2022-12-13 16:46:43 +00:00
1670940342_add_codeintel_scip_symbol_names_table codeintel: Trie-encode SCIP symbol names (#45592) 2022-12-14 09:24:32 -06:00
1670967960_add_codeintel_scip_symbol_names_indexes codeintel: Trie-encode SCIP symbol names (#45592) 2022-12-14 09:24:32 -06:00
1671059396_remove_duplicate_trigger codeintel: Clean up triggers (#45681) 2022-12-15 08:58:38 -06:00
1676423214_remove_lsif_data LSIF: Remove tables from schema (#46127) 2023-03-02 01:25:42 +00:00
1678041507_cleanup_unused_functions chore: Remove unreferenced LSIF trigger functions (#48690) 2023-03-06 07:37:47 -06:00
1678898749_make_unreferenced_documents_index_usable Codeintel: Make index usable (#49440) 2023-03-15 14:03:57 -06:00
1678899132_remove_unused_unreferenced_documents_index Codeintel: Make index usable (#49440) 2023-03-15 14:03:57 -06:00
1679010276_add_missing_index codeintel: Fix missing index (#49565) 2023-03-16 19:10:45 -05:00
1686315964_clean_out_schema_versions_tables codeintel: Fix cleaning up metadata tables in codeintel-db (#53232) 2023-06-16 17:46:07 +00:00
1723117227_add_tenants_table tenant: Ensure tenant table also exists in codeintel and codeinsights DBs (#64359) 2024-08-08 15:33:49 +02:00
1723127341_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