Skip to content

Commit

Permalink
Add artifacts for v5.9.45
Browse files Browse the repository at this point in the history
  • Loading branch information
sourcegraph-bot-devx committed Nov 5, 2024
1 parent e9384b4 commit 2b13919
Show file tree
Hide file tree
Showing 117 changed files with 3,445 additions and 1,724 deletions.
2 changes: 1 addition & 1 deletion TAG
Original file line number Diff line number Diff line change
@@ -1 +1 @@
v5.8.1579
v5.9.45
2 changes: 1 addition & 1 deletion gql/cody_context.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ type CodyContextList {
"""
Name of the list
"""
Name: String!
name: String!

"""
List of context items
Expand Down
26 changes: 26 additions & 0 deletions gql/prompts.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,11 @@ extend type Query {
"""
includeDrafts: Boolean = true

"""
Whether to include only recommended prompts.
"""
recommendedOnly: Boolean

"""
Whether to include draft prompts owned by the viewer.
"""
Expand Down Expand Up @@ -84,6 +89,11 @@ extend type Query {
The field to sort by.
"""
orderBy: PromptsOrderBy = PROMPT_UPDATED_AT

"""
The field to sort by multiple fields.
"""
orderByMultiple: [PromptsOrderBy!]
): PromptsConnection!
}

Expand Down Expand Up @@ -130,6 +140,11 @@ input PromptInput {
Whether to execute prompt as chat, edit or insert command.
"""
mode: PromptMode!

"""
Whether the prompt is recommended.
"""
recommended: Boolean
}

"""
Expand Down Expand Up @@ -183,6 +198,11 @@ input PromptUpdateInput {
Whether to execute prompt as chat, edit or insert command.
"""
mode: PromptMode!

"""
Whether the prompt is recommended.
"""
recommended: Boolean
}

"""
Expand All @@ -207,6 +227,7 @@ The ways that a list of prompts can be ordered.
enum PromptsOrderBy {
PROMPT_NAME_WITH_OWNER
PROMPT_UPDATED_AT
PROMPT_RECOMMENDED
}

"""
Expand Down Expand Up @@ -313,6 +334,11 @@ type Prompt implements Node {
Whether to execute prompt as chat, edit or insert command.
"""
mode: PromptMode!

"""
Whether the prompt is recommended.
"""
recommended: Boolean!
}

"""
Expand Down
13 changes: 12 additions & 1 deletion migrations/codeinsights/1723117231_add_tenants_table/up.sql
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,15 @@ COMMENT ON COLUMN tenants.id IS 'The ID of the tenant. To keep tenants globally
COMMENT ON COLUMN tenants.name IS 'The name of the tenant. This may be displayed to the user and must be unique.';

-- For now, we create one default tenant for every instance. The id 1 is hard-coded in-application.
INSERT INTO tenants (id, name, created_at, updated_at) VALUES (1, 'default', '2024-09-28 09:41:00.000000+00', '2024-09-28 09:41:00.000000+00') ON CONFLICT DO NOTHING;
DO $$
BEGIN
-- Check if the workspace_id column exists. In the case of using multiple database schemas
-- in the same database, the table will already exist since every schema has a
-- copy of tenants.
IF EXISTS (SELECT 1 FROM information_schema.columns
WHERE table_schema = 'public' AND table_name='tenants' AND column_name='workspace_id') THEN
INSERT INTO tenants (id, name, workspace_id, created_at, updated_at) VALUES (1, 'default', '6a6b043c-ffed-42ec-b1f4-abc231cd7222', '2024-09-28 09:41:00.000000+00', '2024-09-28 09:41:00.000000+00') ON CONFLICT DO NOTHING;
ELSE
INSERT INTO tenants (id, name, created_at, updated_at) VALUES (1, 'default', '2024-09-28 09:41:00.000000+00', '2024-09-28 09:41:00.000000+00') ON CONFLICT DO NOTHING;
END IF;
END $$;
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
CREATE UNIQUE INDEX tmp_unique_index ON insight_view (unique_id);
DROP INDEX IF EXISTS insight_view_unique_id_unique_idx;
ALTER INDEX tmp_unique_index RENAME TO insight_view_unique_id_unique_idx;
CREATE UNIQUE INDEX IF NOT EXISTS insight_view_unique_id_unique_idx_new ON insight_view (unique_id, tenant_id);
COMMIT AND CHAIN;

CREATE UNIQUE INDEX tmp_unique_index ON metadata (metadata);
DROP INDEX IF EXISTS metadata_metadata_unique_idx;
ALTER INDEX tmp_unique_index RENAME TO metadata_metadata_unique_idx;
CREATE UNIQUE INDEX IF NOT EXISTS metadata_metadata_unique_idx_new ON metadata (metadata, tenant_id);
COMMIT AND CHAIN;

CREATE UNIQUE INDEX tmp_unique_index ON repo_names (name);
DROP INDEX IF EXISTS repo_names_name_unique_idx;
ALTER INDEX tmp_unique_index RENAME TO repo_names_name_unique_idx;
CREATE UNIQUE INDEX IF NOT EXISTS repo_names_name_unique_idx_new ON repo_names (name, tenant_id);
COMMIT AND CHAIN;
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
name: Migrate unique indexes to respect tenants
parents: [1728937726]
bestEffortTerminateBlockingTransactions: true
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
DO
$$
BEGIN
IF to_regclass('insight_view_unique_id_unique_idx_new') IS NOT NULL THEN
DROP INDEX IF EXISTS insight_view_unique_id_unique_idx;
ALTER INDEX insight_view_unique_id_unique_idx_new RENAME TO insight_view_unique_id_unique_idx;
END IF;
END
$$;
COMMIT AND CHAIN;

DO
$$
BEGIN
IF to_regclass('metadata_metadata_unique_idx_new') IS NOT NULL THEN
DROP INDEX IF EXISTS metadata_metadata_unique_idx;
ALTER INDEX metadata_metadata_unique_idx_new RENAME TO metadata_metadata_unique_idx;
END IF;
END
$$;
COMMIT AND CHAIN;

DO
$$
BEGIN
IF to_regclass('repo_names_name_unique_idx_new') IS NOT NULL THEN
DROP INDEX IF EXISTS repo_names_name_unique_idx;
ALTER INDEX repo_names_name_unique_idx_new RENAME TO repo_names_name_unique_idx;
END IF;
END
$$;
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
CREATE OR REPLACE FUNCTION migrate_tenant_id_non_null_codeinsights_down(table_name text)
RETURNS void AS $$
BEGIN
EXECUTE format('ALTER TABLE %I DROP COLUMN IF EXISTS tenant_id;', table_name);
EXECUTE format('ALTER TABLE %I ADD COLUMN tenant_id integer DEFAULT 1 REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE;', table_name);
END;
$$ LANGUAGE plpgsql;

SELECT migrate_tenant_id_non_null_codeinsights_down('archived_insight_series_recording_times'); COMMIT AND CHAIN;
SELECT migrate_tenant_id_non_null_codeinsights_down('dashboard'); COMMIT AND CHAIN;
SELECT migrate_tenant_id_non_null_codeinsights_down('dashboard_grants'); COMMIT AND CHAIN;
SELECT migrate_tenant_id_non_null_codeinsights_down('dashboard_insight_view'); COMMIT AND CHAIN;
SELECT migrate_tenant_id_non_null_codeinsights_down('insight_series'); COMMIT AND CHAIN;
SELECT migrate_tenant_id_non_null_codeinsights_down('insight_series_backfill'); COMMIT AND CHAIN;
SELECT migrate_tenant_id_non_null_codeinsights_down('insight_series_incomplete_points'); COMMIT AND CHAIN;
SELECT migrate_tenant_id_non_null_codeinsights_down('insight_view'); COMMIT AND CHAIN;
SELECT migrate_tenant_id_non_null_codeinsights_down('insight_view_grants'); COMMIT AND CHAIN;
SELECT migrate_tenant_id_non_null_codeinsights_down('insight_view_series'); COMMIT AND CHAIN;
SELECT migrate_tenant_id_non_null_codeinsights_down('insights_background_jobs'); COMMIT AND CHAIN;
SELECT migrate_tenant_id_non_null_codeinsights_down('insights_data_retention_jobs'); COMMIT AND CHAIN;
SELECT migrate_tenant_id_non_null_codeinsights_down('insight_series_recording_times'); COMMIT AND CHAIN;
SELECT migrate_tenant_id_non_null_codeinsights_down('metadata'); COMMIT AND CHAIN;
SELECT migrate_tenant_id_non_null_codeinsights_down('repo_iterator'); COMMIT AND CHAIN;
SELECT migrate_tenant_id_non_null_codeinsights_down('repo_iterator_errors'); COMMIT AND CHAIN;
SELECT migrate_tenant_id_non_null_codeinsights_down('repo_names'); COMMIT AND CHAIN;
SELECT migrate_tenant_id_non_null_codeinsights_down('archived_series_points'); COMMIT AND CHAIN;
SELECT migrate_tenant_id_non_null_codeinsights_down('series_points'); COMMIT AND CHAIN;
SELECT migrate_tenant_id_non_null_codeinsights_down('series_points_snapshots'); COMMIT AND CHAIN;

DROP FUNCTION migrate_tenant_id_non_null_codeinsights_down(text);
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
name: Make tenant_id columns non-nullable
parents: [1723647665, 1727875004]
bestEffortTerminateBlockingTransactions: true
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
CREATE OR REPLACE FUNCTION migrate_tenant_id_non_null_codeinsights(table_name text)
RETURNS void AS $$
BEGIN
EXECUTE format('ALTER TABLE %I DROP COLUMN IF EXISTS tenant_id;', table_name);
EXECUTE format('ALTER TABLE %I ADD COLUMN tenant_id integer NOT NULL DEFAULT 1;', table_name);
EXECUTE format('ALTER TABLE %I ALTER COLUMN tenant_id SET DEFAULT (current_setting(''app.current_tenant''::text))::integer;', table_name);
END;
$$ LANGUAGE plpgsql;

SELECT migrate_tenant_id_non_null_codeinsights('archived_insight_series_recording_times'); COMMIT AND CHAIN;
SELECT migrate_tenant_id_non_null_codeinsights('dashboard'); COMMIT AND CHAIN;
SELECT migrate_tenant_id_non_null_codeinsights('dashboard_grants'); COMMIT AND CHAIN;
SELECT migrate_tenant_id_non_null_codeinsights('dashboard_insight_view'); COMMIT AND CHAIN;
SELECT migrate_tenant_id_non_null_codeinsights('insight_series'); COMMIT AND CHAIN;
SELECT migrate_tenant_id_non_null_codeinsights('insight_series_backfill'); COMMIT AND CHAIN;
SELECT migrate_tenant_id_non_null_codeinsights('insight_series_incomplete_points'); COMMIT AND CHAIN;
SELECT migrate_tenant_id_non_null_codeinsights('insight_view'); COMMIT AND CHAIN;
SELECT migrate_tenant_id_non_null_codeinsights('insight_view_grants'); COMMIT AND CHAIN;
SELECT migrate_tenant_id_non_null_codeinsights('insight_view_series'); COMMIT AND CHAIN;
SELECT migrate_tenant_id_non_null_codeinsights('insights_background_jobs'); COMMIT AND CHAIN;
SELECT migrate_tenant_id_non_null_codeinsights('insights_data_retention_jobs'); COMMIT AND CHAIN;
SELECT migrate_tenant_id_non_null_codeinsights('insight_series_recording_times'); COMMIT AND CHAIN;
SELECT migrate_tenant_id_non_null_codeinsights('metadata'); COMMIT AND CHAIN;
SELECT migrate_tenant_id_non_null_codeinsights('repo_iterator'); COMMIT AND CHAIN;
SELECT migrate_tenant_id_non_null_codeinsights('repo_iterator_errors'); COMMIT AND CHAIN;
SELECT migrate_tenant_id_non_null_codeinsights('repo_names'); COMMIT AND CHAIN;
SELECT migrate_tenant_id_non_null_codeinsights('archived_series_points'); COMMIT AND CHAIN;
SELECT migrate_tenant_id_non_null_codeinsights('series_points'); COMMIT AND CHAIN;
SELECT migrate_tenant_id_non_null_codeinsights('series_points_snapshots'); COMMIT AND CHAIN;

DROP FUNCTION migrate_tenant_id_non_null_codeinsights(text);
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
CREATE OR REPLACE FUNCTION migrate_enable_rls_codeinsights_down(table_name text)
RETURNS void AS $$
BEGIN
EXECUTE format('ALTER TABLE %I DISABLE ROW LEVEL SECURITY;', table_name);
EXECUTE format('DROP POLICY IF EXISTS %I ON %I;', table_name || '_isolation_policy', table_name);
END;
$$ LANGUAGE plpgsql;

SELECT migrate_enable_rls_codeinsights_down('insights_data_retention_jobs'); COMMIT AND CHAIN;
SELECT migrate_enable_rls_codeinsights_down('series_points_snapshots'); COMMIT AND CHAIN;
SELECT migrate_enable_rls_codeinsights_down('insight_series_recording_times'); COMMIT AND CHAIN;
SELECT migrate_enable_rls_codeinsights_down('insight_view'); COMMIT AND CHAIN;
SELECT migrate_enable_rls_codeinsights_down('insight_view_grants'); COMMIT AND CHAIN;
SELECT migrate_enable_rls_codeinsights_down('archived_insight_series_recording_times'); COMMIT AND CHAIN;
SELECT migrate_enable_rls_codeinsights_down('archived_series_points'); COMMIT AND CHAIN;
SELECT migrate_enable_rls_codeinsights_down('dashboard'); COMMIT AND CHAIN;
SELECT migrate_enable_rls_codeinsights_down('dashboard_grants'); COMMIT AND CHAIN;
SELECT migrate_enable_rls_codeinsights_down('dashboard_insight_view'); COMMIT AND CHAIN;
SELECT migrate_enable_rls_codeinsights_down('insight_series'); COMMIT AND CHAIN;
SELECT migrate_enable_rls_codeinsights_down('insight_series_backfill'); COMMIT AND CHAIN;
SELECT migrate_enable_rls_codeinsights_down('insight_series_incomplete_points'); COMMIT AND CHAIN;
SELECT migrate_enable_rls_codeinsights_down('insight_view_series'); COMMIT AND CHAIN;
SELECT migrate_enable_rls_codeinsights_down('insights_background_jobs'); COMMIT AND CHAIN;
SELECT migrate_enable_rls_codeinsights_down('metadata'); COMMIT AND CHAIN;
SELECT migrate_enable_rls_codeinsights_down('repo_iterator'); COMMIT AND CHAIN;
SELECT migrate_enable_rls_codeinsights_down('repo_iterator_errors'); COMMIT AND CHAIN;
SELECT migrate_enable_rls_codeinsights_down('repo_names'); COMMIT AND CHAIN;
SELECT migrate_enable_rls_codeinsights_down('series_points'); COMMIT AND CHAIN;

DROP FUNCTION migrate_enable_rls_codeinsights_down(text);
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
name: Enable RLS for regular users
parents: [1727399817]
bestEffortTerminateBlockingTransactions: true
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
CREATE OR REPLACE FUNCTION migrate_enable_rls_codeinsights(table_name text)
RETURNS void AS $$
BEGIN
-- Enable RLS for the table.
EXECUTE format('ALTER TABLE %I ENABLE ROW LEVEL SECURITY;', table_name);
EXECUTE format('DROP POLICY IF EXISTS %I ON %I;', table_name || '_isolation_policy', table_name);
EXECUTE format('CREATE POLICY %I ON %I AS PERMISSIVE FOR ALL TO PUBLIC USING (tenant_id = current_setting(''app.current_tenant'')::integer);', table_name || '_isolation_policy', table_name);
END;
$$ LANGUAGE plpgsql;

SELECT migrate_enable_rls_codeinsights('insights_data_retention_jobs'); COMMIT AND CHAIN;
SELECT migrate_enable_rls_codeinsights('series_points_snapshots'); COMMIT AND CHAIN;
SELECT migrate_enable_rls_codeinsights('insight_series_recording_times'); COMMIT AND CHAIN;
SELECT migrate_enable_rls_codeinsights('insight_view'); COMMIT AND CHAIN;
SELECT migrate_enable_rls_codeinsights('insight_view_grants'); COMMIT AND CHAIN;
SELECT migrate_enable_rls_codeinsights('archived_insight_series_recording_times'); COMMIT AND CHAIN;
SELECT migrate_enable_rls_codeinsights('archived_series_points'); COMMIT AND CHAIN;
SELECT migrate_enable_rls_codeinsights('dashboard'); COMMIT AND CHAIN;
SELECT migrate_enable_rls_codeinsights('dashboard_grants'); COMMIT AND CHAIN;
SELECT migrate_enable_rls_codeinsights('dashboard_insight_view'); COMMIT AND CHAIN;
SELECT migrate_enable_rls_codeinsights('insight_series'); COMMIT AND CHAIN;
SELECT migrate_enable_rls_codeinsights('insight_series_backfill'); COMMIT AND CHAIN;
SELECT migrate_enable_rls_codeinsights('insight_series_incomplete_points'); COMMIT AND CHAIN;
SELECT migrate_enable_rls_codeinsights('insight_view_series'); COMMIT AND CHAIN;
SELECT migrate_enable_rls_codeinsights('insights_background_jobs'); COMMIT AND CHAIN;
SELECT migrate_enable_rls_codeinsights('metadata'); COMMIT AND CHAIN;
SELECT migrate_enable_rls_codeinsights('repo_iterator'); COMMIT AND CHAIN;
SELECT migrate_enable_rls_codeinsights('repo_iterator_errors'); COMMIT AND CHAIN;
SELECT migrate_enable_rls_codeinsights('repo_names'); COMMIT AND CHAIN;
SELECT migrate_enable_rls_codeinsights('series_points'); COMMIT AND CHAIN;

DROP FUNCTION migrate_enable_rls_codeinsights(text);
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
ALTER TABLE tenants DROP COLUMN IF EXISTS workspace_id;
ALTER TABLE tenants DROP COLUMN IF EXISTS display_name;
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
name: Extend tenants table with workspace uid and displayname
parents: [1727875004]
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
-- Delete all tenants except the default one, we're not in production yet so this is the
-- simplest.
DELETE FROM tenants where NOT id = 1;

ALTER TABLE tenants ADD COLUMN IF NOT EXISTS workspace_id uuid;
-- Canonical workspace id for the default tenant.
UPDATE tenants SET workspace_id = '6a6b043c-ffed-42ec-b1f4-abc231cd7222' WHERE id = 1;

ALTER TABLE tenants ALTER COLUMN workspace_id SET NOT NULL;
DO $$
BEGIN

BEGIN
ALTER TABLE tenants ADD CONSTRAINT tenants_workspace_id_key UNIQUE (workspace_id);
EXCEPTION
WHEN duplicate_table THEN -- postgres raises duplicate_table at surprising times. Ex.: for UNIQUE constraints.
WHEN duplicate_object THEN
RAISE NOTICE 'Table constraint lsif_last_retention_scan_unique already exists, skipping';
END;
END $$;

ALTER TABLE tenants ADD COLUMN IF NOT EXISTS display_name text;

COMMENT ON COLUMN tenants.workspace_id IS 'The ID in workspaces service of the tenant. This is used for identifying the link between tenant and workspace.';
COMMENT ON COLUMN tenants.display_name IS 'An optional display name for the tenant. This is used for rendering the tenant name in the UI.';
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
DROP INDEX IF EXISTS insight_view_unique_id_unique_idx_new;
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
name: Create insight_view_unique_id_unique_idx_new
parents: [1727490285]
createIndexConcurrently: true
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
CREATE UNIQUE INDEX CONCURRENTLY IF NOT EXISTS insight_view_unique_id_unique_idx_new ON insight_view (unique_id, tenant_id);
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
DROP INDEX IF EXISTS metadata_metadata_unique_idx_new;
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
name: Create metadata_metadata_unique_idx_new
parents: [1728937632]
createIndexConcurrently: true
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
CREATE UNIQUE INDEX CONCURRENTLY IF NOT EXISTS metadata_metadata_unique_idx_new ON metadata (metadata, tenant_id);
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
DROP INDEX IF EXISTS repo_names_name_unique_idx_new;
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
name: Create repo_names_name_unique_idx_new
parents: [1728937673]
createIndexConcurrently: true
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
CREATE UNIQUE INDEX CONCURRENTLY IF NOT EXISTS repo_names_name_unique_idx_new ON repo_names (name, tenant_id);
Loading

0 comments on commit 2b13919

Please sign in to comment.