diff --git a/dev/backcompat/flakes.json b/dev/backcompat/flakes.json index c1d6a8413f7..587514b326c 100644 --- a/dev/backcompat/flakes.json +++ b/dev/backcompat/flakes.json @@ -62,5 +62,11 @@ ], "5.4.0": [], "5.5.0": [], - "5.6.0": [] + "5.6.0": [ + { + "path": "internal/insights/store", + "prefix": "TestCreateDashboard", + "reason": "Updates all tables to have tenant_id and the old query for GetDashboardGrants used SELECT *" + } + ] } diff --git a/doc/dev/background-information/sql/migrations_overview.md b/doc/dev/background-information/sql/migrations_overview.md index b7620020a21..7012bb0b2bd 100644 --- a/doc/dev/background-information/sql/migrations_overview.md +++ b/doc/dev/background-information/sql/migrations_overview.md @@ -42,8 +42,7 @@ Each migration is another subdirectory containing three files: * `privileged` - indicates whether the migration must be run by a privileged user (i.e. super user). As of now, only [squash migrations are marked with a `true` value](https://sourcegraph.com/search?q=context:global+repo:%5Egithub%5C.com/sourcegraph/sourcegraph%24+privileged:+true+f:metadata.yaml&patternType=standard&sm=0&groupBy=path). * `nonIdempotent` - indicates whether the migration is not possible to run repeatedly and create incompatible side effects. As of now, only [squash migrations are marked with a `true` value](https://sourcegraph.com/search?q=context:global+repo:%5Egithub%5C.com/sourcegraph/sourcegraph%24+nonIdempotent:+true&patternType=standard&sm=0&groupBy=path). * `createIndexConcurrently` - indicates whether the migration uses the semantic of `CREATE INDEX CONCURRENTLY` with [caveats](https://github.com/sourcegraph/sourcegraph/blob/daf10fe1d0f921013fe3f14f6c4aaee754fc75cf/dev/sg/internal/migration/add.go#L23-L26). - -The execution of every migration is always wrapped in a single PostgreSQL transaction. If something needs to happen across the boundary of a PostgreSQL transaction, then make them two migrations. + * `noTransaction` - indicates whether the migration is wrapped in a transaction. The execution of every migration is by default wrapped in a single PostgreSQL transaction. If something needs to happen across the boundary of a PostgreSQL transaction, then prefer making them two migrations. Due to the nature of in-band migrations being executed in sequence, it could take quite a bit of time to run through all of them in a fresh installation. Therefore, squashing migrations is used as a technique to have a cumulated version of the database scheme up to the point of the oldest supported version of Sourcegraph to be upgraded from. For example, if the oldest supported version is 3.20, then all migrations created prior to 3.20 are squashed and users must upgrade to 3.20 first (to perform all necessary migrations) before jump start to the latest version (e.g. 3.11 -> 3.20 -> 4.2). diff --git a/internal/database/migration/definition/definition.go b/internal/database/migration/definition/definition.go index a62b7abf6b9..2e0938cdf2a 100644 --- a/internal/database/migration/definition/definition.go +++ b/internal/database/migration/definition/definition.go @@ -15,6 +15,7 @@ type Definition struct { NonIdempotent bool Parents []int IsCreateIndexConcurrently bool + NoTransaction bool IndexMetadata *IndexMetadata } diff --git a/internal/database/migration/definition/json.go b/internal/database/migration/definition/json.go index f9d222e9e86..9d16a82629a 100644 --- a/internal/database/migration/definition/json.go +++ b/internal/database/migration/definition/json.go @@ -34,6 +34,7 @@ type jsonDefinition struct { NonIdempotent bool Parents []int IsCreateIndexConcurrently bool + NoTransaction bool `json:"NoTransaction,omitempty"` IndexMetadata *IndexMetadata } @@ -47,6 +48,7 @@ func (d *Definition) MarshalJSON() ([]byte, error) { NonIdempotent: d.NonIdempotent, Parents: d.Parents, IsCreateIndexConcurrently: d.IsCreateIndexConcurrently, + NoTransaction: d.NoTransaction, IndexMetadata: d.IndexMetadata, }) } @@ -65,6 +67,7 @@ func (d *Definition) UnmarshalJSON(data []byte) error { d.NonIdempotent = jsonDefinition.NonIdempotent d.Parents = jsonDefinition.Parents d.IsCreateIndexConcurrently = jsonDefinition.IsCreateIndexConcurrently + d.NoTransaction = jsonDefinition.NoTransaction d.IndexMetadata = jsonDefinition.IndexMetadata return nil } diff --git a/internal/database/migration/definition/read.go b/internal/database/migration/definition/read.go index ac33e371539..f9e72b6f5c2 100644 --- a/internal/database/migration/definition/read.go +++ b/internal/database/migration/definition/read.go @@ -113,6 +113,7 @@ func hydrateMetadataFromFile(fs fs.FS, schemaBasePath, upFilename, metadataFilen Parent int `yaml:"parent"` Parents []int `yaml:"parents"` CreateIndexConcurrently bool `yaml:"createIndexConcurrently"` + NoTransaction bool `yaml:"noTransaction"` Privileged bool `yaml:"privileged"` NonIdempotent bool `yaml:"nonIdempotent"` } @@ -123,6 +124,7 @@ func hydrateMetadataFromFile(fs fs.FS, schemaBasePath, upFilename, metadataFilen definition.Name = payload.Name definition.Privileged = payload.Privileged definition.NonIdempotent = payload.NonIdempotent + definition.NoTransaction = payload.NoTransaction parents := payload.Parents if payload.Parent != 0 { diff --git a/internal/database/migration/runner/run.go b/internal/database/migration/runner/run.go index c377c717278..72111db0a37 100644 --- a/internal/database/migration/runner/run.go +++ b/internal/database/migration/runner/run.go @@ -364,7 +364,7 @@ func (r *Runner) applyMigration( applyMigration := func() (err error) { tx := schemaContext.store - if !definition.IsCreateIndexConcurrently { + if !definition.IsCreateIndexConcurrently && !definition.NoTransaction { tx, err = schemaContext.store.Transact(ctx) if err != nil { return err diff --git a/internal/database/migration/runner/run_test.go b/internal/database/migration/runner/run_test.go index e1c43f70332..5b6968dad55 100644 --- a/internal/database/migration/runner/run_test.go +++ b/internal/database/migration/runner/run_test.go @@ -30,6 +30,9 @@ func TestRun(t *testing.T) { mockassert.CalledN(t, store.UpFunc, 4) mockassert.NotCalled(t, store.DownFunc) + + // Migration 10004 specifies NoTransaction + mockassert.CalledN(t, store.TransactFunc, 3) }) t.Run("upgrade (partially applied)", func(t *testing.T) { diff --git a/internal/database/migration/runner/testdata/well-formed/10004/metadata.yaml b/internal/database/migration/runner/testdata/well-formed/10004/metadata.yaml index efc5653c72a..ec7d555d6f3 100644 --- a/internal/database/migration/runner/testdata/well-formed/10004/metadata.yaml +++ b/internal/database/migration/runner/testdata/well-formed/10004/metadata.yaml @@ -1,2 +1,3 @@ name: 'third or fourth (2)' parent: 10002 +noTransaction: true diff --git a/internal/database/schema.codeinsights.json b/internal/database/schema.codeinsights.json index 9c31ddb52d1..c5296221d27 100644 --- a/internal/database/schema.codeinsights.json +++ b/internal/database/schema.codeinsights.json @@ -218,6 +218,19 @@ "IsGenerated": "NEVER", "GenerationExpression": "", "Comment": "" + }, + { + "Name": "tenant_id", + "Index": 4, + "TypeName": "integer", + "IsNullable": true, + "Default": "", + "CharacterMaximumLength": 0, + "IsIdentity": false, + "IdentityGeneration": "", + "IsGenerated": "NEVER", + "GenerationExpression": "", + "Comment": "" } ], "Indexes": [ @@ -233,6 +246,13 @@ } ], "Constraints": [ + { + "Name": "archived_insight_series_recording_times_tenant_id_fkey", + "ConstraintType": "f", + "RefTableName": "tenants", + "IsDeferrable": false, + "ConstraintDefinition": "FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE" + }, { "Name": "insight_series_id_fkey", "ConstraintType": "f", @@ -312,6 +332,19 @@ "GenerationExpression": "", "Comment": "" }, + { + "Name": "tenant_id", + "Index": 8, + "TypeName": "integer", + "IsNullable": true, + "Default": "", + "CharacterMaximumLength": 0, + "IsIdentity": false, + "IdentityGeneration": "", + "IsGenerated": "NEVER", + "GenerationExpression": "", + "Comment": "" + }, { "Name": "time", "Index": 2, @@ -341,6 +374,13 @@ ], "Indexes": [], "Constraints": [ + { + "Name": "archived_series_points_tenant_id_fkey", + "ConstraintType": "f", + "RefTableName": "tenants", + "IsDeferrable": false, + "ConstraintDefinition": "FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE" + }, { "Name": "check_repo_fields_specifity", "ConstraintType": "c", @@ -440,6 +480,19 @@ "GenerationExpression": "", "Comment": "TEMPORARY Do not delete this dashboard when migrating settings." }, + { + "Name": "tenant_id", + "Index": 9, + "TypeName": "integer", + "IsNullable": true, + "Default": "", + "CharacterMaximumLength": 0, + "IsIdentity": false, + "IdentityGeneration": "", + "IsGenerated": "NEVER", + "GenerationExpression": "", + "Comment": "" + }, { "Name": "title", "Index": 2, @@ -479,7 +532,15 @@ "ConstraintDefinition": "PRIMARY KEY (id)" } ], - "Constraints": null, + "Constraints": [ + { + "Name": "dashboard_tenant_id_fkey", + "ConstraintType": "f", + "RefTableName": "tenants", + "IsDeferrable": false, + "ConstraintDefinition": "FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE" + } + ], "Triggers": [] }, { @@ -538,6 +599,19 @@ "GenerationExpression": "", "Comment": "Org ID that that receives this grant." }, + { + "Name": "tenant_id", + "Index": 6, + "TypeName": "integer", + "IsNullable": true, + "Default": "", + "CharacterMaximumLength": 0, + "IsIdentity": false, + "IdentityGeneration": "", + "IsGenerated": "NEVER", + "GenerationExpression": "", + "Comment": "" + }, { "Name": "user_id", "Index": 3, @@ -611,6 +685,13 @@ "RefTableName": "dashboard", "IsDeferrable": false, "ConstraintDefinition": "FOREIGN KEY (dashboard_id) REFERENCES dashboard(id) ON DELETE CASCADE" + }, + { + "Name": "dashboard_grants_tenant_id_fkey", + "ConstraintType": "f", + "RefTableName": "tenants", + "IsDeferrable": false, + "ConstraintDefinition": "FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE" } ], "Triggers": [] @@ -657,6 +738,19 @@ "IsGenerated": "NEVER", "GenerationExpression": "", "Comment": "" + }, + { + "Name": "tenant_id", + "Index": 4, + "TypeName": "integer", + "IsNullable": true, + "Default": "", + "CharacterMaximumLength": 0, + "IsIdentity": false, + "IdentityGeneration": "", + "IsGenerated": "NEVER", + "GenerationExpression": "", + "Comment": "" } ], "Indexes": [ @@ -715,6 +809,13 @@ "RefTableName": "insight_view", "IsDeferrable": false, "ConstraintDefinition": "FOREIGN KEY (insight_view_id) REFERENCES insight_view(id) ON DELETE CASCADE" + }, + { + "Name": "dashboard_insight_view_tenant_id_fkey", + "ConstraintType": "f", + "RefTableName": "tenants", + "IsDeferrable": false, + "ConstraintDefinition": "FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE" } ], "Triggers": [] @@ -1034,6 +1135,19 @@ "IsGenerated": "NEVER", "GenerationExpression": "", "Comment": "" + }, + { + "Name": "tenant_id", + "Index": 25, + "TypeName": "integer", + "IsNullable": true, + "Default": "", + "CharacterMaximumLength": 0, + "IsIdentity": false, + "IdentityGeneration": "", + "IsGenerated": "NEVER", + "GenerationExpression": "", + "Comment": "" } ], "Indexes": [ @@ -1078,7 +1192,15 @@ "ConstraintDefinition": "" } ], - "Constraints": null, + "Constraints": [ + { + "Name": "insight_series_tenant_id_fkey", + "ConstraintType": "f", + "RefTableName": "tenants", + "IsDeferrable": false, + "ConstraintDefinition": "FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE" + } + ], "Triggers": [] }, { @@ -1149,6 +1271,19 @@ "IsGenerated": "NEVER", "GenerationExpression": "", "Comment": "" + }, + { + "Name": "tenant_id", + "Index": 6, + "TypeName": "integer", + "IsNullable": true, + "Default": "", + "CharacterMaximumLength": 0, + "IsIdentity": false, + "IdentityGeneration": "", + "IsGenerated": "NEVER", + "GenerationExpression": "", + "Comment": "" } ], "Indexes": [ @@ -1170,6 +1305,13 @@ "RefTableName": "insight_series", "IsDeferrable": false, "ConstraintDefinition": "FOREIGN KEY (series_id) REFERENCES insight_series(id) ON DELETE CASCADE" + }, + { + "Name": "insight_series_backfill_tenant_id_fkey", + "ConstraintType": "f", + "RefTableName": "tenants", + "IsDeferrable": false, + "ConstraintDefinition": "FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE" } ], "Triggers": [] @@ -1230,6 +1372,19 @@ "GenerationExpression": "", "Comment": "" }, + { + "Name": "tenant_id", + "Index": 6, + "TypeName": "integer", + "IsNullable": true, + "Default": "", + "CharacterMaximumLength": 0, + "IsIdentity": false, + "IdentityGeneration": "", + "IsGenerated": "NEVER", + "GenerationExpression": "", + "Comment": "" + }, { "Name": "time", "Index": 4, @@ -1273,6 +1428,13 @@ "RefTableName": "insight_series", "IsDeferrable": false, "ConstraintDefinition": "FOREIGN KEY (series_id) REFERENCES insight_series(id) ON DELETE CASCADE" + }, + { + "Name": "insight_series_incomplete_points_tenant_id_fkey", + "ConstraintType": "f", + "RefTableName": "tenants", + "IsDeferrable": false, + "ConstraintDefinition": "FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE" } ], "Triggers": [] @@ -1319,6 +1481,19 @@ "IsGenerated": "NEVER", "GenerationExpression": "", "Comment": "" + }, + { + "Name": "tenant_id", + "Index": 4, + "TypeName": "integer", + "IsNullable": true, + "Default": "", + "CharacterMaximumLength": 0, + "IsIdentity": false, + "IdentityGeneration": "", + "IsGenerated": "NEVER", + "GenerationExpression": "", + "Comment": "" } ], "Indexes": [ @@ -1340,6 +1515,13 @@ "RefTableName": "insight_series", "IsDeferrable": false, "ConstraintDefinition": "FOREIGN KEY (insight_series_id) REFERENCES insight_series(id) ON DELETE CASCADE" + }, + { + "Name": "insight_series_recording_times_tenant_id_fkey", + "ConstraintType": "f", + "RefTableName": "tenants", + "IsDeferrable": false, + "ConstraintDefinition": "FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE" } ], "Triggers": [] @@ -1504,6 +1686,19 @@ "GenerationExpression": "", "Comment": "" }, + { + "Name": "tenant_id", + "Index": 15, + "TypeName": "integer", + "IsNullable": true, + "Default": "", + "CharacterMaximumLength": 0, + "IsIdentity": false, + "IdentityGeneration": "", + "IsGenerated": "NEVER", + "GenerationExpression": "", + "Comment": "" + }, { "Name": "title", "Index": 2, @@ -1553,7 +1748,15 @@ "ConstraintDefinition": "" } ], - "Constraints": null, + "Constraints": [ + { + "Name": "insight_view_tenant_id_fkey", + "ConstraintType": "f", + "RefTableName": "tenants", + "IsDeferrable": false, + "ConstraintDefinition": "FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE" + } + ], "Triggers": [] }, { @@ -1612,6 +1815,19 @@ "GenerationExpression": "", "Comment": "Org ID that that receives this grant." }, + { + "Name": "tenant_id", + "Index": 6, + "TypeName": "integer", + "IsNullable": true, + "Default": "", + "CharacterMaximumLength": 0, + "IsIdentity": false, + "IdentityGeneration": "", + "IsGenerated": "NEVER", + "GenerationExpression": "", + "Comment": "" + }, { "Name": "user_id", "Index": 3, @@ -1685,6 +1901,13 @@ "RefTableName": "insight_view", "IsDeferrable": false, "ConstraintDefinition": "FOREIGN KEY (insight_view_id) REFERENCES insight_view(id) ON DELETE CASCADE" + }, + { + "Name": "insight_view_grants_tenant_id_fkey", + "ConstraintType": "f", + "RefTableName": "tenants", + "IsDeferrable": false, + "ConstraintDefinition": "FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE" } ], "Triggers": [] @@ -1744,6 +1967,19 @@ "IsGenerated": "NEVER", "GenerationExpression": "", "Comment": "Stroke color metadata for this data series. This may render in a chart depending on the view type." + }, + { + "Name": "tenant_id", + "Index": 5, + "TypeName": "integer", + "IsNullable": true, + "Default": "", + "CharacterMaximumLength": 0, + "IsIdentity": false, + "IdentityGeneration": "", + "IsGenerated": "NEVER", + "GenerationExpression": "", + "Comment": "" } ], "Indexes": [ @@ -1772,6 +2008,13 @@ "RefTableName": "insight_view", "IsDeferrable": false, "ConstraintDefinition": "FOREIGN KEY (insight_view_id) REFERENCES insight_view(id) ON DELETE CASCADE" + }, + { + "Name": "insight_view_series_tenant_id_fkey", + "ConstraintType": "f", + "RefTableName": "tenants", + "IsDeferrable": false, + "ConstraintDefinition": "FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE" } ], "Triggers": [] @@ -1949,6 +2192,19 @@ "GenerationExpression": "", "Comment": "" }, + { + "Name": "tenant_id", + "Index": 15, + "TypeName": "integer", + "IsNullable": true, + "Default": "", + "CharacterMaximumLength": 0, + "IsIdentity": false, + "IdentityGeneration": "", + "IsGenerated": "NEVER", + "GenerationExpression": "", + "Comment": "" + }, { "Name": "worker_hostname", "Index": 12, @@ -1992,6 +2248,13 @@ "RefTableName": "insight_series_backfill", "IsDeferrable": false, "ConstraintDefinition": "FOREIGN KEY (backfill_id) REFERENCES insight_series_backfill(id) ON DELETE CASCADE" + }, + { + "Name": "insights_background_jobs_tenant_id_fkey", + "ConstraintType": "f", + "RefTableName": "tenants", + "IsDeferrable": false, + "ConstraintDefinition": "FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE" } ], "Triggers": [] @@ -2182,6 +2445,19 @@ "GenerationExpression": "", "Comment": "" }, + { + "Name": "tenant_id", + "Index": 16, + "TypeName": "integer", + "IsNullable": true, + "Default": "", + "CharacterMaximumLength": 0, + "IsIdentity": false, + "IdentityGeneration": "", + "IsGenerated": "NEVER", + "GenerationExpression": "", + "Comment": "" + }, { "Name": "worker_hostname", "Index": 12, @@ -2208,7 +2484,15 @@ "ConstraintDefinition": "PRIMARY KEY (id)" } ], - "Constraints": null, + "Constraints": [ + { + "Name": "insights_data_retention_jobs_tenant_id_fkey", + "ConstraintType": "f", + "RefTableName": "tenants", + "IsDeferrable": false, + "ConstraintDefinition": "FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE" + } + ], "Triggers": [] }, { @@ -2240,6 +2524,19 @@ "IsGenerated": "NEVER", "GenerationExpression": "", "Comment": "Metadata about some event, this can be any arbitrary JSON emtadata which will be returned when querying events, and can be filtered on and grouped using jsonb operators ?, ?\u0026, ?|, and @\u003e. This should be small data only." + }, + { + "Name": "tenant_id", + "Index": 3, + "TypeName": "integer", + "IsNullable": true, + "Default": "", + "CharacterMaximumLength": 0, + "IsIdentity": false, + "IdentityGeneration": "", + "IsGenerated": "NEVER", + "GenerationExpression": "", + "Comment": "" } ], "Indexes": [ @@ -2274,7 +2571,15 @@ "ConstraintDefinition": "" } ], - "Constraints": null, + "Constraints": [ + { + "Name": "metadata_tenant_id_fkey", + "ConstraintType": "f", + "RefTableName": "tenants", + "IsDeferrable": false, + "ConstraintDefinition": "FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE" + } + ], "Triggers": [] }, { @@ -2561,6 +2866,19 @@ "GenerationExpression": "", "Comment": "" }, + { + "Name": "tenant_id", + "Index": 12, + "TypeName": "integer", + "IsNullable": true, + "Default": "", + "CharacterMaximumLength": 0, + "IsIdentity": false, + "IdentityGeneration": "", + "IsGenerated": "NEVER", + "GenerationExpression": "", + "Comment": "" + }, { "Name": "total_count", "Index": 8, @@ -2587,7 +2905,15 @@ "ConstraintDefinition": "PRIMARY KEY (id)" } ], - "Constraints": null, + "Constraints": [ + { + "Name": "repo_iterator_tenant_id_fkey", + "ConstraintType": "f", + "RefTableName": "tenants", + "IsDeferrable": false, + "ConstraintDefinition": "FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE" + } + ], "Triggers": [] }, { @@ -2658,6 +2984,19 @@ "IsGenerated": "NEVER", "GenerationExpression": "", "Comment": "" + }, + { + "Name": "tenant_id", + "Index": 6, + "TypeName": "integer", + "IsNullable": true, + "Default": "", + "CharacterMaximumLength": 0, + "IsIdentity": false, + "IdentityGeneration": "", + "IsGenerated": "NEVER", + "GenerationExpression": "", + "Comment": "" } ], "Indexes": [ @@ -2683,6 +3022,13 @@ } ], "Constraints": [ + { + "Name": "repo_iterator_errors_tenant_id_fkey", + "ConstraintType": "f", + "RefTableName": "tenants", + "IsDeferrable": false, + "ConstraintDefinition": "FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE" + }, { "Name": "repo_iterator_fk", "ConstraintType": "f", @@ -2722,6 +3068,19 @@ "IsGenerated": "NEVER", "GenerationExpression": "", "Comment": "The repository name string, with unique constraint for table entry deduplication and trigram index for e.g. regex filtering." + }, + { + "Name": "tenant_id", + "Index": 3, + "TypeName": "integer", + "IsNullable": true, + "Default": "", + "CharacterMaximumLength": 0, + "IsIdentity": false, + "IdentityGeneration": "", + "IsGenerated": "NEVER", + "GenerationExpression": "", + "Comment": "" } ], "Indexes": [ @@ -2763,6 +3122,13 @@ "RefTableName": "", "IsDeferrable": false, "ConstraintDefinition": "CHECK (name \u003c\u003e ''::citext)" + }, + { + "Name": "repo_names_tenant_id_fkey", + "ConstraintType": "f", + "RefTableName": "tenants", + "IsDeferrable": false, + "ConstraintDefinition": "FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE" } ], "Triggers": [] @@ -2849,6 +3215,19 @@ "GenerationExpression": "", "Comment": "A unique identifier for the series of data being recorded. This is not an ID from another table, but rather just a unique identifier." }, + { + "Name": "tenant_id", + "Index": 9, + "TypeName": "integer", + "IsNullable": true, + "Default": "", + "CharacterMaximumLength": 0, + "IsIdentity": false, + "IdentityGeneration": "", + "IsGenerated": "NEVER", + "GenerationExpression": "", + "Comment": "" + }, { "Name": "time", "Index": 2, @@ -2956,6 +3335,13 @@ "RefTableName": "repo_names", "IsDeferrable": true, "ConstraintDefinition": "FOREIGN KEY (repo_name_id) REFERENCES repo_names(id) ON DELETE CASCADE DEFERRABLE" + }, + { + "Name": "series_points_tenant_id_fkey", + "ConstraintType": "f", + "RefTableName": "tenants", + "IsDeferrable": false, + "ConstraintDefinition": "FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE" } ], "Triggers": [] @@ -3042,6 +3428,19 @@ "GenerationExpression": "", "Comment": "" }, + { + "Name": "tenant_id", + "Index": 9, + "TypeName": "integer", + "IsNullable": true, + "Default": "", + "CharacterMaximumLength": 0, + "IsIdentity": false, + "IdentityGeneration": "", + "IsGenerated": "NEVER", + "GenerationExpression": "", + "Comment": "" + }, { "Name": "time", "Index": 2, @@ -3128,6 +3527,13 @@ "RefTableName": "", "IsDeferrable": false, "ConstraintDefinition": "CHECK (repo_id IS NULL AND repo_name_id IS NULL AND original_repo_name_id IS NULL OR repo_id IS NOT NULL AND repo_name_id IS NOT NULL AND original_repo_name_id IS NOT NULL)" + }, + { + "Name": "series_points_snapshots_tenant_id_fkey", + "ConstraintType": "f", + "RefTableName": "tenants", + "IsDeferrable": false, + "ConstraintDefinition": "FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE" } ], "Triggers": [] diff --git a/internal/database/schema.codeinsights.md b/internal/database/schema.codeinsights.md index 13fdc83272b..f97e128639e 100644 --- a/internal/database/schema.codeinsights.md +++ b/internal/database/schema.codeinsights.md @@ -5,9 +5,11 @@ insight_series_id | integer | | not null | recording_time | timestamp with time zone | | not null | snapshot | boolean | | not null | + tenant_id | integer | | | Indexes: "archived_insight_series_recor_insight_series_id_recording_t_key" UNIQUE CONSTRAINT, btree (insight_series_id, recording_time) Foreign-key constraints: + "archived_insight_series_recording_times_tenant_id_fkey" FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE "insight_series_id_fkey" FOREIGN KEY (insight_series_id) REFERENCES insight_series(id) ON DELETE CASCADE ``` @@ -23,9 +25,11 @@ Foreign-key constraints: repo_name_id | integer | | | original_repo_name_id | integer | | | capture | text | | | + tenant_id | integer | | | Check constraints: "check_repo_fields_specifity" CHECK (repo_id IS NULL AND repo_name_id IS NULL AND original_repo_name_id IS NULL OR repo_id IS NOT NULL AND repo_name_id IS NOT NULL AND original_repo_name_id IS NOT NULL) Foreign-key constraints: + "archived_series_points_tenant_id_fkey" FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE "insight_series_series_id_fkey" FOREIGN KEY (series_id) REFERENCES insight_series(series_id) ON DELETE CASCADE ``` @@ -42,8 +46,11 @@ Foreign-key constraints: deleted_at | timestamp without time zone | | | save | boolean | | not null | false type | text | | not null | 'standard'::text + tenant_id | integer | | | Indexes: "dashboard_pk" PRIMARY KEY, btree (id) +Foreign-key constraints: + "dashboard_tenant_id_fkey" FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE Referenced by: TABLE "dashboard_grants" CONSTRAINT "dashboard_grants_dashboard_id_fk" FOREIGN KEY (dashboard_id) REFERENCES dashboard(id) ON DELETE CASCADE TABLE "dashboard_insight_view" CONSTRAINT "dashboard_insight_view_dashboard_id_fk" FOREIGN KEY (dashboard_id) REFERENCES dashboard(id) ON DELETE CASCADE @@ -73,6 +80,7 @@ Metadata for dashboards of insights user_id | integer | | | org_id | integer | | | global | boolean | | | + tenant_id | integer | | | Indexes: "dashboard_grants_pk" PRIMARY KEY, btree (id) "dashboard_grants_dashboard_id_index" btree (dashboard_id) @@ -81,6 +89,7 @@ Indexes: "dashboard_grants_user_id_idx" btree (user_id) Foreign-key constraints: "dashboard_grants_dashboard_id_fk" FOREIGN KEY (dashboard_id) REFERENCES dashboard(id) ON DELETE CASCADE + "dashboard_grants_tenant_id_fkey" FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE ``` @@ -99,6 +108,7 @@ Permission grants for dashboards. Each row should represent a unique principal ( id | integer | | not null | nextval('dashboard_insight_view_id_seq'::regclass) dashboard_id | integer | | not null | insight_view_id | integer | | not null | + tenant_id | integer | | | Indexes: "dashboard_insight_view_pk" PRIMARY KEY, btree (id) "unique_dashboard_id_insight_view_id" UNIQUE CONSTRAINT, btree (dashboard_id, insight_view_id) @@ -107,6 +117,7 @@ Indexes: Foreign-key constraints: "dashboard_insight_view_dashboard_id_fk" FOREIGN KEY (dashboard_id) REFERENCES dashboard(id) ON DELETE CASCADE "dashboard_insight_view_insight_view_id_fk" FOREIGN KEY (insight_view_id) REFERENCES insight_view(id) ON DELETE CASCADE + "dashboard_insight_view_tenant_id_fkey" FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE ``` @@ -138,11 +149,14 @@ Foreign-key constraints: supports_augmentation | boolean | | not null | true repository_criteria | text | | | query_old | text | | | + tenant_id | integer | | | Indexes: "insight_series_pkey" PRIMARY KEY, btree (id) "insight_series_series_id_unique_idx" UNIQUE, btree (series_id) "insight_series_deleted_at_idx" btree (deleted_at) "insight_series_next_recording_after_idx" btree (next_recording_after) +Foreign-key constraints: + "insight_series_tenant_id_fkey" FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE Referenced by: TABLE "insight_series_backfill" CONSTRAINT "insight_series_backfill_series_id_fk" FOREIGN KEY (series_id) REFERENCES insight_series(id) ON DELETE CASCADE TABLE "archived_insight_series_recording_times" CONSTRAINT "insight_series_id_fkey" FOREIGN KEY (insight_series_id) REFERENCES insight_series(id) ON DELETE CASCADE @@ -188,10 +202,12 @@ Data series that comprise code insights. repo_iterator_id | integer | | | estimated_cost | double precision | | | state | text | | not null | 'new'::text + tenant_id | integer | | | Indexes: "insight_series_backfill_pk" PRIMARY KEY, btree (id) Foreign-key constraints: "insight_series_backfill_series_id_fk" FOREIGN KEY (series_id) REFERENCES insight_series(id) ON DELETE CASCADE + "insight_series_backfill_tenant_id_fkey" FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE Referenced by: TABLE "insights_background_jobs" CONSTRAINT "insights_background_jobs_backfill_id_fkey" FOREIGN KEY (backfill_id) REFERENCES insight_series_backfill(id) ON DELETE CASCADE @@ -206,11 +222,13 @@ Referenced by: reason | text | | not null | time | timestamp without time zone | | not null | repo_id | integer | | | + tenant_id | integer | | | Indexes: "insight_series_incomplete_points_pk" PRIMARY KEY, btree (id) "insight_series_incomplete_points_unique_idx" UNIQUE, btree (series_id, reason, "time", repo_id) Foreign-key constraints: "insight_series_incomplete_points_series_id_fk" FOREIGN KEY (series_id) REFERENCES insight_series(id) ON DELETE CASCADE + "insight_series_incomplete_points_tenant_id_fkey" FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE ``` @@ -221,10 +239,12 @@ Foreign-key constraints: insight_series_id | integer | | | recording_time | timestamp with time zone | | | snapshot | boolean | | | + tenant_id | integer | | | Indexes: "insight_series_recording_time_insight_series_id_recording_t_key" UNIQUE CONSTRAINT, btree (insight_series_id, recording_time) Foreign-key constraints: "insight_series_id_fkey" FOREIGN KEY (insight_series_id) REFERENCES insight_series(id) ON DELETE CASCADE + "insight_series_recording_times_tenant_id_fkey" FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE ``` @@ -246,9 +266,12 @@ Foreign-key constraints: series_sort_direction | series_sort_direction_enum | | | series_limit | integer | | | series_num_samples | integer | | | + tenant_id | integer | | | Indexes: "insight_view_pkey" PRIMARY KEY, btree (id) "insight_view_unique_id_unique_idx" UNIQUE, btree (unique_id) +Foreign-key constraints: + "insight_view_tenant_id_fkey" FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE Referenced by: TABLE "dashboard_insight_view" CONSTRAINT "dashboard_insight_view_insight_view_id_fk" FOREIGN KEY (insight_view_id) REFERENCES insight_view(id) ON DELETE CASCADE TABLE "insight_view_grants" CONSTRAINT "insight_view_grants_insight_view_id_fk" FOREIGN KEY (insight_view_id) REFERENCES insight_view(id) ON DELETE CASCADE @@ -279,6 +302,7 @@ Views for insight data series. An insight view is an abstraction on top of an in user_id | integer | | | org_id | integer | | | global | boolean | | | + tenant_id | integer | | | Indexes: "insight_view_grants_pk" PRIMARY KEY, btree (id) "insight_view_grants_global_idx" btree (global) WHERE global IS TRUE @@ -287,6 +311,7 @@ Indexes: "insight_view_grants_user_id_idx" btree (user_id) Foreign-key constraints: "insight_view_grants_insight_view_id_fk" FOREIGN KEY (insight_view_id) REFERENCES insight_view(id) ON DELETE CASCADE + "insight_view_grants_tenant_id_fkey" FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE ``` @@ -306,11 +331,13 @@ Permission grants for insight views. Each row should represent a unique principa insight_series_id | integer | | not null | label | text | | | stroke | text | | | + tenant_id | integer | | | Indexes: "insight_view_series_pkey" PRIMARY KEY, btree (insight_view_id, insight_series_id) Foreign-key constraints: "insight_view_series_insight_series_id_fkey" FOREIGN KEY (insight_series_id) REFERENCES insight_series(id) "insight_view_series_insight_view_id_fkey" FOREIGN KEY (insight_view_id) REFERENCES insight_view(id) ON DELETE CASCADE + "insight_view_series_tenant_id_fkey" FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE ``` @@ -342,11 +369,13 @@ Join table to correlate data series with insight views worker_hostname | text | | not null | ''::text cancel | boolean | | not null | false backfill_id | integer | | | + tenant_id | integer | | | Indexes: "insights_background_jobs_pkey" PRIMARY KEY, btree (id) "insights_jobs_state_idx" btree (state) Foreign-key constraints: "insights_background_jobs_backfill_id_fkey" FOREIGN KEY (backfill_id) REFERENCES insight_series_backfill(id) ON DELETE CASCADE + "insights_background_jobs_tenant_id_fkey" FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE ``` @@ -369,21 +398,27 @@ Foreign-key constraints: cancel | boolean | | not null | false series_id | integer | | not null | series_id_string | text | | not null | ''::text + tenant_id | integer | | | Indexes: "insights_data_retention_jobs_pkey" PRIMARY KEY, btree (id) +Foreign-key constraints: + "insights_data_retention_jobs_tenant_id_fkey" FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE ``` # Table "public.metadata" ``` - Column | Type | Collation | Nullable | Default -----------+--------+-----------+----------+-------------------------------------- - id | bigint | | not null | nextval('metadata_id_seq'::regclass) - metadata | jsonb | | not null | + Column | Type | Collation | Nullable | Default +-----------+---------+-----------+----------+-------------------------------------- + id | bigint | | not null | nextval('metadata_id_seq'::regclass) + metadata | jsonb | | not null | + tenant_id | integer | | | Indexes: "metadata_pkey" PRIMARY KEY, btree (id) "metadata_metadata_unique_idx" UNIQUE, btree (metadata) "metadata_metadata_gin" gin (metadata) +Foreign-key constraints: + "metadata_tenant_id_fkey" FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE Referenced by: TABLE "series_points" CONSTRAINT "series_points_metadata_id_fkey" FOREIGN KEY (metadata_id) REFERENCES metadata(id) ON DELETE CASCADE DEFERRABLE @@ -429,8 +464,11 @@ Indexes: success_count | integer | | not null | 0 repos | integer[] | | | repo_cursor | integer | | | 0 + tenant_id | integer | | | Indexes: "repo_iterator_pk" PRIMARY KEY, btree (id) +Foreign-key constraints: + "repo_iterator_tenant_id_fkey" FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE Referenced by: TABLE "repo_iterator_errors" CONSTRAINT "repo_iterator_fk" FOREIGN KEY (repo_iterator_id) REFERENCES repo_iterator(id) @@ -445,26 +483,31 @@ Referenced by: repo_id | integer | | not null | error_message | text[] | | not null | failure_count | integer | | | 1 + tenant_id | integer | | | Indexes: "repo_iterator_errors_pk" PRIMARY KEY, btree (id) "repo_iterator_errors_fk_idx" btree (repo_iterator_id) Foreign-key constraints: + "repo_iterator_errors_tenant_id_fkey" FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE "repo_iterator_fk" FOREIGN KEY (repo_iterator_id) REFERENCES repo_iterator(id) ``` # Table "public.repo_names" ``` - Column | Type | Collation | Nullable | Default ---------+--------+-----------+----------+---------------------------------------- - id | bigint | | not null | nextval('repo_names_id_seq'::regclass) - name | citext | | not null | + Column | Type | Collation | Nullable | Default +-----------+---------+-----------+----------+---------------------------------------- + id | bigint | | not null | nextval('repo_names_id_seq'::regclass) + name | citext | | not null | + tenant_id | integer | | | Indexes: "repo_names_pkey" PRIMARY KEY, btree (id) "repo_names_name_unique_idx" UNIQUE, btree (name) "repo_names_name_trgm" gin (lower(name::text) gin_trgm_ops) Check constraints: "check_name_nonempty" CHECK (name <> ''::citext) +Foreign-key constraints: + "repo_names_tenant_id_fkey" FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE Referenced by: TABLE "series_points" CONSTRAINT "series_points_original_repo_name_id_fkey" FOREIGN KEY (original_repo_name_id) REFERENCES repo_names(id) ON DELETE CASCADE DEFERRABLE TABLE "series_points" CONSTRAINT "series_points_repo_name_id_fkey" FOREIGN KEY (repo_name_id) REFERENCES repo_names(id) ON DELETE CASCADE DEFERRABLE @@ -489,6 +532,7 @@ Records repository names, both historical and present, using a unique repository repo_name_id | integer | | | original_repo_name_id | integer | | | capture | text | | | + tenant_id | integer | | | Indexes: "series_points_original_repo_name_id_btree" btree (original_repo_name_id) "series_points_repo_id_btree" btree (repo_id) @@ -501,6 +545,7 @@ Foreign-key constraints: "series_points_metadata_id_fkey" FOREIGN KEY (metadata_id) REFERENCES metadata(id) ON DELETE CASCADE DEFERRABLE "series_points_original_repo_name_id_fkey" FOREIGN KEY (original_repo_name_id) REFERENCES repo_names(id) ON DELETE CASCADE DEFERRABLE "series_points_repo_name_id_fkey" FOREIGN KEY (repo_name_id) REFERENCES repo_names(id) ON DELETE CASCADE DEFERRABLE + "series_points_tenant_id_fkey" FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE ``` @@ -532,6 +577,7 @@ Records events over time associated with a repository (or none, i.e. globally) w repo_name_id | integer | | | original_repo_name_id | integer | | | capture | text | | | + tenant_id | integer | | | Indexes: "series_points_snapshots_original_repo_name_id_idx" btree (original_repo_name_id) "series_points_snapshots_repo_id_idx" btree (repo_id) @@ -540,6 +586,8 @@ Indexes: "series_points_snapshots_series_id_repo_id_time_idx" btree (series_id, repo_id, "time") Check constraints: "check_repo_fields_specifity" CHECK (repo_id IS NULL AND repo_name_id IS NULL AND original_repo_name_id IS NULL OR repo_id IS NOT NULL AND repo_name_id IS NOT NULL AND original_repo_name_id IS NOT NULL) +Foreign-key constraints: + "series_points_snapshots_tenant_id_fkey" FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE ``` @@ -559,6 +607,27 @@ Indexes: Check constraints: "tenant_name_length" CHECK (char_length(name) <= 32 AND char_length(name) >= 3) "tenant_name_valid_chars" CHECK (name ~ '^[a-z](?:[a-z0-9\_-])*[a-z0-9]$'::text) +Referenced by: + TABLE "archived_insight_series_recording_times" CONSTRAINT "archived_insight_series_recording_times_tenant_id_fkey" FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE + TABLE "archived_series_points" CONSTRAINT "archived_series_points_tenant_id_fkey" FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE + TABLE "dashboard_grants" CONSTRAINT "dashboard_grants_tenant_id_fkey" FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE + TABLE "dashboard_insight_view" CONSTRAINT "dashboard_insight_view_tenant_id_fkey" FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE + TABLE "dashboard" CONSTRAINT "dashboard_tenant_id_fkey" FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE + TABLE "insight_series_backfill" CONSTRAINT "insight_series_backfill_tenant_id_fkey" FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE + TABLE "insight_series_incomplete_points" CONSTRAINT "insight_series_incomplete_points_tenant_id_fkey" FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE + TABLE "insight_series_recording_times" CONSTRAINT "insight_series_recording_times_tenant_id_fkey" FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE + TABLE "insight_series" CONSTRAINT "insight_series_tenant_id_fkey" FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE + TABLE "insight_view_grants" CONSTRAINT "insight_view_grants_tenant_id_fkey" FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE + TABLE "insight_view_series" CONSTRAINT "insight_view_series_tenant_id_fkey" FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE + TABLE "insight_view" CONSTRAINT "insight_view_tenant_id_fkey" FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE + TABLE "insights_background_jobs" CONSTRAINT "insights_background_jobs_tenant_id_fkey" FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE + TABLE "insights_data_retention_jobs" CONSTRAINT "insights_data_retention_jobs_tenant_id_fkey" FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE + TABLE "metadata" CONSTRAINT "metadata_tenant_id_fkey" FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE + TABLE "repo_iterator_errors" CONSTRAINT "repo_iterator_errors_tenant_id_fkey" FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE + TABLE "repo_iterator" CONSTRAINT "repo_iterator_tenant_id_fkey" FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE + TABLE "repo_names" CONSTRAINT "repo_names_tenant_id_fkey" FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE + TABLE "series_points_snapshots" CONSTRAINT "series_points_snapshots_tenant_id_fkey" FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE + TABLE "series_points" CONSTRAINT "series_points_tenant_id_fkey" FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE ``` diff --git a/internal/database/schema.codeintel.json b/internal/database/schema.codeintel.json index 605881e5b78..ae3a97e3867 100644 --- a/internal/database/schema.codeintel.json +++ b/internal/database/schema.codeintel.json @@ -139,6 +139,19 @@ "IsGenerated": "NEVER", "GenerationExpression": "", "Comment": "" + }, + { + "Name": "tenant_id", + "Index": 3, + "TypeName": "integer", + "IsNullable": true, + "Default": "", + "CharacterMaximumLength": 0, + "IsIdentity": false, + "IdentityGeneration": "", + "IsGenerated": "NEVER", + "GenerationExpression": "", + "Comment": "" } ], "Indexes": [ @@ -163,7 +176,15 @@ "ConstraintDefinition": "" } ], - "Constraints": null, + "Constraints": [ + { + "Name": "codeintel_last_reconcile_tenant_id_fkey", + "ConstraintType": "f", + "RefTableName": "tenants", + "IsDeferrable": false, + "ConstraintDefinition": "FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE" + } + ], "Triggers": [] }, { @@ -209,6 +230,19 @@ "GenerationExpression": "", "Comment": "An auto-generated identifier. This column is used as a foreign key target to reduce occurrences of the full document path value." }, + { + "Name": "tenant_id", + "Index": 5, + "TypeName": "integer", + "IsNullable": true, + "Default": "", + "CharacterMaximumLength": 0, + "IsIdentity": false, + "IdentityGeneration": "", + "IsGenerated": "NEVER", + "GenerationExpression": "", + "Comment": "" + }, { "Name": "upload_id", "Index": 2, @@ -262,6 +296,13 @@ "RefTableName": "codeintel_scip_documents", "IsDeferrable": false, "ConstraintDefinition": "FOREIGN KEY (document_id) REFERENCES codeintel_scip_documents(id)" + }, + { + "Name": "codeintel_scip_document_lookup_tenant_id_fkey", + "ConstraintType": "f", + "RefTableName": "tenants", + "IsDeferrable": false, + "ConstraintDefinition": "FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE" } ], "Triggers": [ @@ -305,6 +346,19 @@ "GenerationExpression": "", "Comment": "A lower-bound on the `schema_version` values of the records in the table [`codeintel_scip_document_lookup`](#table-publiccodeintel_scip_document_lookup) where the `upload_id` column matches the associated SCIP index." }, + { + "Name": "tenant_id", + "Index": 4, + "TypeName": "integer", + "IsNullable": true, + "Default": "", + "CharacterMaximumLength": 0, + "IsIdentity": false, + "IdentityGeneration": "", + "IsGenerated": "NEVER", + "GenerationExpression": "", + "Comment": "" + }, { "Name": "upload_id", "Index": 1, @@ -331,7 +385,15 @@ "ConstraintDefinition": "PRIMARY KEY (upload_id)" } ], - "Constraints": null, + "Constraints": [ + { + "Name": "codeintel_scip_document_lookup_schema_versions_tenant_id_fkey", + "ConstraintType": "f", + "RefTableName": "tenants", + "IsDeferrable": false, + "ConstraintDefinition": "FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE" + } + ], "Triggers": [] }, { @@ -389,6 +451,19 @@ "IsGenerated": "NEVER", "GenerationExpression": "", "Comment": "The schema version of this row - used to determine presence and encoding of (future) denormalized data." + }, + { + "Name": "tenant_id", + "Index": 6, + "TypeName": "integer", + "IsNullable": true, + "Default": "", + "CharacterMaximumLength": 0, + "IsIdentity": false, + "IdentityGeneration": "", + "IsGenerated": "NEVER", + "GenerationExpression": "", + "Comment": "" } ], "Indexes": [ @@ -413,7 +488,15 @@ "ConstraintDefinition": "PRIMARY KEY (id)" } ], - "Constraints": null, + "Constraints": [ + { + "Name": "codeintel_scip_documents_tenant_id_fkey", + "ConstraintType": "f", + "RefTableName": "tenants", + "IsDeferrable": false, + "ConstraintDefinition": "FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE" + } + ], "Triggers": [] }, { @@ -458,6 +541,19 @@ "IsGenerated": "NEVER", "GenerationExpression": "", "Comment": "The time that the log entry was inserted." + }, + { + "Name": "tenant_id", + "Index": 4, + "TypeName": "integer", + "IsNullable": true, + "Default": "", + "CharacterMaximumLength": 0, + "IsIdentity": false, + "IdentityGeneration": "", + "IsGenerated": "NEVER", + "GenerationExpression": "", + "Comment": "" } ], "Indexes": [ @@ -482,7 +578,15 @@ "ConstraintDefinition": "" } ], - "Constraints": null, + "Constraints": [ + { + "Name": "codeintel_scip_documents_dereference_logs_tenant_id_fkey", + "ConstraintType": "f", + "RefTableName": "tenants", + "IsDeferrable": false, + "ConstraintDefinition": "FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE" + } + ], "Triggers": [] }, { @@ -515,6 +619,19 @@ "GenerationExpression": "", "Comment": "The version of the SCIP protocol used to encode this index." }, + { + "Name": "tenant_id", + "Index": 8, + "TypeName": "integer", + "IsNullable": true, + "Default": "", + "CharacterMaximumLength": 0, + "IsIdentity": false, + "IdentityGeneration": "", + "IsGenerated": "NEVER", + "GenerationExpression": "", + "Comment": "" + }, { "Name": "text_document_encoding", "Index": 6, @@ -603,7 +720,15 @@ "ConstraintDefinition": "" } ], - "Constraints": null, + "Constraints": [ + { + "Name": "codeintel_scip_metadata_tenant_id_fkey", + "ConstraintType": "f", + "RefTableName": "tenants", + "IsDeferrable": false, + "ConstraintDefinition": "FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE" + } + ], "Triggers": [] }, { @@ -649,6 +774,19 @@ "GenerationExpression": "", "Comment": "The identifier of the segment that forms the prefix of this symbol, if any." }, + { + "Name": "tenant_id", + "Index": 5, + "TypeName": "integer", + "IsNullable": true, + "Default": "", + "CharacterMaximumLength": 0, + "IsIdentity": false, + "IdentityGeneration": "", + "IsGenerated": "NEVER", + "GenerationExpression": "", + "Comment": "" + }, { "Name": "upload_id", "Index": 2, @@ -695,7 +833,15 @@ "ConstraintDefinition": "" } ], - "Constraints": null, + "Constraints": [ + { + "Name": "codeintel_scip_symbol_names_tenant_id_fkey", + "ConstraintType": "f", + "RefTableName": "tenants", + "IsDeferrable": false, + "ConstraintDefinition": "FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE" + } + ], "Triggers": [] }, { @@ -780,6 +926,19 @@ "GenerationExpression": "", "Comment": "The identifier of the segment that terminates the name of this symbol. See the table [`codeintel_scip_symbol_names`](#table-publiccodeintel_scip_symbol_names) on how to reconstruct the full symbol name." }, + { + "Name": "tenant_id", + "Index": 10, + "TypeName": "integer", + "IsNullable": true, + "Default": "", + "CharacterMaximumLength": 0, + "IsIdentity": false, + "IdentityGeneration": "", + "IsGenerated": "NEVER", + "GenerationExpression": "", + "Comment": "" + }, { "Name": "type_definition_ranges", "Index": 8, @@ -836,6 +995,13 @@ "RefTableName": "codeintel_scip_document_lookup", "IsDeferrable": false, "ConstraintDefinition": "FOREIGN KEY (document_lookup_id) REFERENCES codeintel_scip_document_lookup(id) ON DELETE CASCADE" + }, + { + "Name": "codeintel_scip_symbols_tenant_id_fkey", + "ConstraintType": "f", + "RefTableName": "tenants", + "IsDeferrable": false, + "ConstraintDefinition": "FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE" } ], "Triggers": [ @@ -875,6 +1041,19 @@ "GenerationExpression": "", "Comment": "A lower-bound on the `schema_version` values of the records in the table [`codeintel_scip_symbols`](#table-publiccodeintel_scip_symbols) where the `upload_id` column matches the associated SCIP index." }, + { + "Name": "tenant_id", + "Index": 4, + "TypeName": "integer", + "IsNullable": true, + "Default": "", + "CharacterMaximumLength": 0, + "IsIdentity": false, + "IdentityGeneration": "", + "IsGenerated": "NEVER", + "GenerationExpression": "", + "Comment": "" + }, { "Name": "upload_id", "Index": 1, @@ -901,7 +1080,15 @@ "ConstraintDefinition": "PRIMARY KEY (upload_id)" } ], - "Constraints": null, + "Constraints": [ + { + "Name": "codeintel_scip_symbols_schema_versions_tenant_id_fkey", + "ConstraintType": "f", + "RefTableName": "tenants", + "IsDeferrable": false, + "ConstraintDefinition": "FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE" + } + ], "Triggers": [] }, { @@ -1122,6 +1309,19 @@ "IsGenerated": "NEVER", "GenerationExpression": "", "Comment": "" + }, + { + "Name": "tenant_id", + "Index": 6, + "TypeName": "integer", + "IsNullable": true, + "Default": "", + "CharacterMaximumLength": 0, + "IsIdentity": false, + "IdentityGeneration": "", + "IsGenerated": "NEVER", + "GenerationExpression": "", + "Comment": "" } ], "Indexes": [ @@ -1156,7 +1356,15 @@ "ConstraintDefinition": "" } ], - "Constraints": null, + "Constraints": [ + { + "Name": "rockskip_ancestry_tenant_id_fkey", + "ConstraintType": "f", + "RefTableName": "tenants", + "IsDeferrable": false, + "ConstraintDefinition": "FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE" + } + ], "Triggers": [] }, { @@ -1201,6 +1409,19 @@ "IsGenerated": "NEVER", "GenerationExpression": "", "Comment": "" + }, + { + "Name": "tenant_id", + "Index": 4, + "TypeName": "integer", + "IsNullable": true, + "Default": "", + "CharacterMaximumLength": 0, + "IsIdentity": false, + "IdentityGeneration": "", + "IsGenerated": "NEVER", + "GenerationExpression": "", + "Comment": "" } ], "Indexes": [ @@ -1245,7 +1466,15 @@ "ConstraintDefinition": "" } ], - "Constraints": null, + "Constraints": [ + { + "Name": "rockskip_repos_tenant_id_fkey", + "ConstraintType": "f", + "RefTableName": "tenants", + "IsDeferrable": false, + "ConstraintDefinition": "FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE" + } + ], "Triggers": [] }, { @@ -1329,6 +1558,19 @@ "IsGenerated": "NEVER", "GenerationExpression": "", "Comment": "" + }, + { + "Name": "tenant_id", + "Index": 7, + "TypeName": "integer", + "IsNullable": true, + "Default": "", + "CharacterMaximumLength": 0, + "IsIdentity": false, + "IdentityGeneration": "", + "IsGenerated": "NEVER", + "GenerationExpression": "", + "Comment": "" } ], "Indexes": [ @@ -1363,7 +1605,15 @@ "ConstraintDefinition": "" } ], - "Constraints": null, + "Constraints": [ + { + "Name": "rockskip_symbols_tenant_id_fkey", + "ConstraintType": "f", + "RefTableName": "tenants", + "IsDeferrable": false, + "ConstraintDefinition": "FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE" + } + ], "Triggers": [] }, { diff --git a/internal/database/schema.codeintel.md b/internal/database/schema.codeintel.md index bbcfbdb3a63..09fef53ec0b 100644 --- a/internal/database/schema.codeintel.md +++ b/internal/database/schema.codeintel.md @@ -4,9 +4,12 @@ -------------------+--------------------------+-----------+----------+--------- dump_id | integer | | not null | last_reconcile_at | timestamp with time zone | | not null | + tenant_id | integer | | | Indexes: "codeintel_last_reconcile_dump_id_key" UNIQUE CONSTRAINT, btree (dump_id) "codeintel_last_reconcile_last_reconcile_at_dump_id" btree (last_reconcile_at, dump_id) +Foreign-key constraints: + "codeintel_last_reconcile_tenant_id_fkey" FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE ``` @@ -20,12 +23,14 @@ Stores the last time processed LSIF data was reconciled with the other database. upload_id | integer | | not null | document_path | text | | not null | document_id | bigint | | not null | + tenant_id | integer | | | Indexes: "codeintel_scip_document_lookup_pkey" PRIMARY KEY, btree (id) "codeintel_scip_document_lookup_upload_id_document_path_key" UNIQUE CONSTRAINT, btree (upload_id, document_path) "codeintel_scip_document_lookup_document_id" hash (document_id) Foreign-key constraints: "codeintel_scip_document_lookup_document_id_fk" FOREIGN KEY (document_id) REFERENCES codeintel_scip_documents(id) + "codeintel_scip_document_lookup_tenant_id_fkey" FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE Referenced by: TABLE "codeintel_scip_symbols" CONSTRAINT "codeintel_scip_symbols_document_lookup_id_fk" FOREIGN KEY (document_lookup_id) REFERENCES codeintel_scip_document_lookup(id) ON DELETE CASCADE Triggers: @@ -51,8 +56,11 @@ A mapping from file paths to document references within a particular SCIP index. upload_id | integer | | not null | min_schema_version | integer | | | max_schema_version | integer | | | + tenant_id | integer | | | Indexes: "codeintel_scip_document_lookup_schema_versions_pkey" PRIMARY KEY, btree (upload_id) +Foreign-key constraints: + "codeintel_scip_document_lookup_schema_versions_tenant_id_fkey" FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE ``` @@ -72,9 +80,12 @@ Tracks the range of `schema_versions` values associated with each SCIP index in payload_hash | bytea | | not null | schema_version | integer | | not null | raw_scip_payload | bytea | | not null | + tenant_id | integer | | | Indexes: "codeintel_scip_documents_pkey" PRIMARY KEY, btree (id) "codeintel_scip_documents_payload_hash_key" UNIQUE CONSTRAINT, btree (payload_hash) +Foreign-key constraints: + "codeintel_scip_documents_tenant_id_fkey" FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE Referenced by: TABLE "codeintel_scip_document_lookup" CONSTRAINT "codeintel_scip_document_lookup_document_id_fk" FOREIGN KEY (document_id) REFERENCES codeintel_scip_documents(id) @@ -97,9 +108,12 @@ A lookup of SCIP [Document](https://sourcegraph.com/search?q=context:%40sourcegr id | bigint | | not null | nextval('codeintel_scip_documents_dereference_logs_id_seq'::regclass) document_id | bigint | | not null | last_removal_time | timestamp with time zone | | not null | now() + tenant_id | integer | | | Indexes: "codeintel_scip_documents_dereference_logs_pkey" PRIMARY KEY, btree (id) "codeintel_scip_documents_dereference_logs_last_removal_time_des" btree (last_removal_time DESC, document_id) +Foreign-key constraints: + "codeintel_scip_documents_dereference_logs_tenant_id_fkey" FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE ``` @@ -120,9 +134,12 @@ A list of document rows that were recently dereferenced by the deletion of an in tool_arguments | text[] | | not null | text_document_encoding | text | | not null | protocol_version | integer | | not null | + tenant_id | integer | | | Indexes: "codeintel_scip_metadata_pkey" PRIMARY KEY, btree (id) "codeintel_scip_metadata_upload_id" btree (upload_id) +Foreign-key constraints: + "codeintel_scip_metadata_tenant_id_fkey" FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE ``` @@ -150,10 +167,13 @@ Global metadatadata about a single processed upload. upload_id | integer | | not null | name_segment | text | | not null | prefix_id | integer | | | + tenant_id | integer | | | Indexes: "codeintel_scip_symbol_names_pkey" PRIMARY KEY, btree (upload_id, id) "codeintel_scip_symbol_names_upload_id_roots" btree (upload_id) WHERE prefix_id IS NULL "codeisdntel_scip_symbol_names_upload_id_children" btree (upload_id, prefix_id) WHERE prefix_id IS NOT NULL +Foreign-key constraints: + "codeintel_scip_symbol_names_tenant_id_fkey" FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE ``` @@ -179,11 +199,13 @@ Stores a prefix tree of symbol names within a particular upload. implementation_ranges | bytea | | | type_definition_ranges | bytea | | | symbol_id | integer | | not null | + tenant_id | integer | | | Indexes: "codeintel_scip_symbols_pkey" PRIMARY KEY, btree (upload_id, symbol_id, document_lookup_id) "codeintel_scip_symbols_document_lookup_id" btree (document_lookup_id) Foreign-key constraints: "codeintel_scip_symbols_document_lookup_id_fk" FOREIGN KEY (document_lookup_id) REFERENCES codeintel_scip_document_lookup(id) ON DELETE CASCADE + "codeintel_scip_symbols_tenant_id_fkey" FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE Triggers: codeintel_scip_symbols_schema_versions_insert AFTER INSERT ON codeintel_scip_symbols REFERENCING NEW TABLE AS newtab FOR EACH STATEMENT EXECUTE FUNCTION update_codeintel_scip_symbols_schema_versions_insert() @@ -214,8 +236,11 @@ A mapping from SCIP [Symbol names](https://sourcegraph.com/search?q=context:%40s upload_id | integer | | not null | min_schema_version | integer | | | max_schema_version | integer | | | + tenant_id | integer | | | Indexes: "codeintel_scip_symbols_schema_versions_pkey" PRIMARY KEY, btree (upload_id) +Foreign-key constraints: + "codeintel_scip_symbols_schema_versions_tenant_id_fkey" FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE ``` @@ -255,10 +280,13 @@ Indexes: commit_id | character varying(40) | | not null | height | integer | | not null | ancestor | integer | | not null | + tenant_id | integer | | | Indexes: "rockskip_ancestry_pkey" PRIMARY KEY, btree (id) "rockskip_ancestry_repo_id_commit_id_key" UNIQUE CONSTRAINT, btree (repo_id, commit_id) "rockskip_ancestry_repo_commit_id" btree (repo_id, commit_id) +Foreign-key constraints: + "rockskip_ancestry_tenant_id_fkey" FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE ``` @@ -269,28 +297,34 @@ Indexes: id | integer | | not null | nextval('rockskip_repos_id_seq'::regclass) repo | text | | not null | last_accessed_at | timestamp with time zone | | not null | + tenant_id | integer | | | Indexes: "rockskip_repos_pkey" PRIMARY KEY, btree (id) "rockskip_repos_repo_key" UNIQUE CONSTRAINT, btree (repo) "rockskip_repos_last_accessed_at" btree (last_accessed_at) "rockskip_repos_repo" btree (repo) +Foreign-key constraints: + "rockskip_repos_tenant_id_fkey" FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE ``` # Table "public.rockskip_symbols" ``` - Column | Type | Collation | Nullable | Default ----------+-----------+-----------+----------+---------------------------------------------- - id | integer | | not null | nextval('rockskip_symbols_id_seq'::regclass) - added | integer[] | | not null | - deleted | integer[] | | not null | - repo_id | integer | | not null | - path | text | | not null | - name | text | | not null | + Column | Type | Collation | Nullable | Default +-----------+-----------+-----------+----------+---------------------------------------------- + id | integer | | not null | nextval('rockskip_symbols_id_seq'::regclass) + added | integer[] | | not null | + deleted | integer[] | | not null | + repo_id | integer | | not null | + path | text | | not null | + name | text | | not null | + tenant_id | integer | | | Indexes: "rockskip_symbols_pkey" PRIMARY KEY, btree (id) "rockskip_symbols_gin" gin (singleton_integer(repo_id) gin__int_ops, added gin__int_ops, deleted gin__int_ops, name gin_trgm_ops, singleton(name), singleton(lower(name)), path gin_trgm_ops, singleton(path), path_prefixes(path), singleton(lower(path)), path_prefixes(lower(path)), singleton(get_file_extension(path)), singleton(get_file_extension(lower(path)))) "rockskip_symbols_repo_id_path_name" btree (repo_id, path, name) +Foreign-key constraints: + "rockskip_symbols_tenant_id_fkey" FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE ``` @@ -308,6 +342,19 @@ Indexes: Check constraints: "tenant_name_length" CHECK (char_length(name) <= 32 AND char_length(name) >= 3) "tenant_name_valid_chars" CHECK (name ~ '^[a-z](?:[a-z0-9\_-])*[a-z0-9]$'::text) +Referenced by: + TABLE "codeintel_last_reconcile" CONSTRAINT "codeintel_last_reconcile_tenant_id_fkey" FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE + TABLE "codeintel_scip_document_lookup_schema_versions" CONSTRAINT "codeintel_scip_document_lookup_schema_versions_tenant_id_fkey" FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE + TABLE "codeintel_scip_document_lookup" CONSTRAINT "codeintel_scip_document_lookup_tenant_id_fkey" FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE + TABLE "codeintel_scip_documents_dereference_logs" CONSTRAINT "codeintel_scip_documents_dereference_logs_tenant_id_fkey" FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE + TABLE "codeintel_scip_documents" CONSTRAINT "codeintel_scip_documents_tenant_id_fkey" FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE + TABLE "codeintel_scip_metadata" CONSTRAINT "codeintel_scip_metadata_tenant_id_fkey" FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE + TABLE "codeintel_scip_symbol_names" CONSTRAINT "codeintel_scip_symbol_names_tenant_id_fkey" FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE + TABLE "codeintel_scip_symbols_schema_versions" CONSTRAINT "codeintel_scip_symbols_schema_versions_tenant_id_fkey" FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE + TABLE "codeintel_scip_symbols" CONSTRAINT "codeintel_scip_symbols_tenant_id_fkey" FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE + TABLE "rockskip_ancestry" CONSTRAINT "rockskip_ancestry_tenant_id_fkey" FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE + TABLE "rockskip_repos" CONSTRAINT "rockskip_repos_tenant_id_fkey" FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE + TABLE "rockskip_symbols" CONSTRAINT "rockskip_symbols_tenant_id_fkey" FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE ``` diff --git a/internal/database/schema.json b/internal/database/schema.json index 851a1aefdff..b647045662c 100644 --- a/internal/database/schema.json +++ b/internal/database/schema.json @@ -1490,6 +1490,19 @@ "GenerationExpression": "", "Comment": "" }, + { + "Name": "tenant_id", + "Index": 9, + "TypeName": "integer", + "IsNullable": true, + "Default": "", + "CharacterMaximumLength": 0, + "IsIdentity": false, + "IdentityGeneration": "", + "IsGenerated": "NEVER", + "GenerationExpression": "", + "Comment": "" + }, { "Name": "updated_at", "Index": 3, @@ -1553,6 +1566,13 @@ "RefTableName": "users", "IsDeferrable": false, "ConstraintDefinition": "FOREIGN KEY (decision_by_user_id) REFERENCES users(id) ON DELETE SET NULL" + }, + { + "Name": "access_requests_tenant_id_fkey", + "ConstraintType": "f", + "RefTableName": "tenants", + "IsDeferrable": false, + "ConstraintDefinition": "FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE" } ], "Triggers": [] @@ -1691,6 +1711,19 @@ "GenerationExpression": "", "Comment": "" }, + { + "Name": "tenant_id", + "Index": 12, + "TypeName": "integer", + "IsNullable": true, + "Default": "", + "CharacterMaximumLength": 0, + "IsIdentity": false, + "IdentityGeneration": "", + "IsGenerated": "NEVER", + "GenerationExpression": "", + "Comment": "" + }, { "Name": "value_sha256", "Index": 3, @@ -1761,6 +1794,13 @@ "RefTableName": "users", "IsDeferrable": false, "ConstraintDefinition": "FOREIGN KEY (subject_user_id) REFERENCES users(id)" + }, + { + "Name": "access_tokens_tenant_id_fkey", + "ConstraintType": "f", + "RefTableName": "tenants", + "IsDeferrable": false, + "ConstraintDefinition": "FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE" } ], "Triggers": [] @@ -1782,6 +1822,19 @@ "GenerationExpression": "", "Comment": "" }, + { + "Name": "tenant_id", + "Index": 6, + "TypeName": "integer", + "IsNullable": true, + "Default": "", + "CharacterMaximumLength": 0, + "IsIdentity": false, + "IdentityGeneration": "", + "IsGenerated": "NEVER", + "GenerationExpression": "", + "Comment": "" + }, { "Name": "updated_at", "Index": 3, @@ -1848,6 +1901,13 @@ } ], "Constraints": [ + { + "Name": "aggregated_user_statistics_tenant_id_fkey", + "ConstraintType": "f", + "RefTableName": "tenants", + "IsDeferrable": false, + "ConstraintDefinition": "FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE" + }, { "Name": "aggregated_user_statistics_user_id_fkey", "ConstraintType": "f", @@ -1914,6 +1974,19 @@ "GenerationExpression": "", "Comment": "" }, + { + "Name": "tenant_id", + "Index": 6, + "TypeName": "integer", + "IsNullable": true, + "Default": "", + "CharacterMaximumLength": 0, + "IsIdentity": false, + "IdentityGeneration": "", + "IsGenerated": "NEVER", + "GenerationExpression": "", + "Comment": "" + }, { "Name": "who_assigned_user_id", "Index": 4, @@ -1965,6 +2038,13 @@ "IsDeferrable": true, "ConstraintDefinition": "FOREIGN KEY (owner_user_id) REFERENCES users(id) ON DELETE CASCADE DEFERRABLE" }, + { + "Name": "assigned_owners_tenant_id_fkey", + "ConstraintType": "f", + "RefTableName": "tenants", + "IsDeferrable": false, + "ConstraintDefinition": "FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE" + }, { "Name": "assigned_owners_who_assigned_user_id_fkey", "ConstraintType": "f", @@ -2031,6 +2111,19 @@ "GenerationExpression": "", "Comment": "" }, + { + "Name": "tenant_id", + "Index": 6, + "TypeName": "integer", + "IsNullable": true, + "Default": "", + "CharacterMaximumLength": 0, + "IsIdentity": false, + "IdentityGeneration": "", + "IsGenerated": "NEVER", + "GenerationExpression": "", + "Comment": "" + }, { "Name": "who_assigned_team_id", "Index": 4, @@ -2082,6 +2175,13 @@ "IsDeferrable": true, "ConstraintDefinition": "FOREIGN KEY (owner_team_id) REFERENCES teams(id) ON DELETE CASCADE DEFERRABLE" }, + { + "Name": "assigned_teams_tenant_id_fkey", + "ConstraintType": "f", + "RefTableName": "tenants", + "IsDeferrable": false, + "ConstraintDefinition": "FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE" + }, { "Name": "assigned_teams_who_assigned_team_id_fkey", "ConstraintType": "f", @@ -2239,6 +2339,19 @@ "GenerationExpression": "", "Comment": "" }, + { + "Name": "tenant_id", + "Index": 13, + "TypeName": "integer", + "IsNullable": true, + "Default": "", + "CharacterMaximumLength": 0, + "IsIdentity": false, + "IdentityGeneration": "", + "IsGenerated": "NEVER", + "GenerationExpression": "", + "Comment": "" + }, { "Name": "updated_at", "Index": 8, @@ -2361,6 +2474,13 @@ "RefTableName": "users", "IsDeferrable": true, "ConstraintDefinition": "FOREIGN KEY (namespace_user_id) REFERENCES users(id) ON DELETE CASCADE DEFERRABLE" + }, + { + "Name": "batch_changes_tenant_id_fkey", + "ConstraintType": "f", + "RefTableName": "tenants", + "IsDeferrable": false, + "ConstraintDefinition": "FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE" } ], "Triggers": [ @@ -2465,6 +2585,19 @@ "GenerationExpression": "", "Comment": "" }, + { + "Name": "tenant_id", + "Index": 9, + "TypeName": "integer", + "IsNullable": true, + "Default": "", + "CharacterMaximumLength": 0, + "IsIdentity": false, + "IdentityGeneration": "", + "IsGenerated": "NEVER", + "GenerationExpression": "", + "Comment": "" + }, { "Name": "updated_at", "Index": 5, @@ -2519,6 +2652,13 @@ "IsDeferrable": false, "ConstraintDefinition": "FOREIGN KEY (github_app_id) REFERENCES github_apps(id) ON DELETE CASCADE" }, + { + "Name": "batch_changes_site_credentials_tenant_id_fkey", + "ConstraintType": "f", + "RefTableName": "tenants", + "IsDeferrable": false, + "ConstraintDefinition": "FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE" + }, { "Name": "check_github_app_id_and_external_service_type_site_credentials", "ConstraintType": "c", @@ -2585,6 +2725,19 @@ "GenerationExpression": "", "Comment": "" }, + { + "Name": "tenant_id", + "Index": 8, + "TypeName": "integer", + "IsNullable": true, + "Default": "", + "CharacterMaximumLength": 0, + "IsIdentity": false, + "IdentityGeneration": "", + "IsGenerated": "NEVER", + "GenerationExpression": "", + "Comment": "" + }, { "Name": "user_id", "Index": 7, @@ -2648,6 +2801,13 @@ } ], "Constraints": [ + { + "Name": "batch_spec_execution_cache_entries_tenant_id_fkey", + "ConstraintType": "f", + "RefTableName": "tenants", + "IsDeferrable": false, + "ConstraintDefinition": "FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE" + }, { "Name": "batch_spec_execution_cache_entries_user_id_fkey", "ConstraintType": "f", @@ -2857,6 +3017,19 @@ "GenerationExpression": "", "Comment": "" }, + { + "Name": "tenant_id", + "Index": 18, + "TypeName": "integer", + "IsNullable": true, + "Default": "", + "CharacterMaximumLength": 0, + "IsIdentity": false, + "IdentityGeneration": "", + "IsGenerated": "NEVER", + "GenerationExpression": "", + "Comment": "" + }, { "Name": "updated_at", "Index": 14, @@ -2930,6 +3103,13 @@ "RefTableName": "users", "IsDeferrable": true, "ConstraintDefinition": "FOREIGN KEY (initiator_id) REFERENCES users(id) ON UPDATE CASCADE ON DELETE CASCADE DEFERRABLE" + }, + { + "Name": "batch_spec_resolution_jobs_tenant_id_fkey", + "ConstraintType": "f", + "RefTableName": "tenants", + "IsDeferrable": false, + "ConstraintDefinition": "FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE" } ], "Triggers": [] @@ -3120,6 +3300,19 @@ "GenerationExpression": "", "Comment": "" }, + { + "Name": "tenant_id", + "Index": 20, + "TypeName": "integer", + "IsNullable": true, + "Default": "", + "CharacterMaximumLength": 0, + "IsIdentity": false, + "IdentityGeneration": "", + "IsGenerated": "NEVER", + "GenerationExpression": "", + "Comment": "" + }, { "Name": "updated_at", "Index": 14, @@ -3232,6 +3425,13 @@ "RefTableName": "batch_spec_workspaces", "IsDeferrable": true, "ConstraintDefinition": "FOREIGN KEY (batch_spec_workspace_id) REFERENCES batch_spec_workspaces(id) ON DELETE CASCADE DEFERRABLE" + }, + { + "Name": "batch_spec_workspace_execution_jobs_tenant_id_fkey", + "ConstraintType": "f", + "RefTableName": "tenants", + "IsDeferrable": false, + "ConstraintDefinition": "FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE" } ], "Triggers": [ @@ -3262,6 +3462,19 @@ "GenerationExpression": "", "Comment": "" }, + { + "Name": "tenant_id", + "Index": 3, + "TypeName": "integer", + "IsNullable": true, + "Default": "", + "CharacterMaximumLength": 0, + "IsIdentity": false, + "IdentityGeneration": "", + "IsGenerated": "NEVER", + "GenerationExpression": "", + "Comment": "" + }, { "Name": "user_id", "Index": 1, @@ -3289,6 +3502,13 @@ } ], "Constraints": [ + { + "Name": "batch_spec_workspace_execution_last_dequeues_tenant_id_fkey", + "ConstraintType": "f", + "RefTableName": "tenants", + "IsDeferrable": false, + "ConstraintDefinition": "FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE" + }, { "Name": "batch_spec_workspace_execution_last_dequeues_user_id_fkey", "ConstraintType": "f", @@ -3420,6 +3640,19 @@ "GenerationExpression": "", "Comment": "" }, + { + "Name": "tenant_id", + "Index": 11, + "TypeName": "integer", + "IsNullable": true, + "Default": "", + "CharacterMaximumLength": 0, + "IsIdentity": false, + "IdentityGeneration": "", + "IsGenerated": "NEVER", + "GenerationExpression": "", + "Comment": "" + }, { "Name": "updated_at", "Index": 10, @@ -3473,6 +3706,13 @@ "RefTableName": "batch_specs", "IsDeferrable": false, "ConstraintDefinition": "FOREIGN KEY (batch_spec_id) REFERENCES batch_specs(id) ON DELETE CASCADE" + }, + { + "Name": "batch_spec_workspace_files_tenant_id_fkey", + "ConstraintType": "f", + "RefTableName": "tenants", + "IsDeferrable": false, + "ConstraintDefinition": "FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE" } ], "Triggers": [] @@ -3663,6 +3903,19 @@ "GenerationExpression": "", "Comment": "" }, + { + "Name": "tenant_id", + "Index": 17, + "TypeName": "integer", + "IsNullable": true, + "Default": "", + "CharacterMaximumLength": 0, + "IsIdentity": false, + "IdentityGeneration": "", + "IsGenerated": "NEVER", + "GenerationExpression": "", + "Comment": "" + }, { "Name": "unsupported", "Index": 13, @@ -3736,6 +3989,13 @@ "RefTableName": "repo", "IsDeferrable": true, "ConstraintDefinition": "FOREIGN KEY (repo_id) REFERENCES repo(id) DEFERRABLE" + }, + { + "Name": "batch_spec_workspaces_tenant_id_fkey", + "ConstraintType": "f", + "RefTableName": "tenants", + "IsDeferrable": false, + "ConstraintDefinition": "FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE" } ], "Triggers": [] @@ -3900,6 +4160,19 @@ "GenerationExpression": "", "Comment": "" }, + { + "Name": "tenant_id", + "Index": 15, + "TypeName": "integer", + "IsNullable": true, + "Default": "", + "CharacterMaximumLength": 0, + "IsIdentity": false, + "IdentityGeneration": "", + "IsGenerated": "NEVER", + "GenerationExpression": "", + "Comment": "" + }, { "Name": "updated_at", "Index": 9, @@ -3964,6 +4237,13 @@ "IsDeferrable": false, "ConstraintDefinition": "CHECK ((namespace_user_id IS NULL) \u003c\u003e (namespace_org_id IS NULL))" }, + { + "Name": "batch_specs_tenant_id_fkey", + "ConstraintType": "f", + "RefTableName": "tenants", + "IsDeferrable": false, + "ConstraintDefinition": "FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE" + }, { "Name": "batch_specs_user_id_fkey", "ConstraintType": "f", @@ -4029,6 +4309,19 @@ "IsGenerated": "NEVER", "GenerationExpression": "", "Comment": "" + }, + { + "Name": "tenant_id", + "Index": 5, + "TypeName": "integer", + "IsNullable": true, + "Default": "", + "CharacterMaximumLength": 0, + "IsIdentity": false, + "IdentityGeneration": "", + "IsGenerated": "NEVER", + "GenerationExpression": "", + "Comment": "" } ], "Indexes": [ @@ -4063,7 +4356,15 @@ "ConstraintDefinition": "" } ], - "Constraints": null, + "Constraints": [ + { + "Name": "cached_available_indexers_tenant_id_fkey", + "ConstraintType": "f", + "RefTableName": "tenants", + "IsDeferrable": false, + "ConstraintDefinition": "FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE" + } + ], "Triggers": [] }, { @@ -4148,6 +4449,19 @@ "GenerationExpression": "", "Comment": "" }, + { + "Name": "tenant_id", + "Index": 8, + "TypeName": "integer", + "IsNullable": true, + "Default": "", + "CharacterMaximumLength": 0, + "IsIdentity": false, + "IdentityGeneration": "", + "IsGenerated": "NEVER", + "GenerationExpression": "", + "Comment": "" + }, { "Name": "updated_at", "Index": 7, @@ -4212,6 +4526,13 @@ "RefTableName": "", "IsDeferrable": false, "ConstraintDefinition": "CHECK (jsonb_typeof(metadata) = 'object'::text)" + }, + { + "Name": "changeset_events_tenant_id_fkey", + "ConstraintType": "f", + "RefTableName": "tenants", + "IsDeferrable": false, + "ConstraintDefinition": "FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE" } ], "Triggers": [] @@ -4454,6 +4775,19 @@ "GenerationExpression": "", "Comment": "" }, + { + "Name": "tenant_id", + "Index": 22, + "TypeName": "integer", + "IsNullable": true, + "Default": "", + "CharacterMaximumLength": 0, + "IsIdentity": false, + "IdentityGeneration": "", + "IsGenerated": "NEVER", + "GenerationExpression": "", + "Comment": "" + }, { "Name": "updated_at", "Index": 17, @@ -4548,6 +4882,13 @@ "IsDeferrable": false, "ConstraintDefinition": "CHECK (jsonb_typeof(payload) = 'object'::text)" }, + { + "Name": "changeset_jobs_tenant_id_fkey", + "ConstraintType": "f", + "RefTableName": "tenants", + "IsDeferrable": false, + "ConstraintDefinition": "FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE" + }, { "Name": "changeset_jobs_user_id_fkey", "ConstraintType": "f", @@ -4809,6 +5150,19 @@ "GenerationExpression": "", "Comment": "" }, + { + "Name": "tenant_id", + "Index": 25, + "TypeName": "integer", + "IsNullable": true, + "Default": "", + "CharacterMaximumLength": 0, + "IsIdentity": false, + "IdentityGeneration": "", + "IsGenerated": "NEVER", + "GenerationExpression": "", + "Comment": "" + }, { "Name": "title", "Index": 13, @@ -4956,6 +5310,13 @@ "IsDeferrable": true, "ConstraintDefinition": "FOREIGN KEY (repo_id) REFERENCES repo(id) DEFERRABLE" }, + { + "Name": "changeset_specs_tenant_id_fkey", + "ConstraintType": "f", + "RefTableName": "tenants", + "IsDeferrable": false, + "ConstraintDefinition": "FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE" + }, { "Name": "changeset_specs_user_id_fkey", "ConstraintType": "f", @@ -5503,6 +5864,19 @@ "GenerationExpression": "", "Comment": "" }, + { + "Name": "tenant_id", + "Index": 46, + "TypeName": "integer", + "IsNullable": true, + "Default": "", + "CharacterMaximumLength": 0, + "IsIdentity": false, + "IdentityGeneration": "", + "IsGenerated": "NEVER", + "GenerationExpression": "", + "Comment": "" + }, { "Name": "ui_publication_state", "Index": 36, @@ -5712,6 +6086,13 @@ "IsDeferrable": true, "ConstraintDefinition": "FOREIGN KEY (repo_id) REFERENCES repo(id) ON DELETE CASCADE DEFERRABLE" }, + { + "Name": "changesets_tenant_id_fkey", + "ConstraintType": "f", + "RefTableName": "tenants", + "IsDeferrable": false, + "ConstraintDefinition": "FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE" + }, { "Name": "external_branch_ref_prefix", "ConstraintType": "c", @@ -5926,6 +6307,19 @@ "GenerationExpression": "", "Comment": "" }, + { + "Name": "tenant_id", + "Index": 19, + "TypeName": "integer", + "IsNullable": true, + "Default": "", + "CharacterMaximumLength": 0, + "IsIdentity": false, + "IdentityGeneration": "", + "IsGenerated": "NEVER", + "GenerationExpression": "", + "Comment": "" + }, { "Name": "trigger_event", "Index": 11, @@ -6020,6 +6414,13 @@ "IsDeferrable": false, "ConstraintDefinition": "FOREIGN KEY (slack_webhook) REFERENCES cm_slack_webhooks(id) ON DELETE CASCADE" }, + { + "Name": "cm_action_jobs_tenant_id_fkey", + "ConstraintType": "f", + "RefTableName": "tenants", + "IsDeferrable": false, + "ConstraintDefinition": "FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE" + }, { "Name": "cm_action_jobs_trigger_event_fk", "ConstraintType": "f", @@ -6170,6 +6571,19 @@ "IsGenerated": "NEVER", "GenerationExpression": "", "Comment": "" + }, + { + "Name": "tenant_id", + "Index": 11, + "TypeName": "integer", + "IsNullable": true, + "Default": "", + "CharacterMaximumLength": 0, + "IsIdentity": false, + "IdentityGeneration": "", + "IsGenerated": "NEVER", + "GenerationExpression": "", + "Comment": "" } ], "Indexes": [ @@ -6205,6 +6619,13 @@ "RefTableName": "cm_monitors", "IsDeferrable": false, "ConstraintDefinition": "FOREIGN KEY (monitor) REFERENCES cm_monitors(id) ON DELETE CASCADE" + }, + { + "Name": "cm_emails_tenant_id_fkey", + "ConstraintType": "f", + "RefTableName": "tenants", + "IsDeferrable": false, + "ConstraintDefinition": "FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE" } ], "Triggers": [] @@ -6251,6 +6672,19 @@ "IsGenerated": "NEVER", "GenerationExpression": "", "Comment": "" + }, + { + "Name": "tenant_id", + "Index": 5, + "TypeName": "integer", + "IsNullable": true, + "Default": "", + "CharacterMaximumLength": 0, + "IsIdentity": false, + "IdentityGeneration": "", + "IsGenerated": "NEVER", + "GenerationExpression": "", + "Comment": "" } ], "Indexes": [ @@ -6279,6 +6713,13 @@ "RefTableName": "repo", "IsDeferrable": false, "ConstraintDefinition": "FOREIGN KEY (repo_id) REFERENCES repo(id) ON DELETE CASCADE" + }, + { + "Name": "cm_last_searched_tenant_id_fkey", + "ConstraintType": "f", + "RefTableName": "tenants", + "IsDeferrable": false, + "ConstraintDefinition": "FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE" } ], "Triggers": [] @@ -6403,6 +6844,19 @@ "IsGenerated": "NEVER", "GenerationExpression": "", "Comment": "" + }, + { + "Name": "tenant_id", + "Index": 10, + "TypeName": "integer", + "IsNullable": true, + "Default": "", + "CharacterMaximumLength": 0, + "IsIdentity": false, + "IdentityGeneration": "", + "IsGenerated": "NEVER", + "GenerationExpression": "", + "Comment": "" } ], "Indexes": [ @@ -6439,6 +6893,13 @@ "IsDeferrable": false, "ConstraintDefinition": "FOREIGN KEY (namespace_org_id) REFERENCES orgs(id) ON DELETE CASCADE" }, + { + "Name": "cm_monitors_tenant_id_fkey", + "ConstraintType": "f", + "RefTableName": "tenants", + "IsDeferrable": false, + "ConstraintDefinition": "FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE" + }, { "Name": "cm_monitors_user_id_fk", "ConstraintType": "f", @@ -6569,6 +7030,19 @@ "IsGenerated": "NEVER", "GenerationExpression": "", "Comment": "" + }, + { + "Name": "tenant_id", + "Index": 10, + "TypeName": "integer", + "IsNullable": true, + "Default": "", + "CharacterMaximumLength": 0, + "IsIdentity": false, + "IdentityGeneration": "", + "IsGenerated": "NEVER", + "GenerationExpression": "", + "Comment": "" } ], "Indexes": [ @@ -6584,6 +7058,13 @@ } ], "Constraints": [ + { + "Name": "cm_queries_tenant_id_fkey", + "ConstraintType": "f", + "RefTableName": "tenants", + "IsDeferrable": false, + "ConstraintDefinition": "FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE" + }, { "Name": "cm_triggers_changed_by_fk", "ConstraintType": "f", @@ -6663,6 +7144,19 @@ "IsGenerated": "NEVER", "GenerationExpression": "", "Comment": "" + }, + { + "Name": "tenant_id", + "Index": 5, + "TypeName": "integer", + "IsNullable": true, + "Default": "", + "CharacterMaximumLength": 0, + "IsIdentity": false, + "IdentityGeneration": "", + "IsGenerated": "NEVER", + "GenerationExpression": "", + "Comment": "" } ], "Indexes": [ @@ -6692,6 +7186,13 @@ "IsDeferrable": false, "ConstraintDefinition": "FOREIGN KEY (namespace_org_id) REFERENCES orgs(id) ON DELETE CASCADE" }, + { + "Name": "cm_recipients_tenant_id_fkey", + "ConstraintType": "f", + "RefTableName": "tenants", + "IsDeferrable": false, + "ConstraintDefinition": "FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE" + }, { "Name": "cm_recipients_user_id_fk", "ConstraintType": "f", @@ -6810,6 +7311,19 @@ "GenerationExpression": "", "Comment": "The code monitor that the action is defined on" }, + { + "Name": "tenant_id", + "Index": 10, + "TypeName": "integer", + "IsNullable": true, + "Default": "", + "CharacterMaximumLength": 0, + "IsIdentity": false, + "IdentityGeneration": "", + "IsGenerated": "NEVER", + "GenerationExpression": "", + "Comment": "" + }, { "Name": "url", "Index": 3, @@ -6867,6 +7381,13 @@ "RefTableName": "cm_monitors", "IsDeferrable": false, "ConstraintDefinition": "FOREIGN KEY (monitor) REFERENCES cm_monitors(id) ON DELETE CASCADE" + }, + { + "Name": "cm_slack_webhooks_tenant_id_fkey", + "ConstraintType": "f", + "RefTableName": "tenants", + "IsDeferrable": false, + "ConstraintDefinition": "FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE" } ], "Triggers": [] @@ -7096,6 +7617,19 @@ "GenerationExpression": "", "Comment": "" }, + { + "Name": "tenant_id", + "Index": 21, + "TypeName": "integer", + "IsNullable": true, + "Default": "", + "CharacterMaximumLength": 0, + "IsIdentity": false, + "IdentityGeneration": "", + "IsGenerated": "NEVER", + "GenerationExpression": "", + "Comment": "" + }, { "Name": "worker_hostname", "Index": 14, @@ -7150,6 +7684,13 @@ "IsDeferrable": false, "ConstraintDefinition": "FOREIGN KEY (query) REFERENCES cm_queries(id) ON DELETE CASCADE" }, + { + "Name": "cm_trigger_jobs_tenant_id_fkey", + "ConstraintType": "f", + "RefTableName": "tenants", + "IsDeferrable": false, + "ConstraintDefinition": "FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE" + }, { "Name": "search_results_is_array", "ConstraintType": "c", @@ -7268,6 +7809,19 @@ "GenerationExpression": "", "Comment": "The code monitor that the action is defined on" }, + { + "Name": "tenant_id", + "Index": 10, + "TypeName": "integer", + "IsNullable": true, + "Default": "", + "CharacterMaximumLength": 0, + "IsIdentity": false, + "IdentityGeneration": "", + "IsGenerated": "NEVER", + "GenerationExpression": "", + "Comment": "" + }, { "Name": "url", "Index": 3, @@ -7325,6 +7879,13 @@ "RefTableName": "cm_monitors", "IsDeferrable": false, "ConstraintDefinition": "FOREIGN KEY (monitor) REFERENCES cm_monitors(id) ON DELETE CASCADE" + }, + { + "Name": "cm_webhooks_tenant_id_fkey", + "ConstraintType": "f", + "RefTableName": "tenants", + "IsDeferrable": false, + "ConstraintDefinition": "FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE" } ], "Triggers": [] @@ -7424,6 +7985,19 @@ "GenerationExpression": "", "Comment": "" }, + { + "Name": "tenant_id", + "Index": 10, + "TypeName": "integer", + "IsNullable": true, + "Default": "", + "CharacterMaximumLength": 0, + "IsIdentity": false, + "IdentityGeneration": "", + "IsGenerated": "NEVER", + "GenerationExpression": "", + "Comment": "" + }, { "Name": "updated_at", "Index": 9, @@ -7473,7 +8047,15 @@ "ConstraintDefinition": "UNIQUE (url)" } ], - "Constraints": null, + "Constraints": [ + { + "Name": "code_hosts_tenant_id_fkey", + "ConstraintType": "f", + "RefTableName": "tenants", + "IsDeferrable": false, + "ConstraintDefinition": "FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE" + } + ], "Triggers": [] }, { @@ -7544,6 +8126,19 @@ "IsGenerated": "NEVER", "GenerationExpression": "", "Comment": "" + }, + { + "Name": "tenant_id", + "Index": 6, + "TypeName": "integer", + "IsNullable": true, + "Default": "", + "CharacterMaximumLength": 0, + "IsIdentity": false, + "IdentityGeneration": "", + "IsGenerated": "NEVER", + "GenerationExpression": "", + "Comment": "" } ], "Indexes": [ @@ -7568,7 +8163,15 @@ "ConstraintDefinition": "" } ], - "Constraints": null, + "Constraints": [ + { + "Name": "codeintel_autoindex_queue_tenant_id_fkey", + "ConstraintType": "f", + "RefTableName": "tenants", + "IsDeferrable": false, + "ConstraintDefinition": "FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE" + } + ], "Triggers": [] }, { @@ -7626,6 +8229,19 @@ "IsGenerated": "NEVER", "GenerationExpression": "", "Comment": "" + }, + { + "Name": "tenant_id", + "Index": 5, + "TypeName": "integer", + "IsNullable": true, + "Default": "", + "CharacterMaximumLength": 0, + "IsIdentity": false, + "IdentityGeneration": "", + "IsGenerated": "NEVER", + "GenerationExpression": "", + "Comment": "" } ], "Indexes": [ @@ -7657,6 +8273,13 @@ "RefTableName": "repo", "IsDeferrable": false, "ConstraintDefinition": "FOREIGN KEY (repository_id) REFERENCES repo(id) ON DELETE CASCADE" + }, + { + "Name": "codeintel_autoindexing_exceptions_tenant_id_fkey", + "ConstraintType": "f", + "RefTableName": "tenants", + "IsDeferrable": false, + "ConstraintDefinition": "FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE" } ], "Triggers": [] @@ -7703,6 +8326,19 @@ "IsGenerated": "NEVER", "GenerationExpression": "", "Comment": "Identifies a row in the `repo` table." + }, + { + "Name": "tenant_id", + "Index": 4, + "TypeName": "integer", + "IsNullable": true, + "Default": "", + "CharacterMaximumLength": 0, + "IsIdentity": false, + "IdentityGeneration": "", + "IsGenerated": "NEVER", + "GenerationExpression": "", + "Comment": "" } ], "Indexes": [ @@ -7717,7 +8353,15 @@ "ConstraintDefinition": "PRIMARY KEY (repository_id, commit_bytea)" } ], - "Constraints": null, + "Constraints": [ + { + "Name": "codeintel_commit_dates_tenant_id_fkey", + "ConstraintType": "f", + "RefTableName": "tenants", + "IsDeferrable": false, + "ConstraintDefinition": "FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE" + } + ], "Triggers": [] }, { @@ -7749,10 +8393,31 @@ "IsGenerated": "NEVER", "GenerationExpression": "", "Comment": "" + }, + { + "Name": "tenant_id", + "Index": 3, + "TypeName": "integer", + "IsNullable": true, + "Default": "", + "CharacterMaximumLength": 0, + "IsIdentity": false, + "IdentityGeneration": "", + "IsGenerated": "NEVER", + "GenerationExpression": "", + "Comment": "" } ], "Indexes": [], - "Constraints": null, + "Constraints": [ + { + "Name": "codeintel_inference_scripts_tenant_id_fkey", + "ConstraintType": "f", + "RefTableName": "tenants", + "IsDeferrable": false, + "ConstraintDefinition": "FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE" + } + ], "Triggers": [] }, { @@ -7823,6 +8488,19 @@ "IsGenerated": "NEVER", "GenerationExpression": "", "Comment": "" + }, + { + "Name": "tenant_id", + "Index": 9, + "TypeName": "integer", + "IsNullable": true, + "Default": "", + "CharacterMaximumLength": 0, + "IsIdentity": false, + "IdentityGeneration": "", + "IsGenerated": "NEVER", + "GenerationExpression": "", + "Comment": "" } ], "Indexes": [ @@ -7864,6 +8542,13 @@ "RefTableName": "codeintel_ranking_exports", "IsDeferrable": false, "ConstraintDefinition": "FOREIGN KEY (exported_upload_id) REFERENCES codeintel_ranking_exports(id) ON DELETE CASCADE" + }, + { + "Name": "codeintel_initial_path_ranks_tenant_id_fkey", + "ConstraintType": "f", + "RefTableName": "tenants", + "IsDeferrable": false, + "ConstraintDefinition": "FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE" } ], "Triggers": [] @@ -7910,6 +8595,19 @@ "IsGenerated": "NEVER", "GenerationExpression": "", "Comment": "" + }, + { + "Name": "tenant_id", + "Index": 4, + "TypeName": "integer", + "IsNullable": true, + "Default": "", + "CharacterMaximumLength": 0, + "IsIdentity": false, + "IdentityGeneration": "", + "IsGenerated": "NEVER", + "GenerationExpression": "", + "Comment": "" } ], "Indexes": [ @@ -7945,6 +8643,13 @@ } ], "Constraints": [ + { + "Name": "codeintel_initial_path_ranks_processed_tenant_id_fkey", + "ConstraintType": "f", + "RefTableName": "tenants", + "IsDeferrable": false, + "ConstraintDefinition": "FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE" + }, { "Name": "fk_codeintel_initial_path_ranks", "ConstraintType": "f", @@ -7985,6 +8690,19 @@ "GenerationExpression": "", "Comment": "" }, + { + "Name": "tenant_id", + "Index": 4, + "TypeName": "integer", + "IsNullable": true, + "Default": "", + "CharacterMaximumLength": 0, + "IsIdentity": false, + "IdentityGeneration": "", + "IsGenerated": "NEVER", + "GenerationExpression": "", + "Comment": "" + }, { "Name": "user_id", "Index": 2, @@ -8011,7 +8729,15 @@ "ConstraintDefinition": "" } ], - "Constraints": null, + "Constraints": [ + { + "Name": "codeintel_langugage_support_requests_tenant_id_fkey", + "ConstraintType": "f", + "RefTableName": "tenants", + "IsDeferrable": false, + "ConstraintDefinition": "FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE" + } + ], "Triggers": [] }, { @@ -8096,6 +8822,19 @@ "GenerationExpression": "", "Comment": "" }, + { + "Name": "tenant_id", + "Index": 9, + "TypeName": "integer", + "IsNullable": true, + "Default": "", + "CharacterMaximumLength": 0, + "IsIdentity": false, + "IdentityGeneration": "", + "IsGenerated": "NEVER", + "GenerationExpression": "", + "Comment": "" + }, { "Name": "updated_at", "Index": 4, @@ -8152,7 +8891,15 @@ "ConstraintDefinition": "" } ], - "Constraints": null, + "Constraints": [ + { + "Name": "codeintel_path_ranks_tenant_id_fkey", + "ConstraintType": "f", + "RefTableName": "tenants", + "IsDeferrable": false, + "ConstraintDefinition": "FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE" + } + ], "Triggers": [ { "Name": "insert_codeintel_path_ranks_statistics", @@ -8249,6 +8996,19 @@ "IsGenerated": "NEVER", "GenerationExpression": "", "Comment": "" + }, + { + "Name": "tenant_id", + "Index": 11, + "TypeName": "integer", + "IsNullable": true, + "Default": "", + "CharacterMaximumLength": 0, + "IsIdentity": false, + "IdentityGeneration": "", + "IsGenerated": "NEVER", + "GenerationExpression": "", + "Comment": "" } ], "Indexes": [ @@ -8290,6 +9050,13 @@ "RefTableName": "codeintel_ranking_exports", "IsDeferrable": false, "ConstraintDefinition": "FOREIGN KEY (exported_upload_id) REFERENCES codeintel_ranking_exports(id) ON DELETE CASCADE" + }, + { + "Name": "codeintel_ranking_definitions_tenant_id_fkey", + "ConstraintType": "f", + "RefTableName": "tenants", + "IsDeferrable": false, + "ConstraintDefinition": "FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE" } ], "Triggers": [] @@ -8363,6 +9130,19 @@ "GenerationExpression": "", "Comment": "" }, + { + "Name": "tenant_id", + "Index": 9, + "TypeName": "integer", + "IsNullable": true, + "Default": "", + "CharacterMaximumLength": 0, + "IsIdentity": false, + "IdentityGeneration": "", + "IsGenerated": "NEVER", + "GenerationExpression": "", + "Comment": "" + }, { "Name": "upload_id", "Index": 1, @@ -8433,6 +9213,13 @@ } ], "Constraints": [ + { + "Name": "codeintel_ranking_exports_tenant_id_fkey", + "ConstraintType": "f", + "RefTableName": "tenants", + "IsDeferrable": false, + "ConstraintDefinition": "FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE" + }, { "Name": "codeintel_ranking_exports_upload_id_fkey", "ConstraintType": "f", @@ -8485,6 +9272,19 @@ "IsGenerated": "NEVER", "GenerationExpression": "", "Comment": "" + }, + { + "Name": "tenant_id", + "Index": 4, + "TypeName": "integer", + "IsNullable": true, + "Default": "", + "CharacterMaximumLength": 0, + "IsIdentity": false, + "IdentityGeneration": "", + "IsGenerated": "NEVER", + "GenerationExpression": "", + "Comment": "" } ], "Indexes": [ @@ -8499,7 +9299,15 @@ "ConstraintDefinition": "PRIMARY KEY (id)" } ], - "Constraints": null, + "Constraints": [ + { + "Name": "codeintel_ranking_graph_keys_tenant_id_fkey", + "ConstraintType": "f", + "RefTableName": "tenants", + "IsDeferrable": false, + "ConstraintDefinition": "FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE" + } + ], "Triggers": [] }, { @@ -8570,6 +9378,19 @@ "IsGenerated": "NEVER", "GenerationExpression": "", "Comment": "" + }, + { + "Name": "tenant_id", + "Index": 9, + "TypeName": "integer", + "IsNullable": true, + "Default": "", + "CharacterMaximumLength": 0, + "IsIdentity": false, + "IdentityGeneration": "", + "IsGenerated": "NEVER", + "GenerationExpression": "", + "Comment": "" } ], "Indexes": [ @@ -8604,7 +9425,15 @@ "ConstraintDefinition": "" } ], - "Constraints": null, + "Constraints": [ + { + "Name": "codeintel_ranking_path_counts_inputs_tenant_id_fkey", + "ConstraintType": "f", + "RefTableName": "tenants", + "IsDeferrable": false, + "ConstraintDefinition": "FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE" + } + ], "Triggers": [] }, { @@ -8844,6 +9673,19 @@ "IsGenerated": "NEVER", "GenerationExpression": "", "Comment": "" + }, + { + "Name": "tenant_id", + "Index": 25, + "TypeName": "integer", + "IsNullable": true, + "Default": "", + "CharacterMaximumLength": 0, + "IsIdentity": false, + "IdentityGeneration": "", + "IsGenerated": "NEVER", + "GenerationExpression": "", + "Comment": "" } ], "Indexes": [ @@ -8868,7 +9710,15 @@ "ConstraintDefinition": "PRIMARY KEY (id)" } ], - "Constraints": null, + "Constraints": [ + { + "Name": "codeintel_ranking_progress_tenant_id_fkey", + "ConstraintType": "f", + "RefTableName": "tenants", + "IsDeferrable": false, + "ConstraintDefinition": "FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE" + } + ], "Triggers": [] }, { @@ -8939,6 +9789,19 @@ "IsGenerated": "NEVER", "GenerationExpression": "", "Comment": "" + }, + { + "Name": "tenant_id", + "Index": 10, + "TypeName": "integer", + "IsNullable": true, + "Default": "", + "CharacterMaximumLength": 0, + "IsIdentity": false, + "IdentityGeneration": "", + "IsGenerated": "NEVER", + "GenerationExpression": "", + "Comment": "" } ], "Indexes": [ @@ -8980,6 +9843,13 @@ "RefTableName": "codeintel_ranking_exports", "IsDeferrable": false, "ConstraintDefinition": "FOREIGN KEY (exported_upload_id) REFERENCES codeintel_ranking_exports(id) ON DELETE CASCADE" + }, + { + "Name": "codeintel_ranking_references_tenant_id_fkey", + "ConstraintType": "f", + "RefTableName": "tenants", + "IsDeferrable": false, + "ConstraintDefinition": "FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE" } ], "Triggers": [] @@ -9026,6 +9896,19 @@ "IsGenerated": "NEVER", "GenerationExpression": "", "Comment": "" + }, + { + "Name": "tenant_id", + "Index": 5, + "TypeName": "integer", + "IsNullable": true, + "Default": "", + "CharacterMaximumLength": 0, + "IsIdentity": false, + "IdentityGeneration": "", + "IsGenerated": "NEVER", + "GenerationExpression": "", + "Comment": "" } ], "Indexes": [ @@ -9061,6 +9944,13 @@ } ], "Constraints": [ + { + "Name": "codeintel_ranking_references_processed_tenant_id_fkey", + "ConstraintType": "f", + "RefTableName": "tenants", + "IsDeferrable": false, + "ConstraintDefinition": "FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE" + }, { "Name": "fk_codeintel_ranking_reference", "ConstraintType": "f", @@ -9140,6 +10030,19 @@ "GenerationExpression": "", "Comment": "" }, + { + "Name": "tenant_id", + "Index": 7, + "TypeName": "integer", + "IsNullable": true, + "Default": "", + "CharacterMaximumLength": 0, + "IsIdentity": false, + "IdentityGeneration": "", + "IsGenerated": "NEVER", + "GenerationExpression": "", + "Comment": "" + }, { "Name": "updated_at", "Index": 6, @@ -9183,6 +10086,13 @@ "RefTableName": "repo", "IsDeferrable": false, "ConstraintDefinition": "FOREIGN KEY (repo_id) REFERENCES repo(id) ON DELETE CASCADE" + }, + { + "Name": "codeowners_tenant_id_fkey", + "ConstraintType": "f", + "RefTableName": "tenants", + "IsDeferrable": false, + "ConstraintDefinition": "FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE" } ], "Triggers": [] @@ -9217,6 +10127,19 @@ "GenerationExpression": "", "Comment": "" }, + { + "Name": "tenant_id", + "Index": 5, + "TypeName": "integer", + "IsNullable": true, + "Default": "", + "CharacterMaximumLength": 0, + "IsIdentity": false, + "IdentityGeneration": "", + "IsGenerated": "NEVER", + "GenerationExpression": "", + "Comment": "" + }, { "Name": "tree_owned_files_count", "Index": 3, @@ -9270,6 +10193,13 @@ "RefTableName": "codeowners_owners", "IsDeferrable": false, "ConstraintDefinition": "FOREIGN KEY (owner_id) REFERENCES codeowners_owners(id)" + }, + { + "Name": "codeowners_individual_stats_tenant_id_fkey", + "ConstraintType": "f", + "RefTableName": "tenants", + "IsDeferrable": false, + "ConstraintDefinition": "FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE" } ], "Triggers": [] @@ -9303,6 +10233,19 @@ "IsGenerated": "NEVER", "GenerationExpression": "", "Comment": "We just keep the reference as opposed to splitting it to handle or email\nsince the distinction is not relevant for query, and this makes indexing way easier." + }, + { + "Name": "tenant_id", + "Index": 3, + "TypeName": "integer", + "IsNullable": true, + "Default": "", + "CharacterMaximumLength": 0, + "IsIdentity": false, + "IdentityGeneration": "", + "IsGenerated": "NEVER", + "GenerationExpression": "", + "Comment": "" } ], "Indexes": [ @@ -9327,7 +10270,15 @@ "ConstraintDefinition": "" } ], - "Constraints": null, + "Constraints": [ + { + "Name": "codeowners_owners_tenant_id_fkey", + "ConstraintType": "f", + "RefTableName": "tenants", + "IsDeferrable": false, + "ConstraintDefinition": "FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE" + } + ], "Triggers": [] }, { @@ -9372,6 +10323,19 @@ "IsGenerated": "NEVER", "GenerationExpression": "", "Comment": "" + }, + { + "Name": "tenant_id", + "Index": 4, + "TypeName": "integer", + "IsNullable": true, + "Default": "", + "CharacterMaximumLength": 0, + "IsIdentity": false, + "IdentityGeneration": "", + "IsGenerated": "NEVER", + "GenerationExpression": "", + "Comment": "" } ], "Indexes": [ @@ -9396,7 +10360,15 @@ "ConstraintDefinition": "PRIMARY KEY (id)" } ], - "Constraints": null, + "Constraints": [ + { + "Name": "commit_authors_tenant_id_fkey", + "ConstraintType": "f", + "RefTableName": "tenants", + "IsDeferrable": false, + "ConstraintDefinition": "FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE" + } + ], "Triggers": [] }, { @@ -9468,6 +10440,19 @@ "GenerationExpression": "", "Comment": "" }, + { + "Name": "tenant_id", + "Index": 7, + "TypeName": "integer", + "IsNullable": true, + "Default": "", + "CharacterMaximumLength": 0, + "IsIdentity": false, + "IdentityGeneration": "", + "IsGenerated": "NEVER", + "GenerationExpression": "", + "Comment": "" + }, { "Name": "transition_columns", "Index": 4, @@ -9504,7 +10489,15 @@ "ConstraintDefinition": "" } ], - "Constraints": null, + "Constraints": [ + { + "Name": "configuration_policies_audit_logs_tenant_id_fkey", + "ConstraintType": "f", + "RefTableName": "tenants", + "IsDeferrable": false, + "ConstraintDefinition": "FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE" + } + ], "Triggers": [] }, { @@ -9667,6 +10660,19 @@ "GenerationExpression": "", "Comment": "" }, + { + "Name": "tenant_id", + "Index": 14, + "TypeName": "integer", + "IsNullable": true, + "Default": "", + "CharacterMaximumLength": 0, + "IsIdentity": false, + "IdentityGeneration": "", + "IsGenerated": "NEVER", + "GenerationExpression": "", + "Comment": "" + }, { "Name": "worker_hostname", "Index": 12, @@ -9693,7 +10699,15 @@ "ConstraintDefinition": "PRIMARY KEY (id)" } ], - "Constraints": null, + "Constraints": [ + { + "Name": "context_detection_embedding_jobs_tenant_id_fkey", + "ConstraintType": "f", + "RefTableName": "tenants", + "IsDeferrable": false, + "ConstraintDefinition": "FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE" + } + ], "Triggers": [] }, { @@ -9899,6 +10913,19 @@ "GenerationExpression": "", "Comment": "" }, + { + "Name": "tenant_id", + "Index": 9, + "TypeName": "integer", + "IsNullable": true, + "Default": "", + "CharacterMaximumLength": 0, + "IsIdentity": false, + "IdentityGeneration": "", + "IsGenerated": "NEVER", + "GenerationExpression": "", + "Comment": "" + }, { "Name": "thread_id", "Index": 2, @@ -9976,6 +11003,13 @@ "IsDeferrable": false, "ConstraintDefinition": "FOREIGN KEY (author_user_id) REFERENCES users(id) ON DELETE RESTRICT" }, + { + "Name": "discussion_comments_tenant_id_fkey", + "ConstraintType": "f", + "RefTableName": "tenants", + "IsDeferrable": false, + "ConstraintDefinition": "FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE" + }, { "Name": "discussion_comments_thread_id_fkey", "ConstraintType": "f", @@ -10003,6 +11037,19 @@ "GenerationExpression": "", "Comment": "" }, + { + "Name": "tenant_id", + "Index": 5, + "TypeName": "integer", + "IsNullable": true, + "Default": "", + "CharacterMaximumLength": 0, + "IsIdentity": false, + "IdentityGeneration": "", + "IsGenerated": "NEVER", + "GenerationExpression": "", + "Comment": "" + }, { "Name": "thread_id", "Index": 3, @@ -10066,6 +11113,13 @@ } ], "Constraints": [ + { + "Name": "discussion_mail_reply_tokens_tenant_id_fkey", + "ConstraintType": "f", + "RefTableName": "tenants", + "IsDeferrable": false, + "ConstraintDefinition": "FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE" + }, { "Name": "discussion_mail_reply_tokens_thread_id_fkey", "ConstraintType": "f", @@ -10165,6 +11219,19 @@ "GenerationExpression": "", "Comment": "" }, + { + "Name": "tenant_id", + "Index": 9, + "TypeName": "integer", + "IsNullable": true, + "Default": "", + "CharacterMaximumLength": 0, + "IsIdentity": false, + "IdentityGeneration": "", + "IsGenerated": "NEVER", + "GenerationExpression": "", + "Comment": "" + }, { "Name": "title", "Index": 3, @@ -10228,6 +11295,13 @@ "RefTableName": "discussion_threads_target_repo", "IsDeferrable": false, "ConstraintDefinition": "FOREIGN KEY (target_repo_id) REFERENCES discussion_threads_target_repo(id) ON DELETE CASCADE" + }, + { + "Name": "discussion_threads_tenant_id_fkey", + "ConstraintType": "f", + "RefTableName": "tenants", + "IsDeferrable": false, + "ConstraintDefinition": "FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE" } ], "Triggers": [] @@ -10392,6 +11466,19 @@ "GenerationExpression": "", "Comment": "" }, + { + "Name": "tenant_id", + "Index": 14, + "TypeName": "integer", + "IsNullable": true, + "Default": "", + "CharacterMaximumLength": 0, + "IsIdentity": false, + "IdentityGeneration": "", + "IsGenerated": "NEVER", + "GenerationExpression": "", + "Comment": "" + }, { "Name": "thread_id", "Index": 2, @@ -10436,6 +11523,13 @@ "IsDeferrable": false, "ConstraintDefinition": "FOREIGN KEY (repo_id) REFERENCES repo(id) ON DELETE CASCADE" }, + { + "Name": "discussion_threads_target_repo_tenant_id_fkey", + "ConstraintType": "f", + "RefTableName": "tenants", + "IsDeferrable": false, + "ConstraintDefinition": "FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE" + }, { "Name": "discussion_threads_target_repo_thread_id_fkey", "ConstraintType": "f", @@ -10658,6 +11752,19 @@ "GenerationExpression": "", "Comment": "" }, + { + "Name": "tenant_id", + "Index": 21, + "TypeName": "integer", + "IsNullable": true, + "Default": "", + "CharacterMaximumLength": 0, + "IsIdentity": false, + "IdentityGeneration": "", + "IsGenerated": "NEVER", + "GenerationExpression": "", + "Comment": "" + }, { "Name": "timestamp", "Index": 9, @@ -10821,6 +11928,13 @@ "RefTableName": "", "IsDeferrable": false, "ConstraintDefinition": "CHECK (version \u003c\u003e ''::text)" + }, + { + "Name": "event_logs_tenant_id_fkey", + "ConstraintType": "f", + "RefTableName": "tenants", + "IsDeferrable": false, + "ConstraintDefinition": "FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE" } ], "Triggers": [] @@ -10854,6 +11968,19 @@ "IsGenerated": "NEVER", "GenerationExpression": "", "Comment": "" + }, + { + "Name": "tenant_id", + "Index": 3, + "TypeName": "integer", + "IsNullable": true, + "Default": "", + "CharacterMaximumLength": 0, + "IsIdentity": false, + "IdentityGeneration": "", + "IsGenerated": "NEVER", + "GenerationExpression": "", + "Comment": "" } ], "Indexes": [ @@ -10878,7 +12005,15 @@ "ConstraintDefinition": "PRIMARY KEY (id)" } ], - "Constraints": null, + "Constraints": [ + { + "Name": "event_logs_export_allowlist_tenant_id_fkey", + "ConstraintType": "f", + "RefTableName": "tenants", + "IsDeferrable": false, + "ConstraintDefinition": "FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE" + } + ], "Triggers": [] }, { @@ -10910,6 +12045,19 @@ "IsGenerated": "NEVER", "GenerationExpression": "", "Comment": "" + }, + { + "Name": "tenant_id", + "Index": 3, + "TypeName": "integer", + "IsNullable": true, + "Default": "", + "CharacterMaximumLength": 0, + "IsIdentity": false, + "IdentityGeneration": "", + "IsGenerated": "NEVER", + "GenerationExpression": "", + "Comment": "" } ], "Indexes": [ @@ -10924,7 +12072,15 @@ "ConstraintDefinition": "PRIMARY KEY (id)" } ], - "Constraints": null, + "Constraints": [ + { + "Name": "event_logs_scrape_state_tenant_id_fkey", + "ConstraintType": "f", + "RefTableName": "tenants", + "IsDeferrable": false, + "ConstraintDefinition": "FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE" + } + ], "Triggers": [] }, { @@ -10969,6 +12125,19 @@ "IsGenerated": "NEVER", "GenerationExpression": "", "Comment": "" + }, + { + "Name": "tenant_id", + "Index": 4, + "TypeName": "integer", + "IsNullable": true, + "Default": "", + "CharacterMaximumLength": 0, + "IsIdentity": false, + "IdentityGeneration": "", + "IsGenerated": "NEVER", + "GenerationExpression": "", + "Comment": "" } ], "Indexes": [ @@ -10983,7 +12152,15 @@ "ConstraintDefinition": "PRIMARY KEY (id)" } ], - "Constraints": null, + "Constraints": [ + { + "Name": "event_logs_scrape_state_own_tenant_id_fkey", + "ConstraintType": "f", + "RefTableName": "tenants", + "IsDeferrable": false, + "ConstraintDefinition": "FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE" + } + ], "Triggers": [] }, { @@ -11158,6 +12335,19 @@ "IsGenerated": "NEVER", "GenerationExpression": "", "Comment": "The version of src-cli used by the executor." + }, + { + "Name": "tenant_id", + "Index": 14, + "TypeName": "integer", + "IsNullable": true, + "Default": "", + "CharacterMaximumLength": 0, + "IsIdentity": false, + "IdentityGeneration": "", + "IsGenerated": "NEVER", + "GenerationExpression": "", + "Comment": "" } ], "Indexes": [ @@ -11183,6 +12373,13 @@ } ], "Constraints": [ + { + "Name": "executor_heartbeats_tenant_id_fkey", + "ConstraintType": "f", + "RefTableName": "tenants", + "IsDeferrable": false, + "ConstraintDefinition": "FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE" + }, { "Name": "one_of_queue_name_queue_names", "ConstraintType": "c", @@ -11262,6 +12459,19 @@ "GenerationExpression": "", "Comment": "" }, + { + "Name": "tenant_id", + "Index": 8, + "TypeName": "integer", + "IsNullable": true, + "Default": "", + "CharacterMaximumLength": 0, + "IsIdentity": false, + "IdentityGeneration": "", + "IsGenerated": "NEVER", + "GenerationExpression": "", + "Comment": "" + }, { "Name": "updated_at", "Index": 7, @@ -11321,7 +12531,15 @@ "ConstraintDefinition": "UNIQUE (value_sha256)" } ], - "Constraints": null, + "Constraints": [ + { + "Name": "executor_job_tokens_tenant_id_fkey", + "ConstraintType": "f", + "RefTableName": "tenants", + "IsDeferrable": false, + "ConstraintDefinition": "FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE" + } + ], "Triggers": [] }, { @@ -11380,6 +12598,19 @@ "GenerationExpression": "", "Comment": "" }, + { + "Name": "tenant_id", + "Index": 6, + "TypeName": "integer", + "IsNullable": true, + "Default": "", + "CharacterMaximumLength": 0, + "IsIdentity": false, + "IdentityGeneration": "", + "IsGenerated": "NEVER", + "GenerationExpression": "", + "Comment": "" + }, { "Name": "user_id", "Index": 3, @@ -11414,6 +12645,13 @@ "IsDeferrable": false, "ConstraintDefinition": "FOREIGN KEY (executor_secret_id) REFERENCES executor_secrets(id) ON DELETE CASCADE" }, + { + "Name": "executor_secret_access_logs_tenant_id_fkey", + "ConstraintType": "f", + "RefTableName": "tenants", + "IsDeferrable": false, + "ConstraintDefinition": "FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE" + }, { "Name": "executor_secret_access_logs_user_id_fkey", "ConstraintType": "f", @@ -11539,6 +12777,19 @@ "GenerationExpression": "", "Comment": "" }, + { + "Name": "tenant_id", + "Index": 11, + "TypeName": "integer", + "IsNullable": true, + "Default": "", + "CharacterMaximumLength": 0, + "IsIdentity": false, + "IdentityGeneration": "", + "IsGenerated": "NEVER", + "GenerationExpression": "", + "Comment": "" + }, { "Name": "updated_at", "Index": 9, @@ -11629,6 +12880,13 @@ "RefTableName": "users", "IsDeferrable": false, "ConstraintDefinition": "FOREIGN KEY (namespace_user_id) REFERENCES users(id) ON DELETE CASCADE" + }, + { + "Name": "executor_secrets_tenant_id_fkey", + "ConstraintType": "f", + "RefTableName": "tenants", + "IsDeferrable": false, + "ConstraintDefinition": "FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE" } ], "Triggers": [] @@ -11845,6 +13103,19 @@ "GenerationExpression": "", "Comment": "" }, + { + "Name": "tenant_id", + "Index": 19, + "TypeName": "integer", + "IsNullable": true, + "Default": "", + "CharacterMaximumLength": 0, + "IsIdentity": false, + "IdentityGeneration": "", + "IsGenerated": "NEVER", + "GenerationExpression": "", + "Comment": "" + }, { "Name": "updated_at", "Index": 16, @@ -11901,6 +13172,13 @@ "RefTableName": "users", "IsDeferrable": true, "ConstraintDefinition": "FOREIGN KEY (initiator_id) REFERENCES users(id) ON UPDATE CASCADE ON DELETE CASCADE DEFERRABLE" + }, + { + "Name": "exhaustive_search_jobs_tenant_id_fkey", + "ConstraintType": "f", + "RefTableName": "tenants", + "IsDeferrable": false, + "ConstraintDefinition": "FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE" } ], "Triggers": [] @@ -12117,6 +13395,19 @@ "GenerationExpression": "", "Comment": "" }, + { + "Name": "tenant_id", + "Index": 19, + "TypeName": "integer", + "IsNullable": true, + "Default": "", + "CharacterMaximumLength": 0, + "IsIdentity": false, + "IdentityGeneration": "", + "IsGenerated": "NEVER", + "GenerationExpression": "", + "Comment": "" + }, { "Name": "updated_at", "Index": 17, @@ -12180,6 +13471,13 @@ "RefTableName": "exhaustive_search_jobs", "IsDeferrable": false, "ConstraintDefinition": "FOREIGN KEY (search_job_id) REFERENCES exhaustive_search_jobs(id) ON DELETE CASCADE" + }, + { + "Name": "exhaustive_search_repo_jobs_tenant_id_fkey", + "ConstraintType": "f", + "RefTableName": "tenants", + "IsDeferrable": false, + "ConstraintDefinition": "FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE" } ], "Triggers": [] @@ -12383,6 +13681,19 @@ "GenerationExpression": "", "Comment": "" }, + { + "Name": "tenant_id", + "Index": 18, + "TypeName": "integer", + "IsNullable": true, + "Default": "", + "CharacterMaximumLength": 0, + "IsIdentity": false, + "IdentityGeneration": "", + "IsGenerated": "NEVER", + "GenerationExpression": "", + "Comment": "" + }, { "Name": "updated_at", "Index": 16, @@ -12439,6 +13750,13 @@ "RefTableName": "exhaustive_search_repo_jobs", "IsDeferrable": false, "ConstraintDefinition": "FOREIGN KEY (search_repo_job_id) REFERENCES exhaustive_search_repo_jobs(id) ON DELETE CASCADE" + }, + { + "Name": "exhaustive_search_repo_revision_jobs_tenant_id_fkey", + "ConstraintType": "f", + "RefTableName": "tenants", + "IsDeferrable": false, + "ConstraintDefinition": "FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE" } ], "Triggers": [] @@ -12642,6 +13960,19 @@ "GenerationExpression": "", "Comment": "" }, + { + "Name": "tenant_id", + "Index": 18, + "TypeName": "integer", + "IsNullable": true, + "Default": "", + "CharacterMaximumLength": 0, + "IsIdentity": false, + "IdentityGeneration": "", + "IsGenerated": "NEVER", + "GenerationExpression": "", + "Comment": "" + }, { "Name": "unrestricted", "Index": 16, @@ -12718,6 +14049,13 @@ "RefTableName": "", "IsDeferrable": false, "ConstraintDefinition": "CHECK (permissions IS NOT NULL AND unrestricted IS FALSE OR permissions IS NULL AND unrestricted IS TRUE)" + }, + { + "Name": "explicit_permissions_bitbucket_projects_jobs_tenant_id_fkey", + "ConstraintType": "f", + "RefTableName": "tenants", + "IsDeferrable": false, + "ConstraintDefinition": "FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE" } ], "Triggers": [] @@ -12777,6 +14115,19 @@ "IsGenerated": "NEVER", "GenerationExpression": "", "Comment": "" + }, + { + "Name": "tenant_id", + "Index": 7, + "TypeName": "integer", + "IsNullable": true, + "Default": "", + "CharacterMaximumLength": 0, + "IsIdentity": false, + "IdentityGeneration": "", + "IsGenerated": "NEVER", + "GenerationExpression": "", + "Comment": "" } ], "Indexes": [ @@ -12825,6 +14176,13 @@ "RefTableName": "repo", "IsDeferrable": true, "ConstraintDefinition": "FOREIGN KEY (repo_id) REFERENCES repo(id) ON DELETE CASCADE DEFERRABLE" + }, + { + "Name": "external_service_repos_tenant_id_fkey", + "ConstraintType": "f", + "RefTableName": "tenants", + "IsDeferrable": false, + "ConstraintDefinition": "FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE" } ], "Triggers": [] @@ -13093,6 +14451,19 @@ "GenerationExpression": "", "Comment": "" }, + { + "Name": "tenant_id", + "Index": 22, + "TypeName": "integer", + "IsNullable": true, + "Default": "", + "CharacterMaximumLength": 0, + "IsIdentity": false, + "IdentityGeneration": "", + "IsGenerated": "NEVER", + "GenerationExpression": "", + "Comment": "" + }, { "Name": "worker_hostname", "Index": 12, @@ -13120,6 +14491,13 @@ } ], "Constraints": [ + { + "Name": "external_service_sync_jobs_tenant_id_fkey", + "ConstraintType": "f", + "RefTableName": "tenants", + "IsDeferrable": false, + "ConstraintDefinition": "FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE" + }, { "Name": "external_services_id_fk", "ConstraintType": "f", @@ -13316,6 +14694,19 @@ "GenerationExpression": "", "Comment": "" }, + { + "Name": "tenant_id", + "Index": 20, + "TypeName": "integer", + "IsNullable": true, + "Default": "", + "CharacterMaximumLength": 0, + "IsIdentity": false, + "IdentityGeneration": "", + "IsGenerated": "NEVER", + "GenerationExpression": "", + "Comment": "" + }, { "Name": "token_expires_at", "Index": 16, @@ -13416,6 +14807,13 @@ "RefTableName": "users", "IsDeferrable": true, "ConstraintDefinition": "FOREIGN KEY (last_updater_id) REFERENCES users(id) ON DELETE SET NULL DEFERRABLE" + }, + { + "Name": "external_services_tenant_id_fkey", + "ConstraintType": "f", + "RefTableName": "tenants", + "IsDeferrable": false, + "ConstraintDefinition": "FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE" } ], "Triggers": [] @@ -13502,6 +14900,19 @@ "GenerationExpression": "", "Comment": "" }, + { + "Name": "tenant_id", + "Index": 8, + "TypeName": "integer", + "IsNullable": true, + "Default": "", + "CharacterMaximumLength": 0, + "IsIdentity": false, + "IdentityGeneration": "", + "IsGenerated": "NEVER", + "GenerationExpression": "", + "Comment": "" + }, { "Name": "updated_at", "Index": 6, @@ -13579,6 +14990,13 @@ "RefTableName": "users", "IsDeferrable": false, "ConstraintDefinition": "FOREIGN KEY (namespace_user_id) REFERENCES users(id) ON DELETE CASCADE" + }, + { + "Name": "feature_flag_overrides_tenant_id_fkey", + "ConstraintType": "f", + "RefTableName": "tenants", + "IsDeferrable": false, + "ConstraintDefinition": "FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE" } ], "Triggers": [] @@ -13665,6 +15083,19 @@ "GenerationExpression": "", "Comment": "Rollout only defined when flag_type is rollout. Increments of 0.01%" }, + { + "Name": "tenant_id", + "Index": 8, + "TypeName": "integer", + "IsNullable": true, + "Default": "", + "CharacterMaximumLength": 0, + "IsIdentity": false, + "IdentityGeneration": "", + "IsGenerated": "NEVER", + "GenerationExpression": "", + "Comment": "" + }, { "Name": "updated_at", "Index": 6, @@ -13699,6 +15130,13 @@ "IsDeferrable": false, "ConstraintDefinition": "CHECK (rollout \u003e= 0 AND rollout \u003c= 10000)" }, + { + "Name": "feature_flags_tenant_id_fkey", + "ConstraintType": "f", + "RefTableName": "tenants", + "IsDeferrable": false, + "ConstraintDefinition": "FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE" + }, { "Name": "required_bool_fields", "ConstraintType": "c", @@ -13824,6 +15262,19 @@ "GenerationExpression": "", "Comment": "" }, + { + "Name": "tenant_id", + "Index": 11, + "TypeName": "integer", + "IsNullable": true, + "Default": "", + "CharacterMaximumLength": 0, + "IsIdentity": false, + "IdentityGeneration": "", + "IsGenerated": "NEVER", + "GenerationExpression": "", + "Comment": "" + }, { "Name": "updated_at", "Index": 10, @@ -13910,6 +15361,13 @@ "RefTableName": "github_apps", "IsDeferrable": false, "ConstraintDefinition": "FOREIGN KEY (app_id) REFERENCES github_apps(id) ON DELETE CASCADE" + }, + { + "Name": "github_app_installs_tenant_id_fkey", + "ConstraintType": "f", + "RefTableName": "tenants", + "IsDeferrable": false, + "ConstraintDefinition": "FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE" } ], "Triggers": [] @@ -14113,6 +15571,19 @@ "GenerationExpression": "", "Comment": "" }, + { + "Name": "tenant_id", + "Index": 18, + "TypeName": "integer", + "IsNullable": true, + "Default": "", + "CharacterMaximumLength": 0, + "IsIdentity": false, + "IdentityGeneration": "", + "IsGenerated": "NEVER", + "GenerationExpression": "", + "Comment": "" + }, { "Name": "updated_at", "Index": 12, @@ -14163,6 +15634,13 @@ } ], "Constraints": [ + { + "Name": "github_apps_tenant_id_fkey", + "ConstraintType": "f", + "RefTableName": "tenants", + "IsDeferrable": false, + "ConstraintDefinition": "FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE" + }, { "Name": "github_apps_webhook_id_fkey", "ConstraintType": "f", @@ -14385,6 +15863,19 @@ "GenerationExpression": "", "Comment": "" }, + { + "Name": "tenant_id", + "Index": 18, + "TypeName": "integer", + "IsNullable": true, + "Default": "", + "CharacterMaximumLength": 0, + "IsIdentity": false, + "IdentityGeneration": "", + "IsGenerated": "NEVER", + "GenerationExpression": "", + "Comment": "" + }, { "Name": "worker_hostname", "Index": 12, @@ -14421,7 +15912,15 @@ "ConstraintDefinition": "" } ], - "Constraints": null, + "Constraints": [ + { + "Name": "gitserver_relocator_jobs_tenant_id_fkey", + "ConstraintType": "f", + "RefTableName": "tenants", + "IsDeferrable": false, + "ConstraintDefinition": "FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE" + } + ], "Triggers": [] }, { @@ -14558,6 +16057,19 @@ "GenerationExpression": "", "Comment": "" }, + { + "Name": "tenant_id", + "Index": 14, + "TypeName": "integer", + "IsNullable": true, + "Default": "", + "CharacterMaximumLength": 0, + "IsIdentity": false, + "IdentityGeneration": "", + "IsGenerated": "NEVER", + "GenerationExpression": "", + "Comment": "" + }, { "Name": "updated_at", "Index": 5, @@ -14671,6 +16183,13 @@ "RefTableName": "repo", "IsDeferrable": false, "ConstraintDefinition": "FOREIGN KEY (repo_id) REFERENCES repo(id) ON DELETE CASCADE" + }, + { + "Name": "gitserver_repos_tenant_id_fkey", + "ConstraintType": "f", + "RefTableName": "tenants", + "IsDeferrable": false, + "ConstraintDefinition": "FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE" } ], "Triggers": [ @@ -14770,6 +16289,19 @@ "GenerationExpression": "", "Comment": "ID of this gitserver shard. If an empty string then the repositories havent been assigned a shard." }, + { + "Name": "tenant_id", + "Index": 8, + "TypeName": "integer", + "IsNullable": true, + "Default": "", + "CharacterMaximumLength": 0, + "IsIdentity": false, + "IdentityGeneration": "", + "IsGenerated": "NEVER", + "GenerationExpression": "", + "Comment": "" + }, { "Name": "total", "Index": 2, @@ -14796,7 +16328,15 @@ "ConstraintDefinition": "" } ], - "Constraints": null, + "Constraints": [ + { + "Name": "gitserver_repos_statistics_tenant_id_fkey", + "ConstraintType": "f", + "RefTableName": "tenants", + "IsDeferrable": false, + "ConstraintDefinition": "FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE" + } + ], "Triggers": [] }, { @@ -14829,6 +16369,19 @@ "GenerationExpression": "", "Comment": "" }, + { + "Name": "tenant_id", + "Index": 4, + "TypeName": "integer", + "IsNullable": true, + "Default": "", + "CharacterMaximumLength": 0, + "IsIdentity": false, + "IdentityGeneration": "", + "IsGenerated": "NEVER", + "GenerationExpression": "", + "Comment": "" + }, { "Name": "updated_at", "Index": 3, @@ -14862,6 +16415,13 @@ "RefTableName": "repo", "IsDeferrable": false, "ConstraintDefinition": "FOREIGN KEY (repo_id) REFERENCES repo(id) ON DELETE CASCADE" + }, + { + "Name": "gitserver_repos_sync_output_tenant_id_fkey", + "ConstraintType": "f", + "RefTableName": "tenants", + "IsDeferrable": false, + "ConstraintDefinition": "FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE" } ], "Triggers": [] @@ -14895,6 +16455,19 @@ "IsGenerated": "NEVER", "GenerationExpression": "", "Comment": "" + }, + { + "Name": "tenant_id", + "Index": 3, + "TypeName": "integer", + "IsNullable": true, + "Default": "", + "CharacterMaximumLength": 0, + "IsIdentity": false, + "IdentityGeneration": "", + "IsGenerated": "NEVER", + "GenerationExpression": "", + "Comment": "" } ], "Indexes": [ @@ -14909,7 +16482,15 @@ "ConstraintDefinition": "PRIMARY KEY (site_id)" } ], - "Constraints": null, + "Constraints": [ + { + "Name": "global_state_tenant_id_fkey", + "ConstraintType": "f", + "RefTableName": "tenants", + "IsDeferrable": false, + "ConstraintDefinition": "FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE" + } + ], "Triggers": [] }, { @@ -15150,6 +16731,19 @@ "GenerationExpression": "", "Comment": "" }, + { + "Name": "tenant_id", + "Index": 21, + "TypeName": "integer", + "IsNullable": true, + "Default": "", + "CharacterMaximumLength": 0, + "IsIdentity": false, + "IdentityGeneration": "", + "IsGenerated": "NEVER", + "GenerationExpression": "", + "Comment": "" + }, { "Name": "trace_id", "Index": 20, @@ -15259,7 +16853,15 @@ "ConstraintDefinition": "" } ], - "Constraints": null, + "Constraints": [ + { + "Name": "insights_query_runner_jobs_tenant_id_fkey", + "ConstraintType": "f", + "RefTableName": "tenants", + "IsDeferrable": false, + "ConstraintDefinition": "FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE" + } + ], "Triggers": [] }, { @@ -15304,6 +16906,19 @@ "IsGenerated": "NEVER", "GenerationExpression": "", "Comment": "The time for which this dependency should be recorded at using the parents value." + }, + { + "Name": "tenant_id", + "Index": 4, + "TypeName": "integer", + "IsNullable": true, + "Default": "", + "CharacterMaximumLength": 0, + "IsIdentity": false, + "IdentityGeneration": "", + "IsGenerated": "NEVER", + "GenerationExpression": "", + "Comment": "" } ], "Indexes": [ @@ -15335,6 +16950,13 @@ "RefTableName": "insights_query_runner_jobs", "IsDeferrable": false, "ConstraintDefinition": "FOREIGN KEY (job_id) REFERENCES insights_query_runner_jobs(id) ON DELETE CASCADE" + }, + { + "Name": "insights_query_runner_jobs_dependencies_tenant_id_fkey", + "ConstraintType": "f", + "RefTableName": "tenants", + "IsDeferrable": false, + "ConstraintDefinition": "FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE" } ], "Triggers": [] @@ -15447,6 +17069,19 @@ "GenerationExpression": "", "Comment": "" }, + { + "Name": "tenant_id", + "Index": 12, + "TypeName": "integer", + "IsNullable": true, + "Default": "", + "CharacterMaximumLength": 0, + "IsIdentity": false, + "IdentityGeneration": "", + "IsGenerated": "NEVER", + "GenerationExpression": "", + "Comment": "" + }, { "Name": "total_dashboards", "Index": 8, @@ -15488,7 +17123,15 @@ } ], "Indexes": [], - "Constraints": null, + "Constraints": [ + { + "Name": "insights_settings_migration_jobs_tenant_id_fkey", + "ConstraintType": "f", + "RefTableName": "tenants", + "IsDeferrable": false, + "ConstraintDefinition": "FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE" + } + ], "Triggers": [] }, { @@ -15690,6 +17333,19 @@ "GenerationExpression": "", "Comment": "" }, + { + "Name": "tenant_id", + "Index": 18, + "TypeName": "integer", + "IsNullable": true, + "Default": "", + "CharacterMaximumLength": 0, + "IsIdentity": false, + "IdentityGeneration": "", + "IsGenerated": "NEVER", + "GenerationExpression": "", + "Comment": "" + }, { "Name": "type", "Index": 4, @@ -15726,7 +17382,15 @@ "ConstraintDefinition": "" } ], - "Constraints": null, + "Constraints": [ + { + "Name": "lsif_configuration_policies_tenant_id_fkey", + "ConstraintType": "f", + "RefTableName": "tenants", + "IsDeferrable": false, + "ConstraintDefinition": "FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE" + } + ], "Triggers": [ { "Name": "trigger_configuration_policies_delete", @@ -15771,6 +17435,19 @@ "IsGenerated": "NEVER", "GenerationExpression": "", "Comment": "The repository identifier associated with the policy." + }, + { + "Name": "tenant_id", + "Index": 3, + "TypeName": "integer", + "IsNullable": true, + "Default": "", + "CharacterMaximumLength": 0, + "IsIdentity": false, + "IdentityGeneration": "", + "IsGenerated": "NEVER", + "GenerationExpression": "", + "Comment": "" } ], "Indexes": [ @@ -15785,7 +17462,15 @@ "ConstraintDefinition": "PRIMARY KEY (policy_id, repo_id)" } ], - "Constraints": null, + "Constraints": [ + { + "Name": "lsif_configuration_policies_repository_pattern_l_tenant_id_fkey", + "ConstraintType": "f", + "RefTableName": "tenants", + "IsDeferrable": false, + "ConstraintDefinition": "FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE" + } + ], "Triggers": [] }, { @@ -15974,6 +17659,19 @@ "GenerationExpression": "", "Comment": "" }, + { + "Name": "tenant_id", + "Index": 17, + "TypeName": "integer", + "IsNullable": true, + "Default": "", + "CharacterMaximumLength": 0, + "IsIdentity": false, + "IdentityGeneration": "", + "IsGenerated": "NEVER", + "GenerationExpression": "", + "Comment": "" + }, { "Name": "upload_id", "Index": 13, @@ -16024,6 +17722,13 @@ } ], "Constraints": [ + { + "Name": "lsif_dependency_indexing_jobs_tenant_id_fkey", + "ConstraintType": "f", + "RefTableName": "tenants", + "IsDeferrable": false, + "ConstraintDefinition": "FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE" + }, { "Name": "lsif_dependency_indexing_jobs_upload_id_fkey1", "ConstraintType": "f", @@ -16102,6 +17807,19 @@ "IsGenerated": "NEVER", "GenerationExpression": "", "Comment": "" + }, + { + "Name": "tenant_id", + "Index": 7, + "TypeName": "integer", + "IsNullable": true, + "Default": "", + "CharacterMaximumLength": 0, + "IsIdentity": false, + "IdentityGeneration": "", + "IsGenerated": "NEVER", + "GenerationExpression": "", + "Comment": "" } ], "Indexes": [ @@ -16176,7 +17894,15 @@ "ConstraintDefinition": "" } ], - "Constraints": null, + "Constraints": [ + { + "Name": "lsif_dependency_repos_tenant_id_fkey", + "ConstraintType": "f", + "RefTableName": "tenants", + "IsDeferrable": false, + "ConstraintDefinition": "FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE" + } + ], "Triggers": [] }, { @@ -16339,6 +18065,19 @@ "GenerationExpression": "", "Comment": "" }, + { + "Name": "tenant_id", + "Index": 15, + "TypeName": "integer", + "IsNullable": true, + "Default": "", + "CharacterMaximumLength": 0, + "IsIdentity": false, + "IdentityGeneration": "", + "IsGenerated": "NEVER", + "GenerationExpression": "", + "Comment": "" + }, { "Name": "upload_id", "Index": 11, @@ -16405,6 +18144,13 @@ "RefTableName": "lsif_uploads", "IsDeferrable": false, "ConstraintDefinition": "FOREIGN KEY (upload_id) REFERENCES lsif_uploads(id) ON DELETE CASCADE" + }, + { + "Name": "lsif_dependency_syncing_jobs_tenant_id_fkey", + "ConstraintType": "f", + "RefTableName": "tenants", + "IsDeferrable": false, + "ConstraintDefinition": "FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE" } ], "Triggers": [] @@ -16452,6 +18198,19 @@ "GenerationExpression": "", "Comment": "" }, + { + "Name": "tenant_id", + "Index": 6, + "TypeName": "integer", + "IsNullable": true, + "Default": "", + "CharacterMaximumLength": 0, + "IsIdentity": false, + "IdentityGeneration": "", + "IsGenerated": "NEVER", + "GenerationExpression": "", + "Comment": "" + }, { "Name": "update_token", "Index": 3, @@ -16491,7 +18250,15 @@ "ConstraintDefinition": "PRIMARY KEY (repository_id)" } ], - "Constraints": null, + "Constraints": [ + { + "Name": "lsif_dirty_repositories_tenant_id_fkey", + "ConstraintType": "f", + "RefTableName": "tenants", + "IsDeferrable": false, + "ConstraintDefinition": "FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE" + } + ], "Triggers": [] }, { @@ -16549,6 +18316,19 @@ "IsGenerated": "NEVER", "GenerationExpression": "", "Comment": "" + }, + { + "Name": "tenant_id", + "Index": 5, + "TypeName": "integer", + "IsNullable": true, + "Default": "", + "CharacterMaximumLength": 0, + "IsIdentity": false, + "IdentityGeneration": "", + "IsGenerated": "NEVER", + "GenerationExpression": "", + "Comment": "" } ], "Indexes": [ @@ -16580,6 +18360,13 @@ "RefTableName": "repo", "IsDeferrable": false, "ConstraintDefinition": "FOREIGN KEY (repository_id) REFERENCES repo(id) ON DELETE CASCADE" + }, + { + "Name": "lsif_index_configuration_tenant_id_fkey", + "ConstraintType": "f", + "RefTableName": "tenants", + "IsDeferrable": false, + "ConstraintDefinition": "FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE" } ], "Triggers": [] @@ -16913,6 +18700,19 @@ "GenerationExpression": "", "Comment": "" }, + { + "Name": "tenant_id", + "Index": 27, + "TypeName": "integer", + "IsNullable": true, + "Default": "", + "CharacterMaximumLength": 0, + "IsIdentity": false, + "IdentityGeneration": "", + "IsGenerated": "NEVER", + "GenerationExpression": "", + "Comment": "" + }, { "Name": "worker_hostname", "Index": 21, @@ -17000,6 +18800,13 @@ } ], "Constraints": [ + { + "Name": "lsif_indexes_tenant_id_fkey", + "ConstraintType": "f", + "RefTableName": "tenants", + "IsDeferrable": false, + "ConstraintDefinition": "FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE" + }, { "Name": "lsif_uploads_commit_valid_chars", "ConstraintType": "c", @@ -17039,6 +18846,19 @@ "IsGenerated": "NEVER", "GenerationExpression": "", "Comment": "" + }, + { + "Name": "tenant_id", + "Index": 3, + "TypeName": "integer", + "IsNullable": true, + "Default": "", + "CharacterMaximumLength": 0, + "IsIdentity": false, + "IdentityGeneration": "", + "IsGenerated": "NEVER", + "GenerationExpression": "", + "Comment": "" } ], "Indexes": [ @@ -17053,7 +18873,15 @@ "ConstraintDefinition": "PRIMARY KEY (repository_id)" } ], - "Constraints": null, + "Constraints": [ + { + "Name": "lsif_last_index_scan_tenant_id_fkey", + "ConstraintType": "f", + "RefTableName": "tenants", + "IsDeferrable": false, + "ConstraintDefinition": "FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE" + } + ], "Triggers": [] }, { @@ -17085,6 +18913,19 @@ "IsGenerated": "NEVER", "GenerationExpression": "", "Comment": "" + }, + { + "Name": "tenant_id", + "Index": 3, + "TypeName": "integer", + "IsNullable": true, + "Default": "", + "CharacterMaximumLength": 0, + "IsIdentity": false, + "IdentityGeneration": "", + "IsGenerated": "NEVER", + "GenerationExpression": "", + "Comment": "" } ], "Indexes": [ @@ -17099,7 +18940,15 @@ "ConstraintDefinition": "PRIMARY KEY (repository_id)" } ], - "Constraints": null, + "Constraints": [ + { + "Name": "lsif_last_retention_scan_tenant_id_fkey", + "ConstraintType": "f", + "RefTableName": "tenants", + "IsDeferrable": false, + "ConstraintDefinition": "FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE" + } + ], "Triggers": [] }, { @@ -17132,6 +18981,19 @@ "GenerationExpression": "", "Comment": "" }, + { + "Name": "tenant_id", + "Index": 4, + "TypeName": "integer", + "IsNullable": true, + "Default": "", + "CharacterMaximumLength": 0, + "IsIdentity": false, + "IdentityGeneration": "", + "IsGenerated": "NEVER", + "GenerationExpression": "", + "Comment": "" + }, { "Name": "uploads", "Index": 3, @@ -17168,7 +19030,15 @@ "ConstraintDefinition": "" } ], - "Constraints": null, + "Constraints": [ + { + "Name": "lsif_nearest_uploads_tenant_id_fkey", + "ConstraintType": "f", + "RefTableName": "tenants", + "IsDeferrable": false, + "ConstraintDefinition": "FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE" + } + ], "Triggers": [] }, { @@ -17226,6 +19096,19 @@ "IsGenerated": "NEVER", "GenerationExpression": "", "Comment": "" + }, + { + "Name": "tenant_id", + "Index": 5, + "TypeName": "integer", + "IsNullable": true, + "Default": "", + "CharacterMaximumLength": 0, + "IsIdentity": false, + "IdentityGeneration": "", + "IsGenerated": "NEVER", + "GenerationExpression": "", + "Comment": "" } ], "Indexes": [ @@ -17250,7 +19133,15 @@ "ConstraintDefinition": "" } ], - "Constraints": null, + "Constraints": [ + { + "Name": "lsif_nearest_uploads_links_tenant_id_fkey", + "ConstraintType": "f", + "RefTableName": "tenants", + "IsDeferrable": false, + "ConstraintDefinition": "FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE" + } + ], "Triggers": [] }, { @@ -17322,6 +19213,19 @@ "GenerationExpression": "", "Comment": "The (export) moniker scheme." }, + { + "Name": "tenant_id", + "Index": 7, + "TypeName": "integer", + "IsNullable": true, + "Default": "", + "CharacterMaximumLength": 0, + "IsIdentity": false, + "IdentityGeneration": "", + "IsGenerated": "NEVER", + "GenerationExpression": "", + "Comment": "" + }, { "Name": "version", "Index": 4, @@ -17375,6 +19279,13 @@ "RefTableName": "lsif_uploads", "IsDeferrable": false, "ConstraintDefinition": "FOREIGN KEY (dump_id) REFERENCES lsif_uploads(id) ON DELETE CASCADE" + }, + { + "Name": "lsif_packages_tenant_id_fkey", + "ConstraintType": "f", + "RefTableName": "tenants", + "IsDeferrable": false, + "ConstraintDefinition": "FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE" } ], "Triggers": [] @@ -17448,6 +19359,19 @@ "GenerationExpression": "", "Comment": "The (import) moniker scheme." }, + { + "Name": "tenant_id", + "Index": 8, + "TypeName": "integer", + "IsNullable": true, + "Default": "", + "CharacterMaximumLength": 0, + "IsIdentity": false, + "IdentityGeneration": "", + "IsGenerated": "NEVER", + "GenerationExpression": "", + "Comment": "" + }, { "Name": "version", "Index": 4, @@ -17501,6 +19425,13 @@ "RefTableName": "lsif_uploads", "IsDeferrable": false, "ConstraintDefinition": "FOREIGN KEY (dump_id) REFERENCES lsif_uploads(id) ON DELETE CASCADE" + }, + { + "Name": "lsif_references_tenant_id_fkey", + "ConstraintType": "f", + "RefTableName": "tenants", + "IsDeferrable": false, + "ConstraintDefinition": "FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE" } ], "Triggers": [] @@ -17560,6 +19491,19 @@ "IsGenerated": "NEVER", "GenerationExpression": "", "Comment": "" + }, + { + "Name": "tenant_id", + "Index": 5, + "TypeName": "integer", + "IsNullable": true, + "Default": "", + "CharacterMaximumLength": 0, + "IsIdentity": false, + "IdentityGeneration": "", + "IsGenerated": "NEVER", + "GenerationExpression": "", + "Comment": "" } ], "Indexes": [ @@ -17591,6 +19535,13 @@ "RefTableName": "repo", "IsDeferrable": false, "ConstraintDefinition": "FOREIGN KEY (repository_id) REFERENCES repo(id) ON DELETE CASCADE" + }, + { + "Name": "lsif_retention_configuration_tenant_id_fkey", + "ConstraintType": "f", + "RefTableName": "tenants", + "IsDeferrable": false, + "ConstraintDefinition": "FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE" } ], "Triggers": [] @@ -17989,6 +19940,19 @@ "GenerationExpression": "", "Comment": "" }, + { + "Name": "tenant_id", + "Index": 36, + "TypeName": "integer", + "IsNullable": true, + "Default": "", + "CharacterMaximumLength": 0, + "IsIdentity": false, + "IdentityGeneration": "", + "IsGenerated": "NEVER", + "GenerationExpression": "", + "Comment": "" + }, { "Name": "uncompressed_size", "Index": 30, @@ -18164,6 +20128,13 @@ "RefTableName": "", "IsDeferrable": false, "ConstraintDefinition": "CHECK (commit ~ '^[a-z0-9]{40}$'::text)" + }, + { + "Name": "lsif_uploads_tenant_id_fkey", + "ConstraintType": "f", + "RefTableName": "tenants", + "IsDeferrable": false, + "ConstraintDefinition": "FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE" } ], "Triggers": [ @@ -18341,6 +20312,19 @@ "GenerationExpression": "", "Comment": "" }, + { + "Name": "tenant_id", + "Index": 18, + "TypeName": "integer", + "IsNullable": true, + "Default": "", + "CharacterMaximumLength": 0, + "IsIdentity": false, + "IdentityGeneration": "", + "IsGenerated": "NEVER", + "GenerationExpression": "", + "Comment": "" + }, { "Name": "transition_columns", "Index": 13, @@ -18416,7 +20400,15 @@ "ConstraintDefinition": "" } ], - "Constraints": null, + "Constraints": [ + { + "Name": "lsif_uploads_audit_logs_tenant_id_fkey", + "ConstraintType": "f", + "RefTableName": "tenants", + "IsDeferrable": false, + "ConstraintDefinition": "FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE" + } + ], "Triggers": [] }, { @@ -18436,6 +20428,19 @@ "GenerationExpression": "", "Comment": "The number of references to the associated upload from other records (via lsif_references)." }, + { + "Name": "tenant_id", + "Index": 3, + "TypeName": "integer", + "IsNullable": true, + "Default": "", + "CharacterMaximumLength": 0, + "IsIdentity": false, + "IdentityGeneration": "", + "IsGenerated": "NEVER", + "GenerationExpression": "", + "Comment": "" + }, { "Name": "upload_id", "Index": 1, @@ -18463,6 +20468,13 @@ } ], "Constraints": [ + { + "Name": "lsif_uploads_reference_counts_tenant_id_fkey", + "ConstraintType": "f", + "RefTableName": "tenants", + "IsDeferrable": false, + "ConstraintDefinition": "FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE" + }, { "Name": "lsif_uploads_reference_counts_upload_id_fk", "ConstraintType": "f", @@ -18516,6 +20528,19 @@ "GenerationExpression": "", "Comment": "" }, + { + "Name": "tenant_id", + "Index": 5, + "TypeName": "integer", + "IsNullable": true, + "Default": "", + "CharacterMaximumLength": 0, + "IsIdentity": false, + "IdentityGeneration": "", + "IsGenerated": "NEVER", + "GenerationExpression": "", + "Comment": "" + }, { "Name": "upload_id", "Index": 2, @@ -18552,7 +20577,15 @@ "ConstraintDefinition": "" } ], - "Constraints": null, + "Constraints": [ + { + "Name": "lsif_uploads_visible_at_tip_tenant_id_fkey", + "ConstraintType": "f", + "RefTableName": "tenants", + "IsDeferrable": false, + "ConstraintDefinition": "FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE" + } + ], "Triggers": [] }, { @@ -18585,6 +20618,19 @@ "GenerationExpression": "", "Comment": "" }, + { + "Name": "tenant_id", + "Index": 4, + "TypeName": "integer", + "IsNullable": true, + "Default": "", + "CharacterMaximumLength": 0, + "IsIdentity": false, + "IdentityGeneration": "", + "IsGenerated": "NEVER", + "GenerationExpression": "", + "Comment": "" + }, { "Name": "upload_id", "Index": 2, @@ -18628,6 +20674,13 @@ "RefTableName": "lsif_uploads", "IsDeferrable": false, "ConstraintDefinition": "FOREIGN KEY (upload_id) REFERENCES lsif_uploads(id) ON DELETE CASCADE" + }, + { + "Name": "lsif_uploads_vulnerability_scan_tenant_id_fkey", + "ConstraintType": "f", + "RefTableName": "tenants", + "IsDeferrable": false, + "ConstraintDefinition": "FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE" } ], "Triggers": [] @@ -18825,6 +20878,19 @@ "GenerationExpression": "", "Comment": "" }, + { + "Name": "tenant_id", + "Index": 5, + "TypeName": "integer", + "IsNullable": true, + "Default": "", + "CharacterMaximumLength": 0, + "IsIdentity": false, + "IdentityGeneration": "", + "IsGenerated": "NEVER", + "GenerationExpression": "", + "Comment": "" + }, { "Name": "user_id", "Index": 2, @@ -18873,6 +20939,13 @@ "IsDeferrable": false, "ConstraintDefinition": "FOREIGN KEY (team_id) REFERENCES teams(id) ON UPDATE CASCADE ON DELETE CASCADE" }, + { + "Name": "names_tenant_id_fkey", + "ConstraintType": "f", + "RefTableName": "tenants", + "IsDeferrable": false, + "ConstraintDefinition": "FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE" + }, { "Name": "names_user_id_fkey", "ConstraintType": "f", @@ -18939,6 +21012,19 @@ "GenerationExpression": "", "Comment": "" }, + { + "Name": "tenant_id", + "Index": 7, + "TypeName": "integer", + "IsNullable": true, + "Default": "", + "CharacterMaximumLength": 0, + "IsIdentity": false, + "IdentityGeneration": "", + "IsGenerated": "NEVER", + "GenerationExpression": "", + "Comment": "" + }, { "Name": "user_id", "Index": 5, @@ -18983,6 +21069,13 @@ "IsDeferrable": false, "ConstraintDefinition": "CHECK (namespace \u003c\u003e ''::text)" }, + { + "Name": "namespace_permissions_tenant_id_fkey", + "ConstraintType": "f", + "RefTableName": "tenants", + "IsDeferrable": false, + "ConstraintDefinition": "FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE" + }, { "Name": "namespace_permissions_user_id_fkey", "ConstraintType": "f", @@ -19023,6 +21116,19 @@ "GenerationExpression": "", "Comment": "" }, + { + "Name": "tenant_id", + "Index": 4, + "TypeName": "integer", + "IsNullable": true, + "Default": "", + "CharacterMaximumLength": 0, + "IsIdentity": false, + "IdentityGeneration": "", + "IsGenerated": "NEVER", + "GenerationExpression": "", + "Comment": "" + }, { "Name": "user_id", "Index": 2, @@ -19067,6 +21173,13 @@ "IsDeferrable": true, "ConstraintDefinition": "FOREIGN KEY (notebook_id) REFERENCES notebooks(id) ON DELETE CASCADE DEFERRABLE" }, + { + "Name": "notebook_stars_tenant_id_fkey", + "ConstraintType": "f", + "RefTableName": "tenants", + "IsDeferrable": false, + "ConstraintDefinition": "FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE" + }, { "Name": "notebook_stars_user_id_fkey", "ConstraintType": "f", @@ -19198,6 +21311,19 @@ "GenerationExpression": "", "Comment": "" }, + { + "Name": "tenant_id", + "Index": 13, + "TypeName": "integer", + "IsNullable": true, + "Default": "", + "CharacterMaximumLength": 0, + "IsIdentity": false, + "IdentityGeneration": "", + "IsGenerated": "NEVER", + "GenerationExpression": "", + "Comment": "" + }, { "Name": "title", "Index": 2, @@ -19326,6 +21452,13 @@ "IsDeferrable": true, "ConstraintDefinition": "FOREIGN KEY (namespace_user_id) REFERENCES users(id) ON DELETE SET NULL DEFERRABLE" }, + { + "Name": "notebooks_tenant_id_fkey", + "ConstraintType": "f", + "RefTableName": "tenants", + "IsDeferrable": false, + "ConstraintDefinition": "FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE" + }, { "Name": "notebooks_updater_user_id_fkey", "ConstraintType": "f", @@ -19495,6 +21628,19 @@ "IsGenerated": "NEVER", "GenerationExpression": "", "Comment": "" + }, + { + "Name": "tenant_id", + "Index": 13, + "TypeName": "integer", + "IsNullable": true, + "Default": "", + "CharacterMaximumLength": 0, + "IsIdentity": false, + "IdentityGeneration": "", + "IsGenerated": "NEVER", + "GenerationExpression": "", + "Comment": "" } ], "Indexes": [ @@ -19571,6 +21717,13 @@ "RefTableName": "users", "IsDeferrable": false, "ConstraintDefinition": "FOREIGN KEY (sender_user_id) REFERENCES users(id)" + }, + { + "Name": "org_invitations_tenant_id_fkey", + "ConstraintType": "f", + "RefTableName": "tenants", + "IsDeferrable": false, + "ConstraintDefinition": "FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE" } ], "Triggers": [] @@ -19618,6 +21771,19 @@ "GenerationExpression": "", "Comment": "" }, + { + "Name": "tenant_id", + "Index": 6, + "TypeName": "integer", + "IsNullable": true, + "Default": "", + "CharacterMaximumLength": 0, + "IsIdentity": false, + "IdentityGeneration": "", + "IsGenerated": "NEVER", + "GenerationExpression": "", + "Comment": "" + }, { "Name": "updated_at", "Index": 4, @@ -19675,6 +21841,13 @@ "IsDeferrable": false, "ConstraintDefinition": "FOREIGN KEY (org_id) REFERENCES orgs(id) ON DELETE RESTRICT" }, + { + "Name": "org_members_tenant_id_fkey", + "ConstraintType": "f", + "RefTableName": "tenants", + "IsDeferrable": false, + "ConstraintDefinition": "FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE" + }, { "Name": "org_members_user_id_fkey", "ConstraintType": "f", @@ -19715,6 +21888,19 @@ "GenerationExpression": "", "Comment": "Org ID that the stats relate to." }, + { + "Name": "tenant_id", + "Index": 4, + "TypeName": "integer", + "IsNullable": true, + "Default": "", + "CharacterMaximumLength": 0, + "IsIdentity": false, + "IdentityGeneration": "", + "IsGenerated": "NEVER", + "GenerationExpression": "", + "Comment": "" + }, { "Name": "updated_at", "Index": 3, @@ -19748,6 +21934,13 @@ "RefTableName": "orgs", "IsDeferrable": true, "ConstraintDefinition": "FOREIGN KEY (org_id) REFERENCES orgs(id) ON DELETE CASCADE DEFERRABLE" + }, + { + "Name": "org_stats_tenant_id_fkey", + "ConstraintType": "f", + "RefTableName": "tenants", + "IsDeferrable": false, + "ConstraintDefinition": "FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE" } ], "Triggers": [] @@ -19834,6 +22027,19 @@ "GenerationExpression": "", "Comment": "" }, + { + "Name": "tenant_id", + "Index": 8, + "TypeName": "integer", + "IsNullable": true, + "Default": "", + "CharacterMaximumLength": 0, + "IsIdentity": false, + "IdentityGeneration": "", + "IsGenerated": "NEVER", + "GenerationExpression": "", + "Comment": "" + }, { "Name": "updated_at", "Index": 4, @@ -19891,6 +22097,13 @@ "RefTableName": "", "IsDeferrable": false, "ConstraintDefinition": "CHECK (name ~ '^[a-zA-Z0-9](?:[a-zA-Z0-9]|[-.](?=[a-zA-Z0-9]))*-?$'::citext)" + }, + { + "Name": "orgs_tenant_id_fkey", + "ConstraintType": "f", + "RefTableName": "tenants", + "IsDeferrable": false, + "ConstraintDefinition": "FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE" } ], "Triggers": [] @@ -19951,6 +22164,19 @@ "GenerationExpression": "", "Comment": "" }, + { + "Name": "tenant_id", + "Index": 6, + "TypeName": "integer", + "IsNullable": true, + "Default": "", + "CharacterMaximumLength": 0, + "IsIdentity": false, + "IdentityGeneration": "", + "IsGenerated": "NEVER", + "GenerationExpression": "", + "Comment": "" + }, { "Name": "user_id", "Index": 2, @@ -19977,7 +22203,15 @@ "ConstraintDefinition": "PRIMARY KEY (id)" } ], - "Constraints": null, + "Constraints": [ + { + "Name": "orgs_open_beta_stats_tenant_id_fkey", + "ConstraintType": "f", + "RefTableName": "tenants", + "IsDeferrable": false, + "ConstraintDefinition": "FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE" + } + ], "Triggers": [] }, { @@ -20178,6 +22412,19 @@ "IsGenerated": "NEVER", "GenerationExpression": "", "Comment": "The name of the engineering team responsible for the migration." + }, + { + "Name": "tenant_id", + "Index": 16, + "TypeName": "integer", + "IsNullable": true, + "Default": "", + "CharacterMaximumLength": 0, + "IsIdentity": false, + "IdentityGeneration": "", + "IsGenerated": "NEVER", + "GenerationExpression": "", + "Comment": "" } ], "Indexes": [ @@ -20220,6 +22467,13 @@ "RefTableName": "", "IsDeferrable": false, "ConstraintDefinition": "CHECK (team \u003c\u003e ''::text)" + }, + { + "Name": "out_of_band_migrations_tenant_id_fkey", + "ConstraintType": "f", + "RefTableName": "tenants", + "IsDeferrable": false, + "ConstraintDefinition": "FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE" } ], "Triggers": [] @@ -20279,6 +22533,19 @@ "IsGenerated": "NEVER", "GenerationExpression": "", "Comment": "The identifier of the migration." + }, + { + "Name": "tenant_id", + "Index": 5, + "TypeName": "integer", + "IsNullable": true, + "Default": "", + "CharacterMaximumLength": 0, + "IsIdentity": false, + "IdentityGeneration": "", + "IsGenerated": "NEVER", + "GenerationExpression": "", + "Comment": "" } ], "Indexes": [ @@ -20307,6 +22574,13 @@ "RefTableName": "out_of_band_migrations", "IsDeferrable": false, "ConstraintDefinition": "FOREIGN KEY (migration_id) REFERENCES out_of_band_migrations(id) ON DELETE CASCADE" + }, + { + "Name": "out_of_band_migrations_errors_tenant_id_fkey", + "ConstraintType": "f", + "RefTableName": "tenants", + "IsDeferrable": false, + "ConstraintDefinition": "FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE" } ], "Triggers": [] @@ -20366,6 +22640,19 @@ "IsGenerated": "NEVER", "GenerationExpression": "", "Comment": "" + }, + { + "Name": "tenant_id", + "Index": 5, + "TypeName": "integer", + "IsNullable": true, + "Default": "", + "CharacterMaximumLength": 0, + "IsIdentity": false, + "IdentityGeneration": "", + "IsGenerated": "NEVER", + "GenerationExpression": "", + "Comment": "" } ], "Indexes": [ @@ -20397,6 +22684,13 @@ "RefTableName": "outbound_webhooks", "IsDeferrable": false, "ConstraintDefinition": "FOREIGN KEY (outbound_webhook_id) REFERENCES outbound_webhooks(id) ON UPDATE CASCADE ON DELETE CASCADE" + }, + { + "Name": "outbound_webhook_event_types_tenant_id_fkey", + "ConstraintType": "f", + "RefTableName": "tenants", + "IsDeferrable": false, + "ConstraintDefinition": "FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE" } ], "Triggers": [] @@ -20613,6 +22907,19 @@ "GenerationExpression": "", "Comment": "" }, + { + "Name": "tenant_id", + "Index": 18, + "TypeName": "integer", + "IsNullable": true, + "Default": "", + "CharacterMaximumLength": 0, + "IsIdentity": false, + "IdentityGeneration": "", + "IsGenerated": "NEVER", + "GenerationExpression": "", + "Comment": "" + }, { "Name": "worker_hostname", "Index": 16, @@ -20659,7 +22966,15 @@ "ConstraintDefinition": "" } ], - "Constraints": null, + "Constraints": [ + { + "Name": "outbound_webhook_jobs_tenant_id_fkey", + "ConstraintType": "f", + "RefTableName": "tenants", + "IsDeferrable": false, + "ConstraintDefinition": "FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE" + } + ], "Triggers": [] }, { @@ -20782,6 +23097,19 @@ "IsGenerated": "NEVER", "GenerationExpression": "", "Comment": "" + }, + { + "Name": "tenant_id", + "Index": 10, + "TypeName": "integer", + "IsNullable": true, + "Default": "", + "CharacterMaximumLength": 0, + "IsIdentity": false, + "IdentityGeneration": "", + "IsGenerated": "NEVER", + "GenerationExpression": "", + "Comment": "" } ], "Indexes": [ @@ -20830,6 +23158,13 @@ "RefTableName": "outbound_webhooks", "IsDeferrable": false, "ConstraintDefinition": "FOREIGN KEY (outbound_webhook_id) REFERENCES outbound_webhooks(id) ON UPDATE CASCADE ON DELETE CASCADE" + }, + { + "Name": "outbound_webhook_logs_tenant_id_fkey", + "ConstraintType": "f", + "RefTableName": "tenants", + "IsDeferrable": false, + "ConstraintDefinition": "FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE" } ], "Triggers": [] @@ -20903,6 +23238,19 @@ "GenerationExpression": "", "Comment": "" }, + { + "Name": "tenant_id", + "Index": 9, + "TypeName": "integer", + "IsNullable": true, + "Default": "", + "CharacterMaximumLength": 0, + "IsIdentity": false, + "IdentityGeneration": "", + "IsGenerated": "NEVER", + "GenerationExpression": "", + "Comment": "" + }, { "Name": "updated_at", "Index": 5, @@ -20963,6 +23311,13 @@ "IsDeferrable": false, "ConstraintDefinition": "FOREIGN KEY (created_by) REFERENCES users(id) ON DELETE SET NULL" }, + { + "Name": "outbound_webhooks_tenant_id_fkey", + "ConstraintType": "f", + "RefTableName": "tenants", + "IsDeferrable": false, + "ConstraintDefinition": "FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE" + }, { "Name": "outbound_webhooks_updated_by_fkey", "ConstraintType": "f", @@ -21028,6 +23383,19 @@ "IsGenerated": "NEVER", "GenerationExpression": "", "Comment": "" + }, + { + "Name": "tenant_id", + "Index": 5, + "TypeName": "integer", + "IsNullable": true, + "Default": "", + "CharacterMaximumLength": 0, + "IsIdentity": false, + "IdentityGeneration": "", + "IsGenerated": "NEVER", + "GenerationExpression": "", + "Comment": "" } ], "Indexes": [ @@ -21066,6 +23434,13 @@ "RefTableName": "commit_authors", "IsDeferrable": false, "ConstraintDefinition": "FOREIGN KEY (commit_author_id) REFERENCES commit_authors(id)" + }, + { + "Name": "own_aggregate_recent_contribution_tenant_id_fkey", + "ConstraintType": "f", + "RefTableName": "tenants", + "IsDeferrable": false, + "ConstraintDefinition": "FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE" } ], "Triggers": [] @@ -21087,6 +23462,19 @@ "GenerationExpression": "", "Comment": "" }, + { + "Name": "tenant_id", + "Index": 5, + "TypeName": "integer", + "IsNullable": true, + "Default": "", + "CharacterMaximumLength": 0, + "IsIdentity": false, + "IdentityGeneration": "", + "IsGenerated": "NEVER", + "GenerationExpression": "", + "Comment": "" + }, { "Name": "viewed_file_path_id", "Index": 3, @@ -21150,6 +23538,13 @@ } ], "Constraints": [ + { + "Name": "own_aggregate_recent_view_tenant_id_fkey", + "ConstraintType": "f", + "RefTableName": "tenants", + "IsDeferrable": false, + "ConstraintDefinition": "FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE" + }, { "Name": "own_aggregate_recent_view_viewed_file_path_id_fkey", "ConstraintType": "f", @@ -21353,6 +23748,19 @@ "GenerationExpression": "", "Comment": "" }, + { + "Name": "tenant_id", + "Index": 16, + "TypeName": "integer", + "IsNullable": true, + "Default": "", + "CharacterMaximumLength": 0, + "IsIdentity": false, + "IdentityGeneration": "", + "IsGenerated": "NEVER", + "GenerationExpression": "", + "Comment": "" + }, { "Name": "worker_hostname", "Index": 12, @@ -21399,7 +23807,15 @@ "ConstraintDefinition": "" } ], - "Constraints": null, + "Constraints": [ + { + "Name": "own_background_jobs_tenant_id_fkey", + "ConstraintType": "f", + "RefTableName": "tenants", + "IsDeferrable": false, + "ConstraintDefinition": "FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE" + } + ], "Triggers": [] }, { @@ -21470,6 +23886,19 @@ "IsGenerated": "NEVER", "GenerationExpression": "", "Comment": "" + }, + { + "Name": "tenant_id", + "Index": 6, + "TypeName": "integer", + "IsNullable": true, + "Default": "", + "CharacterMaximumLength": 0, + "IsIdentity": false, + "IdentityGeneration": "", + "IsGenerated": "NEVER", + "GenerationExpression": "", + "Comment": "" } ], "Indexes": [ @@ -21494,7 +23923,15 @@ "ConstraintDefinition": "PRIMARY KEY (id)" } ], - "Constraints": null, + "Constraints": [ + { + "Name": "own_signal_configurations_tenant_id_fkey", + "ConstraintType": "f", + "RefTableName": "tenants", + "IsDeferrable": false, + "ConstraintDefinition": "FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE" + } + ], "Triggers": [] }, { @@ -21565,6 +24002,19 @@ "IsGenerated": "NEVER", "GenerationExpression": "", "Comment": "" + }, + { + "Name": "tenant_id", + "Index": 6, + "TypeName": "integer", + "IsNullable": true, + "Default": "", + "CharacterMaximumLength": 0, + "IsIdentity": false, + "IdentityGeneration": "", + "IsGenerated": "NEVER", + "GenerationExpression": "", + "Comment": "" } ], "Indexes": [ @@ -21593,6 +24043,13 @@ "RefTableName": "commit_authors", "IsDeferrable": false, "ConstraintDefinition": "FOREIGN KEY (commit_author_id) REFERENCES commit_authors(id)" + }, + { + "Name": "own_signal_recent_contribution_tenant_id_fkey", + "ConstraintType": "f", + "RefTableName": "tenants", + "IsDeferrable": false, + "ConstraintDefinition": "FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE" } ], "Triggers": [ @@ -21632,6 +24089,19 @@ "GenerationExpression": "", "Comment": "When the last background job updating counts run." }, + { + "Name": "tenant_id", + "Index": 6, + "TypeName": "integer", + "IsNullable": true, + "Default": "", + "CharacterMaximumLength": 0, + "IsIdentity": false, + "IdentityGeneration": "", + "IsGenerated": "NEVER", + "GenerationExpression": "", + "Comment": "" + }, { "Name": "tree_any_ownership_files_count", "Index": 5, @@ -21691,6 +24161,13 @@ "RefTableName": "repo_paths", "IsDeferrable": false, "ConstraintDefinition": "FOREIGN KEY (file_path_id) REFERENCES repo_paths(id)" + }, + { + "Name": "ownership_path_stats_tenant_id_fkey", + "ConstraintType": "f", + "RefTableName": "tenants", + "IsDeferrable": false, + "ConstraintDefinition": "FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE" } ], "Triggers": [] @@ -21764,6 +24241,19 @@ "GenerationExpression": "", "Comment": "" }, + { + "Name": "tenant_id", + "Index": 7, + "TypeName": "integer", + "IsNullable": true, + "Default": "", + "CharacterMaximumLength": 0, + "IsIdentity": false, + "IdentityGeneration": "", + "IsGenerated": "NEVER", + "GenerationExpression": "", + "Comment": "" + }, { "Name": "updated_at", "Index": 6, @@ -21815,6 +24305,13 @@ "IsDeferrable": false, "ConstraintDefinition": "CHECK (scheme = ANY ('{semanticdb,npm,go,python,rust-analyzer,scip-ruby}'::text[]))" }, + { + "Name": "package_repo_filters_tenant_id_fkey", + "ConstraintType": "f", + "RefTableName": "tenants", + "IsDeferrable": false, + "ConstraintDefinition": "FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE" + }, { "Name": "package_repo_filters_valid_oneof_glob", "ConstraintType": "c", @@ -21886,6 +24383,19 @@ "GenerationExpression": "", "Comment": "" }, + { + "Name": "tenant_id", + "Index": 6, + "TypeName": "integer", + "IsNullable": true, + "Default": "", + "CharacterMaximumLength": 0, + "IsIdentity": false, + "IdentityGeneration": "", + "IsGenerated": "NEVER", + "GenerationExpression": "", + "Comment": "" + }, { "Name": "version", "Index": 3, @@ -21949,6 +24459,13 @@ "RefTableName": "lsif_dependency_repos", "IsDeferrable": false, "ConstraintDefinition": "FOREIGN KEY (package_id) REFERENCES lsif_dependency_repos(id) ON DELETE CASCADE" + }, + { + "Name": "package_repo_versions_tenant_id_fkey", + "ConstraintType": "f", + "RefTableName": "tenants", + "IsDeferrable": false, + "ConstraintDefinition": "FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE" } ], "Triggers": [] @@ -22256,6 +24773,19 @@ "GenerationExpression": "", "Comment": "" }, + { + "Name": "tenant_id", + "Index": 27, + "TypeName": "integer", + "IsNullable": true, + "Default": "", + "CharacterMaximumLength": 0, + "IsIdentity": false, + "IdentityGeneration": "", + "IsGenerated": "NEVER", + "GenerationExpression": "", + "Comment": "" + }, { "Name": "triggered_by_user_id", "Index": 17, @@ -22373,6 +24903,13 @@ "IsDeferrable": false, "ConstraintDefinition": "FOREIGN KEY (repository_id) REFERENCES repo(id) ON DELETE CASCADE" }, + { + "Name": "permission_sync_jobs_tenant_id_fkey", + "ConstraintType": "f", + "RefTableName": "tenants", + "IsDeferrable": false, + "ConstraintDefinition": "FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE" + }, { "Name": "permission_sync_jobs_triggered_by_user_id_fkey", "ConstraintType": "f", @@ -22445,6 +24982,19 @@ "IsGenerated": "NEVER", "GenerationExpression": "", "Comment": "" + }, + { + "Name": "tenant_id", + "Index": 5, + "TypeName": "integer", + "IsNullable": true, + "Default": "", + "CharacterMaximumLength": 0, + "IsIdentity": false, + "IdentityGeneration": "", + "IsGenerated": "NEVER", + "GenerationExpression": "", + "Comment": "" } ], "Indexes": [ @@ -22483,6 +25033,13 @@ "RefTableName": "", "IsDeferrable": false, "ConstraintDefinition": "CHECK (namespace \u003c\u003e ''::text)" + }, + { + "Name": "permissions_tenant_id_fkey", + "ConstraintType": "f", + "RefTableName": "tenants", + "IsDeferrable": false, + "ConstraintDefinition": "FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE" } ], "Triggers": [] @@ -22556,6 +25113,19 @@ "GenerationExpression": "", "Comment": "" }, + { + "Name": "tenant_id", + "Index": 8, + "TypeName": "integer", + "IsNullable": true, + "Default": "", + "CharacterMaximumLength": 0, + "IsIdentity": false, + "IdentityGeneration": "", + "IsGenerated": "NEVER", + "GenerationExpression": "", + "Comment": "" + }, { "Name": "updated_at", "Index": 5, @@ -22605,7 +25175,15 @@ "ConstraintDefinition": "UNIQUE (repo_name)" } ], - "Constraints": null, + "Constraints": [ + { + "Name": "phabricator_repos_tenant_id_fkey", + "ConstraintType": "f", + "RefTableName": "tenants", + "IsDeferrable": false, + "ConstraintDefinition": "FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE" + } + ], "Triggers": [] }, { @@ -22806,6 +25384,19 @@ "IsGenerated": "NEVER", "GenerationExpression": "", "Comment": "" + }, + { + "Name": "tenant_id", + "Index": 16, + "TypeName": "integer", + "IsNullable": true, + "Default": "", + "CharacterMaximumLength": 0, + "IsIdentity": false, + "IdentityGeneration": "", + "IsGenerated": "NEVER", + "GenerationExpression": "", + "Comment": "" } ], "Indexes": [ @@ -22837,6 +25428,13 @@ "RefTableName": "product_subscriptions", "IsDeferrable": false, "ConstraintDefinition": "FOREIGN KEY (product_subscription_id) REFERENCES product_subscriptions(id)" + }, + { + "Name": "product_licenses_tenant_id_fkey", + "ConstraintType": "f", + "RefTableName": "tenants", + "IsDeferrable": false, + "ConstraintDefinition": "FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE" } ], "Triggers": [] @@ -23040,6 +25638,19 @@ "GenerationExpression": "", "Comment": "" }, + { + "Name": "tenant_id", + "Index": 18, + "TypeName": "integer", + "IsNullable": true, + "Default": "", + "CharacterMaximumLength": 0, + "IsIdentity": false, + "IdentityGeneration": "", + "IsGenerated": "NEVER", + "GenerationExpression": "", + "Comment": "" + }, { "Name": "updated_at", "Index": 5, @@ -23080,6 +25691,13 @@ } ], "Constraints": [ + { + "Name": "product_subscriptions_tenant_id_fkey", + "ConstraintType": "f", + "RefTableName": "tenants", + "IsDeferrable": false, + "ConstraintDefinition": "FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE" + }, { "Name": "product_subscriptions_user_id_fkey", "ConstraintType": "f", @@ -23211,6 +25829,19 @@ "GenerationExpression": "", "Comment": "" }, + { + "Name": "tenant_id", + "Index": 13, + "TypeName": "integer", + "IsNullable": true, + "Default": "", + "CharacterMaximumLength": 0, + "IsIdentity": false, + "IdentityGeneration": "", + "IsGenerated": "NEVER", + "GenerationExpression": "", + "Comment": "" + }, { "Name": "updated_at", "Index": 12, @@ -23340,6 +25971,13 @@ "IsDeferrable": false, "ConstraintDefinition": "FOREIGN KEY (owner_user_id) REFERENCES users(id) ON DELETE CASCADE" }, + { + "Name": "prompts_tenant_id_fkey", + "ConstraintType": "f", + "RefTableName": "tenants", + "IsDeferrable": false, + "ConstraintDefinition": "FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE" + }, { "Name": "prompts_updated_by_fkey", "ConstraintType": "f", @@ -23405,10 +26043,31 @@ "IsGenerated": "NEVER", "GenerationExpression": "", "Comment": "" + }, + { + "Name": "tenant_id", + "Index": 5, + "TypeName": "integer", + "IsNullable": true, + "Default": "", + "CharacterMaximumLength": 0, + "IsIdentity": false, + "IdentityGeneration": "", + "IsGenerated": "NEVER", + "GenerationExpression": "", + "Comment": "" } ], "Indexes": [], - "Constraints": null, + "Constraints": [ + { + "Name": "query_runner_state_tenant_id_fkey", + "ConstraintType": "f", + "RefTableName": "tenants", + "IsDeferrable": false, + "ConstraintDefinition": "FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE" + } + ], "Triggers": [] }, { @@ -23441,6 +26100,19 @@ "GenerationExpression": "", "Comment": "" }, + { + "Name": "tenant_id", + "Index": 4, + "TypeName": "integer", + "IsNullable": true, + "Default": "", + "CharacterMaximumLength": 0, + "IsIdentity": false, + "IdentityGeneration": "", + "IsGenerated": "NEVER", + "GenerationExpression": "", + "Comment": "" + }, { "Name": "value", "Index": 3, @@ -23467,7 +26139,15 @@ "ConstraintDefinition": "PRIMARY KEY (namespace, key) INCLUDE (value)" } ], - "Constraints": null, + "Constraints": [ + { + "Name": "redis_key_value_tenant_id_fkey", + "ConstraintType": "f", + "RefTableName": "tenants", + "IsDeferrable": false, + "ConstraintDefinition": "FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE" + } + ], "Triggers": [] }, { @@ -23603,6 +26283,19 @@ "IsGenerated": "NEVER", "GenerationExpression": "", "Comment": "" + }, + { + "Name": "tenant_id", + "Index": 11, + "TypeName": "integer", + "IsNullable": true, + "Default": "", + "CharacterMaximumLength": 0, + "IsIdentity": false, + "IdentityGeneration": "", + "IsGenerated": "NEVER", + "GenerationExpression": "", + "Comment": "" } ], "Indexes": [ @@ -23661,6 +26354,13 @@ "RefTableName": "registry_extensions", "IsDeferrable": false, "ConstraintDefinition": "FOREIGN KEY (registry_extension_id) REFERENCES registry_extensions(id) ON UPDATE CASCADE ON DELETE CASCADE" + }, + { + "Name": "registry_extension_releases_tenant_id_fkey", + "ConstraintType": "f", + "RefTableName": "tenants", + "IsDeferrable": false, + "ConstraintDefinition": "FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE" } ], "Triggers": [] @@ -23760,6 +26460,19 @@ "GenerationExpression": "", "Comment": "" }, + { + "Name": "tenant_id", + "Index": 10, + "TypeName": "integer", + "IsNullable": true, + "Default": "", + "CharacterMaximumLength": 0, + "IsIdentity": false, + "IdentityGeneration": "", + "IsGenerated": "NEVER", + "GenerationExpression": "", + "Comment": "" + }, { "Name": "updated_at", "Index": 8, @@ -23854,6 +26567,13 @@ "RefTableName": "", "IsDeferrable": false, "ConstraintDefinition": "CHECK ((publisher_user_id IS NULL) \u003c\u003e (publisher_org_id IS NULL))" + }, + { + "Name": "registry_extensions_tenant_id_fkey", + "ConstraintType": "f", + "RefTableName": "tenants", + "IsDeferrable": false, + "ConstraintDefinition": "FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE" } ], "Triggers": [] @@ -24044,6 +26764,19 @@ "GenerationExpression": "", "Comment": "" }, + { + "Name": "tenant_id", + "Index": 18, + "TypeName": "integer", + "IsNullable": true, + "Default": "", + "CharacterMaximumLength": 0, + "IsIdentity": false, + "IdentityGeneration": "", + "IsGenerated": "NEVER", + "GenerationExpression": "", + "Comment": "" + }, { "Name": "topics", "Index": 17, @@ -24310,6 +27043,13 @@ "RefTableName": "", "IsDeferrable": false, "ConstraintDefinition": "CHECK (jsonb_typeof(metadata) = 'object'::text)" + }, + { + "Name": "repo_tenant_id_fkey", + "ConstraintType": "f", + "RefTableName": "tenants", + "IsDeferrable": false, + "ConstraintDefinition": "FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE" } ], "Triggers": [ @@ -24411,6 +27151,19 @@ "IsGenerated": "NEVER", "GenerationExpression": "", "Comment": "" + }, + { + "Name": "tenant_id", + "Index": 6, + "TypeName": "integer", + "IsNullable": true, + "Default": "", + "CharacterMaximumLength": 0, + "IsIdentity": false, + "IdentityGeneration": "", + "IsGenerated": "NEVER", + "GenerationExpression": "", + "Comment": "" } ], "Indexes": [ @@ -24442,6 +27195,13 @@ "RefTableName": "repo", "IsDeferrable": true, "ConstraintDefinition": "FOREIGN KEY (repo_id) REFERENCES repo(id) ON DELETE CASCADE DEFERRABLE" + }, + { + "Name": "repo_commits_changelists_tenant_id_fkey", + "ConstraintType": "f", + "RefTableName": "tenants", + "IsDeferrable": false, + "ConstraintDefinition": "FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE" } ], "Triggers": [] @@ -24554,6 +27314,19 @@ "GenerationExpression": "", "Comment": "" }, + { + "Name": "tenant_id", + "Index": 15, + "TypeName": "integer", + "IsNullable": true, + "Default": "", + "CharacterMaximumLength": 0, + "IsIdentity": false, + "IdentityGeneration": "", + "IsGenerated": "NEVER", + "GenerationExpression": "", + "Comment": "" + }, { "Name": "text_bytes_embedded", "Index": 12, @@ -24652,6 +27425,13 @@ "RefTableName": "repo_embedding_jobs", "IsDeferrable": true, "ConstraintDefinition": "FOREIGN KEY (job_id) REFERENCES repo_embedding_jobs(id) ON DELETE CASCADE DEFERRABLE" + }, + { + "Name": "repo_embedding_job_stats_tenant_id_fkey", + "ConstraintType": "f", + "RefTableName": "tenants", + "IsDeferrable": false, + "ConstraintDefinition": "FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE" } ], "Triggers": [] @@ -24842,6 +27622,19 @@ "GenerationExpression": "", "Comment": "" }, + { + "Name": "tenant_id", + "Index": 16, + "TypeName": "integer", + "IsNullable": true, + "Default": "", + "CharacterMaximumLength": 0, + "IsIdentity": false, + "IdentityGeneration": "", + "IsGenerated": "NEVER", + "GenerationExpression": "", + "Comment": "" + }, { "Name": "worker_hostname", "Index": 12, @@ -24878,7 +27671,15 @@ "ConstraintDefinition": "" } ], - "Constraints": null, + "Constraints": [ + { + "Name": "repo_embedding_jobs_tenant_id_fkey", + "ConstraintType": "f", + "RefTableName": "tenants", + "IsDeferrable": false, + "ConstraintDefinition": "FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE" + } + ], "Triggers": [] }, { @@ -24911,6 +27712,19 @@ "GenerationExpression": "", "Comment": "" }, + { + "Name": "tenant_id", + "Index": 4, + "TypeName": "integer", + "IsNullable": true, + "Default": "", + "CharacterMaximumLength": 0, + "IsIdentity": false, + "IdentityGeneration": "", + "IsGenerated": "NEVER", + "GenerationExpression": "", + "Comment": "" + }, { "Name": "value", "Index": 3, @@ -24954,6 +27768,13 @@ "RefTableName": "repo", "IsDeferrable": false, "ConstraintDefinition": "FOREIGN KEY (repo_id) REFERENCES repo(id) ON DELETE CASCADE" + }, + { + "Name": "repo_kvps_tenant_id_fkey", + "ConstraintType": "f", + "RefTableName": "tenants", + "IsDeferrable": false, + "ConstraintDefinition": "FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE" } ], "Triggers": [] @@ -25014,6 +27835,19 @@ "GenerationExpression": "", "Comment": "" }, + { + "Name": "tenant_id", + "Index": 7, + "TypeName": "integer", + "IsNullable": true, + "Default": "", + "CharacterMaximumLength": 0, + "IsIdentity": false, + "IdentityGeneration": "", + "IsGenerated": "NEVER", + "GenerationExpression": "", + "Comment": "" + }, { "Name": "tree_files_count", "Index": 5, @@ -25077,6 +27911,13 @@ "RefTableName": "repo", "IsDeferrable": true, "ConstraintDefinition": "FOREIGN KEY (repo_id) REFERENCES repo(id) ON DELETE CASCADE DEFERRABLE" + }, + { + "Name": "repo_paths_tenant_id_fkey", + "ConstraintType": "f", + "RefTableName": "tenants", + "IsDeferrable": false, + "ConstraintDefinition": "FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE" } ], "Triggers": [] @@ -25111,6 +27952,19 @@ "GenerationExpression": "", "Comment": "" }, + { + "Name": "tenant_id", + "Index": 5, + "TypeName": "integer", + "IsNullable": true, + "Default": "", + "CharacterMaximumLength": 0, + "IsIdentity": false, + "IdentityGeneration": "", + "IsGenerated": "NEVER", + "GenerationExpression": "", + "Comment": "" + }, { "Name": "updated_at", "Index": 3, @@ -25150,7 +28004,15 @@ "ConstraintDefinition": "UNIQUE (repo_id, permission)" } ], - "Constraints": null, + "Constraints": [ + { + "Name": "repo_pending_permissions_tenant_id_fkey", + "ConstraintType": "f", + "RefTableName": "tenants", + "IsDeferrable": false, + "ConstraintDefinition": "FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE" + } + ], "Triggers": [] }, { @@ -25196,6 +28058,19 @@ "GenerationExpression": "", "Comment": "" }, + { + "Name": "tenant_id", + "Index": 7, + "TypeName": "integer", + "IsNullable": true, + "Default": "", + "CharacterMaximumLength": 0, + "IsIdentity": false, + "IdentityGeneration": "", + "IsGenerated": "NEVER", + "GenerationExpression": "", + "Comment": "" + }, { "Name": "unrestricted", "Index": 6, @@ -25258,7 +28133,15 @@ "ConstraintDefinition": "" } ], - "Constraints": null, + "Constraints": [ + { + "Name": "repo_permissions_tenant_id_fkey", + "ConstraintType": "f", + "RefTableName": "tenants", + "IsDeferrable": false, + "ConstraintDefinition": "FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE" + } + ], "Triggers": [] }, { @@ -25343,6 +28226,19 @@ "GenerationExpression": "", "Comment": "Number of repositories that are soft-deleted and not blocked" }, + { + "Name": "tenant_id", + "Index": 8, + "TypeName": "integer", + "IsNullable": true, + "Default": "", + "CharacterMaximumLength": 0, + "IsIdentity": false, + "IdentityGeneration": "", + "IsGenerated": "NEVER", + "GenerationExpression": "", + "Comment": "" + }, { "Name": "total", "Index": 1, @@ -25358,7 +28254,15 @@ } ], "Indexes": [], - "Constraints": null, + "Constraints": [ + { + "Name": "repo_statistics_tenant_id_fkey", + "ConstraintType": "f", + "RefTableName": "tenants", + "IsDeferrable": false, + "ConstraintDefinition": "FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE" + } + ], "Triggers": [] }, { @@ -25403,6 +28307,19 @@ "IsGenerated": "NEVER", "GenerationExpression": "", "Comment": "" + }, + { + "Name": "tenant_id", + "Index": 4, + "TypeName": "integer", + "IsNullable": true, + "Default": "", + "CharacterMaximumLength": 0, + "IsIdentity": false, + "IdentityGeneration": "", + "IsGenerated": "NEVER", + "GenerationExpression": "", + "Comment": "" } ], "Indexes": [ @@ -25431,6 +28348,13 @@ "RefTableName": "roles", "IsDeferrable": true, "ConstraintDefinition": "FOREIGN KEY (role_id) REFERENCES roles(id) ON DELETE CASCADE DEFERRABLE" + }, + { + "Name": "role_permissions_tenant_id_fkey", + "ConstraintType": "f", + "RefTableName": "tenants", + "IsDeferrable": false, + "ConstraintDefinition": "FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE" } ], "Triggers": [] @@ -25490,6 +28414,19 @@ "IsGenerated": "NEVER", "GenerationExpression": "", "Comment": "This is used to indicate whether a role is read-only or can be modified." + }, + { + "Name": "tenant_id", + "Index": 7, + "TypeName": "integer", + "IsNullable": true, + "Default": "", + "CharacterMaximumLength": 0, + "IsIdentity": false, + "IdentityGeneration": "", + "IsGenerated": "NEVER", + "GenerationExpression": "", + "Comment": "" } ], "Indexes": [ @@ -25514,7 +28451,15 @@ "ConstraintDefinition": "" } ], - "Constraints": null, + "Constraints": [ + { + "Name": "roles_tenant_id_fkey", + "ConstraintType": "f", + "RefTableName": "tenants", + "IsDeferrable": false, + "ConstraintDefinition": "FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE" + } + ], "Triggers": [] }, { @@ -25651,6 +28596,19 @@ "GenerationExpression": "", "Comment": "" }, + { + "Name": "tenant_id", + "Index": 15, + "TypeName": "integer", + "IsNullable": true, + "Default": "", + "CharacterMaximumLength": 0, + "IsIdentity": false, + "IdentityGeneration": "", + "IsGenerated": "NEVER", + "GenerationExpression": "", + "Comment": "" + }, { "Name": "updated_at", "Index": 5, @@ -25738,6 +28696,13 @@ "IsDeferrable": false, "ConstraintDefinition": "FOREIGN KEY (org_id) REFERENCES orgs(id)" }, + { + "Name": "saved_searches_tenant_id_fkey", + "ConstraintType": "f", + "RefTableName": "tenants", + "IsDeferrable": false, + "ConstraintDefinition": "FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE" + }, { "Name": "saved_searches_updated_by_fkey", "ConstraintType": "f", @@ -25779,6 +28744,19 @@ "GenerationExpression": "", "Comment": "" }, + { + "Name": "tenant_id", + "Index": 3, + "TypeName": "integer", + "IsNullable": true, + "Default": "", + "CharacterMaximumLength": 0, + "IsIdentity": false, + "IdentityGeneration": "", + "IsGenerated": "NEVER", + "GenerationExpression": "", + "Comment": "" + }, { "Name": "user_id", "Index": 1, @@ -25813,6 +28791,13 @@ "IsDeferrable": true, "ConstraintDefinition": "FOREIGN KEY (search_context_id) REFERENCES search_contexts(id) ON DELETE CASCADE DEFERRABLE" }, + { + "Name": "search_context_default_tenant_id_fkey", + "ConstraintType": "f", + "RefTableName": "tenants", + "IsDeferrable": false, + "ConstraintDefinition": "FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE" + }, { "Name": "search_context_default_user_id_fkey", "ConstraintType": "f", @@ -25865,6 +28850,19 @@ "IsGenerated": "NEVER", "GenerationExpression": "", "Comment": "" + }, + { + "Name": "tenant_id", + "Index": 4, + "TypeName": "integer", + "IsNullable": true, + "Default": "", + "CharacterMaximumLength": 0, + "IsIdentity": false, + "IdentityGeneration": "", + "IsGenerated": "NEVER", + "GenerationExpression": "", + "Comment": "" } ], "Indexes": [ @@ -25893,6 +28891,13 @@ "RefTableName": "search_contexts", "IsDeferrable": false, "ConstraintDefinition": "FOREIGN KEY (search_context_id) REFERENCES search_contexts(id) ON DELETE CASCADE" + }, + { + "Name": "search_context_repos_tenant_id_fkey", + "ConstraintType": "f", + "RefTableName": "tenants", + "IsDeferrable": false, + "ConstraintDefinition": "FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE" } ], "Triggers": [] @@ -25927,6 +28932,19 @@ "GenerationExpression": "", "Comment": "" }, + { + "Name": "tenant_id", + "Index": 4, + "TypeName": "integer", + "IsNullable": true, + "Default": "", + "CharacterMaximumLength": 0, + "IsIdentity": false, + "IdentityGeneration": "", + "IsGenerated": "NEVER", + "GenerationExpression": "", + "Comment": "" + }, { "Name": "user_id", "Index": 2, @@ -25961,6 +28979,13 @@ "IsDeferrable": true, "ConstraintDefinition": "FOREIGN KEY (search_context_id) REFERENCES search_contexts(id) ON DELETE CASCADE DEFERRABLE" }, + { + "Name": "search_context_stars_tenant_id_fkey", + "ConstraintType": "f", + "RefTableName": "tenants", + "IsDeferrable": false, + "ConstraintDefinition": "FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE" + }, { "Name": "search_context_stars_user_id_fkey", "ConstraintType": "f", @@ -26092,6 +29117,19 @@ "GenerationExpression": "", "Comment": "" }, + { + "Name": "tenant_id", + "Index": 11, + "TypeName": "integer", + "IsNullable": true, + "Default": "", + "CharacterMaximumLength": 0, + "IsIdentity": false, + "IdentityGeneration": "", + "IsGenerated": "NEVER", + "GenerationExpression": "", + "Comment": "" + }, { "Name": "updated_at", "Index": 8, @@ -26179,6 +29217,13 @@ "RefTableName": "users", "IsDeferrable": false, "ConstraintDefinition": "FOREIGN KEY (namespace_user_id) REFERENCES users(id) ON DELETE CASCADE" + }, + { + "Name": "search_contexts_tenant_id_fkey", + "ConstraintType": "f", + "RefTableName": "tenants", + "IsDeferrable": false, + "ConstraintDefinition": "FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE" } ], "Triggers": [] @@ -26252,6 +29297,19 @@ "GenerationExpression": "", "Comment": "The site section (WEB, BACKEND, etc.) that generated the event." }, + { + "Name": "tenant_id", + "Index": 10, + "TypeName": "integer", + "IsNullable": true, + "Default": "", + "CharacterMaximumLength": 0, + "IsIdentity": false, + "IdentityGeneration": "", + "IsGenerated": "NEVER", + "GenerationExpression": "", + "Comment": "" + }, { "Name": "timestamp", "Index": 9, @@ -26355,6 +29413,13 @@ "RefTableName": "", "IsDeferrable": false, "ConstraintDefinition": "CHECK (version \u003c\u003e ''::text)" + }, + { + "Name": "security_event_logs_tenant_id_fkey", + "ConstraintType": "f", + "RefTableName": "tenants", + "IsDeferrable": false, + "ConstraintDefinition": "FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE" } ], "Triggers": [] @@ -26428,6 +29493,19 @@ "GenerationExpression": "", "Comment": "" }, + { + "Name": "tenant_id", + "Index": 7, + "TypeName": "integer", + "IsNullable": true, + "Default": "", + "CharacterMaximumLength": 0, + "IsIdentity": false, + "IdentityGeneration": "", + "IsGenerated": "NEVER", + "GenerationExpression": "", + "Comment": "" + }, { "Name": "user_id", "Index": 5, @@ -26506,6 +29584,13 @@ "IsDeferrable": false, "ConstraintDefinition": "FOREIGN KEY (org_id) REFERENCES orgs(id) ON DELETE RESTRICT" }, + { + "Name": "settings_tenant_id_fkey", + "ConstraintType": "f", + "RefTableName": "tenants", + "IsDeferrable": false, + "ConstraintDefinition": "FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE" + }, { "Name": "settings_user_id_fkey", "ConstraintType": "f", @@ -26559,6 +29644,19 @@ "GenerationExpression": "", "Comment": "" }, + { + "Name": "tenant_id", + "Index": 9, + "TypeName": "integer", + "IsNullable": true, + "Default": "", + "CharacterMaximumLength": 0, + "IsIdentity": false, + "IdentityGeneration": "", + "IsGenerated": "NEVER", + "GenerationExpression": "", + "Comment": "" + }, { "Name": "updated_at", "Index": 6, @@ -26636,6 +29734,13 @@ "IsDeferrable": false, "ConstraintDefinition": "FOREIGN KEY (repo_id) REFERENCES repo(id) ON DELETE CASCADE" }, + { + "Name": "sub_repo_permissions_tenant_id_fkey", + "ConstraintType": "f", + "RefTableName": "tenants", + "IsDeferrable": false, + "ConstraintDefinition": "FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE" + }, { "Name": "sub_repo_permissions_users_id_fk", "ConstraintType": "f", @@ -26741,6 +29846,19 @@ "GenerationExpression": "", "Comment": "" }, + { + "Name": "tenant_id", + "Index": 10, + "TypeName": "integer", + "IsNullable": true, + "Default": "", + "CharacterMaximumLength": 0, + "IsIdentity": false, + "IdentityGeneration": "", + "IsGenerated": "NEVER", + "GenerationExpression": "", + "Comment": "" + }, { "Name": "use_cases", "Index": 8, @@ -26781,6 +29899,13 @@ } ], "Constraints": [ + { + "Name": "survey_responses_tenant_id_fkey", + "ConstraintType": "f", + "RefTableName": "tenants", + "IsDeferrable": false, + "ConstraintDefinition": "FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE" + }, { "Name": "survey_responses_user_id_fkey", "ConstraintType": "f", @@ -27016,6 +30141,19 @@ "GenerationExpression": "", "Comment": "" }, + { + "Name": "tenant_id", + "Index": 19, + "TypeName": "integer", + "IsNullable": true, + "Default": "", + "CharacterMaximumLength": 0, + "IsIdentity": false, + "IdentityGeneration": "", + "IsGenerated": "NEVER", + "GenerationExpression": "", + "Comment": "" + }, { "Name": "worker_hostname", "Index": 14, @@ -27089,6 +30227,13 @@ "RefTableName": "", "IsDeferrable": false, "ConstraintDefinition": "CHECK (commit ~ '^[a-f0-9]{40}$'::text)" + }, + { + "Name": "syntactic_scip_indexing_jobs_tenant_id_fkey", + "ConstraintType": "f", + "RefTableName": "tenants", + "IsDeferrable": false, + "ConstraintDefinition": "FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE" } ], "Triggers": [] @@ -27122,6 +30267,19 @@ "IsGenerated": "NEVER", "GenerationExpression": "", "Comment": "" + }, + { + "Name": "tenant_id", + "Index": 3, + "TypeName": "integer", + "IsNullable": true, + "Default": "", + "CharacterMaximumLength": 0, + "IsIdentity": false, + "IdentityGeneration": "", + "IsGenerated": "NEVER", + "GenerationExpression": "", + "Comment": "" } ], "Indexes": [ @@ -27136,7 +30294,15 @@ "ConstraintDefinition": "PRIMARY KEY (repository_id)" } ], - "Constraints": null, + "Constraints": [ + { + "Name": "syntactic_scip_last_index_scan_tenant_id_fkey", + "ConstraintType": "f", + "RefTableName": "tenants", + "IsDeferrable": false, + "ConstraintDefinition": "FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE" + } + ], "Triggers": [] }, { @@ -27169,6 +30335,19 @@ "GenerationExpression": "", "Comment": "" }, + { + "Name": "tenant_id", + "Index": 5, + "TypeName": "integer", + "IsNullable": true, + "Default": "", + "CharacterMaximumLength": 0, + "IsIdentity": false, + "IdentityGeneration": "", + "IsGenerated": "NEVER", + "GenerationExpression": "", + "Comment": "" + }, { "Name": "updated_at", "Index": 4, @@ -27216,6 +30395,13 @@ "IsDeferrable": false, "ConstraintDefinition": "FOREIGN KEY (team_id) REFERENCES teams(id) ON DELETE CASCADE" }, + { + "Name": "team_members_tenant_id_fkey", + "ConstraintType": "f", + "RefTableName": "tenants", + "IsDeferrable": false, + "ConstraintDefinition": "FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE" + }, { "Name": "team_members_user_id_fkey", "ConstraintType": "f", @@ -27321,6 +30507,19 @@ "GenerationExpression": "", "Comment": "" }, + { + "Name": "tenant_id", + "Index": 9, + "TypeName": "integer", + "IsNullable": true, + "Default": "", + "CharacterMaximumLength": 0, + "IsIdentity": false, + "IdentityGeneration": "", + "IsGenerated": "NEVER", + "GenerationExpression": "", + "Comment": "" + }, { "Name": "updated_at", "Index": 8, @@ -27392,6 +30591,13 @@ "RefTableName": "teams", "IsDeferrable": false, "ConstraintDefinition": "FOREIGN KEY (parent_team_id) REFERENCES teams(id) ON DELETE CASCADE" + }, + { + "Name": "teams_tenant_id_fkey", + "ConstraintType": "f", + "RefTableName": "tenants", + "IsDeferrable": false, + "ConstraintDefinition": "FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE" } ], "Triggers": [] @@ -27439,6 +30645,19 @@ "GenerationExpression": "", "Comment": "" }, + { + "Name": "tenant_id", + "Index": 5, + "TypeName": "integer", + "IsNullable": true, + "Default": "", + "CharacterMaximumLength": 0, + "IsIdentity": false, + "IdentityGeneration": "", + "IsGenerated": "NEVER", + "GenerationExpression": "", + "Comment": "" + }, { "Name": "timestamp", "Index": 2, @@ -27465,7 +30684,15 @@ "ConstraintDefinition": "PRIMARY KEY (id)" } ], - "Constraints": null, + "Constraints": [ + { + "Name": "telemetry_events_export_queue_tenant_id_fkey", + "ConstraintType": "f", + "RefTableName": "tenants", + "IsDeferrable": false, + "ConstraintDefinition": "FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE" + } + ], "Triggers": [] }, { @@ -27511,6 +30738,19 @@ "GenerationExpression": "", "Comment": "" }, + { + "Name": "tenant_id", + "Index": 6, + "TypeName": "integer", + "IsNullable": true, + "Default": "", + "CharacterMaximumLength": 0, + "IsIdentity": false, + "IdentityGeneration": "", + "IsGenerated": "NEVER", + "GenerationExpression": "", + "Comment": "" + }, { "Name": "updated_at", "Index": 5, @@ -27561,6 +30801,13 @@ } ], "Constraints": [ + { + "Name": "temporary_settings_tenant_id_fkey", + "ConstraintType": "f", + "RefTableName": "tenants", + "IsDeferrable": false, + "ConstraintDefinition": "FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE" + }, { "Name": "temporary_settings_user_id_fkey", "ConstraintType": "f", @@ -27789,6 +31036,19 @@ "GenerationExpression": "", "Comment": "" }, + { + "Name": "tenant_id", + "Index": 12, + "TypeName": "integer", + "IsNullable": true, + "Default": "", + "CharacterMaximumLength": 0, + "IsIdentity": false, + "IdentityGeneration": "", + "IsGenerated": "NEVER", + "GenerationExpression": "", + "Comment": "" + }, { "Name": "updated_at", "Index": 7, @@ -27863,6 +31123,13 @@ "IsDeferrable": false, "ConstraintDefinition": "FOREIGN KEY (github_app_id) REFERENCES github_apps(id) ON DELETE CASCADE" }, + { + "Name": "user_credentials_tenant_id_fkey", + "ConstraintType": "f", + "RefTableName": "tenants", + "IsDeferrable": false, + "ConstraintDefinition": "FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE" + }, { "Name": "user_credentials_user_id_fkey", "ConstraintType": "f", @@ -27929,6 +31196,19 @@ "GenerationExpression": "", "Comment": "" }, + { + "Name": "tenant_id", + "Index": 8, + "TypeName": "integer", + "IsNullable": true, + "Default": "", + "CharacterMaximumLength": 0, + "IsIdentity": false, + "IdentityGeneration": "", + "IsGenerated": "NEVER", + "GenerationExpression": "", + "Comment": "" + }, { "Name": "user_id", "Index": 1, @@ -28002,6 +31282,13 @@ } ], "Constraints": [ + { + "Name": "user_emails_tenant_id_fkey", + "ConstraintType": "f", + "RefTableName": "tenants", + "IsDeferrable": false, + "ConstraintDefinition": "FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE" + }, { "Name": "user_emails_user_id_fkey", "ConstraintType": "f", @@ -28172,6 +31459,19 @@ "GenerationExpression": "", "Comment": "" }, + { + "Name": "tenant_id", + "Index": 15, + "TypeName": "integer", + "IsNullable": true, + "Default": "", + "CharacterMaximumLength": 0, + "IsIdentity": false, + "IdentityGeneration": "", + "IsGenerated": "NEVER", + "GenerationExpression": "", + "Comment": "" + }, { "Name": "updated_at", "Index": 9, @@ -28242,6 +31542,13 @@ } ], "Constraints": [ + { + "Name": "user_external_accounts_tenant_id_fkey", + "ConstraintType": "f", + "RefTableName": "tenants", + "IsDeferrable": false, + "ConstraintDefinition": "FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE" + }, { "Name": "user_external_accounts_user_id_fkey", "ConstraintType": "f", @@ -28300,6 +31607,19 @@ "GenerationExpression": "", "Comment": "" }, + { + "Name": "tenant_id", + "Index": 5, + "TypeName": "integer", + "IsNullable": true, + "Default": "", + "CharacterMaximumLength": 0, + "IsIdentity": false, + "IdentityGeneration": "", + "IsGenerated": "NEVER", + "GenerationExpression": "", + "Comment": "" + }, { "Name": "updated_by", "Index": 4, @@ -28327,6 +31647,13 @@ } ], "Constraints": [ + { + "Name": "user_onboarding_tour_tenant_id_fkey", + "ConstraintType": "f", + "RefTableName": "tenants", + "IsDeferrable": false, + "ConstraintDefinition": "FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE" + }, { "Name": "user_onboarding_tour_users_fk", "ConstraintType": "f", @@ -28432,6 +31759,19 @@ "GenerationExpression": "", "Comment": "" }, + { + "Name": "tenant_id", + "Index": 9, + "TypeName": "integer", + "IsNullable": true, + "Default": "", + "CharacterMaximumLength": 0, + "IsIdentity": false, + "IdentityGeneration": "", + "IsGenerated": "NEVER", + "GenerationExpression": "", + "Comment": "" + }, { "Name": "updated_at", "Index": 5, @@ -28458,7 +31798,15 @@ "ConstraintDefinition": "UNIQUE (service_type, service_id, permission, object_type, bind_id)" } ], - "Constraints": null, + "Constraints": [ + { + "Name": "user_pending_permissions_tenant_id_fkey", + "ConstraintType": "f", + "RefTableName": "tenants", + "IsDeferrable": false, + "ConstraintDefinition": "FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE" + } + ], "Triggers": [] }, { @@ -28530,6 +31878,19 @@ "GenerationExpression": "", "Comment": "" }, + { + "Name": "tenant_id", + "Index": 8, + "TypeName": "integer", + "IsNullable": true, + "Default": "", + "CharacterMaximumLength": 0, + "IsIdentity": false, + "IdentityGeneration": "", + "IsGenerated": "NEVER", + "GenerationExpression": "", + "Comment": "" + }, { "Name": "updated_at", "Index": 4, @@ -28569,7 +31930,15 @@ "ConstraintDefinition": "UNIQUE (user_id, permission, object_type)" } ], - "Constraints": null, + "Constraints": [ + { + "Name": "user_permissions_tenant_id_fkey", + "ConstraintType": "f", + "RefTableName": "tenants", + "IsDeferrable": false, + "ConstraintDefinition": "FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE" + } + ], "Triggers": [] }, { @@ -28602,6 +31971,19 @@ "GenerationExpression": "", "Comment": "" }, + { + "Name": "tenant_id", + "Index": 4, + "TypeName": "integer", + "IsNullable": true, + "Default": "", + "CharacterMaximumLength": 0, + "IsIdentity": false, + "IdentityGeneration": "", + "IsGenerated": "NEVER", + "GenerationExpression": "", + "Comment": "" + }, { "Name": "user_id", "Index": 1, @@ -28636,6 +32018,13 @@ "IsDeferrable": false, "ConstraintDefinition": "FOREIGN KEY (repo_id) REFERENCES repo(id) ON DELETE CASCADE" }, + { + "Name": "user_public_repos_tenant_id_fkey", + "ConstraintType": "f", + "RefTableName": "tenants", + "IsDeferrable": false, + "ConstraintDefinition": "FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE" + }, { "Name": "user_public_repos_user_id_fkey", "ConstraintType": "f", @@ -28702,6 +32091,19 @@ "GenerationExpression": "", "Comment": "" }, + { + "Name": "tenant_id", + "Index": 8, + "TypeName": "integer", + "IsNullable": true, + "Default": "", + "CharacterMaximumLength": 0, + "IsIdentity": false, + "IdentityGeneration": "", + "IsGenerated": "NEVER", + "GenerationExpression": "", + "Comment": "" + }, { "Name": "updated_at", "Index": 6, @@ -28812,6 +32214,13 @@ "IsDeferrable": false, "ConstraintDefinition": "FOREIGN KEY (repo_id) REFERENCES repo(id) ON DELETE CASCADE" }, + { + "Name": "user_repo_permissions_tenant_id_fkey", + "ConstraintType": "f", + "RefTableName": "tenants", + "IsDeferrable": false, + "ConstraintDefinition": "FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE" + }, { "Name": "user_repo_permissions_user_external_account_id_fkey", "ConstraintType": "f", @@ -28859,6 +32268,19 @@ "GenerationExpression": "", "Comment": "" }, + { + "Name": "tenant_id", + "Index": 4, + "TypeName": "integer", + "IsNullable": true, + "Default": "", + "CharacterMaximumLength": 0, + "IsIdentity": false, + "IdentityGeneration": "", + "IsGenerated": "NEVER", + "GenerationExpression": "", + "Comment": "" + }, { "Name": "user_id", "Index": 1, @@ -28893,6 +32315,13 @@ "IsDeferrable": true, "ConstraintDefinition": "FOREIGN KEY (role_id) REFERENCES roles(id) ON DELETE CASCADE DEFERRABLE" }, + { + "Name": "user_roles_tenant_id_fkey", + "ConstraintType": "f", + "RefTableName": "tenants", + "IsDeferrable": false, + "ConstraintDefinition": "FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE" + }, { "Name": "user_roles_user_id_fkey", "ConstraintType": "f", @@ -29141,6 +32570,19 @@ "GenerationExpression": "", "Comment": "" }, + { + "Name": "tenant_id", + "Index": 24, + "TypeName": "integer", + "IsNullable": true, + "Default": "", + "CharacterMaximumLength": 0, + "IsIdentity": false, + "IdentityGeneration": "", + "IsGenerated": "NEVER", + "GenerationExpression": "", + "Comment": "" + }, { "Name": "tos_accepted", "Index": 18, @@ -29231,6 +32673,13 @@ "IsDeferrable": false, "ConstraintDefinition": "CHECK (char_length(display_name) \u003c= 255)" }, + { + "Name": "users_tenant_id_fkey", + "ConstraintType": "f", + "RefTableName": "tenants", + "IsDeferrable": false, + "ConstraintDefinition": "FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE" + }, { "Name": "users_username_max_length", "ConstraintType": "c", @@ -29533,6 +32982,19 @@ "GenerationExpression": "", "Comment": "" }, + { + "Name": "tenant_id", + "Index": 17, + "TypeName": "integer", + "IsNullable": true, + "Default": "", + "CharacterMaximumLength": 0, + "IsIdentity": false, + "IdentityGeneration": "", + "IsGenerated": "NEVER", + "GenerationExpression": "", + "Comment": "" + }, { "Name": "urls", "Index": 10, @@ -29582,7 +33044,15 @@ "ConstraintDefinition": "" } ], - "Constraints": null, + "Constraints": [ + { + "Name": "vulnerabilities_tenant_id_fkey", + "ConstraintType": "f", + "RefTableName": "tenants", + "IsDeferrable": false, + "ConstraintDefinition": "FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE" + } + ], "Triggers": [] }, { @@ -29667,6 +33137,19 @@ "GenerationExpression": "", "Comment": "" }, + { + "Name": "tenant_id", + "Index": 9, + "TypeName": "integer", + "IsNullable": true, + "Default": "", + "CharacterMaximumLength": 0, + "IsIdentity": false, + "IdentityGeneration": "", + "IsGenerated": "NEVER", + "GenerationExpression": "", + "Comment": "" + }, { "Name": "version_constraint", "Index": 6, @@ -29723,6 +33206,13 @@ "RefTableName": "vulnerabilities", "IsDeferrable": false, "ConstraintDefinition": "FOREIGN KEY (vulnerability_id) REFERENCES vulnerabilities(id) ON DELETE CASCADE" + }, + { + "Name": "vulnerability_affected_packages_tenant_id_fkey", + "ConstraintType": "f", + "RefTableName": "tenants", + "IsDeferrable": false, + "ConstraintDefinition": "FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE" } ], "Triggers": [] @@ -29770,6 +33260,19 @@ "GenerationExpression": "", "Comment": "" }, + { + "Name": "tenant_id", + "Index": 5, + "TypeName": "integer", + "IsNullable": true, + "Default": "", + "CharacterMaximumLength": 0, + "IsIdentity": false, + "IdentityGeneration": "", + "IsGenerated": "NEVER", + "GenerationExpression": "", + "Comment": "" + }, { "Name": "vulnerability_affected_package_id", "Index": 2, @@ -29813,6 +33316,13 @@ "RefTableName": "vulnerability_affected_packages", "IsDeferrable": false, "ConstraintDefinition": "FOREIGN KEY (vulnerability_affected_package_id) REFERENCES vulnerability_affected_packages(id) ON DELETE CASCADE" + }, + { + "Name": "vulnerability_affected_symbols_tenant_id_fkey", + "ConstraintType": "f", + "RefTableName": "tenants", + "IsDeferrable": false, + "ConstraintDefinition": "FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE" } ], "Triggers": [] @@ -29834,6 +33344,19 @@ "GenerationExpression": "", "Comment": "" }, + { + "Name": "tenant_id", + "Index": 4, + "TypeName": "integer", + "IsNullable": true, + "Default": "", + "CharacterMaximumLength": 0, + "IsIdentity": false, + "IdentityGeneration": "", + "IsGenerated": "NEVER", + "GenerationExpression": "", + "Comment": "" + }, { "Name": "upload_id", "Index": 2, @@ -29907,6 +33430,13 @@ "RefTableName": "vulnerability_affected_packages", "IsDeferrable": false, "ConstraintDefinition": "FOREIGN KEY (vulnerability_affected_package_id) REFERENCES vulnerability_affected_packages(id) ON DELETE CASCADE" + }, + { + "Name": "vulnerability_matches_tenant_id_fkey", + "ConstraintType": "f", + "RefTableName": "tenants", + "IsDeferrable": false, + "ConstraintDefinition": "FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE" } ], "Triggers": [] @@ -30006,6 +33536,19 @@ "GenerationExpression": "", "Comment": "" }, + { + "Name": "tenant_id", + "Index": 9, + "TypeName": "integer", + "IsNullable": true, + "Default": "", + "CharacterMaximumLength": 0, + "IsIdentity": false, + "IdentityGeneration": "", + "IsGenerated": "NEVER", + "GenerationExpression": "", + "Comment": "" + }, { "Name": "webhook_id", "Index": 8, @@ -30070,6 +33613,13 @@ "IsDeferrable": false, "ConstraintDefinition": "FOREIGN KEY (external_service_id) REFERENCES external_services(id) ON UPDATE CASCADE ON DELETE CASCADE" }, + { + "Name": "webhook_logs_tenant_id_fkey", + "ConstraintType": "f", + "RefTableName": "tenants", + "IsDeferrable": false, + "ConstraintDefinition": "FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE" + }, { "Name": "webhook_logs_webhook_id_fkey", "ConstraintType": "f", @@ -30188,6 +33738,19 @@ "GenerationExpression": "", "Comment": "Secret used to decrypt webhook payload (if supported by the code host)." }, + { + "Name": "tenant_id", + "Index": 13, + "TypeName": "integer", + "IsNullable": true, + "Default": "", + "CharacterMaximumLength": 0, + "IsIdentity": false, + "IdentityGeneration": "", + "IsGenerated": "NEVER", + "GenerationExpression": "", + "Comment": "" + }, { "Name": "updated_at", "Index": 7, @@ -30258,6 +33821,13 @@ "IsDeferrable": false, "ConstraintDefinition": "FOREIGN KEY (created_by_user_id) REFERENCES users(id) ON DELETE SET NULL" }, + { + "Name": "webhooks_tenant_id_fkey", + "ConstraintType": "f", + "RefTableName": "tenants", + "IsDeferrable": false, + "ConstraintDefinition": "FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE" + }, { "Name": "webhooks_updated_by_user_id_fkey", "ConstraintType": "f", @@ -30337,6 +33907,19 @@ "GenerationExpression": "", "Comment": "" }, + { + "Name": "tenant_id", + "Index": 7, + "TypeName": "integer", + "IsNullable": true, + "Default": "", + "CharacterMaximumLength": 0, + "IsIdentity": false, + "IdentityGeneration": "", + "IsGenerated": "NEVER", + "GenerationExpression": "", + "Comment": "" + }, { "Name": "updated_at", "Index": 4, @@ -30380,6 +33963,13 @@ "RefTableName": "repo", "IsDeferrable": false, "ConstraintDefinition": "FOREIGN KEY (repo_id) REFERENCES repo(id) ON DELETE CASCADE" + }, + { + "Name": "zoekt_repos_tenant_id_fkey", + "ConstraintType": "f", + "RefTableName": "tenants", + "IsDeferrable": false, + "ConstraintDefinition": "FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE" } ], "Triggers": [] diff --git a/internal/database/schema.md b/internal/database/schema.md index e8e7722c3e2..1ceb4266381 100644 --- a/internal/database/schema.md +++ b/internal/database/schema.md @@ -10,6 +10,7 @@ additional_info | text | | | status | text | | not null | decision_by_user_id | integer | | | + tenant_id | integer | | | Indexes: "access_requests_pkey" PRIMARY KEY, btree (id) "access_requests_email_key" UNIQUE CONSTRAINT, btree (email) @@ -17,6 +18,7 @@ Indexes: "access_requests_status" btree (status) Foreign-key constraints: "access_requests_decision_by_user_id_fkey" FOREIGN KEY (decision_by_user_id) REFERENCES users(id) ON DELETE SET NULL + "access_requests_tenant_id_fkey" FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE ``` @@ -35,6 +37,7 @@ Foreign-key constraints: scopes | text[] | | not null | internal | boolean | | | false expires_at | timestamp with time zone | | | + tenant_id | integer | | | Indexes: "access_tokens_pkey" PRIMARY KEY, btree (id) "access_tokens_value_sha256_key" UNIQUE CONSTRAINT, btree (value_sha256) @@ -43,6 +46,7 @@ Indexes: Foreign-key constraints: "access_tokens_creator_user_id_fkey" FOREIGN KEY (creator_user_id) REFERENCES users(id) "access_tokens_subject_user_id_fkey" FOREIGN KEY (subject_user_id) REFERENCES users(id) + "access_tokens_tenant_id_fkey" FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE ``` @@ -55,9 +59,11 @@ Foreign-key constraints: updated_at | timestamp with time zone | | not null | now() user_last_active_at | timestamp with time zone | | | user_events_count | bigint | | | + tenant_id | integer | | | Indexes: "aggregated_user_statistics_pkey" PRIMARY KEY, btree (user_id) Foreign-key constraints: + "aggregated_user_statistics_tenant_id_fkey" FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE "aggregated_user_statistics_user_id_fkey" FOREIGN KEY (user_id) REFERENCES users(id) ON DELETE CASCADE ``` @@ -71,12 +77,14 @@ Foreign-key constraints: file_path_id | integer | | not null | who_assigned_user_id | integer | | | assigned_at | timestamp without time zone | | not null | now() + tenant_id | integer | | | Indexes: "assigned_owners_pkey" PRIMARY KEY, btree (id) "assigned_owners_file_path_owner" UNIQUE, btree (file_path_id, owner_user_id) Foreign-key constraints: "assigned_owners_file_path_id_fkey" FOREIGN KEY (file_path_id) REFERENCES repo_paths(id) "assigned_owners_owner_user_id_fkey" FOREIGN KEY (owner_user_id) REFERENCES users(id) ON DELETE CASCADE DEFERRABLE + "assigned_owners_tenant_id_fkey" FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE "assigned_owners_who_assigned_user_id_fkey" FOREIGN KEY (who_assigned_user_id) REFERENCES users(id) ON DELETE SET NULL DEFERRABLE ``` @@ -92,12 +100,14 @@ Table for ownership assignments, one entry contains an assigned user ID, which r file_path_id | integer | | not null | who_assigned_team_id | integer | | | assigned_at | timestamp without time zone | | not null | now() + tenant_id | integer | | | Indexes: "assigned_teams_pkey" PRIMARY KEY, btree (id) "assigned_teams_file_path_owner" UNIQUE, btree (file_path_id, owner_team_id) Foreign-key constraints: "assigned_teams_file_path_id_fkey" FOREIGN KEY (file_path_id) REFERENCES repo_paths(id) "assigned_teams_owner_team_id_fkey" FOREIGN KEY (owner_team_id) REFERENCES teams(id) ON DELETE CASCADE DEFERRABLE + "assigned_teams_tenant_id_fkey" FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE "assigned_teams_who_assigned_team_id_fkey" FOREIGN KEY (who_assigned_team_id) REFERENCES users(id) ON DELETE SET NULL DEFERRABLE ``` @@ -120,6 +130,7 @@ Table for team ownership assignments, one entry contains an assigned team ID, wh batch_spec_id | bigint | | not null | last_applier_id | bigint | | | last_applied_at | timestamp with time zone | | | + tenant_id | integer | | | Indexes: "batch_changes_pkey" PRIMARY KEY, btree (id) "batch_changes_unique_org_id" UNIQUE, btree (name, namespace_org_id) WHERE namespace_org_id IS NOT NULL @@ -136,6 +147,7 @@ Foreign-key constraints: "batch_changes_last_applier_id_fkey" FOREIGN KEY (last_applier_id) REFERENCES users(id) ON DELETE SET NULL DEFERRABLE "batch_changes_namespace_org_id_fkey" FOREIGN KEY (namespace_org_id) REFERENCES orgs(id) ON DELETE CASCADE DEFERRABLE "batch_changes_namespace_user_id_fkey" FOREIGN KEY (namespace_user_id) REFERENCES users(id) ON DELETE CASCADE DEFERRABLE + "batch_changes_tenant_id_fkey" FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE Referenced by: TABLE "batch_specs" CONSTRAINT "batch_specs_batch_change_id_fkey" FOREIGN KEY (batch_change_id) REFERENCES batch_changes(id) ON DELETE SET NULL DEFERRABLE TABLE "changeset_jobs" CONSTRAINT "changeset_jobs_batch_change_id_fkey" FOREIGN KEY (batch_change_id) REFERENCES batch_changes(id) ON DELETE CASCADE DEFERRABLE @@ -157,6 +169,7 @@ Triggers: credential | bytea | | not null | encryption_key_id | text | | not null | ''::text github_app_id | integer | | | + tenant_id | integer | | | Indexes: "batch_changes_site_credentials_pkey" PRIMARY KEY, btree (id) "batch_changes_site_credentials_unique" UNIQUE, btree (external_service_type, external_service_id) @@ -165,6 +178,7 @@ Check constraints: "check_github_app_id_and_external_service_type_site_credentials" CHECK (github_app_id IS NULL OR external_service_type = 'github'::text) Foreign-key constraints: "batch_changes_site_credentials_github_app_id_fkey" FOREIGN KEY (github_app_id) REFERENCES github_apps(id) ON DELETE CASCADE + "batch_changes_site_credentials_tenant_id_fkey" FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE ``` @@ -179,10 +193,12 @@ Foreign-key constraints: last_used_at | timestamp with time zone | | | created_at | timestamp with time zone | | not null | now() user_id | integer | | not null | + tenant_id | integer | | | Indexes: "batch_spec_execution_cache_entries_pkey" PRIMARY KEY, btree (id) "batch_spec_execution_cache_entries_user_id_key_unique" UNIQUE CONSTRAINT, btree (user_id, key) Foreign-key constraints: + "batch_spec_execution_cache_entries_tenant_id_fkey" FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE "batch_spec_execution_cache_entries_user_id_fkey" FOREIGN KEY (user_id) REFERENCES users(id) ON DELETE CASCADE DEFERRABLE ``` @@ -208,6 +224,7 @@ Foreign-key constraints: queued_at | timestamp with time zone | | | now() initiator_id | integer | | not null | cancel | boolean | | not null | false + tenant_id | integer | | | Indexes: "batch_spec_resolution_jobs_pkey" PRIMARY KEY, btree (id) "batch_spec_resolution_jobs_batch_spec_id_unique" UNIQUE CONSTRAINT, btree (batch_spec_id) @@ -215,6 +232,7 @@ Indexes: Foreign-key constraints: "batch_spec_resolution_jobs_batch_spec_id_fkey" FOREIGN KEY (batch_spec_id) REFERENCES batch_specs(id) ON DELETE CASCADE DEFERRABLE "batch_spec_resolution_jobs_initiator_id_fkey" FOREIGN KEY (initiator_id) REFERENCES users(id) ON UPDATE CASCADE ON DELETE CASCADE DEFERRABLE + "batch_spec_resolution_jobs_tenant_id_fkey" FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE ``` @@ -240,6 +258,7 @@ Foreign-key constraints: queued_at | timestamp with time zone | | | now() user_id | integer | | not null | version | integer | | not null | 1 + tenant_id | integer | | | Indexes: "batch_spec_workspace_execution_jobs_pkey" PRIMARY KEY, btree (id) "batch_spec_workspace_execution_jobs_batch_spec_workspace_id" btree (batch_spec_workspace_id) @@ -248,6 +267,7 @@ Indexes: "batch_spec_workspace_execution_jobs_state" btree (state) Foreign-key constraints: "batch_spec_workspace_execution_job_batch_spec_workspace_id_fkey" FOREIGN KEY (batch_spec_workspace_id) REFERENCES batch_spec_workspaces(id) ON DELETE CASCADE DEFERRABLE + "batch_spec_workspace_execution_jobs_tenant_id_fkey" FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE Triggers: batch_spec_workspace_execution_last_dequeues_insert AFTER INSERT ON batch_spec_workspace_execution_jobs REFERENCING NEW TABLE AS newtab FOR EACH STATEMENT EXECUTE FUNCTION batch_spec_workspace_execution_last_dequeues_upsert() batch_spec_workspace_execution_last_dequeues_update AFTER UPDATE ON batch_spec_workspace_execution_jobs REFERENCING NEW TABLE AS newtab FOR EACH STATEMENT EXECUTE FUNCTION batch_spec_workspace_execution_last_dequeues_upsert() @@ -260,9 +280,11 @@ Triggers: ----------------+--------------------------+-----------+----------+--------- user_id | integer | | not null | latest_dequeue | timestamp with time zone | | | + tenant_id | integer | | | Indexes: "batch_spec_workspace_execution_last_dequeues_pkey" PRIMARY KEY, btree (user_id) Foreign-key constraints: + "batch_spec_workspace_execution_last_dequeues_tenant_id_fkey" FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE "batch_spec_workspace_execution_last_dequeues_user_id_fkey" FOREIGN KEY (user_id) REFERENCES users(id) ON UPDATE CASCADE ON DELETE CASCADE DEFERRABLE INITIALLY DEFERRED ``` @@ -281,12 +303,14 @@ Foreign-key constraints: modified_at | timestamp with time zone | | not null | created_at | timestamp with time zone | | not null | now() updated_at | timestamp with time zone | | not null | now() + tenant_id | integer | | | Indexes: "batch_spec_workspace_files_pkey" PRIMARY KEY, btree (id) "batch_spec_workspace_files_batch_spec_id_filename_path" UNIQUE, btree (batch_spec_id, filename, path) "batch_spec_workspace_files_rand_id" btree (rand_id) Foreign-key constraints: "batch_spec_workspace_files_batch_spec_id_fkey" FOREIGN KEY (batch_spec_id) REFERENCES batch_specs(id) ON DELETE CASCADE + "batch_spec_workspace_files_tenant_id_fkey" FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE ``` @@ -310,6 +334,7 @@ Foreign-key constraints: skipped | boolean | | not null | false cached_result_found | boolean | | not null | false step_cache_results | jsonb | | not null | '{}'::jsonb + tenant_id | integer | | | Indexes: "batch_spec_workspaces_pkey" PRIMARY KEY, btree (id) "batch_spec_workspaces_batch_spec_id" btree (batch_spec_id) @@ -317,6 +342,7 @@ Indexes: Foreign-key constraints: "batch_spec_workspaces_batch_spec_id_fkey" FOREIGN KEY (batch_spec_id) REFERENCES batch_specs(id) ON DELETE CASCADE DEFERRABLE "batch_spec_workspaces_repo_id_fkey" FOREIGN KEY (repo_id) REFERENCES repo(id) DEFERRABLE + "batch_spec_workspaces_tenant_id_fkey" FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE Referenced by: TABLE "batch_spec_workspace_execution_jobs" CONSTRAINT "batch_spec_workspace_execution_job_batch_spec_workspace_id_fkey" FOREIGN KEY (batch_spec_workspace_id) REFERENCES batch_spec_workspaces(id) ON DELETE CASCADE DEFERRABLE @@ -340,6 +366,7 @@ Referenced by: allow_ignored | boolean | | not null | false no_cache | boolean | | not null | false batch_change_id | bigint | | | + tenant_id | integer | | | Indexes: "batch_specs_pkey" PRIMARY KEY, btree (id) "batch_specs_unique_rand_id" UNIQUE, btree (rand_id) @@ -347,6 +374,7 @@ Check constraints: "batch_specs_has_1_namespace" CHECK ((namespace_user_id IS NULL) <> (namespace_org_id IS NULL)) Foreign-key constraints: "batch_specs_batch_change_id_fkey" FOREIGN KEY (batch_change_id) REFERENCES batch_changes(id) ON DELETE SET NULL DEFERRABLE + "batch_specs_tenant_id_fkey" FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE "batch_specs_user_id_fkey" FOREIGN KEY (user_id) REFERENCES users(id) ON DELETE SET NULL DEFERRABLE Referenced by: TABLE "batch_changes" CONSTRAINT "batch_changes_batch_spec_id_fkey" FOREIGN KEY (batch_spec_id) REFERENCES batch_specs(id) DEFERRABLE @@ -365,10 +393,13 @@ Referenced by: repository_id | integer | | not null | num_events | integer | | not null | available_indexers | jsonb | | not null | + tenant_id | integer | | | Indexes: "cached_available_indexers_pkey" PRIMARY KEY, btree (id) "cached_available_indexers_repository_id" UNIQUE, btree (repository_id) "cached_available_indexers_num_events" btree (num_events DESC) WHERE available_indexers::text <> '{}'::text +Foreign-key constraints: + "cached_available_indexers_tenant_id_fkey" FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE ``` @@ -383,6 +414,7 @@ Indexes: created_at | timestamp with time zone | | not null | now() metadata | jsonb | | not null | '{}'::jsonb updated_at | timestamp with time zone | | not null | now() + tenant_id | integer | | | Indexes: "changeset_events_pkey" PRIMARY KEY, btree (id) "changeset_events_changeset_id_kind_key_unique" UNIQUE CONSTRAINT, btree (changeset_id, kind, key) @@ -392,6 +424,7 @@ Check constraints: "changeset_events_metadata_check" CHECK (jsonb_typeof(metadata) = 'object'::text) Foreign-key constraints: "changeset_events_changeset_id_fkey" FOREIGN KEY (changeset_id) REFERENCES changesets(id) ON DELETE CASCADE DEFERRABLE + "changeset_events_tenant_id_fkey" FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE ``` @@ -420,6 +453,7 @@ Foreign-key constraints: last_heartbeat_at | timestamp with time zone | | | queued_at | timestamp with time zone | | | now() cancel | boolean | | not null | false + tenant_id | integer | | | Indexes: "changeset_jobs_pkey" PRIMARY KEY, btree (id) "changeset_jobs_bulk_group_idx" btree (bulk_group) @@ -429,6 +463,7 @@ Check constraints: Foreign-key constraints: "changeset_jobs_batch_change_id_fkey" FOREIGN KEY (batch_change_id) REFERENCES batch_changes(id) ON DELETE CASCADE DEFERRABLE "changeset_jobs_changeset_id_fkey" FOREIGN KEY (changeset_id) REFERENCES changesets(id) ON DELETE CASCADE DEFERRABLE + "changeset_jobs_tenant_id_fkey" FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE "changeset_jobs_user_id_fkey" FOREIGN KEY (user_id) REFERENCES users(id) ON DELETE CASCADE DEFERRABLE ``` @@ -460,6 +495,7 @@ Foreign-key constraints: commit_author_name | text | | | commit_author_email | text | | | type | text | | not null | + tenant_id | integer | | | Indexes: "changeset_specs_pkey" PRIMARY KEY, btree (id) "changeset_specs_unique_rand_id" UNIQUE, btree (rand_id) @@ -473,6 +509,7 @@ Check constraints: Foreign-key constraints: "changeset_specs_batch_spec_id_fkey" FOREIGN KEY (batch_spec_id) REFERENCES batch_specs(id) ON DELETE CASCADE DEFERRABLE "changeset_specs_repo_id_fkey" FOREIGN KEY (repo_id) REFERENCES repo(id) DEFERRABLE + "changeset_specs_tenant_id_fkey" FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE "changeset_specs_user_id_fkey" FOREIGN KEY (user_id) REFERENCES users(id) ON DELETE SET NULL DEFERRABLE Referenced by: TABLE "changesets" CONSTRAINT "changesets_changeset_spec_id_fkey" FOREIGN KEY (current_spec_id) REFERENCES changeset_specs(id) DEFERRABLE @@ -528,6 +565,7 @@ Referenced by: external_fork_name | citext | | | previous_failure_message | text | | | commit_verification | jsonb | | not null | '{}'::jsonb + tenant_id | integer | | | Indexes: "changesets_pkey" PRIMARY KEY, btree (id) "changesets_repo_external_id_unique" UNIQUE CONSTRAINT, btree (repo_id, external_id) @@ -551,6 +589,7 @@ Foreign-key constraints: "changesets_owned_by_batch_spec_id_fkey" FOREIGN KEY (owned_by_batch_change_id) REFERENCES batch_changes(id) ON DELETE SET NULL DEFERRABLE "changesets_previous_spec_id_fkey" FOREIGN KEY (previous_spec_id) REFERENCES changeset_specs(id) DEFERRABLE "changesets_repo_id_fkey" FOREIGN KEY (repo_id) REFERENCES repo(id) ON DELETE CASCADE DEFERRABLE + "changesets_tenant_id_fkey" FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE Referenced by: TABLE "changeset_events" CONSTRAINT "changeset_events_changeset_id_fkey" FOREIGN KEY (changeset_id) REFERENCES changesets(id) ON DELETE CASCADE DEFERRABLE TABLE "changeset_jobs" CONSTRAINT "changeset_jobs_changeset_id_fkey" FOREIGN KEY (changeset_id) REFERENCES changesets(id) ON DELETE CASCADE DEFERRABLE @@ -583,6 +622,7 @@ Triggers: slack_webhook | bigint | | | queued_at | timestamp with time zone | | | now() cancel | boolean | | not null | false + tenant_id | integer | | | Indexes: "cm_action_jobs_pkey" PRIMARY KEY, btree (id) "cm_action_jobs_state_idx" btree (state) @@ -604,6 +644,7 @@ END) = 1) Foreign-key constraints: "cm_action_jobs_email_fk" FOREIGN KEY (email) REFERENCES cm_emails(id) ON DELETE CASCADE "cm_action_jobs_slack_webhook_fkey" FOREIGN KEY (slack_webhook) REFERENCES cm_slack_webhooks(id) ON DELETE CASCADE + "cm_action_jobs_tenant_id_fkey" FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE "cm_action_jobs_trigger_event_fk" FOREIGN KEY (trigger_event) REFERENCES cm_trigger_jobs(id) ON DELETE CASCADE "cm_action_jobs_webhook_fkey" FOREIGN KEY (webhook) REFERENCES cm_webhooks(id) ON DELETE CASCADE @@ -629,12 +670,14 @@ Foreign-key constraints: changed_by | integer | | not null | changed_at | timestamp with time zone | | not null | now() include_results | boolean | | not null | false + tenant_id | integer | | | Indexes: "cm_emails_pkey" PRIMARY KEY, btree (id) Foreign-key constraints: "cm_emails_changed_by_fk" FOREIGN KEY (changed_by) REFERENCES users(id) ON DELETE CASCADE "cm_emails_created_by_fk" FOREIGN KEY (created_by) REFERENCES users(id) ON DELETE CASCADE "cm_emails_monitor" FOREIGN KEY (monitor) REFERENCES cm_monitors(id) ON DELETE CASCADE + "cm_emails_tenant_id_fkey" FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE Referenced by: TABLE "cm_action_jobs" CONSTRAINT "cm_action_jobs_email_fk" FOREIGN KEY (email) REFERENCES cm_emails(id) ON DELETE CASCADE TABLE "cm_recipients" CONSTRAINT "cm_recipients_emails" FOREIGN KEY (email) REFERENCES cm_emails(id) ON DELETE CASCADE @@ -648,11 +691,13 @@ Referenced by: monitor_id | bigint | | not null | commit_oids | text[] | | not null | repo_id | integer | | not null | + tenant_id | integer | | | Indexes: "cm_last_searched_pkey" PRIMARY KEY, btree (monitor_id, repo_id) Foreign-key constraints: "cm_last_searched_monitor_id_fkey" FOREIGN KEY (monitor_id) REFERENCES cm_monitors(id) ON DELETE CASCADE "cm_last_searched_repo_id_fkey" FOREIGN KEY (repo_id) REFERENCES repo(id) ON DELETE CASCADE + "cm_last_searched_tenant_id_fkey" FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE ``` @@ -673,12 +718,14 @@ The last searched commit hashes for the given code monitor and unique set of sea enabled | boolean | | not null | true namespace_user_id | integer | | not null | namespace_org_id | integer | | | + tenant_id | integer | | | Indexes: "cm_monitors_pkey" PRIMARY KEY, btree (id) Foreign-key constraints: "cm_monitors_changed_by_fk" FOREIGN KEY (changed_by) REFERENCES users(id) ON DELETE CASCADE "cm_monitors_created_by_fk" FOREIGN KEY (created_by) REFERENCES users(id) ON DELETE CASCADE "cm_monitors_org_id_fk" FOREIGN KEY (namespace_org_id) REFERENCES orgs(id) ON DELETE CASCADE + "cm_monitors_tenant_id_fkey" FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE "cm_monitors_user_id_fk" FOREIGN KEY (namespace_user_id) REFERENCES users(id) ON DELETE CASCADE Referenced by: TABLE "cm_emails" CONSTRAINT "cm_emails_monitor" FOREIGN KEY (monitor) REFERENCES cm_monitors(id) ON DELETE CASCADE @@ -704,9 +751,11 @@ Referenced by: changed_at | timestamp with time zone | | not null | now() next_run | timestamp with time zone | | | now() latest_result | timestamp with time zone | | | + tenant_id | integer | | | Indexes: "cm_queries_pkey" PRIMARY KEY, btree (id) Foreign-key constraints: + "cm_queries_tenant_id_fkey" FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE "cm_triggers_changed_by_fk" FOREIGN KEY (changed_by) REFERENCES users(id) ON DELETE CASCADE "cm_triggers_created_by_fk" FOREIGN KEY (created_by) REFERENCES users(id) ON DELETE CASCADE "cm_triggers_monitor" FOREIGN KEY (monitor) REFERENCES cm_monitors(id) ON DELETE CASCADE @@ -723,11 +772,13 @@ Referenced by: email | bigint | | not null | namespace_user_id | integer | | | namespace_org_id | integer | | | + tenant_id | integer | | | Indexes: "cm_recipients_pkey" PRIMARY KEY, btree (id) Foreign-key constraints: "cm_recipients_emails" FOREIGN KEY (email) REFERENCES cm_emails(id) ON DELETE CASCADE "cm_recipients_org_id_fk" FOREIGN KEY (namespace_org_id) REFERENCES orgs(id) ON DELETE CASCADE + "cm_recipients_tenant_id_fkey" FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE "cm_recipients_user_id_fk" FOREIGN KEY (namespace_user_id) REFERENCES users(id) ON DELETE CASCADE ``` @@ -745,6 +796,7 @@ Foreign-key constraints: changed_by | integer | | not null | changed_at | timestamp with time zone | | not null | now() include_results | boolean | | not null | false + tenant_id | integer | | | Indexes: "cm_slack_webhooks_pkey" PRIMARY KEY, btree (id) "cm_slack_webhooks_monitor" btree (monitor) @@ -752,6 +804,7 @@ Foreign-key constraints: "cm_slack_webhooks_changed_by_fkey" FOREIGN KEY (changed_by) REFERENCES users(id) ON DELETE CASCADE "cm_slack_webhooks_created_by_fkey" FOREIGN KEY (created_by) REFERENCES users(id) ON DELETE CASCADE "cm_slack_webhooks_monitor_fkey" FOREIGN KEY (monitor) REFERENCES cm_monitors(id) ON DELETE CASCADE + "cm_slack_webhooks_tenant_id_fkey" FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE Referenced by: TABLE "cm_action_jobs" CONSTRAINT "cm_action_jobs_slack_webhook_fkey" FOREIGN KEY (slack_webhook) REFERENCES cm_slack_webhooks(id) ON DELETE CASCADE @@ -785,6 +838,7 @@ Slack webhook actions configured on code monitors queued_at | timestamp with time zone | | | now() cancel | boolean | | not null | false logs | json[] | | | + tenant_id | integer | | | Indexes: "cm_trigger_jobs_pkey" PRIMARY KEY, btree (id) "cm_trigger_jobs_finished_at" btree (finished_at) @@ -793,6 +847,7 @@ Check constraints: "search_results_is_array" CHECK (jsonb_typeof(search_results) = 'array'::text) Foreign-key constraints: "cm_trigger_jobs_query_fk" FOREIGN KEY (query) REFERENCES cm_queries(id) ON DELETE CASCADE + "cm_trigger_jobs_tenant_id_fkey" FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE Referenced by: TABLE "cm_action_jobs" CONSTRAINT "cm_action_jobs_trigger_event_fk" FOREIGN KEY (trigger_event) REFERENCES cm_trigger_jobs(id) ON DELETE CASCADE @@ -811,6 +866,7 @@ Referenced by: changed_by | integer | | not null | changed_at | timestamp with time zone | | not null | now() include_results | boolean | | not null | false + tenant_id | integer | | | Indexes: "cm_webhooks_pkey" PRIMARY KEY, btree (id) "cm_webhooks_monitor" btree (monitor) @@ -818,6 +874,7 @@ Foreign-key constraints: "cm_webhooks_changed_by_fkey" FOREIGN KEY (changed_by) REFERENCES users(id) ON DELETE CASCADE "cm_webhooks_created_by_fkey" FOREIGN KEY (created_by) REFERENCES users(id) ON DELETE CASCADE "cm_webhooks_monitor_fkey" FOREIGN KEY (monitor) REFERENCES cm_monitors(id) ON DELETE CASCADE + "cm_webhooks_tenant_id_fkey" FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE Referenced by: TABLE "cm_action_jobs" CONSTRAINT "cm_action_jobs_webhook_fkey" FOREIGN KEY (webhook) REFERENCES cm_webhooks(id) ON DELETE CASCADE @@ -844,9 +901,12 @@ Webhook actions configured on code monitors git_rate_limit_interval_seconds | integer | | | created_at | timestamp with time zone | | not null | now() updated_at | timestamp with time zone | | not null | now() + tenant_id | integer | | | Indexes: "code_hosts_pkey" PRIMARY KEY, btree (id) "code_hosts_url_key" UNIQUE CONSTRAINT, btree (url) +Foreign-key constraints: + "code_hosts_tenant_id_fkey" FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE Referenced by: TABLE "external_services" CONSTRAINT "external_services_code_host_id_fkey" FOREIGN KEY (code_host_id) REFERENCES code_hosts(id) ON UPDATE CASCADE ON DELETE SET NULL DEFERRABLE INITIALLY DEFERRED @@ -861,9 +921,12 @@ Referenced by: rev | text | | not null | queued_at | timestamp with time zone | | not null | now() processed_at | timestamp with time zone | | | + tenant_id | integer | | | Indexes: "codeintel_autoindex_queue_pkey" PRIMARY KEY, btree (id) "codeintel_autoindex_queue_repository_id_commit" UNIQUE, btree (repository_id, rev) +Foreign-key constraints: + "codeintel_autoindex_queue_tenant_id_fkey" FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE ``` @@ -875,11 +938,13 @@ Indexes: repository_id | integer | | not null | disable_scheduling | boolean | | not null | false disable_inference | boolean | | not null | false + tenant_id | integer | | | Indexes: "codeintel_autoindexing_exceptions_pkey" PRIMARY KEY, btree (id) "codeintel_autoindexing_exceptions_repository_id_key" UNIQUE CONSTRAINT, btree (repository_id) Foreign-key constraints: "codeintel_autoindexing_exceptions_repository_id_fkey" FOREIGN KEY (repository_id) REFERENCES repo(id) ON DELETE CASCADE + "codeintel_autoindexing_exceptions_tenant_id_fkey" FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE ``` @@ -890,8 +955,11 @@ Foreign-key constraints: repository_id | integer | | not null | commit_bytea | bytea | | not null | committed_at | timestamp with time zone | | | + tenant_id | integer | | | Indexes: "codeintel_commit_dates_pkey" PRIMARY KEY, btree (repository_id, commit_bytea) +Foreign-key constraints: + "codeintel_commit_dates_tenant_id_fkey" FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE ``` @@ -909,6 +977,9 @@ Maps commits within a repository to the commit date as reported by gitserver. ------------------+--------------------------+-----------+----------+--------- insert_timestamp | timestamp with time zone | | not null | now() script | text | | not null | + tenant_id | integer | | | +Foreign-key constraints: + "codeintel_inference_scripts_tenant_id_fkey" FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE ``` @@ -923,12 +994,14 @@ Contains auto-index job inference Lua scripts as an alternative to setting via e graph_key | text | | not null | document_paths | text[] | | not null | '{}'::text[] exported_upload_id | integer | | not null | + tenant_id | integer | | | Indexes: "codeintel_initial_path_ranks_pkey" PRIMARY KEY, btree (id) "codeintel_initial_path_ranks_exported_upload_id" btree (exported_upload_id) "codeintel_initial_path_ranks_graph_key_id" btree (graph_key, id) Foreign-key constraints: "codeintel_initial_path_ranks_exported_upload_id_fkey" FOREIGN KEY (exported_upload_id) REFERENCES codeintel_ranking_exports(id) ON DELETE CASCADE + "codeintel_initial_path_ranks_tenant_id_fkey" FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE Referenced by: TABLE "codeintel_initial_path_ranks_processed" CONSTRAINT "fk_codeintel_initial_path_ranks" FOREIGN KEY (codeintel_initial_path_ranks_id) REFERENCES codeintel_initial_path_ranks(id) ON DELETE CASCADE @@ -936,16 +1009,18 @@ Referenced by: # Table "public.codeintel_initial_path_ranks_processed" ``` - Column | Type | Collation | Nullable | Default ----------------------------------+--------+-----------+----------+-------------------------------------------------------------------- - id | bigint | | not null | nextval('codeintel_initial_path_ranks_processed_id_seq'::regclass) - graph_key | text | | not null | - codeintel_initial_path_ranks_id | bigint | | not null | + Column | Type | Collation | Nullable | Default +---------------------------------+---------+-----------+----------+-------------------------------------------------------------------- + id | bigint | | not null | nextval('codeintel_initial_path_ranks_processed_id_seq'::regclass) + graph_key | text | | not null | + codeintel_initial_path_ranks_id | bigint | | not null | + tenant_id | integer | | | Indexes: "codeintel_initial_path_ranks_processed_pkey" PRIMARY KEY, btree (id) "codeintel_initial_path_ranks_processed_cgraph_key_codeintel_ini" UNIQUE, btree (graph_key, codeintel_initial_path_ranks_id) "codeintel_initial_path_ranks_processed_codeintel_initial_path_r" btree (codeintel_initial_path_ranks_id) Foreign-key constraints: + "codeintel_initial_path_ranks_processed_tenant_id_fkey" FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE "fk_codeintel_initial_path_ranks" FOREIGN KEY (codeintel_initial_path_ranks_id) REFERENCES codeintel_initial_path_ranks(id) ON DELETE CASCADE ``` @@ -957,8 +1032,11 @@ Foreign-key constraints: id | integer | | not null | nextval('codeintel_langugage_support_requests_id_seq'::regclass) user_id | integer | | not null | language_id | text | | not null | + tenant_id | integer | | | Indexes: "codeintel_langugage_support_requests_user_id_language" UNIQUE, btree (user_id, language_id) +Foreign-key constraints: + "codeintel_langugage_support_requests_tenant_id_fkey" FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE ``` @@ -973,11 +1051,14 @@ Indexes: num_paths | integer | | | refcount_logsum | double precision | | | id | bigint | | not null | nextval('codeintel_path_ranks_id_seq'::regclass) + tenant_id | integer | | | Indexes: "codeintel_path_ranks_pkey" PRIMARY KEY, btree (id) "codeintel_path_ranks_graph_key_repository_id" UNIQUE, btree (graph_key, repository_id) "codeintel_path_ranks_graph_key" btree (graph_key, updated_at NULLS FIRST, id) "codeintel_path_ranks_repository_id_updated_at_id" btree (repository_id, updated_at NULLS FIRST, id) +Foreign-key constraints: + "codeintel_path_ranks_tenant_id_fkey" FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE Triggers: insert_codeintel_path_ranks_statistics BEFORE INSERT ON codeintel_path_ranks FOR EACH ROW EXECUTE FUNCTION update_codeintel_path_ranks_statistics_columns() update_codeintel_path_ranks_statistics BEFORE UPDATE ON codeintel_path_ranks FOR EACH ROW WHEN (new.* IS DISTINCT FROM old.*) EXECUTE FUNCTION update_codeintel_path_ranks_statistics_columns() @@ -995,12 +1076,14 @@ Triggers: graph_key | text | | not null | exported_upload_id | integer | | not null | symbol_checksum | bytea | | not null | '\x'::bytea + tenant_id | integer | | | Indexes: "codeintel_ranking_definitions_pkey" PRIMARY KEY, btree (id) "codeintel_ranking_definitions_exported_upload_id" btree (exported_upload_id) "codeintel_ranking_definitions_graph_key_symbol_checksum_search" btree (graph_key, symbol_checksum, exported_upload_id, document_path) Foreign-key constraints: "codeintel_ranking_definitions_exported_upload_id_fkey" FOREIGN KEY (exported_upload_id) REFERENCES codeintel_ranking_exports(id) ON DELETE CASCADE + "codeintel_ranking_definitions_tenant_id_fkey" FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE ``` @@ -1015,12 +1098,14 @@ Foreign-key constraints: last_scanned_at | timestamp with time zone | | | deleted_at | timestamp with time zone | | | upload_key | text | | | + tenant_id | integer | | | Indexes: "codeintel_ranking_exports_pkey" PRIMARY KEY, btree (id) "codeintel_ranking_exports_graph_key_upload_id" UNIQUE, btree (graph_key, upload_id) "codeintel_ranking_exports_graph_key_deleted_at_id" btree (graph_key, deleted_at DESC, id) "codeintel_ranking_exports_graph_key_last_scanned_at" btree (graph_key, last_scanned_at NULLS FIRST, id) Foreign-key constraints: + "codeintel_ranking_exports_tenant_id_fkey" FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE "codeintel_ranking_exports_upload_id_fkey" FOREIGN KEY (upload_id) REFERENCES lsif_uploads(id) ON DELETE SET NULL Referenced by: TABLE "codeintel_initial_path_ranks" CONSTRAINT "codeintel_initial_path_ranks_exported_upload_id_fkey" FOREIGN KEY (exported_upload_id) REFERENCES codeintel_ranking_exports(id) ON DELETE CASCADE @@ -1036,8 +1121,11 @@ Referenced by: id | integer | | not null | nextval('codeintel_ranking_graph_keys_id_seq'::regclass) graph_key | text | | not null | created_at | timestamp with time zone | | | now() + tenant_id | integer | | | Indexes: "codeintel_ranking_graph_keys_pkey" PRIMARY KEY, btree (id) +Foreign-key constraints: + "codeintel_ranking_graph_keys_tenant_id_fkey" FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE ``` @@ -1050,10 +1138,13 @@ Indexes: graph_key | text | | not null | processed | boolean | | not null | false definition_id | bigint | | | + tenant_id | integer | | | Indexes: "codeintel_ranking_path_counts_inputs_pkey" PRIMARY KEY, btree (id) "codeintel_ranking_path_counts_inputs_graph_key_unique_definitio" UNIQUE, btree (graph_key, definition_id) WHERE NOT processed "codeintel_ranking_path_counts_inputs_graph_key_id" btree (graph_key, id) +Foreign-key constraints: + "codeintel_ranking_path_counts_inputs_tenant_id_fkey" FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE ``` @@ -1079,9 +1170,12 @@ Indexes: reference_cursor_export_id | integer | | | path_cursor_deleted_export_at | timestamp with time zone | | | path_cursor_export_id | integer | | | + tenant_id | integer | | | Indexes: "codeintel_ranking_progress_pkey" PRIMARY KEY, btree (id) "codeintel_ranking_progress_graph_key_key" UNIQUE CONSTRAINT, btree (graph_key) +Foreign-key constraints: + "codeintel_ranking_progress_tenant_id_fkey" FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE ``` @@ -1094,12 +1188,14 @@ Indexes: graph_key | text | | not null | exported_upload_id | integer | | not null | symbol_checksums | bytea[] | | not null | '{}'::bytea[] + tenant_id | integer | | | Indexes: "codeintel_ranking_references_pkey" PRIMARY KEY, btree (id) "codeintel_ranking_references_exported_upload_id" btree (exported_upload_id) "codeintel_ranking_references_graph_key_id" btree (graph_key, id) Foreign-key constraints: "codeintel_ranking_references_exported_upload_id_fkey" FOREIGN KEY (exported_upload_id) REFERENCES codeintel_ranking_exports(id) ON DELETE CASCADE + "codeintel_ranking_references_tenant_id_fkey" FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE Referenced by: TABLE "codeintel_ranking_references_processed" CONSTRAINT "fk_codeintel_ranking_reference" FOREIGN KEY (codeintel_ranking_reference_id) REFERENCES codeintel_ranking_references(id) ON DELETE CASCADE @@ -1114,11 +1210,13 @@ References for a given upload proceduced by background job consuming SCIP indexe graph_key | text | | not null | codeintel_ranking_reference_id | integer | | not null | id | bigint | | not null | nextval('codeintel_ranking_references_processed_id_seq'::regclass) + tenant_id | integer | | | Indexes: "codeintel_ranking_references_processed_pkey" PRIMARY KEY, btree (id) "codeintel_ranking_references_processed_graph_key_codeintel_rank" UNIQUE, btree (graph_key, codeintel_ranking_reference_id) "codeintel_ranking_references_processed_reference_id" btree (codeintel_ranking_reference_id) Foreign-key constraints: + "codeintel_ranking_references_processed_tenant_id_fkey" FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE "fk_codeintel_ranking_reference" FOREIGN KEY (codeintel_ranking_reference_id) REFERENCES codeintel_ranking_references(id) ON DELETE CASCADE ``` @@ -1133,11 +1231,13 @@ Foreign-key constraints: repo_id | integer | | not null | created_at | timestamp with time zone | | not null | now() updated_at | timestamp with time zone | | not null | now() + tenant_id | integer | | | Indexes: "codeowners_pkey" PRIMARY KEY, btree (id) "codeowners_repo_id_key" UNIQUE CONSTRAINT, btree (repo_id) Foreign-key constraints: "codeowners_repo_id_fkey" FOREIGN KEY (repo_id) REFERENCES repo(id) ON DELETE CASCADE + "codeowners_tenant_id_fkey" FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE ``` @@ -1149,11 +1249,13 @@ Foreign-key constraints: owner_id | integer | | not null | tree_owned_files_count | integer | | not null | updated_at | timestamp without time zone | | not null | + tenant_id | integer | | | Indexes: "codeowners_individual_stats_pkey" PRIMARY KEY, btree (file_path_id, owner_id) Foreign-key constraints: "codeowners_individual_stats_file_path_id_fkey" FOREIGN KEY (file_path_id) REFERENCES repo_paths(id) "codeowners_individual_stats_owner_id_fkey" FOREIGN KEY (owner_id) REFERENCES codeowners_owners(id) + "codeowners_individual_stats_tenant_id_fkey" FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE ``` @@ -1173,9 +1275,12 @@ we are also indexing on owner_id which is CODEOWNERS-specific. -----------+---------+-----------+----------+----------------------------------------------- id | integer | | not null | nextval('codeowners_owners_id_seq'::regclass) reference | text | | not null | + tenant_id | integer | | | Indexes: "codeowners_owners_pkey" PRIMARY KEY, btree (id) "codeowners_owners_reference" btree (reference) +Foreign-key constraints: + "codeowners_owners_tenant_id_fkey" FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE Referenced by: TABLE "codeowners_individual_stats" CONSTRAINT "codeowners_individual_stats_owner_id_fkey" FOREIGN KEY (owner_id) REFERENCES codeowners_owners(id) @@ -1188,14 +1293,17 @@ since the distinction is not relevant for query, and this makes indexing way eas # Table "public.commit_authors" ``` - Column | Type | Collation | Nullable | Default ---------+---------+-----------+----------+-------------------------------------------- - id | integer | | not null | nextval('commit_authors_id_seq'::regclass) - email | text | | not null | - name | text | | not null | + Column | Type | Collation | Nullable | Default +-----------+---------+-----------+----------+-------------------------------------------- + id | integer | | not null | nextval('commit_authors_id_seq'::regclass) + email | text | | not null | + name | text | | not null | + tenant_id | integer | | | Indexes: "commit_authors_pkey" PRIMARY KEY, btree (id) "commit_authors_email_name" UNIQUE, btree (email, name) +Foreign-key constraints: + "commit_authors_tenant_id_fkey" FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE Referenced by: TABLE "own_aggregate_recent_contribution" CONSTRAINT "own_aggregate_recent_contribution_commit_author_id_fkey" FOREIGN KEY (commit_author_id) REFERENCES commit_authors(id) TABLE "own_signal_recent_contribution" CONSTRAINT "own_signal_recent_contribution_commit_author_id_fkey" FOREIGN KEY (commit_author_id) REFERENCES commit_authors(id) @@ -1212,9 +1320,12 @@ Referenced by: transition_columns | USER-DEFINED[] | | | sequence | bigint | | not null | nextval('configuration_policies_audit_logs_seq'::regclass) operation | audit_log_operation | | not null | + tenant_id | integer | | | Indexes: "configuration_policies_audit_logs_policy_id" btree (policy_id) "configuration_policies_audit_logs_timestamp" brin (log_timestamp) +Foreign-key constraints: + "configuration_policies_audit_logs_tenant_id_fkey" FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE ``` @@ -1241,8 +1352,11 @@ Indexes: execution_logs | json[] | | | worker_hostname | text | | not null | ''::text cancel | boolean | | not null | false + tenant_id | integer | | | Indexes: "context_detection_embedding_jobs_pkey" PRIMARY KEY, btree (id) +Foreign-key constraints: + "context_detection_embedding_jobs_tenant_id_fkey" FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE ``` @@ -1279,6 +1393,7 @@ Indexes: updated_at | timestamp with time zone | | not null | now() deleted_at | timestamp with time zone | | | reports | text[] | | not null | '{}'::text[] + tenant_id | integer | | | Indexes: "discussion_comments_pkey" PRIMARY KEY, btree (id) "discussion_comments_author_user_id_idx" btree (author_user_id) @@ -1286,6 +1401,7 @@ Indexes: "discussion_comments_thread_id_idx" btree (thread_id) Foreign-key constraints: "discussion_comments_author_user_id_fkey" FOREIGN KEY (author_user_id) REFERENCES users(id) ON DELETE RESTRICT + "discussion_comments_tenant_id_fkey" FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE "discussion_comments_thread_id_fkey" FOREIGN KEY (thread_id) REFERENCES discussion_threads(id) ON DELETE CASCADE ``` @@ -1298,10 +1414,12 @@ Foreign-key constraints: user_id | integer | | not null | thread_id | bigint | | not null | deleted_at | timestamp with time zone | | | + tenant_id | integer | | | Indexes: "discussion_mail_reply_tokens_pkey" PRIMARY KEY, btree (token) "discussion_mail_reply_tokens_user_id_thread_id_idx" btree (user_id, thread_id) Foreign-key constraints: + "discussion_mail_reply_tokens_tenant_id_fkey" FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE "discussion_mail_reply_tokens_thread_id_fkey" FOREIGN KEY (thread_id) REFERENCES discussion_threads(id) ON DELETE CASCADE "discussion_mail_reply_tokens_user_id_fkey" FOREIGN KEY (user_id) REFERENCES users(id) ON DELETE RESTRICT @@ -1319,12 +1437,14 @@ Foreign-key constraints: archived_at | timestamp with time zone | | | updated_at | timestamp with time zone | | not null | now() deleted_at | timestamp with time zone | | | + tenant_id | integer | | | Indexes: "discussion_threads_pkey" PRIMARY KEY, btree (id) "discussion_threads_author_user_id_idx" btree (author_user_id) Foreign-key constraints: "discussion_threads_author_user_id_fkey" FOREIGN KEY (author_user_id) REFERENCES users(id) ON DELETE RESTRICT "discussion_threads_target_repo_id_fk" FOREIGN KEY (target_repo_id) REFERENCES discussion_threads_target_repo(id) ON DELETE CASCADE + "discussion_threads_tenant_id_fkey" FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE Referenced by: TABLE "discussion_comments" CONSTRAINT "discussion_comments_thread_id_fkey" FOREIGN KEY (thread_id) REFERENCES discussion_threads(id) ON DELETE CASCADE TABLE "discussion_mail_reply_tokens" CONSTRAINT "discussion_mail_reply_tokens_thread_id_fkey" FOREIGN KEY (thread_id) REFERENCES discussion_threads(id) ON DELETE CASCADE @@ -1349,11 +1469,13 @@ Referenced by: lines_before | text | | | lines | text | | | lines_after | text | | | + tenant_id | integer | | | Indexes: "discussion_threads_target_repo_pkey" PRIMARY KEY, btree (id) "discussion_threads_target_repo_repo_id_path_idx" btree (repo_id, path) Foreign-key constraints: "discussion_threads_target_repo_repo_id_fkey" FOREIGN KEY (repo_id) REFERENCES repo(id) ON DELETE CASCADE + "discussion_threads_target_repo_tenant_id_fkey" FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE "discussion_threads_target_repo_thread_id_fkey" FOREIGN KEY (thread_id) REFERENCES discussion_threads(id) ON DELETE CASCADE Referenced by: TABLE "discussion_threads" CONSTRAINT "discussion_threads_target_repo_id_fk" FOREIGN KEY (target_repo_id) REFERENCES discussion_threads_target_repo(id) ON DELETE CASCADE @@ -1384,6 +1506,7 @@ Referenced by: billing_product_category | text | | | billing_event_id | text | | | client | text | | | + tenant_id | integer | | | Indexes: "event_logs_pkey" PRIMARY KEY, btree (id) "event_logs_anonymous_user_id" btree (anonymous_user_id) @@ -1398,6 +1521,8 @@ Check constraints: "event_logs_check_name_not_empty" CHECK (name <> ''::text) "event_logs_check_source_not_empty" CHECK (source <> ''::text) "event_logs_check_version_not_empty" CHECK (version <> ''::text) +Foreign-key constraints: + "event_logs_tenant_id_fkey" FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE ``` @@ -1407,9 +1532,12 @@ Check constraints: ------------+---------+-----------+----------+--------------------------------------------------------- id | integer | | not null | nextval('event_logs_export_allowlist_id_seq'::regclass) event_name | text | | not null | + tenant_id | integer | | | Indexes: "event_logs_export_allowlist_pkey" PRIMARY KEY, btree (id) "event_logs_export_allowlist_event_name_idx" UNIQUE, btree (event_name) +Foreign-key constraints: + "event_logs_export_allowlist_tenant_id_fkey" FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE ``` @@ -1423,8 +1551,11 @@ An allowlist of events that are approved for export if the scraping job is enabl -------------+---------+-----------+----------+----------------------------------------------------- id | integer | | not null | nextval('event_logs_scrape_state_id_seq'::regclass) bookmark_id | integer | | not null | + tenant_id | integer | | | Indexes: "event_logs_scrape_state_pk" PRIMARY KEY, btree (id) +Foreign-key constraints: + "event_logs_scrape_state_tenant_id_fkey" FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE ``` @@ -1439,8 +1570,11 @@ Contains state for the periodic telemetry job that scrapes events if enabled. id | integer | | not null | nextval('event_logs_scrape_state_own_id_seq'::regclass) bookmark_id | integer | | not null | job_type | integer | | not null | + tenant_id | integer | | | Indexes: "event_logs_scrape_state_own_pk" PRIMARY KEY, btree (id) +Foreign-key constraints: + "event_logs_scrape_state_own_tenant_id_fkey" FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE ``` @@ -1465,11 +1599,14 @@ Contains state for own jobs that scrape events if enabled. first_seen_at | timestamp with time zone | | not null | now() last_seen_at | timestamp with time zone | | not null | now() queue_names | text[] | | | + tenant_id | integer | | | Indexes: "executor_heartbeats_pkey" PRIMARY KEY, btree (id) "executor_heartbeats_hostname_key" UNIQUE CONSTRAINT, btree (hostname) Check constraints: "one_of_queue_name_queue_names" CHECK (queue_name IS NOT NULL AND queue_names IS NULL OR queue_names IS NOT NULL AND queue_name IS NULL) +Foreign-key constraints: + "executor_heartbeats_tenant_id_fkey" FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE ``` @@ -1510,10 +1647,13 @@ Tracks the most recent activity of executors attached to this Sourcegraph instan repo_id | bigint | | not null | created_at | timestamp with time zone | | not null | now() updated_at | timestamp with time zone | | not null | now() + tenant_id | integer | | | Indexes: "executor_job_tokens_pkey" PRIMARY KEY, btree (id) "executor_job_tokens_job_id_queue_repo_id_key" UNIQUE CONSTRAINT, btree (job_id, queue, repo_id) "executor_job_tokens_value_sha256_key" UNIQUE CONSTRAINT, btree (value_sha256) +Foreign-key constraints: + "executor_job_tokens_tenant_id_fkey" FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE ``` @@ -1526,12 +1666,14 @@ Indexes: user_id | integer | | | created_at | timestamp with time zone | | not null | now() machine_user | text | | not null | ''::text + tenant_id | integer | | | Indexes: "executor_secret_access_logs_pkey" PRIMARY KEY, btree (id) Check constraints: "user_id_or_machine_user" CHECK (user_id IS NULL AND machine_user <> ''::text OR user_id IS NOT NULL AND machine_user = ''::text) Foreign-key constraints: "executor_secret_access_logs_executor_secret_id_fkey" FOREIGN KEY (executor_secret_id) REFERENCES executor_secrets(id) ON DELETE CASCADE + "executor_secret_access_logs_tenant_id_fkey" FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE "executor_secret_access_logs_user_id_fkey" FOREIGN KEY (user_id) REFERENCES users(id) ON DELETE CASCADE ``` @@ -1550,6 +1692,7 @@ Foreign-key constraints: created_at | timestamp with time zone | | not null | now() updated_at | timestamp with time zone | | not null | now() creator_id | integer | | | + tenant_id | integer | | | Indexes: "executor_secrets_pkey" PRIMARY KEY, btree (id) "executor_secrets_unique_key_global" UNIQUE, btree (key, scope) WHERE namespace_user_id IS NULL AND namespace_org_id IS NULL @@ -1559,6 +1702,7 @@ Foreign-key constraints: "executor_secrets_creator_id_fkey" FOREIGN KEY (creator_id) REFERENCES users(id) ON DELETE SET NULL "executor_secrets_namespace_org_id_fkey" FOREIGN KEY (namespace_org_id) REFERENCES orgs(id) ON DELETE CASCADE "executor_secrets_namespace_user_id_fkey" FOREIGN KEY (namespace_user_id) REFERENCES users(id) ON DELETE CASCADE + "executor_secrets_tenant_id_fkey" FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE Referenced by: TABLE "executor_secret_access_logs" CONSTRAINT "executor_secret_access_logs_executor_secret_id_fkey" FOREIGN KEY (executor_secret_id) REFERENCES executor_secrets(id) ON DELETE CASCADE @@ -1588,11 +1732,13 @@ Referenced by: updated_at | timestamp with time zone | | not null | now() queued_at | timestamp with time zone | | | now() is_aggregated | boolean | | not null | false + tenant_id | integer | | | Indexes: "exhaustive_search_jobs_pkey" PRIMARY KEY, btree (id) "exhaustive_search_jobs_state" btree (state) Foreign-key constraints: "exhaustive_search_jobs_initiator_id_fkey" FOREIGN KEY (initiator_id) REFERENCES users(id) ON UPDATE CASCADE ON DELETE CASCADE DEFERRABLE + "exhaustive_search_jobs_tenant_id_fkey" FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE Referenced by: TABLE "exhaustive_search_repo_jobs" CONSTRAINT "exhaustive_search_repo_jobs_search_job_id_fkey" FOREIGN KEY (search_job_id) REFERENCES exhaustive_search_jobs(id) ON DELETE CASCADE @@ -1620,12 +1766,14 @@ Referenced by: created_at | timestamp with time zone | | not null | now() updated_at | timestamp with time zone | | not null | now() queued_at | timestamp with time zone | | | now() + tenant_id | integer | | | Indexes: "exhaustive_search_repo_jobs_pkey" PRIMARY KEY, btree (id) "exhaustive_search_repo_jobs_state" btree (state) Foreign-key constraints: "exhaustive_search_repo_jobs_repo_id_fkey" FOREIGN KEY (repo_id) REFERENCES repo(id) ON DELETE CASCADE "exhaustive_search_repo_jobs_search_job_id_fkey" FOREIGN KEY (search_job_id) REFERENCES exhaustive_search_jobs(id) ON DELETE CASCADE + "exhaustive_search_repo_jobs_tenant_id_fkey" FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE Referenced by: TABLE "exhaustive_search_repo_revision_jobs" CONSTRAINT "exhaustive_search_repo_revision_jobs_search_repo_job_id_fkey" FOREIGN KEY (search_repo_job_id) REFERENCES exhaustive_search_repo_jobs(id) ON DELETE CASCADE @@ -1652,11 +1800,13 @@ Referenced by: created_at | timestamp with time zone | | not null | now() updated_at | timestamp with time zone | | not null | now() queued_at | timestamp with time zone | | | now() + tenant_id | integer | | | Indexes: "exhaustive_search_repo_revision_jobs_pkey" PRIMARY KEY, btree (id) "exhaustive_search_repo_revision_jobs_state" btree (state) Foreign-key constraints: "exhaustive_search_repo_revision_jobs_search_repo_job_id_fkey" FOREIGN KEY (search_repo_job_id) REFERENCES exhaustive_search_repo_jobs(id) ON DELETE CASCADE + "exhaustive_search_repo_revision_jobs_tenant_id_fkey" FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE ``` @@ -1681,6 +1831,7 @@ Foreign-key constraints: permissions | json[] | | | unrestricted | boolean | | not null | false cancel | boolean | | not null | false + tenant_id | integer | | | Indexes: "explicit_permissions_bitbucket_projects_jobs_pkey" PRIMARY KEY, btree (id) "explicit_permissions_bitbucket_projects_jobs_project_key_extern" btree (project_key, external_service_id, state) @@ -1688,6 +1839,8 @@ Indexes: "explicit_permissions_bitbucket_projects_jobs_state_idx" btree (state) Check constraints: "explicit_permissions_bitbucket_projects_jobs_check" CHECK (permissions IS NOT NULL AND unrestricted IS FALSE OR permissions IS NULL AND unrestricted IS TRUE) +Foreign-key constraints: + "explicit_permissions_bitbucket_projects_jobs_tenant_id_fkey" FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE ``` @@ -1699,6 +1852,7 @@ Check constraints: repo_id | integer | | not null | clone_url | text | | not null | created_at | timestamp with time zone | | not null | transaction_timestamp() + tenant_id | integer | | | Indexes: "external_service_repos_repo_id_external_service_id_unique" UNIQUE CONSTRAINT, btree (repo_id, external_service_id) "external_service_repos_clone_url_idx" btree (clone_url) @@ -1706,6 +1860,7 @@ Indexes: Foreign-key constraints: "external_service_repos_external_service_id_fkey" FOREIGN KEY (external_service_id) REFERENCES external_services(id) ON DELETE CASCADE DEFERRABLE "external_service_repos_repo_id_fkey" FOREIGN KEY (repo_id) REFERENCES repo(id) ON DELETE CASCADE DEFERRABLE + "external_service_repos_tenant_id_fkey" FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE ``` @@ -1734,9 +1889,11 @@ Foreign-key constraints: repos_deleted | integer | | not null | 0 repos_modified | integer | | not null | 0 repos_unmodified | integer | | not null | 0 + tenant_id | integer | | | Indexes: "external_service_sync_jobs_state_external_service_id" btree (state, external_service_id) INCLUDE (finished_at) Foreign-key constraints: + "external_service_sync_jobs_tenant_id_fkey" FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE "external_services_id_fk" FOREIGN KEY (external_service_id) REFERENCES external_services(id) ON DELETE CASCADE ``` @@ -1774,6 +1931,7 @@ Foreign-key constraints: code_host_id | integer | | | creator_id | integer | | | last_updater_id | integer | | | + tenant_id | integer | | | Indexes: "external_services_pkey" PRIMARY KEY, btree (id) "kind_cloud_default" UNIQUE, btree (kind, cloud_default) WHERE cloud_default = true AND deleted_at IS NULL @@ -1784,6 +1942,7 @@ Foreign-key constraints: "external_services_code_host_id_fkey" FOREIGN KEY (code_host_id) REFERENCES code_hosts(id) ON UPDATE CASCADE ON DELETE SET NULL DEFERRABLE INITIALLY DEFERRED "external_services_creator_id_fkey" FOREIGN KEY (creator_id) REFERENCES users(id) ON DELETE SET NULL DEFERRABLE "external_services_last_updater_id_fkey" FOREIGN KEY (last_updater_id) REFERENCES users(id) ON DELETE SET NULL DEFERRABLE + "external_services_tenant_id_fkey" FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE Referenced by: TABLE "external_service_repos" CONSTRAINT "external_service_repos_external_service_id_fkey" FOREIGN KEY (external_service_id) REFERENCES external_services(id) ON DELETE CASCADE DEFERRABLE TABLE "external_service_sync_jobs" CONSTRAINT "external_services_id_fk" FOREIGN KEY (external_service_id) REFERENCES external_services(id) ON DELETE CASCADE @@ -1802,6 +1961,7 @@ Referenced by: created_at | timestamp with time zone | | not null | now() updated_at | timestamp with time zone | | not null | now() deleted_at | timestamp with time zone | | | + tenant_id | integer | | | Indexes: "feature_flag_overrides_unique_org_flag" UNIQUE CONSTRAINT, btree (namespace_org_id, flag_name) "feature_flag_overrides_unique_user_flag" UNIQUE CONSTRAINT, btree (namespace_user_id, flag_name) @@ -1812,6 +1972,7 @@ Check constraints: Foreign-key constraints: "feature_flag_overrides_namespace_org_id_fkey" FOREIGN KEY (namespace_org_id) REFERENCES orgs(id) ON DELETE CASCADE "feature_flag_overrides_namespace_user_id_fkey" FOREIGN KEY (namespace_user_id) REFERENCES users(id) ON DELETE CASCADE + "feature_flag_overrides_tenant_id_fkey" FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE ``` @@ -1826,6 +1987,7 @@ Foreign-key constraints: created_at | timestamp with time zone | | not null | now() updated_at | timestamp with time zone | | not null | now() deleted_at | timestamp with time zone | | | + tenant_id | integer | | | Indexes: "feature_flags_pkey" PRIMARY KEY, btree (flag_name) Check constraints: @@ -1842,6 +2004,8 @@ CASE WHEN flag_type <> 'rollout'::feature_flag_type AND rollout IS NOT NULL THEN 0 ELSE 1 END) +Foreign-key constraints: + "feature_flags_tenant_id_fkey" FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE ``` @@ -1863,6 +2027,7 @@ END) account_url | text | | | account_type | text | | | updated_at | timestamp with time zone | | not null | now() + tenant_id | integer | | | Indexes: "github_app_installs_pkey" PRIMARY KEY, btree (id) "unique_app_install" UNIQUE CONSTRAINT, btree (app_id, installation_id) @@ -1871,6 +2036,7 @@ Indexes: "installation_id_idx" btree (installation_id) Foreign-key constraints: "github_app_installs_app_id_fkey" FOREIGN KEY (app_id) REFERENCES github_apps(id) ON DELETE CASCADE + "github_app_installs_tenant_id_fkey" FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE ``` @@ -1895,10 +2061,12 @@ Foreign-key constraints: domain | text | | not null | 'repos'::text kind | github_app_kind | | not null | 'REPO_SYNC'::github_app_kind creator_id | bigint | | not null | 0 + tenant_id | integer | | | Indexes: "github_apps_pkey" PRIMARY KEY, btree (id) "github_apps_app_id_slug_base_url_unique" UNIQUE, btree (app_id, slug, base_url) Foreign-key constraints: + "github_apps_tenant_id_fkey" FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE "github_apps_webhook_id_fkey" FOREIGN KEY (webhook_id) REFERENCES webhooks(id) ON DELETE SET NULL Referenced by: TABLE "batch_changes_site_credentials" CONSTRAINT "batch_changes_site_credentials_github_app_id_fkey" FOREIGN KEY (github_app_id) REFERENCES github_apps(id) ON DELETE CASCADE @@ -1928,9 +2096,12 @@ Referenced by: dest_hostname | text | | not null | delete_source | boolean | | not null | false cancel | boolean | | not null | false + tenant_id | integer | | | Indexes: "gitserver_relocator_jobs_pkey" PRIMARY KEY, btree (id) "gitserver_relocator_jobs_state" btree (state) +Foreign-key constraints: + "gitserver_relocator_jobs_tenant_id_fkey" FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE ``` @@ -1949,6 +2120,7 @@ Indexes: corrupted_at | timestamp with time zone | | | corruption_logs | jsonb | | not null | '[]'::jsonb cloning_progress | text | | | ''::text + tenant_id | integer | | | Indexes: "gitserver_repos_pkey" PRIMARY KEY, btree (repo_id) "gitserver_repo_size_bytes" btree (repo_size_bytes) @@ -1961,6 +2133,7 @@ Indexes: "gitserver_repos_shard_id" btree (shard_id, repo_id) Foreign-key constraints: "gitserver_repos_repo_id_fkey" FOREIGN KEY (repo_id) REFERENCES repo(id) ON DELETE CASCADE + "gitserver_repos_tenant_id_fkey" FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE Triggers: trig_recalc_gitserver_repos_statistics_on_delete AFTER DELETE ON gitserver_repos REFERENCING OLD TABLE AS oldtab FOR EACH STATEMENT EXECUTE FUNCTION recalc_gitserver_repos_statistics_on_delete() trig_recalc_gitserver_repos_statistics_on_insert AFTER INSERT ON gitserver_repos REFERENCING NEW TABLE AS newtab FOR EACH STATEMENT EXECUTE FUNCTION recalc_gitserver_repos_statistics_on_insert() @@ -1974,17 +2147,20 @@ Triggers: # Table "public.gitserver_repos_statistics" ``` - Column | Type | Collation | Nullable | Default ---------------+--------+-----------+----------+--------- - shard_id | text | | | - total | bigint | | not null | 0 - not_cloned | bigint | | not null | 0 - cloning | bigint | | not null | 0 - cloned | bigint | | not null | 0 - failed_fetch | bigint | | not null | 0 - corrupted | bigint | | not null | 0 + Column | Type | Collation | Nullable | Default +--------------+---------+-----------+----------+--------- + shard_id | text | | | + total | bigint | | not null | 0 + not_cloned | bigint | | not null | 0 + cloning | bigint | | not null | 0 + cloned | bigint | | not null | 0 + failed_fetch | bigint | | not null | 0 + corrupted | bigint | | not null | 0 + tenant_id | integer | | | Indexes: "gitserver_repos_statistics_shard_id" btree (shard_id) +Foreign-key constraints: + "gitserver_repos_statistics_tenant_id_fkey" FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE ``` @@ -2009,10 +2185,12 @@ Indexes: repo_id | integer | | not null | last_output | text | | not null | ''::text updated_at | timestamp with time zone | | not null | now() + tenant_id | integer | | | Indexes: "gitserver_repos_sync_output_pkey" PRIMARY KEY, btree (repo_id) Foreign-key constraints: "gitserver_repos_sync_output_repo_id_fkey" FOREIGN KEY (repo_id) REFERENCES repo(id) ON DELETE CASCADE + "gitserver_repos_sync_output_tenant_id_fkey" FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE ``` @@ -2024,8 +2202,11 @@ Contains the most recent output from gitserver repository sync jobs. -------------+---------+-----------+----------+--------- site_id | uuid | | not null | initialized | boolean | | not null | false + tenant_id | integer | | | Indexes: "global_state_pkey" PRIMARY KEY, btree (site_id) +Foreign-key constraints: + "global_state_tenant_id_fkey" FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE ``` @@ -2053,6 +2234,7 @@ Indexes: queued_at | timestamp with time zone | | | now() cancel | boolean | | not null | false trace_id | text | | | + tenant_id | integer | | | Indexes: "insights_query_runner_jobs_pkey" PRIMARY KEY, btree (id) "finished_at_insights_query_runner_jobs_idx" btree (finished_at) @@ -2062,6 +2244,8 @@ Indexes: "insights_query_runner_jobs_series_id_state" btree (series_id, state) "insights_query_runner_jobs_state_btree" btree (state) "process_after_insights_query_runner_jobs_idx" btree (process_after) +Foreign-key constraints: + "insights_query_runner_jobs_tenant_id_fkey" FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE Referenced by: TABLE "insights_query_runner_jobs_dependencies" CONSTRAINT "insights_query_runner_jobs_dependencies_fk_job_id" FOREIGN KEY (job_id) REFERENCES insights_query_runner_jobs(id) ON DELETE CASCADE @@ -2082,11 +2266,13 @@ See [internal/insights/background/queryrunner/worker.go:Job](https://sourcegraph id | integer | | not null | nextval('insights_query_runner_jobs_dependencies_id_seq'::regclass) job_id | integer | | not null | recording_time | timestamp without time zone | | not null | + tenant_id | integer | | | Indexes: "insights_query_runner_jobs_dependencies_pkey" PRIMARY KEY, btree (id) "insights_query_runner_jobs_dependencies_job_id_fk_idx" btree (job_id) Foreign-key constraints: "insights_query_runner_jobs_dependencies_fk_job_id" FOREIGN KEY (job_id) REFERENCES insights_query_runner_jobs(id) ON DELETE CASCADE + "insights_query_runner_jobs_dependencies_tenant_id_fkey" FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE ``` @@ -2111,6 +2297,9 @@ Stores data points for a code insight that do not need to be queried directly, b migrated_dashboards | integer | | not null | 0 runs | integer | | not null | 0 completed_at | timestamp without time zone | | | + tenant_id | integer | | | +Foreign-key constraints: + "insights_settings_migration_jobs_tenant_id_fkey" FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE ``` @@ -2134,9 +2323,12 @@ Stores data points for a code insight that do not need to be queried directly, b last_resolved_at | timestamp with time zone | | | embeddings_enabled | boolean | | not null | false syntactic_indexing_enabled | boolean | | not null | false + tenant_id | integer | | | Indexes: "lsif_configuration_policies_pkey" PRIMARY KEY, btree (id) "lsif_configuration_policies_repository_id" btree (repository_id) +Foreign-key constraints: + "lsif_configuration_policies_tenant_id_fkey" FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE Triggers: trigger_configuration_policies_delete AFTER DELETE ON lsif_configuration_policies REFERENCING OLD TABLE AS old FOR EACH STATEMENT EXECUTE FUNCTION func_configuration_policies_delete() trigger_configuration_policies_insert AFTER INSERT ON lsif_configuration_policies FOR EACH ROW EXECUTE FUNCTION func_configuration_policies_insert() @@ -2172,8 +2364,11 @@ Triggers: -----------+---------+-----------+----------+--------- policy_id | integer | | not null | repo_id | integer | | not null | + tenant_id | integer | | | Indexes: "lsif_configuration_policies_repository_pattern_lookup_pkey" PRIMARY KEY, btree (policy_id, repo_id) +Foreign-key constraints: + "lsif_configuration_policies_repository_pattern_l_tenant_id_fkey" FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE ``` @@ -2203,10 +2398,12 @@ A lookup table to get all the repository patterns by repository id that apply to external_service_kind | text | | not null | ''::text external_service_sync | timestamp with time zone | | | cancel | boolean | | not null | false + tenant_id | integer | | | Indexes: "lsif_dependency_indexing_jobs_pkey1" PRIMARY KEY, btree (id) "lsif_dependency_indexing_jobs_state" btree (state) Foreign-key constraints: + "lsif_dependency_indexing_jobs_tenant_id_fkey" FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE "lsif_dependency_indexing_jobs_upload_id_fkey1" FOREIGN KEY (upload_id) REFERENCES lsif_uploads(id) ON DELETE CASCADE ``` @@ -2224,6 +2421,7 @@ Foreign-key constraints: scheme | text | | not null | blocked | boolean | | not null | false last_checked_at | timestamp with time zone | | | + tenant_id | integer | | | Indexes: "lsif_dependency_repos_pkey" PRIMARY KEY, btree (id) "lsif_dependency_repos_unique_scheme_name" UNIQUE, btree (scheme, name) @@ -2232,6 +2430,8 @@ Indexes: "lsif_dependency_repos_name_gin" gin (name gin_trgm_ops) "lsif_dependency_repos_name_id" btree (name, id) "lsif_dependency_repos_scheme_id" btree (scheme, id) +Foreign-key constraints: + "lsif_dependency_repos_tenant_id_fkey" FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE Referenced by: TABLE "package_repo_versions" CONSTRAINT "package_id_fk" FOREIGN KEY (package_id) REFERENCES lsif_dependency_repos(id) ON DELETE CASCADE @@ -2255,12 +2455,14 @@ Referenced by: worker_hostname | text | | not null | ''::text last_heartbeat_at | timestamp with time zone | | | cancel | boolean | | not null | false + tenant_id | integer | | | Indexes: "lsif_dependency_indexing_jobs_pkey" PRIMARY KEY, btree (id) "lsif_dependency_indexing_jobs_upload_id" btree (upload_id) "lsif_dependency_syncing_jobs_state" btree (state) Foreign-key constraints: "lsif_dependency_indexing_jobs_upload_id_fkey" FOREIGN KEY (upload_id) REFERENCES lsif_uploads(id) ON DELETE CASCADE + "lsif_dependency_syncing_jobs_tenant_id_fkey" FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE ``` @@ -2277,8 +2479,11 @@ Tracks jobs that scan imports of indexes to schedule auto-index jobs. update_token | integer | | not null | updated_at | timestamp with time zone | | | set_dirty_at | timestamp with time zone | | not null | now() + tenant_id | integer | | | Indexes: "lsif_dirty_repositories_pkey" PRIMARY KEY, btree (repository_id) +Foreign-key constraints: + "lsif_dirty_repositories_tenant_id_fkey" FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE ``` @@ -2298,11 +2503,13 @@ Stores whether or not the nearest upload data for a repository is out of date (w repository_id | integer | | not null | data | bytea | | not null | autoindex_enabled | boolean | | not null | true + tenant_id | integer | | | Indexes: "lsif_index_configuration_pkey" PRIMARY KEY, btree (id) "lsif_index_configuration_repository_id_key" UNIQUE CONSTRAINT, btree (repository_id) Foreign-key constraints: "lsif_index_configuration_repository_id_fkey" FOREIGN KEY (repository_id) REFERENCES repo(id) ON DELETE CASCADE + "lsif_index_configuration_tenant_id_fkey" FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE ``` @@ -2342,6 +2549,7 @@ Stores the configuration used for code intel index jobs for a repository. should_reindex | boolean | | not null | false requested_envvars | text[] | | | enqueuer_user_id | integer | | not null | 0 + tenant_id | integer | | | Indexes: "lsif_indexes_pkey" PRIMARY KEY, btree (id) "lsif_indexes_commit_last_checked_at" btree (commit_last_checked_at) WHERE state <> 'deleted'::text @@ -2352,6 +2560,8 @@ Indexes: "lsif_indexes_state" btree (state) Check constraints: "lsif_uploads_commit_valid_chars" CHECK (commit ~ '^[a-z0-9]{40}$'::text) +Foreign-key constraints: + "lsif_indexes_tenant_id_fkey" FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE ``` @@ -2381,8 +2591,11 @@ Stores metadata about a code intel index job. --------------------+--------------------------+-----------+----------+--------- repository_id | integer | | not null | last_index_scan_at | timestamp with time zone | | not null | + tenant_id | integer | | | Indexes: "lsif_last_index_scan_pkey" PRIMARY KEY, btree (repository_id) +Foreign-key constraints: + "lsif_last_index_scan_tenant_id_fkey" FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE ``` @@ -2396,8 +2609,11 @@ Tracks the last time repository was checked for auto-indexing job scheduling. ------------------------+--------------------------+-----------+----------+--------- repository_id | integer | | not null | last_retention_scan_at | timestamp with time zone | | not null | + tenant_id | integer | | | Indexes: "lsif_last_retention_scan_pkey" PRIMARY KEY, btree (repository_id) +Foreign-key constraints: + "lsif_last_retention_scan_tenant_id_fkey" FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE ``` @@ -2412,9 +2628,12 @@ Tracks the last time uploads a repository were checked against data retention po repository_id | integer | | not null | commit_bytea | bytea | | not null | uploads | jsonb | | not null | + tenant_id | integer | | | Indexes: "lsif_nearest_uploads_repository_id_commit_bytea" btree (repository_id, commit_bytea) "lsif_nearest_uploads_uploads" gin (uploads) +Foreign-key constraints: + "lsif_nearest_uploads_tenant_id_fkey" FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE ``` @@ -2432,9 +2651,12 @@ Associates commits with the complete set of uploads visible from that commit. Ev commit_bytea | bytea | | not null | ancestor_commit_bytea | bytea | | not null | distance | integer | | not null | + tenant_id | integer | | | Indexes: "lsif_nearest_uploads_links_repository_id_ancestor_commit_bytea" btree (repository_id, ancestor_commit_bytea) "lsif_nearest_uploads_links_repository_id_commit_bytea" btree (repository_id, commit_bytea) +Foreign-key constraints: + "lsif_nearest_uploads_links_tenant_id_fkey" FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE ``` @@ -2448,20 +2670,22 @@ Associates commits with the closest ancestor commit with usable upload data. Tog # Table "public.lsif_packages" ``` - Column | Type | Collation | Nullable | Default ----------+---------+-----------+----------+------------------------------------------- - id | integer | | not null | nextval('lsif_packages_id_seq'::regclass) - scheme | text | | not null | - name | text | | not null | - version | text | | | - dump_id | integer | | not null | - manager | text | | not null | ''::text + Column | Type | Collation | Nullable | Default +-----------+---------+-----------+----------+------------------------------------------- + id | integer | | not null | nextval('lsif_packages_id_seq'::regclass) + scheme | text | | not null | + name | text | | not null | + version | text | | | + dump_id | integer | | not null | + manager | text | | not null | ''::text + tenant_id | integer | | | Indexes: "lsif_packages_pkey" PRIMARY KEY, btree (id) "lsif_packages_dump_id" btree (dump_id) "lsif_packages_scheme_name_version_dump_id" btree (scheme, name, version, dump_id) Foreign-key constraints: "lsif_packages_dump_id_fkey" FOREIGN KEY (dump_id) REFERENCES lsif_uploads(id) ON DELETE CASCADE + "lsif_packages_tenant_id_fkey" FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE ``` @@ -2479,20 +2703,22 @@ Associates an upload with the set of packages they provide within a given packag # Table "public.lsif_references" ``` - Column | Type | Collation | Nullable | Default ----------+---------+-----------+----------+--------------------------------------------- - id | integer | | not null | nextval('lsif_references_id_seq'::regclass) - scheme | text | | not null | - name | text | | not null | - version | text | | | - dump_id | integer | | not null | - manager | text | | not null | ''::text + Column | Type | Collation | Nullable | Default +-----------+---------+-----------+----------+--------------------------------------------- + id | integer | | not null | nextval('lsif_references_id_seq'::regclass) + scheme | text | | not null | + name | text | | not null | + version | text | | | + dump_id | integer | | not null | + manager | text | | not null | ''::text + tenant_id | integer | | | Indexes: "lsif_references_pkey" PRIMARY KEY, btree (id) "lsif_references_dump_id" btree (dump_id) "lsif_references_scheme_name_version_dump_id" btree (scheme, name, version, dump_id) Foreign-key constraints: "lsif_references_dump_id_fkey" FOREIGN KEY (dump_id) REFERENCES lsif_uploads(id) ON DELETE CASCADE + "lsif_references_tenant_id_fkey" FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE ``` @@ -2516,11 +2742,13 @@ Associates an upload with the set of packages they require within a given packag repository_id | integer | | not null | max_age_for_non_stale_branches_seconds | integer | | not null | max_age_for_non_stale_tags_seconds | integer | | not null | + tenant_id | integer | | | Indexes: "lsif_retention_configuration_pkey" PRIMARY KEY, btree (id) "lsif_retention_configuration_repository_id_key" UNIQUE CONSTRAINT, btree (repository_id) Foreign-key constraints: "lsif_retention_configuration_repository_id_fkey" FOREIGN KEY (repository_id) REFERENCES repo(id) ON DELETE CASCADE + "lsif_retention_configuration_tenant_id_fkey" FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE ``` @@ -2569,6 +2797,7 @@ Stores the retention policy of code intellience data for a repository. last_reconcile_at | timestamp with time zone | | | content_type | text | | not null | 'application/x-ndjson+lsif'::text should_reindex | boolean | | not null | false + tenant_id | integer | | | Indexes: "lsif_uploads_pkey" PRIMARY KEY, btree (id) "lsif_uploads_repository_id_commit_root_indexer" UNIQUE, btree (repository_id, commit, root, indexer) WHERE state = 'completed'::text @@ -2582,6 +2811,8 @@ Indexes: "lsif_uploads_uploaded_at_id" btree (uploaded_at DESC, id) WHERE state <> 'deleted'::text Check constraints: "lsif_uploads_commit_valid_chars" CHECK (commit ~ '^[a-z0-9]{40}$'::text) +Foreign-key constraints: + "lsif_uploads_tenant_id_fkey" FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE Referenced by: TABLE "codeintel_ranking_exports" CONSTRAINT "codeintel_ranking_exports_upload_id_fkey" FOREIGN KEY (upload_id) REFERENCES lsif_uploads(id) ON DELETE SET NULL TABLE "vulnerability_matches" CONSTRAINT "fk_upload" FOREIGN KEY (upload_id) REFERENCES lsif_uploads(id) ON DELETE CASCADE @@ -2650,9 +2881,12 @@ Stores metadata about an LSIF index uploaded by a user. sequence | bigint | | not null | nextval('lsif_uploads_audit_logs_seq'::regclass) operation | audit_log_operation | | not null | content_type | text | | not null | 'application/x-ndjson+lsif'::text + tenant_id | integer | | | Indexes: "lsif_uploads_audit_logs_timestamp" brin (log_timestamp) "lsif_uploads_audit_logs_upload_id" btree (upload_id) +Foreign-key constraints: + "lsif_uploads_audit_logs_tenant_id_fkey" FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE ``` @@ -2670,9 +2904,11 @@ Indexes: -----------------+---------+-----------+----------+--------- upload_id | integer | | not null | reference_count | integer | | not null | + tenant_id | integer | | | Indexes: "lsif_uploads_reference_counts_upload_id_key" UNIQUE CONSTRAINT, btree (upload_id) Foreign-key constraints: + "lsif_uploads_reference_counts_tenant_id_fkey" FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE "lsif_uploads_reference_counts_upload_id_fk" FOREIGN KEY (upload_id) REFERENCES lsif_uploads(id) ON DELETE CASCADE ``` @@ -2691,9 +2927,12 @@ A less hot-path reference count for upload records. upload_id | integer | | not null | branch_or_tag_name | text | | not null | ''::text is_default_branch | boolean | | not null | false + tenant_id | integer | | | Indexes: "lsif_uploads_visible_at_tip_is_default_branch" btree (upload_id) WHERE is_default_branch "lsif_uploads_visible_at_tip_repository_id_upload_id" btree (repository_id, upload_id) +Foreign-key constraints: + "lsif_uploads_visible_at_tip_tenant_id_fkey" FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE ``` @@ -2712,11 +2951,13 @@ Associates a repository with the set of LSIF upload identifiers that can serve i id | bigint | | not null | nextval('lsif_uploads_vulnerability_scan_id_seq'::regclass) upload_id | integer | | not null | last_scanned_at | timestamp without time zone | | not null | now() + tenant_id | integer | | | Indexes: "lsif_uploads_vulnerability_scan_pkey" PRIMARY KEY, btree (id) "lsif_uploads_vulnerability_scan_upload_id" UNIQUE, btree (upload_id) Foreign-key constraints: "fk_upload_id" FOREIGN KEY (upload_id) REFERENCES lsif_uploads(id) ON DELETE CASCADE + "lsif_uploads_vulnerability_scan_tenant_id_fkey" FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE ``` @@ -2741,12 +2982,13 @@ Indexes: # Table "public.names" ``` - Column | Type | Collation | Nullable | Default ----------+---------+-----------+----------+--------- - name | citext | | not null | - user_id | integer | | | - org_id | integer | | | - team_id | integer | | | + Column | Type | Collation | Nullable | Default +-----------+---------+-----------+----------+--------- + name | citext | | not null | + user_id | integer | | | + org_id | integer | | | + team_id | integer | | | + tenant_id | integer | | | Indexes: "names_pkey" PRIMARY KEY, btree (name) Check constraints: @@ -2754,6 +2996,7 @@ Check constraints: Foreign-key constraints: "names_org_id_fkey" FOREIGN KEY (org_id) REFERENCES orgs(id) ON UPDATE CASCADE ON DELETE CASCADE "names_team_id_fkey" FOREIGN KEY (team_id) REFERENCES teams(id) ON UPDATE CASCADE ON DELETE CASCADE + "names_tenant_id_fkey" FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE "names_user_id_fkey" FOREIGN KEY (user_id) REFERENCES users(id) ON UPDATE CASCADE ON DELETE CASCADE ``` @@ -2767,12 +3010,14 @@ Foreign-key constraints: resource_id | integer | | not null | user_id | integer | | not null | created_at | timestamp with time zone | | not null | now() + tenant_id | integer | | | Indexes: "namespace_permissions_pkey" PRIMARY KEY, btree (id) "unique_resource_permission" UNIQUE, btree (namespace, resource_id, user_id) Check constraints: "namespace_not_blank" CHECK (namespace <> ''::text) Foreign-key constraints: + "namespace_permissions_tenant_id_fkey" FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE "namespace_permissions_user_id_fkey" FOREIGN KEY (user_id) REFERENCES users(id) ON DELETE CASCADE DEFERRABLE ``` @@ -2784,11 +3029,13 @@ Foreign-key constraints: notebook_id | integer | | not null | user_id | integer | | not null | created_at | timestamp with time zone | | not null | now() + tenant_id | integer | | | Indexes: "notebook_stars_pkey" PRIMARY KEY, btree (notebook_id, user_id) "notebook_stars_user_id_idx" btree (user_id) Foreign-key constraints: "notebook_stars_notebook_id_fkey" FOREIGN KEY (notebook_id) REFERENCES notebooks(id) ON DELETE CASCADE DEFERRABLE + "notebook_stars_tenant_id_fkey" FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE "notebook_stars_user_id_fkey" FOREIGN KEY (user_id) REFERENCES users(id) ON DELETE CASCADE DEFERRABLE ``` @@ -2809,6 +3056,7 @@ Foreign-key constraints: namespace_org_id | integer | | | updater_user_id | integer | | | pattern_type | pattern_type | | not null | 'keyword'::pattern_type + tenant_id | integer | | | Indexes: "notebooks_pkey" PRIMARY KEY, btree (id) "notebooks_blocks_tsvector_idx" gin (blocks_tsvector) @@ -2822,6 +3070,7 @@ Foreign-key constraints: "notebooks_creator_user_id_fkey" FOREIGN KEY (creator_user_id) REFERENCES users(id) ON DELETE SET NULL DEFERRABLE "notebooks_namespace_org_id_fkey" FOREIGN KEY (namespace_org_id) REFERENCES orgs(id) ON DELETE SET NULL DEFERRABLE "notebooks_namespace_user_id_fkey" FOREIGN KEY (namespace_user_id) REFERENCES users(id) ON DELETE SET NULL DEFERRABLE + "notebooks_tenant_id_fkey" FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE "notebooks_updater_user_id_fkey" FOREIGN KEY (updater_user_id) REFERENCES users(id) ON DELETE SET NULL DEFERRABLE Referenced by: TABLE "notebook_stars" CONSTRAINT "notebook_stars_notebook_id_fkey" FOREIGN KEY (notebook_id) REFERENCES notebooks(id) ON DELETE CASCADE DEFERRABLE @@ -2844,6 +3093,7 @@ Referenced by: deleted_at | timestamp with time zone | | | recipient_email | citext | | | expires_at | timestamp with time zone | | | + tenant_id | integer | | | Indexes: "org_invitations_pkey" PRIMARY KEY, btree (id) "org_invitations_org_id" btree (org_id) WHERE deleted_at IS NULL @@ -2856,6 +3106,7 @@ Foreign-key constraints: "org_invitations_org_id_fkey" FOREIGN KEY (org_id) REFERENCES orgs(id) "org_invitations_recipient_user_id_fkey" FOREIGN KEY (recipient_user_id) REFERENCES users(id) "org_invitations_sender_user_id_fkey" FOREIGN KEY (sender_user_id) REFERENCES users(id) + "org_invitations_tenant_id_fkey" FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE ``` @@ -2868,11 +3119,13 @@ Foreign-key constraints: created_at | timestamp with time zone | | not null | now() updated_at | timestamp with time zone | | not null | now() user_id | integer | | not null | + tenant_id | integer | | | Indexes: "org_members_pkey" PRIMARY KEY, btree (id) "org_members_org_id_user_id_key" UNIQUE CONSTRAINT, btree (org_id, user_id) Foreign-key constraints: "org_members_references_orgs" FOREIGN KEY (org_id) REFERENCES orgs(id) ON DELETE RESTRICT + "org_members_tenant_id_fkey" FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE "org_members_user_id_fkey" FOREIGN KEY (user_id) REFERENCES users(id) ON DELETE RESTRICT ``` @@ -2884,10 +3137,12 @@ Foreign-key constraints: org_id | integer | | not null | code_host_repo_count | integer | | | 0 updated_at | timestamp with time zone | | not null | now() + tenant_id | integer | | | Indexes: "org_stats_pkey" PRIMARY KEY, btree (org_id) Foreign-key constraints: "org_stats_org_id_fkey" FOREIGN KEY (org_id) REFERENCES orgs(id) ON DELETE CASCADE DEFERRABLE + "org_stats_tenant_id_fkey" FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE ``` @@ -2908,6 +3163,7 @@ Business statistics for organizations display_name | text | | | slack_webhook_url | text | | | deleted_at | timestamp with time zone | | | + tenant_id | integer | | | Indexes: "orgs_pkey" PRIMARY KEY, btree (id) "orgs_name" UNIQUE, btree (name) WHERE deleted_at IS NULL @@ -2915,6 +3171,8 @@ Check constraints: "orgs_display_name_max_length" CHECK (char_length(display_name) <= 255) "orgs_name_max_length" CHECK (char_length(name::text) <= 255) "orgs_name_valid_chars" CHECK (name ~ '^[a-zA-Z0-9](?:[a-zA-Z0-9]|[-.](?=[a-zA-Z0-9]))*-?$'::citext) +Foreign-key constraints: + "orgs_tenant_id_fkey" FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE Referenced by: TABLE "batch_changes" CONSTRAINT "batch_changes_namespace_org_id_fkey" FOREIGN KEY (namespace_org_id) REFERENCES orgs(id) ON DELETE CASCADE DEFERRABLE TABLE "cm_monitors" CONSTRAINT "cm_monitors_org_id_fk" FOREIGN KEY (namespace_org_id) REFERENCES orgs(id) ON DELETE CASCADE @@ -2943,8 +3201,11 @@ Referenced by: org_id | integer | | | created_at | timestamp with time zone | | | now() data | jsonb | | not null | '{}'::jsonb + tenant_id | integer | | | Indexes: "orgs_open_beta_stats_pkey" PRIMARY KEY, btree (id) +Foreign-key constraints: + "orgs_open_beta_stats_tenant_id_fkey" FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE ``` @@ -2967,6 +3228,7 @@ Indexes: deprecated_version_major | integer | | | deprecated_version_minor | integer | | | metadata | jsonb | | not null | '{}'::jsonb + tenant_id | integer | | | Indexes: "out_of_band_migrations_pkey" PRIMARY KEY, btree (id) Check constraints: @@ -2974,6 +3236,8 @@ Check constraints: "out_of_band_migrations_description_nonempty" CHECK (description <> ''::text) "out_of_band_migrations_progress_range" CHECK (progress >= 0::double precision AND progress <= 1::double precision) "out_of_band_migrations_team_nonempty" CHECK (team <> ''::text) +Foreign-key constraints: + "out_of_band_migrations_tenant_id_fkey" FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE Referenced by: TABLE "out_of_band_migrations_errors" CONSTRAINT "out_of_band_migrations_errors_migration_id_fkey" FOREIGN KEY (migration_id) REFERENCES out_of_band_migrations(id) ON DELETE CASCADE @@ -3017,12 +3281,14 @@ Stores metadata and progress about an out-of-band migration routine. migration_id | integer | | not null | message | text | | not null | created | timestamp with time zone | | not null | now() + tenant_id | integer | | | Indexes: "out_of_band_migrations_errors_pkey" PRIMARY KEY, btree (id) Check constraints: "out_of_band_migrations_errors_message_nonempty" CHECK (message <> ''::text) Foreign-key constraints: "out_of_band_migrations_errors_migration_id_fkey" FOREIGN KEY (migration_id) REFERENCES out_of_band_migrations(id) ON DELETE CASCADE + "out_of_band_migrations_errors_tenant_id_fkey" FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE ``` @@ -3038,17 +3304,19 @@ Stores errors that occurred while performing an out-of-band migration. # Table "public.outbound_webhook_event_types" ``` - Column | Type | Collation | Nullable | Default ----------------------+--------+-----------+----------+---------------------------------------------------------- - id | bigint | | not null | nextval('outbound_webhook_event_types_id_seq'::regclass) - outbound_webhook_id | bigint | | not null | - event_type | text | | not null | - scope | text | | | + Column | Type | Collation | Nullable | Default +---------------------+---------+-----------+----------+---------------------------------------------------------- + id | bigint | | not null | nextval('outbound_webhook_event_types_id_seq'::regclass) + outbound_webhook_id | bigint | | not null | + event_type | text | | not null | + scope | text | | | + tenant_id | integer | | | Indexes: "outbound_webhook_event_types_pkey" PRIMARY KEY, btree (id) "outbound_webhook_event_types_event_type_idx" btree (event_type, scope) Foreign-key constraints: "outbound_webhook_event_types_outbound_webhook_id_fkey" FOREIGN KEY (outbound_webhook_id) REFERENCES outbound_webhooks(id) ON UPDATE CASCADE ON DELETE CASCADE + "outbound_webhook_event_types_tenant_id_fkey" FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE ``` @@ -3073,10 +3341,13 @@ Foreign-key constraints: execution_logs | json[] | | | worker_hostname | text | | not null | ''::text cancel | boolean | | not null | false + tenant_id | integer | | | Indexes: "outbound_webhook_jobs_pkey" PRIMARY KEY, btree (id) "outbound_webhook_jobs_state_idx" btree (state) "outbound_webhook_payload_process_after_idx" btree (process_after) +Foreign-key constraints: + "outbound_webhook_jobs_tenant_id_fkey" FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE Referenced by: TABLE "outbound_webhook_logs" CONSTRAINT "outbound_webhook_logs_job_id_fkey" FOREIGN KEY (job_id) REFERENCES outbound_webhook_jobs(id) ON UPDATE CASCADE ON DELETE CASCADE @@ -3095,6 +3366,7 @@ Referenced by: request | bytea | | not null | response | bytea | | not null | error | bytea | | not null | + tenant_id | integer | | | Indexes: "outbound_webhook_logs_pkey" PRIMARY KEY, btree (id) "outbound_webhook_logs_outbound_webhook_id_idx" btree (outbound_webhook_id) @@ -3102,6 +3374,7 @@ Indexes: Foreign-key constraints: "outbound_webhook_logs_job_id_fkey" FOREIGN KEY (job_id) REFERENCES outbound_webhook_jobs(id) ON UPDATE CASCADE ON DELETE CASCADE "outbound_webhook_logs_outbound_webhook_id_fkey" FOREIGN KEY (outbound_webhook_id) REFERENCES outbound_webhooks(id) ON UPDATE CASCADE ON DELETE CASCADE + "outbound_webhook_logs_tenant_id_fkey" FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE ``` @@ -3117,10 +3390,12 @@ Foreign-key constraints: encryption_key_id | text | | | url | bytea | | not null | secret | bytea | | not null | + tenant_id | integer | | | Indexes: "outbound_webhooks_pkey" PRIMARY KEY, btree (id) Foreign-key constraints: "outbound_webhooks_created_by_fkey" FOREIGN KEY (created_by) REFERENCES users(id) ON DELETE SET NULL + "outbound_webhooks_tenant_id_fkey" FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE "outbound_webhooks_updated_by_fkey" FOREIGN KEY (updated_by) REFERENCES users(id) ON DELETE SET NULL Referenced by: TABLE "outbound_webhook_event_types" CONSTRAINT "outbound_webhook_event_types_outbound_webhook_id_fkey" FOREIGN KEY (outbound_webhook_id) REFERENCES outbound_webhooks(id) ON UPDATE CASCADE ON DELETE CASCADE @@ -3136,12 +3411,14 @@ Referenced by: commit_author_id | integer | | not null | changed_file_path_id | integer | | not null | contributions_count | integer | | | 0 + tenant_id | integer | | | Indexes: "own_aggregate_recent_contribution_pkey" PRIMARY KEY, btree (id) "own_aggregate_recent_contribution_file_author" UNIQUE, btree (changed_file_path_id, commit_author_id) Foreign-key constraints: "own_aggregate_recent_contribution_changed_file_path_id_fkey" FOREIGN KEY (changed_file_path_id) REFERENCES repo_paths(id) "own_aggregate_recent_contribution_commit_author_id_fkey" FOREIGN KEY (commit_author_id) REFERENCES commit_authors(id) + "own_aggregate_recent_contribution_tenant_id_fkey" FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE ``` @@ -3153,10 +3430,12 @@ Foreign-key constraints: viewer_id | integer | | not null | viewed_file_path_id | integer | | not null | views_count | integer | | | 0 + tenant_id | integer | | | Indexes: "own_aggregate_recent_view_pkey" PRIMARY KEY, btree (id) "own_aggregate_recent_view_viewer" UNIQUE, btree (viewed_file_path_id, viewer_id) Foreign-key constraints: + "own_aggregate_recent_view_tenant_id_fkey" FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE "own_aggregate_recent_view_viewed_file_path_id_fkey" FOREIGN KEY (viewed_file_path_id) REFERENCES repo_paths(id) "own_aggregate_recent_view_viewer_id_fkey" FOREIGN KEY (viewer_id) REFERENCES users(id) ON DELETE CASCADE DEFERRABLE @@ -3183,10 +3462,13 @@ One entry contains a number of views of a single file by a given viewer. cancel | boolean | | not null | false repo_id | integer | | not null | job_type | integer | | not null | + tenant_id | integer | | | Indexes: "own_background_jobs_pkey" PRIMARY KEY, btree (id) "own_background_jobs_repo_id_idx" btree (repo_id) "own_background_jobs_state_idx" btree (state) +Foreign-key constraints: + "own_background_jobs_tenant_id_fkey" FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE ``` @@ -3199,9 +3481,12 @@ Indexes: description | text | | not null | ''::text excluded_repo_patterns | text[] | | | enabled | boolean | | not null | false + tenant_id | integer | | | Indexes: "own_signal_configurations_pkey" PRIMARY KEY, btree (id) "own_signal_configurations_name_uidx" UNIQUE, btree (name) +Foreign-key constraints: + "own_signal_configurations_tenant_id_fkey" FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE ``` @@ -3214,11 +3499,13 @@ Indexes: changed_file_path_id | integer | | not null | commit_timestamp | timestamp without time zone | | not null | commit_id | bytea | | not null | + tenant_id | integer | | | Indexes: "own_signal_recent_contribution_pkey" PRIMARY KEY, btree (id) Foreign-key constraints: "own_signal_recent_contribution_changed_file_path_id_fkey" FOREIGN KEY (changed_file_path_id) REFERENCES repo_paths(id) "own_signal_recent_contribution_commit_author_id_fkey" FOREIGN KEY (commit_author_id) REFERENCES commit_authors(id) + "own_signal_recent_contribution_tenant_id_fkey" FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE Triggers: update_own_aggregate_recent_contribution AFTER INSERT ON own_signal_recent_contribution FOR EACH ROW EXECUTE FUNCTION update_own_aggregate_recent_contribution() @@ -3235,10 +3522,12 @@ One entry per file changed in every commit that classifies as a contribution sig last_updated_at | timestamp without time zone | | not null | tree_assigned_ownership_files_count | integer | | | tree_any_ownership_files_count | integer | | | + tenant_id | integer | | | Indexes: "ownership_path_stats_pkey" PRIMARY KEY, btree (file_path_id) Foreign-key constraints: "ownership_path_stats_file_path_id_fkey" FOREIGN KEY (file_path_id) REFERENCES repo_paths(id) + "ownership_path_stats_tenant_id_fkey" FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE ``` @@ -3261,6 +3550,7 @@ or assigned ownership), and perhaps files count by assigned ownership only. matcher | jsonb | | not null | deleted_at | timestamp with time zone | | | updated_at | timestamp with time zone | | not null | statement_timestamp() + tenant_id | integer | | | Indexes: "package_repo_filters_pkey" PRIMARY KEY, btree (id) "package_repo_filters_unique_matcher_per_scheme" UNIQUE, btree (scheme, matcher) @@ -3268,6 +3558,8 @@ Check constraints: "package_repo_filters_behaviour_is_allow_or_block" CHECK (behaviour = ANY ('{BLOCK,ALLOW}'::text[])) "package_repo_filters_is_pkgrepo_scheme" CHECK (scheme = ANY ('{semanticdb,npm,go,python,rust-analyzer,scip-ruby}'::text[])) "package_repo_filters_valid_oneof_glob" CHECK (matcher ? 'VersionGlob'::text AND (matcher ->> 'VersionGlob'::text) <> ''::text AND (matcher ->> 'PackageName'::text) <> ''::text AND NOT matcher ? 'PackageGlob'::text OR matcher ? 'PackageGlob'::text AND (matcher ->> 'PackageGlob'::text) <> ''::text AND NOT matcher ? 'VersionGlob'::text) +Foreign-key constraints: + "package_repo_filters_tenant_id_fkey" FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE Triggers: trigger_package_repo_filters_updated_at BEFORE UPDATE ON package_repo_filters FOR EACH ROW WHEN (old.* IS DISTINCT FROM new.*) EXECUTE FUNCTION func_package_repo_filters_updated_at() @@ -3282,6 +3574,7 @@ Triggers: version | text | | not null | blocked | boolean | | not null | false last_checked_at | timestamp with time zone | | | + tenant_id | integer | | | Indexes: "package_repo_versions_pkey" PRIMARY KEY, btree (id) "package_repo_versions_unique_version_per_package" UNIQUE, btree (package_id, version) @@ -3289,6 +3582,7 @@ Indexes: "package_repo_versions_last_checked_at" btree (last_checked_at NULLS FIRST) Foreign-key constraints: "package_id_fk" FOREIGN KEY (package_id) REFERENCES lsif_dependency_repos(id) ON DELETE CASCADE + "package_repo_versions_tenant_id_fkey" FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE ``` @@ -3322,6 +3616,7 @@ Foreign-key constraints: permissions_found | integer | | not null | 0 code_host_states | json[] | | | is_partial_success | boolean | | | false + tenant_id | integer | | | Indexes: "permission_sync_jobs_pkey" PRIMARY KEY, btree (id) "permission_sync_jobs_unique" UNIQUE, btree (priority, user_id, repository_id, cancel, process_after) WHERE state = 'queued'::text @@ -3333,6 +3628,7 @@ Check constraints: "permission_sync_jobs_for_repo_or_user" CHECK ((user_id IS NULL) <> (repository_id IS NULL)) Foreign-key constraints: "permission_sync_jobs_repository_id_fkey" FOREIGN KEY (repository_id) REFERENCES repo(id) ON DELETE CASCADE + "permission_sync_jobs_tenant_id_fkey" FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE "permission_sync_jobs_triggered_by_user_id_fkey" FOREIGN KEY (triggered_by_user_id) REFERENCES users(id) ON DELETE SET NULL DEFERRABLE "permission_sync_jobs_user_id_fkey" FOREIGN KEY (user_id) REFERENCES users(id) ON DELETE CASCADE @@ -3354,12 +3650,15 @@ Foreign-key constraints: namespace | text | | not null | action | text | | not null | created_at | timestamp with time zone | | not null | now() + tenant_id | integer | | | Indexes: "permissions_pkey" PRIMARY KEY, btree (id) "permissions_unique_namespace_action" UNIQUE, btree (namespace, action) Check constraints: "action_not_blank" CHECK (action <> ''::text) "namespace_not_blank" CHECK (namespace <> ''::text) +Foreign-key constraints: + "permissions_tenant_id_fkey" FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE Referenced by: TABLE "role_permissions" CONSTRAINT "role_permissions_permission_id_fkey" FOREIGN KEY (permission_id) REFERENCES permissions(id) ON DELETE CASCADE DEFERRABLE @@ -3376,9 +3675,12 @@ Referenced by: updated_at | timestamp with time zone | | not null | now() deleted_at | timestamp with time zone | | | url | text | | not null | ''::text + tenant_id | integer | | | Indexes: "phabricator_repos_pkey" PRIMARY KEY, btree (id) "phabricator_repos_repo_name_key" UNIQUE CONSTRAINT, btree (repo_name) +Foreign-key constraints: + "phabricator_repos_tenant_id_fkey" FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE ``` @@ -3401,11 +3703,13 @@ Indexes: salesforce_sub_id | text | | | salesforce_opp_id | text | | | revoke_reason | text | | | + tenant_id | integer | | | Indexes: "product_licenses_pkey" PRIMARY KEY, btree (id) "product_licenses_license_check_token_idx" UNIQUE, btree (license_check_token) Foreign-key constraints: "product_licenses_product_subscription_id_fkey" FOREIGN KEY (product_subscription_id) REFERENCES product_subscriptions(id) + "product_licenses_tenant_id_fkey" FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE ``` @@ -3432,9 +3736,11 @@ Foreign-key constraints: cody_gateway_code_rate_limit | bigint | | | cody_gateway_code_rate_interval_seconds | integer | | | cody_gateway_code_rate_limit_allowed_models | text[] | | | + tenant_id | integer | | | Indexes: "product_subscriptions_pkey" PRIMARY KEY, btree (id) Foreign-key constraints: + "product_subscriptions_tenant_id_fkey" FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE "product_subscriptions_user_id_fkey" FOREIGN KEY (user_id) REFERENCES users(id) Referenced by: TABLE "product_licenses" CONSTRAINT "product_licenses_product_subscription_id_fkey" FOREIGN KEY (product_subscription_id) REFERENCES product_subscriptions(id) @@ -3463,6 +3769,7 @@ Referenced by: created_at | timestamp with time zone | | not null | now() updated_by | integer | | | updated_at | timestamp with time zone | | not null | now() + tenant_id | integer | | | Indexes: "prompts_pkey" PRIMARY KEY, btree (id) "prompts_name_is_unique_in_owner_org" UNIQUE, btree (owner_org_id, name) WHERE owner_org_id IS NOT NULL @@ -3477,6 +3784,7 @@ Foreign-key constraints: "prompts_created_by_fkey" FOREIGN KEY (created_by) REFERENCES users(id) ON DELETE SET NULL "prompts_owner_org_id_fkey" FOREIGN KEY (owner_org_id) REFERENCES orgs(id) ON DELETE CASCADE "prompts_owner_user_id_fkey" FOREIGN KEY (owner_user_id) REFERENCES users(id) ON DELETE CASCADE + "prompts_tenant_id_fkey" FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE "prompts_updated_by_fkey" FOREIGN KEY (updated_by) REFERENCES users(id) ON DELETE SET NULL ``` @@ -3489,18 +3797,24 @@ Foreign-key constraints: last_executed | timestamp with time zone | | | latest_result | timestamp with time zone | | | exec_duration_ns | bigint | | | + tenant_id | integer | | | +Foreign-key constraints: + "query_runner_state_tenant_id_fkey" FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE ``` # Table "public.redis_key_value" ``` - Column | Type | Collation | Nullable | Default ------------+-------+-----------+----------+--------- - namespace | text | | not null | - key | text | | not null | - value | bytea | | not null | + Column | Type | Collation | Nullable | Default +-----------+---------+-----------+----------+--------- + namespace | text | | not null | + key | text | | not null | + value | bytea | | not null | + tenant_id | integer | | | Indexes: "redis_key_value_pkey" PRIMARY KEY, btree (namespace, key) INCLUDE (value) +Foreign-key constraints: + "redis_key_value_tenant_id_fkey" FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE ``` @@ -3518,6 +3832,7 @@ Indexes: created_at | timestamp with time zone | | not null | now() deleted_at | timestamp with time zone | | | source_map | text | | | + tenant_id | integer | | | Indexes: "registry_extension_releases_pkey" PRIMARY KEY, btree (id) "registry_extension_releases_version" UNIQUE, btree (registry_extension_id, release_version) WHERE release_version IS NOT NULL @@ -3526,6 +3841,7 @@ Indexes: Foreign-key constraints: "registry_extension_releases_creator_user_id_fkey" FOREIGN KEY (creator_user_id) REFERENCES users(id) "registry_extension_releases_registry_extension_id_fkey" FOREIGN KEY (registry_extension_id) REFERENCES registry_extensions(id) ON UPDATE CASCADE ON DELETE CASCADE + "registry_extension_releases_tenant_id_fkey" FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE ``` @@ -3542,6 +3858,7 @@ Foreign-key constraints: created_at | timestamp with time zone | | not null | now() updated_at | timestamp with time zone | | not null | now() deleted_at | timestamp with time zone | | | + tenant_id | integer | | | Indexes: "registry_extensions_pkey" PRIMARY KEY, btree (id) "registry_extensions_publisher_name" UNIQUE, btree (COALESCE(publisher_user_id, 0), COALESCE(publisher_org_id, 0), name) WHERE deleted_at IS NULL @@ -3553,6 +3870,7 @@ Check constraints: Foreign-key constraints: "registry_extensions_publisher_org_id_fkey" FOREIGN KEY (publisher_org_id) REFERENCES orgs(id) "registry_extensions_publisher_user_id_fkey" FOREIGN KEY (publisher_user_id) REFERENCES users(id) + "registry_extensions_tenant_id_fkey" FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE Referenced by: TABLE "registry_extension_releases" CONSTRAINT "registry_extension_releases_registry_extension_id_fkey" FOREIGN KEY (registry_extension_id) REFERENCES registry_extensions(id) ON UPDATE CASCADE ON DELETE CASCADE @@ -3579,6 +3897,7 @@ Referenced by: stars | integer | | not null | 0 blocked | jsonb | | | topics | text[] | | | generated always as (extract_topics_from_metadata(external_service_type, metadata)) stored + tenant_id | integer | | | Indexes: "repo_pkey" PRIMARY KEY, btree (id) "repo_external_unique_idx" UNIQUE, btree (external_service_type, external_service_id, external_id) @@ -3604,6 +3923,8 @@ Indexes: Check constraints: "check_name_nonempty" CHECK (name <> ''::citext) "repo_metadata_check" CHECK (jsonb_typeof(metadata) = 'object'::text) +Foreign-key constraints: + "repo_tenant_id_fkey" FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE Referenced by: TABLE "batch_spec_workspaces" CONSTRAINT "batch_spec_workspaces_repo_id_fkey" FOREIGN KEY (repo_id) REFERENCES repo(id) DEFERRABLE TABLE "changeset_specs" CONSTRAINT "changeset_specs_repo_id_fkey" FOREIGN KEY (repo_id) REFERENCES repo(id) DEFERRABLE @@ -3647,11 +3968,13 @@ Triggers: commit_sha | bytea | | not null | perforce_changelist_id | integer | | not null | created_at | timestamp with time zone | | not null | now() + tenant_id | integer | | | Indexes: "repo_commits_changelists_pkey" PRIMARY KEY, btree (id) "repo_id_perforce_changelist_id_unique" UNIQUE, btree (repo_id, perforce_changelist_id) Foreign-key constraints: "repo_commits_changelists_repo_id_fkey" FOREIGN KEY (repo_id) REFERENCES repo(id) ON DELETE CASCADE DEFERRABLE + "repo_commits_changelists_tenant_id_fkey" FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE ``` @@ -3673,10 +3996,12 @@ Foreign-key constraints: text_bytes_embedded | bigint | | not null | 0 code_chunks_excluded | integer | | not null | 0 text_chunks_excluded | integer | | not null | 0 + tenant_id | integer | | | Indexes: "repo_embedding_job_stats_pkey" PRIMARY KEY, btree (job_id) Foreign-key constraints: "repo_embedding_job_stats_job_id_fkey" FOREIGN KEY (job_id) REFERENCES repo_embedding_jobs(id) ON DELETE CASCADE DEFERRABLE + "repo_embedding_job_stats_tenant_id_fkey" FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE ``` @@ -3699,9 +4024,12 @@ Foreign-key constraints: cancel | boolean | | not null | false repo_id | integer | | not null | revision | text | | not null | + tenant_id | integer | | | Indexes: "repo_embedding_jobs_pkey" PRIMARY KEY, btree (id) "repo_embedding_jobs_repo" btree (repo_id, revision) +Foreign-key constraints: + "repo_embedding_jobs_tenant_id_fkey" FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE Referenced by: TABLE "repo_embedding_job_stats" CONSTRAINT "repo_embedding_job_stats_job_id_fkey" FOREIGN KEY (job_id) REFERENCES repo_embedding_jobs(id) ON DELETE CASCADE DEFERRABLE @@ -3709,16 +4037,18 @@ Referenced by: # Table "public.repo_kvps" ``` - Column | Type | Collation | Nullable | Default ----------+---------+-----------+----------+--------- - repo_id | integer | | not null | - key | text | | not null | - value | text | | | + Column | Type | Collation | Nullable | Default +-----------+---------+-----------+----------+--------- + repo_id | integer | | not null | + key | text | | not null | + value | text | | | + tenant_id | integer | | | Indexes: "repo_kvps_pkey" PRIMARY KEY, btree (repo_id, key) INCLUDE (value) "repo_kvps_trgm_idx" gin (key gin_trgm_ops, value gin_trgm_ops) Foreign-key constraints: "repo_kvps_repo_id_fkey" FOREIGN KEY (repo_id) REFERENCES repo(id) ON DELETE CASCADE + "repo_kvps_tenant_id_fkey" FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE ``` @@ -3732,12 +4062,14 @@ Foreign-key constraints: parent_id | integer | | | tree_files_count | integer | | | tree_files_counts_updated_at | timestamp without time zone | | | + tenant_id | integer | | | Indexes: "repo_paths_pkey" PRIMARY KEY, btree (id) "repo_paths_index_absolute_path" UNIQUE, btree (repo_id, absolute_path) Foreign-key constraints: "repo_paths_parent_id_fkey" FOREIGN KEY (parent_id) REFERENCES repo_paths(id) "repo_paths_repo_id_fkey" FOREIGN KEY (repo_id) REFERENCES repo(id) ON DELETE CASCADE DEFERRABLE + "repo_paths_tenant_id_fkey" FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE Referenced by: TABLE "assigned_owners" CONSTRAINT "assigned_owners_file_path_id_fkey" FOREIGN KEY (file_path_id) REFERENCES repo_paths(id) TABLE "assigned_teams" CONSTRAINT "assigned_teams_file_path_id_fkey" FOREIGN KEY (file_path_id) REFERENCES repo_paths(id) @@ -3764,8 +4096,11 @@ Referenced by: permission | text | | not null | updated_at | timestamp with time zone | | not null | user_ids_ints | bigint[] | | not null | '{}'::integer[] + tenant_id | integer | | | Indexes: "repo_pending_permissions_perm_unique" UNIQUE CONSTRAINT, btree (repo_id, permission) +Foreign-key constraints: + "repo_pending_permissions_tenant_id_fkey" FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE ``` @@ -3779,23 +4114,29 @@ Indexes: synced_at | timestamp with time zone | | | user_ids_ints | integer[] | | not null | '{}'::integer[] unrestricted | boolean | | not null | false + tenant_id | integer | | | Indexes: "repo_permissions_perm_unique" UNIQUE CONSTRAINT, btree (repo_id, permission) "repo_permissions_unrestricted_true_idx" btree (unrestricted) WHERE unrestricted +Foreign-key constraints: + "repo_permissions_tenant_id_fkey" FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE ``` # Table "public.repo_statistics" ``` - Column | Type | Collation | Nullable | Default ---------------+--------+-----------+----------+--------- - total | bigint | | not null | 0 - soft_deleted | bigint | | not null | 0 - not_cloned | bigint | | not null | 0 - cloning | bigint | | not null | 0 - cloned | bigint | | not null | 0 - failed_fetch | bigint | | not null | 0 - corrupted | bigint | | not null | 0 + Column | Type | Collation | Nullable | Default +--------------+---------+-----------+----------+--------- + total | bigint | | not null | 0 + soft_deleted | bigint | | not null | 0 + not_cloned | bigint | | not null | 0 + cloning | bigint | | not null | 0 + cloned | bigint | | not null | 0 + failed_fetch | bigint | | not null | 0 + corrupted | bigint | | not null | 0 + tenant_id | integer | | | +Foreign-key constraints: + "repo_statistics_tenant_id_fkey" FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE ``` @@ -3820,11 +4161,13 @@ Indexes: role_id | integer | | not null | permission_id | integer | | not null | created_at | timestamp with time zone | | not null | now() + tenant_id | integer | | | Indexes: "role_permissions_pkey" PRIMARY KEY, btree (permission_id, role_id) Foreign-key constraints: "role_permissions_permission_id_fkey" FOREIGN KEY (permission_id) REFERENCES permissions(id) ON DELETE CASCADE DEFERRABLE "role_permissions_role_id_fkey" FOREIGN KEY (role_id) REFERENCES roles(id) ON DELETE CASCADE DEFERRABLE + "role_permissions_tenant_id_fkey" FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE ``` @@ -3836,9 +4179,12 @@ Foreign-key constraints: created_at | timestamp with time zone | | not null | now() system | boolean | | not null | false name | citext | | not null | + tenant_id | integer | | | Indexes: "roles_pkey" PRIMARY KEY, btree (id) "unique_role_name" UNIQUE, btree (name) +Foreign-key constraints: + "roles_tenant_id_fkey" FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE Referenced by: TABLE "role_permissions" CONSTRAINT "role_permissions_role_id_fkey" FOREIGN KEY (role_id) REFERENCES roles(id) ON DELETE CASCADE DEFERRABLE TABLE "user_roles" CONSTRAINT "user_roles_role_id_fkey" FOREIGN KEY (role_id) REFERENCES roles(id) ON DELETE CASCADE DEFERRABLE @@ -3865,6 +4211,7 @@ Referenced by: updated_by | integer | | | draft | boolean | | not null | false visibility_secret | boolean | | not null | true + tenant_id | integer | | | Indexes: "saved_searches_pkey" PRIMARY KEY, btree (id) Check constraints: @@ -3873,6 +4220,7 @@ Check constraints: Foreign-key constraints: "saved_searches_created_by_fkey" FOREIGN KEY (created_by) REFERENCES users(id) ON DELETE SET NULL "saved_searches_org_id_fkey" FOREIGN KEY (org_id) REFERENCES orgs(id) + "saved_searches_tenant_id_fkey" FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE "saved_searches_updated_by_fkey" FOREIGN KEY (updated_by) REFERENCES users(id) ON DELETE SET NULL "saved_searches_user_id_fkey" FOREIGN KEY (user_id) REFERENCES users(id) @@ -3884,10 +4232,12 @@ Foreign-key constraints: -------------------+---------+-----------+----------+--------- user_id | integer | | not null | search_context_id | bigint | | not null | + tenant_id | integer | | | Indexes: "search_context_default_pkey" PRIMARY KEY, btree (user_id) Foreign-key constraints: "search_context_default_search_context_id_fkey" FOREIGN KEY (search_context_id) REFERENCES search_contexts(id) ON DELETE CASCADE DEFERRABLE + "search_context_default_tenant_id_fkey" FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE "search_context_default_user_id_fkey" FOREIGN KEY (user_id) REFERENCES users(id) ON DELETE CASCADE DEFERRABLE ``` @@ -3901,11 +4251,13 @@ When a user sets a search context as default, a row is inserted into this table. search_context_id | bigint | | not null | repo_id | integer | | not null | revision | text | | not null | + tenant_id | integer | | | Indexes: "search_context_repos_unique" UNIQUE CONSTRAINT, btree (repo_id, search_context_id, revision) Foreign-key constraints: "search_context_repos_repo_id_fk" FOREIGN KEY (repo_id) REFERENCES repo(id) ON DELETE CASCADE "search_context_repos_search_context_id_fk" FOREIGN KEY (search_context_id) REFERENCES search_contexts(id) ON DELETE CASCADE + "search_context_repos_tenant_id_fkey" FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE ``` @@ -3916,10 +4268,12 @@ Foreign-key constraints: search_context_id | bigint | | not null | user_id | integer | | not null | created_at | timestamp with time zone | | not null | now() + tenant_id | integer | | | Indexes: "search_context_stars_pkey" PRIMARY KEY, btree (search_context_id, user_id) Foreign-key constraints: "search_context_stars_search_context_id_fkey" FOREIGN KEY (search_context_id) REFERENCES search_contexts(id) ON DELETE CASCADE DEFERRABLE + "search_context_stars_tenant_id_fkey" FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE "search_context_stars_user_id_fkey" FOREIGN KEY (user_id) REFERENCES users(id) ON DELETE CASCADE DEFERRABLE ``` @@ -3940,6 +4294,7 @@ When a user stars a search context, a row is inserted into this table. If the us updated_at | timestamp with time zone | | not null | now() deleted_at | timestamp with time zone | | | query | text | | | + tenant_id | integer | | | Indexes: "search_contexts_pkey" PRIMARY KEY, btree (id) "search_contexts_name_namespace_org_id_unique" UNIQUE, btree (name, namespace_org_id) WHERE namespace_org_id IS NOT NULL @@ -3951,6 +4306,7 @@ Check constraints: Foreign-key constraints: "search_contexts_namespace_org_id_fk" FOREIGN KEY (namespace_org_id) REFERENCES orgs(id) ON DELETE CASCADE "search_contexts_namespace_user_id_fk" FOREIGN KEY (namespace_user_id) REFERENCES users(id) ON DELETE CASCADE + "search_contexts_tenant_id_fkey" FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE Referenced by: TABLE "search_context_default" CONSTRAINT "search_context_default_search_context_id_fkey" FOREIGN KEY (search_context_id) REFERENCES search_contexts(id) ON DELETE CASCADE DEFERRABLE TABLE "search_context_repos" CONSTRAINT "search_context_repos_search_context_id_fk" FOREIGN KEY (search_context_id) REFERENCES search_contexts(id) ON DELETE CASCADE @@ -3973,6 +4329,7 @@ Referenced by: argument | jsonb | | not null | version | text | | not null | timestamp | timestamp with time zone | | not null | + tenant_id | integer | | | Indexes: "security_event_logs_pkey" PRIMARY KEY, btree (id) "security_event_logs_timestamp" btree ("timestamp") @@ -3981,6 +4338,8 @@ Check constraints: "security_event_logs_check_name_not_empty" CHECK (name <> ''::text) "security_event_logs_check_source_not_empty" CHECK (source <> ''::text) "security_event_logs_check_version_not_empty" CHECK (version <> ''::text) +Foreign-key constraints: + "security_event_logs_tenant_id_fkey" FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE ``` @@ -4010,6 +4369,7 @@ Contains security-relevant events with a long time horizon for storage. created_at | timestamp with time zone | | not null | now() user_id | integer | | | author_user_id | integer | | | + tenant_id | integer | | | Indexes: "settings_pkey" PRIMARY KEY, btree (id) "settings_global_id" btree (id DESC) WHERE user_id IS NULL AND org_id IS NULL @@ -4020,6 +4380,7 @@ Check constraints: Foreign-key constraints: "settings_author_user_id_fkey" FOREIGN KEY (author_user_id) REFERENCES users(id) ON DELETE RESTRICT "settings_references_orgs" FOREIGN KEY (org_id) REFERENCES orgs(id) ON DELETE RESTRICT + "settings_tenant_id_fkey" FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE "settings_user_id_fkey" FOREIGN KEY (user_id) REFERENCES users(id) ON DELETE RESTRICT ``` @@ -4034,6 +4395,7 @@ Foreign-key constraints: updated_at | timestamp with time zone | | not null | now() paths | text[] | | | ips | text[] | | | + tenant_id | integer | | | Indexes: "sub_repo_permissions_repo_id_user_id_version_uindex" UNIQUE, btree (repo_id, user_id, version) "sub_repo_perms_user_id" btree (user_id) @@ -4041,6 +4403,7 @@ Check constraints: "ips_paths_length_check" CHECK (ips IS NULL OR array_length(ips, 1) = array_length(paths, 1) AND NOT (''::text = ANY (ips))) Foreign-key constraints: "sub_repo_permissions_repo_id_fk" FOREIGN KEY (repo_id) REFERENCES repo(id) ON DELETE CASCADE + "sub_repo_permissions_tenant_id_fkey" FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE "sub_repo_permissions_users_id_fk" FOREIGN KEY (user_id) REFERENCES users(id) ON DELETE CASCADE ``` @@ -4064,9 +4427,11 @@ Responsible for storing permissions at a finer granularity than repo created_at | timestamp with time zone | | not null | now() use_cases | text[] | | | other_use_case | text | | | + tenant_id | integer | | | Indexes: "survey_responses_pkey" PRIMARY KEY, btree (id) Foreign-key constraints: + "survey_responses_tenant_id_fkey" FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE "survey_responses_user_id_fkey" FOREIGN KEY (user_id) REFERENCES users(id) ``` @@ -4093,6 +4458,7 @@ Foreign-key constraints: cancel | boolean | | not null | false should_reindex | boolean | | not null | false enqueuer_user_id | integer | | not null | 0 + tenant_id | integer | | | Indexes: "syntactic_scip_indexing_jobs_pkey" PRIMARY KEY, btree (id) "syntactic_scip_indexing_jobs_dequeue_order_idx" btree ((enqueuer_user_id > 0) DESC, queued_at DESC, id) WHERE state = 'queued'::text OR state = 'errored'::text @@ -4101,6 +4467,8 @@ Indexes: "syntactic_scip_indexing_jobs_state" btree (state) Check constraints: "syntactic_scip_indexing_jobs_commit_valid_chars" CHECK (commit ~ '^[a-f0-9]{40}$'::text) +Foreign-key constraints: + "syntactic_scip_indexing_jobs_tenant_id_fkey" FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE ``` @@ -4118,8 +4486,11 @@ Stores metadata about a code intel syntactic index job. --------------------+--------------------------+-----------+----------+--------- repository_id | integer | | not null | last_index_scan_at | timestamp with time zone | | not null | + tenant_id | integer | | | Indexes: "syntactic_scip_last_index_scan_pkey" PRIMARY KEY, btree (repository_id) +Foreign-key constraints: + "syntactic_scip_last_index_scan_tenant_id_fkey" FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE ``` @@ -4135,10 +4506,12 @@ Tracks the last time repository was checked for syntactic indexing job schedulin user_id | integer | | not null | created_at | timestamp with time zone | | not null | now() updated_at | timestamp with time zone | | not null | now() + tenant_id | integer | | | Indexes: "team_members_team_id_user_id_key" PRIMARY KEY, btree (team_id, user_id) Foreign-key constraints: "team_members_team_id_fkey" FOREIGN KEY (team_id) REFERENCES teams(id) ON DELETE CASCADE + "team_members_tenant_id_fkey" FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE "team_members_user_id_fkey" FOREIGN KEY (user_id) REFERENCES users(id) ON DELETE CASCADE ``` @@ -4155,6 +4528,7 @@ Foreign-key constraints: creator_id | integer | | | created_at | timestamp with time zone | | not null | now() updated_at | timestamp with time zone | | not null | now() + tenant_id | integer | | | Indexes: "teams_pkey" PRIMARY KEY, btree (id) "teams_name" UNIQUE, btree (name) @@ -4165,6 +4539,7 @@ Check constraints: Foreign-key constraints: "teams_creator_id_fkey" FOREIGN KEY (creator_id) REFERENCES users(id) ON DELETE SET NULL "teams_parent_team_id_fkey" FOREIGN KEY (parent_team_id) REFERENCES teams(id) ON DELETE CASCADE + "teams_tenant_id_fkey" FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE Referenced by: TABLE "assigned_teams" CONSTRAINT "assigned_teams_owner_team_id_fkey" FOREIGN KEY (owner_team_id) REFERENCES teams(id) ON DELETE CASCADE DEFERRABLE TABLE "names" CONSTRAINT "names_team_id_fkey" FOREIGN KEY (team_id) REFERENCES teams(id) ON UPDATE CASCADE ON DELETE CASCADE @@ -4181,8 +4556,11 @@ Referenced by: timestamp | timestamp with time zone | | not null | payload_pb | bytea | | not null | exported_at | timestamp with time zone | | | + tenant_id | integer | | | Indexes: "telemetry_events_export_queue_pkey" PRIMARY KEY, btree (id) +Foreign-key constraints: + "telemetry_events_export_queue_tenant_id_fkey" FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE ``` @@ -4195,10 +4573,12 @@ Indexes: contents | jsonb | | | created_at | timestamp with time zone | | not null | now() updated_at | timestamp with time zone | | not null | now() + tenant_id | integer | | | Indexes: "temporary_settings_pkey" PRIMARY KEY, btree (id) "temporary_settings_user_id_key" UNIQUE CONSTRAINT, btree (user_id) Foreign-key constraints: + "temporary_settings_tenant_id_fkey" FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE "temporary_settings_user_id_fkey" FOREIGN KEY (user_id) REFERENCES users(id) ON DELETE CASCADE ``` @@ -4223,6 +4603,184 @@ Indexes: Check constraints: "tenant_name_length" CHECK (char_length(name) <= 32 AND char_length(name) >= 3) "tenant_name_valid_chars" CHECK (name ~ '^[a-z](?:[a-z0-9\_-])*[a-z0-9]$'::text) +Referenced by: + TABLE "access_requests" CONSTRAINT "access_requests_tenant_id_fkey" FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE + TABLE "access_tokens" CONSTRAINT "access_tokens_tenant_id_fkey" FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE + TABLE "aggregated_user_statistics" CONSTRAINT "aggregated_user_statistics_tenant_id_fkey" FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE + TABLE "assigned_owners" CONSTRAINT "assigned_owners_tenant_id_fkey" FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE + TABLE "assigned_teams" CONSTRAINT "assigned_teams_tenant_id_fkey" FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE + TABLE "batch_changes_site_credentials" CONSTRAINT "batch_changes_site_credentials_tenant_id_fkey" FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE + TABLE "batch_changes" CONSTRAINT "batch_changes_tenant_id_fkey" FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE + TABLE "batch_spec_execution_cache_entries" CONSTRAINT "batch_spec_execution_cache_entries_tenant_id_fkey" FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE + TABLE "batch_spec_resolution_jobs" CONSTRAINT "batch_spec_resolution_jobs_tenant_id_fkey" FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE + TABLE "batch_spec_workspace_execution_jobs" CONSTRAINT "batch_spec_workspace_execution_jobs_tenant_id_fkey" FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE + TABLE "batch_spec_workspace_execution_last_dequeues" CONSTRAINT "batch_spec_workspace_execution_last_dequeues_tenant_id_fkey" FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE + TABLE "batch_spec_workspace_files" CONSTRAINT "batch_spec_workspace_files_tenant_id_fkey" FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE + TABLE "batch_spec_workspaces" CONSTRAINT "batch_spec_workspaces_tenant_id_fkey" FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE + TABLE "batch_specs" CONSTRAINT "batch_specs_tenant_id_fkey" FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE + TABLE "cached_available_indexers" CONSTRAINT "cached_available_indexers_tenant_id_fkey" FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE + TABLE "changeset_events" CONSTRAINT "changeset_events_tenant_id_fkey" FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE + TABLE "changeset_jobs" CONSTRAINT "changeset_jobs_tenant_id_fkey" FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE + TABLE "changeset_specs" CONSTRAINT "changeset_specs_tenant_id_fkey" FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE + TABLE "changesets" CONSTRAINT "changesets_tenant_id_fkey" FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE + TABLE "cm_action_jobs" CONSTRAINT "cm_action_jobs_tenant_id_fkey" FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE + TABLE "cm_emails" CONSTRAINT "cm_emails_tenant_id_fkey" FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE + TABLE "cm_last_searched" CONSTRAINT "cm_last_searched_tenant_id_fkey" FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE + TABLE "cm_monitors" CONSTRAINT "cm_monitors_tenant_id_fkey" FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE + TABLE "cm_queries" CONSTRAINT "cm_queries_tenant_id_fkey" FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE + TABLE "cm_recipients" CONSTRAINT "cm_recipients_tenant_id_fkey" FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE + TABLE "cm_slack_webhooks" CONSTRAINT "cm_slack_webhooks_tenant_id_fkey" FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE + TABLE "cm_trigger_jobs" CONSTRAINT "cm_trigger_jobs_tenant_id_fkey" FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE + TABLE "cm_webhooks" CONSTRAINT "cm_webhooks_tenant_id_fkey" FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE + TABLE "code_hosts" CONSTRAINT "code_hosts_tenant_id_fkey" FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE + TABLE "codeintel_autoindex_queue" CONSTRAINT "codeintel_autoindex_queue_tenant_id_fkey" FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE + TABLE "codeintel_autoindexing_exceptions" CONSTRAINT "codeintel_autoindexing_exceptions_tenant_id_fkey" FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE + TABLE "codeintel_commit_dates" CONSTRAINT "codeintel_commit_dates_tenant_id_fkey" FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE + TABLE "codeintel_inference_scripts" CONSTRAINT "codeintel_inference_scripts_tenant_id_fkey" FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE + TABLE "codeintel_initial_path_ranks_processed" CONSTRAINT "codeintel_initial_path_ranks_processed_tenant_id_fkey" FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE + TABLE "codeintel_initial_path_ranks" CONSTRAINT "codeintel_initial_path_ranks_tenant_id_fkey" FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE + TABLE "codeintel_langugage_support_requests" CONSTRAINT "codeintel_langugage_support_requests_tenant_id_fkey" FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE + TABLE "codeintel_path_ranks" CONSTRAINT "codeintel_path_ranks_tenant_id_fkey" FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE + TABLE "codeintel_ranking_definitions" CONSTRAINT "codeintel_ranking_definitions_tenant_id_fkey" FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE + TABLE "codeintel_ranking_exports" CONSTRAINT "codeintel_ranking_exports_tenant_id_fkey" FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE + TABLE "codeintel_ranking_graph_keys" CONSTRAINT "codeintel_ranking_graph_keys_tenant_id_fkey" FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE + TABLE "codeintel_ranking_path_counts_inputs" CONSTRAINT "codeintel_ranking_path_counts_inputs_tenant_id_fkey" FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE + TABLE "codeintel_ranking_progress" CONSTRAINT "codeintel_ranking_progress_tenant_id_fkey" FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE + TABLE "codeintel_ranking_references_processed" CONSTRAINT "codeintel_ranking_references_processed_tenant_id_fkey" FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE + TABLE "codeintel_ranking_references" CONSTRAINT "codeintel_ranking_references_tenant_id_fkey" FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE + TABLE "codeowners_individual_stats" CONSTRAINT "codeowners_individual_stats_tenant_id_fkey" FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE + TABLE "codeowners_owners" CONSTRAINT "codeowners_owners_tenant_id_fkey" FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE + TABLE "codeowners" CONSTRAINT "codeowners_tenant_id_fkey" FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE + TABLE "commit_authors" CONSTRAINT "commit_authors_tenant_id_fkey" FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE + TABLE "configuration_policies_audit_logs" CONSTRAINT "configuration_policies_audit_logs_tenant_id_fkey" FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE + TABLE "context_detection_embedding_jobs" CONSTRAINT "context_detection_embedding_jobs_tenant_id_fkey" FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE + TABLE "discussion_comments" CONSTRAINT "discussion_comments_tenant_id_fkey" FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE + TABLE "discussion_mail_reply_tokens" CONSTRAINT "discussion_mail_reply_tokens_tenant_id_fkey" FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE + TABLE "discussion_threads_target_repo" CONSTRAINT "discussion_threads_target_repo_tenant_id_fkey" FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE + TABLE "discussion_threads" CONSTRAINT "discussion_threads_tenant_id_fkey" FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE + TABLE "event_logs_export_allowlist" CONSTRAINT "event_logs_export_allowlist_tenant_id_fkey" FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE + TABLE "event_logs_scrape_state_own" CONSTRAINT "event_logs_scrape_state_own_tenant_id_fkey" FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE + TABLE "event_logs_scrape_state" CONSTRAINT "event_logs_scrape_state_tenant_id_fkey" FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE + TABLE "event_logs" CONSTRAINT "event_logs_tenant_id_fkey" FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE + TABLE "executor_heartbeats" CONSTRAINT "executor_heartbeats_tenant_id_fkey" FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE + TABLE "executor_job_tokens" CONSTRAINT "executor_job_tokens_tenant_id_fkey" FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE + TABLE "executor_secret_access_logs" CONSTRAINT "executor_secret_access_logs_tenant_id_fkey" FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE + TABLE "executor_secrets" CONSTRAINT "executor_secrets_tenant_id_fkey" FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE + TABLE "exhaustive_search_jobs" CONSTRAINT "exhaustive_search_jobs_tenant_id_fkey" FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE + TABLE "exhaustive_search_repo_jobs" CONSTRAINT "exhaustive_search_repo_jobs_tenant_id_fkey" FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE + TABLE "exhaustive_search_repo_revision_jobs" CONSTRAINT "exhaustive_search_repo_revision_jobs_tenant_id_fkey" FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE + TABLE "explicit_permissions_bitbucket_projects_jobs" CONSTRAINT "explicit_permissions_bitbucket_projects_jobs_tenant_id_fkey" FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE + TABLE "external_service_repos" CONSTRAINT "external_service_repos_tenant_id_fkey" FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE + TABLE "external_service_sync_jobs" CONSTRAINT "external_service_sync_jobs_tenant_id_fkey" FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE + TABLE "external_services" CONSTRAINT "external_services_tenant_id_fkey" FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE + TABLE "feature_flag_overrides" CONSTRAINT "feature_flag_overrides_tenant_id_fkey" FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE + TABLE "feature_flags" CONSTRAINT "feature_flags_tenant_id_fkey" FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE + TABLE "github_app_installs" CONSTRAINT "github_app_installs_tenant_id_fkey" FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE + TABLE "github_apps" CONSTRAINT "github_apps_tenant_id_fkey" FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE + TABLE "gitserver_relocator_jobs" CONSTRAINT "gitserver_relocator_jobs_tenant_id_fkey" FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE + TABLE "gitserver_repos_statistics" CONSTRAINT "gitserver_repos_statistics_tenant_id_fkey" FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE + TABLE "gitserver_repos_sync_output" CONSTRAINT "gitserver_repos_sync_output_tenant_id_fkey" FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE + TABLE "gitserver_repos" CONSTRAINT "gitserver_repos_tenant_id_fkey" FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE + TABLE "global_state" CONSTRAINT "global_state_tenant_id_fkey" FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE + TABLE "insights_query_runner_jobs_dependencies" CONSTRAINT "insights_query_runner_jobs_dependencies_tenant_id_fkey" FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE + TABLE "insights_query_runner_jobs" CONSTRAINT "insights_query_runner_jobs_tenant_id_fkey" FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE + TABLE "insights_settings_migration_jobs" CONSTRAINT "insights_settings_migration_jobs_tenant_id_fkey" FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE + TABLE "lsif_configuration_policies_repository_pattern_lookup" CONSTRAINT "lsif_configuration_policies_repository_pattern_l_tenant_id_fkey" FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE + TABLE "lsif_configuration_policies" CONSTRAINT "lsif_configuration_policies_tenant_id_fkey" FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE + TABLE "lsif_dependency_indexing_jobs" CONSTRAINT "lsif_dependency_indexing_jobs_tenant_id_fkey" FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE + TABLE "lsif_dependency_repos" CONSTRAINT "lsif_dependency_repos_tenant_id_fkey" FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE + TABLE "lsif_dependency_syncing_jobs" CONSTRAINT "lsif_dependency_syncing_jobs_tenant_id_fkey" FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE + TABLE "lsif_dirty_repositories" CONSTRAINT "lsif_dirty_repositories_tenant_id_fkey" FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE + TABLE "lsif_index_configuration" CONSTRAINT "lsif_index_configuration_tenant_id_fkey" FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE + TABLE "lsif_indexes" CONSTRAINT "lsif_indexes_tenant_id_fkey" FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE + TABLE "lsif_last_index_scan" CONSTRAINT "lsif_last_index_scan_tenant_id_fkey" FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE + TABLE "lsif_last_retention_scan" CONSTRAINT "lsif_last_retention_scan_tenant_id_fkey" FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE + TABLE "lsif_nearest_uploads_links" CONSTRAINT "lsif_nearest_uploads_links_tenant_id_fkey" FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE + TABLE "lsif_nearest_uploads" CONSTRAINT "lsif_nearest_uploads_tenant_id_fkey" FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE + TABLE "lsif_packages" CONSTRAINT "lsif_packages_tenant_id_fkey" FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE + TABLE "lsif_references" CONSTRAINT "lsif_references_tenant_id_fkey" FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE + TABLE "lsif_retention_configuration" CONSTRAINT "lsif_retention_configuration_tenant_id_fkey" FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE + TABLE "lsif_uploads_audit_logs" CONSTRAINT "lsif_uploads_audit_logs_tenant_id_fkey" FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE + TABLE "lsif_uploads_reference_counts" CONSTRAINT "lsif_uploads_reference_counts_tenant_id_fkey" FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE + TABLE "lsif_uploads" CONSTRAINT "lsif_uploads_tenant_id_fkey" FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE + TABLE "lsif_uploads_visible_at_tip" CONSTRAINT "lsif_uploads_visible_at_tip_tenant_id_fkey" FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE + TABLE "lsif_uploads_vulnerability_scan" CONSTRAINT "lsif_uploads_vulnerability_scan_tenant_id_fkey" FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE + TABLE "names" CONSTRAINT "names_tenant_id_fkey" FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE + TABLE "namespace_permissions" CONSTRAINT "namespace_permissions_tenant_id_fkey" FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE + TABLE "notebook_stars" CONSTRAINT "notebook_stars_tenant_id_fkey" FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE + TABLE "notebooks" CONSTRAINT "notebooks_tenant_id_fkey" FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE + TABLE "org_invitations" CONSTRAINT "org_invitations_tenant_id_fkey" FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE + TABLE "org_members" CONSTRAINT "org_members_tenant_id_fkey" FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE + TABLE "org_stats" CONSTRAINT "org_stats_tenant_id_fkey" FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE + TABLE "orgs_open_beta_stats" CONSTRAINT "orgs_open_beta_stats_tenant_id_fkey" FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE + TABLE "orgs" CONSTRAINT "orgs_tenant_id_fkey" FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE + TABLE "out_of_band_migrations_errors" CONSTRAINT "out_of_band_migrations_errors_tenant_id_fkey" FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE + TABLE "out_of_band_migrations" CONSTRAINT "out_of_band_migrations_tenant_id_fkey" FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE + TABLE "outbound_webhook_event_types" CONSTRAINT "outbound_webhook_event_types_tenant_id_fkey" FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE + TABLE "outbound_webhook_jobs" CONSTRAINT "outbound_webhook_jobs_tenant_id_fkey" FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE + TABLE "outbound_webhook_logs" CONSTRAINT "outbound_webhook_logs_tenant_id_fkey" FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE + TABLE "outbound_webhooks" CONSTRAINT "outbound_webhooks_tenant_id_fkey" FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE + TABLE "own_aggregate_recent_contribution" CONSTRAINT "own_aggregate_recent_contribution_tenant_id_fkey" FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE + TABLE "own_aggregate_recent_view" CONSTRAINT "own_aggregate_recent_view_tenant_id_fkey" FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE + TABLE "own_background_jobs" CONSTRAINT "own_background_jobs_tenant_id_fkey" FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE + TABLE "own_signal_configurations" CONSTRAINT "own_signal_configurations_tenant_id_fkey" FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE + TABLE "own_signal_recent_contribution" CONSTRAINT "own_signal_recent_contribution_tenant_id_fkey" FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE + TABLE "ownership_path_stats" CONSTRAINT "ownership_path_stats_tenant_id_fkey" FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE + TABLE "package_repo_filters" CONSTRAINT "package_repo_filters_tenant_id_fkey" FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE + TABLE "package_repo_versions" CONSTRAINT "package_repo_versions_tenant_id_fkey" FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE + TABLE "permission_sync_jobs" CONSTRAINT "permission_sync_jobs_tenant_id_fkey" FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE + TABLE "permissions" CONSTRAINT "permissions_tenant_id_fkey" FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE + TABLE "phabricator_repos" CONSTRAINT "phabricator_repos_tenant_id_fkey" FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE + TABLE "product_licenses" CONSTRAINT "product_licenses_tenant_id_fkey" FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE + TABLE "product_subscriptions" CONSTRAINT "product_subscriptions_tenant_id_fkey" FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE + TABLE "prompts" CONSTRAINT "prompts_tenant_id_fkey" FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE + TABLE "query_runner_state" CONSTRAINT "query_runner_state_tenant_id_fkey" FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE + TABLE "redis_key_value" CONSTRAINT "redis_key_value_tenant_id_fkey" FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE + TABLE "registry_extension_releases" CONSTRAINT "registry_extension_releases_tenant_id_fkey" FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE + TABLE "registry_extensions" CONSTRAINT "registry_extensions_tenant_id_fkey" FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE + TABLE "repo_commits_changelists" CONSTRAINT "repo_commits_changelists_tenant_id_fkey" FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE + TABLE "repo_embedding_job_stats" CONSTRAINT "repo_embedding_job_stats_tenant_id_fkey" FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE + TABLE "repo_embedding_jobs" CONSTRAINT "repo_embedding_jobs_tenant_id_fkey" FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE + TABLE "repo_kvps" CONSTRAINT "repo_kvps_tenant_id_fkey" FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE + TABLE "repo_paths" CONSTRAINT "repo_paths_tenant_id_fkey" FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE + TABLE "repo_pending_permissions" CONSTRAINT "repo_pending_permissions_tenant_id_fkey" FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE + TABLE "repo_permissions" CONSTRAINT "repo_permissions_tenant_id_fkey" FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE + TABLE "repo_statistics" CONSTRAINT "repo_statistics_tenant_id_fkey" FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE + TABLE "repo" CONSTRAINT "repo_tenant_id_fkey" FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE + TABLE "role_permissions" CONSTRAINT "role_permissions_tenant_id_fkey" FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE + TABLE "roles" CONSTRAINT "roles_tenant_id_fkey" FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE + TABLE "saved_searches" CONSTRAINT "saved_searches_tenant_id_fkey" FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE + TABLE "search_context_default" CONSTRAINT "search_context_default_tenant_id_fkey" FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE + TABLE "search_context_repos" CONSTRAINT "search_context_repos_tenant_id_fkey" FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE + TABLE "search_context_stars" CONSTRAINT "search_context_stars_tenant_id_fkey" FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE + TABLE "search_contexts" CONSTRAINT "search_contexts_tenant_id_fkey" FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE + TABLE "security_event_logs" CONSTRAINT "security_event_logs_tenant_id_fkey" FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE + TABLE "settings" CONSTRAINT "settings_tenant_id_fkey" FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE + TABLE "sub_repo_permissions" CONSTRAINT "sub_repo_permissions_tenant_id_fkey" FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE + TABLE "survey_responses" CONSTRAINT "survey_responses_tenant_id_fkey" FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE + TABLE "syntactic_scip_indexing_jobs" CONSTRAINT "syntactic_scip_indexing_jobs_tenant_id_fkey" FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE + TABLE "syntactic_scip_last_index_scan" CONSTRAINT "syntactic_scip_last_index_scan_tenant_id_fkey" FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE + TABLE "team_members" CONSTRAINT "team_members_tenant_id_fkey" FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE + TABLE "teams" CONSTRAINT "teams_tenant_id_fkey" FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE + TABLE "telemetry_events_export_queue" CONSTRAINT "telemetry_events_export_queue_tenant_id_fkey" FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE + TABLE "temporary_settings" CONSTRAINT "temporary_settings_tenant_id_fkey" FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE + TABLE "user_credentials" CONSTRAINT "user_credentials_tenant_id_fkey" FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE + TABLE "user_emails" CONSTRAINT "user_emails_tenant_id_fkey" FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE + TABLE "user_external_accounts" CONSTRAINT "user_external_accounts_tenant_id_fkey" FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE + TABLE "user_onboarding_tour" CONSTRAINT "user_onboarding_tour_tenant_id_fkey" FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE + TABLE "user_pending_permissions" CONSTRAINT "user_pending_permissions_tenant_id_fkey" FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE + TABLE "user_permissions" CONSTRAINT "user_permissions_tenant_id_fkey" FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE + TABLE "user_public_repos" CONSTRAINT "user_public_repos_tenant_id_fkey" FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE + TABLE "user_repo_permissions" CONSTRAINT "user_repo_permissions_tenant_id_fkey" FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE + TABLE "user_roles" CONSTRAINT "user_roles_tenant_id_fkey" FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE + TABLE "users" CONSTRAINT "users_tenant_id_fkey" FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE + TABLE "vulnerabilities" CONSTRAINT "vulnerabilities_tenant_id_fkey" FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE + TABLE "vulnerability_affected_packages" CONSTRAINT "vulnerability_affected_packages_tenant_id_fkey" FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE + TABLE "vulnerability_affected_symbols" CONSTRAINT "vulnerability_affected_symbols_tenant_id_fkey" FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE + TABLE "vulnerability_matches" CONSTRAINT "vulnerability_matches_tenant_id_fkey" FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE + TABLE "webhook_logs" CONSTRAINT "webhook_logs_tenant_id_fkey" FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE + TABLE "webhooks" CONSTRAINT "webhooks_tenant_id_fkey" FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE + TABLE "zoekt_repos" CONSTRAINT "zoekt_repos_tenant_id_fkey" FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE ``` @@ -4247,6 +4805,7 @@ The table that holds all tenants known to the instance. In enterprise instances, ssh_migration_applied | boolean | | not null | false encryption_key_id | text | | not null | ''::text github_app_id | integer | | | + tenant_id | integer | | | Indexes: "user_credentials_pkey" PRIMARY KEY, btree (id) "user_credentials_domain_user_id_external_service_type_exter_key" UNIQUE CONSTRAINT, btree (domain, user_id, external_service_type, external_service_id) @@ -4255,6 +4814,7 @@ Check constraints: "check_github_app_id_and_external_service_type_user_credentials" CHECK (github_app_id IS NULL OR external_service_type = 'github'::text) Foreign-key constraints: "user_credentials_github_app_id_fkey" FOREIGN KEY (github_app_id) REFERENCES github_apps(id) ON DELETE CASCADE + "user_credentials_tenant_id_fkey" FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE "user_credentials_user_id_fkey" FOREIGN KEY (user_id) REFERENCES users(id) ON DELETE CASCADE DEFERRABLE ``` @@ -4270,11 +4830,13 @@ Foreign-key constraints: verified_at | timestamp with time zone | | | last_verification_sent_at | timestamp with time zone | | | is_primary | boolean | | not null | false + tenant_id | integer | | | Indexes: "user_emails_no_duplicates_per_user" UNIQUE CONSTRAINT, btree (user_id, email) "user_emails_user_id_is_primary_idx" UNIQUE, btree (user_id, is_primary) WHERE is_primary = true "user_emails_unique_verified_email" EXCLUDE USING btree (email) WHERE verified_at IS NOT NULL Foreign-key constraints: + "user_emails_tenant_id_fkey" FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE "user_emails_user_id_fkey" FOREIGN KEY (user_id) REFERENCES users(id) ``` @@ -4297,12 +4859,14 @@ Foreign-key constraints: expired_at | timestamp with time zone | | | last_valid_at | timestamp with time zone | | | encryption_key_id | text | | not null | ''::text + tenant_id | integer | | | Indexes: "user_external_accounts_pkey" PRIMARY KEY, btree (id) "user_external_accounts_account" UNIQUE, btree (service_type, service_id, client_id, account_id) WHERE deleted_at IS NULL "user_external_accounts_user_id_scim_service_type" UNIQUE, btree (user_id, service_type) WHERE service_type = 'scim'::text AND deleted_at IS NULL "user_external_accounts_user_id" btree (user_id) WHERE deleted_at IS NULL Foreign-key constraints: + "user_external_accounts_tenant_id_fkey" FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE "user_external_accounts_user_id_fkey" FOREIGN KEY (user_id) REFERENCES users(id) Referenced by: TABLE "user_repo_permissions" CONSTRAINT "user_repo_permissions_user_external_account_id_fkey" FOREIGN KEY (user_external_account_id) REFERENCES user_external_accounts(id) ON DELETE CASCADE @@ -4319,9 +4883,11 @@ Triggers: raw_json | text | | not null | created_at | timestamp without time zone | | not null | now() updated_by | integer | | | + tenant_id | integer | | | Indexes: "user_onboarding_tour_pkey" PRIMARY KEY, btree (id) Foreign-key constraints: + "user_onboarding_tour_tenant_id_fkey" FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE "user_onboarding_tour_users_fk" FOREIGN KEY (updated_by) REFERENCES users(id) ``` @@ -4338,8 +4904,11 @@ Foreign-key constraints: service_type | text | | not null | service_id | text | | not null | object_ids_ints | integer[] | | not null | '{}'::integer[] + tenant_id | integer | | | Indexes: "user_pending_permissions_service_perm_object_unique" UNIQUE CONSTRAINT, btree (service_type, service_id, permission, object_type, bind_id) +Foreign-key constraints: + "user_pending_permissions_tenant_id_fkey" FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE ``` @@ -4354,22 +4923,27 @@ Indexes: synced_at | timestamp with time zone | | | object_ids_ints | integer[] | | not null | '{}'::integer[] migrated | boolean | | | true + tenant_id | integer | | | Indexes: "user_permissions_perm_object_unique" UNIQUE CONSTRAINT, btree (user_id, permission, object_type) +Foreign-key constraints: + "user_permissions_tenant_id_fkey" FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE ``` # Table "public.user_public_repos" ``` - Column | Type | Collation | Nullable | Default -----------+---------+-----------+----------+--------- - user_id | integer | | not null | - repo_uri | text | | not null | - repo_id | integer | | not null | + Column | Type | Collation | Nullable | Default +-----------+---------+-----------+----------+--------- + user_id | integer | | not null | + repo_uri | text | | not null | + repo_id | integer | | not null | + tenant_id | integer | | | Indexes: "user_public_repos_user_id_repo_id_key" UNIQUE CONSTRAINT, btree (user_id, repo_id) Foreign-key constraints: "user_public_repos_repo_id_fkey" FOREIGN KEY (repo_id) REFERENCES repo(id) ON DELETE CASCADE + "user_public_repos_tenant_id_fkey" FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE "user_public_repos_user_id_fkey" FOREIGN KEY (user_id) REFERENCES users(id) ON DELETE CASCADE ``` @@ -4385,6 +4959,7 @@ Foreign-key constraints: created_at | timestamp with time zone | | not null | now() updated_at | timestamp with time zone | | not null | now() source | text | | not null | 'sync'::text + tenant_id | integer | | | Indexes: "user_repo_permissions_pkey" PRIMARY KEY, btree (id) "user_repo_permissions_perms_unique_idx" UNIQUE, btree (user_id, user_external_account_id, repo_id) @@ -4394,6 +4969,7 @@ Indexes: "user_repo_permissions_user_external_account_id_idx" btree (user_external_account_id) Foreign-key constraints: "user_repo_permissions_repo_id_fkey" FOREIGN KEY (repo_id) REFERENCES repo(id) ON DELETE CASCADE + "user_repo_permissions_tenant_id_fkey" FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE "user_repo_permissions_user_external_account_id_fkey" FOREIGN KEY (user_external_account_id) REFERENCES user_external_accounts(id) ON DELETE CASCADE "user_repo_permissions_user_id_fkey" FOREIGN KEY (user_id) REFERENCES users(id) ON DELETE CASCADE @@ -4406,10 +4982,12 @@ Foreign-key constraints: user_id | integer | | not null | role_id | integer | | not null | created_at | timestamp with time zone | | not null | now() + tenant_id | integer | | | Indexes: "user_roles_pkey" PRIMARY KEY, btree (user_id, role_id) Foreign-key constraints: "user_roles_role_id_fkey" FOREIGN KEY (role_id) REFERENCES roles(id) ON DELETE CASCADE DEFERRABLE + "user_roles_tenant_id_fkey" FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE "user_roles_user_id_fkey" FOREIGN KEY (user_id) REFERENCES users(id) ON DELETE CASCADE DEFERRABLE ``` @@ -4439,6 +5017,7 @@ Foreign-key constraints: code_completions_quota | integer | | | completed_post_signup | boolean | | not null | false cody_pro_enabled_at | timestamp with time zone | | | + tenant_id | integer | | | Indexes: "users_pkey" PRIMARY KEY, btree (id) "users_billing_customer_id" UNIQUE, btree (billing_customer_id) WHERE deleted_at IS NULL @@ -4448,6 +5027,8 @@ Check constraints: "users_display_name_max_length" CHECK (char_length(display_name) <= 255) "users_username_max_length" CHECK (char_length(username::text) <= 255) "users_username_valid_chars" CHECK (username ~ '^\w(?:\w|[-.](?=\w))*-?$'::citext) +Foreign-key constraints: + "users_tenant_id_fkey" FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE Referenced by: TABLE "access_requests" CONSTRAINT "access_requests_decision_by_user_id_fkey" FOREIGN KEY (decision_by_user_id) REFERENCES users(id) ON DELETE SET NULL TABLE "access_tokens" CONSTRAINT "access_tokens_creator_user_id_fkey" FOREIGN KEY (creator_user_id) REFERENCES users(id) @@ -4571,9 +5152,12 @@ Triggers: published_at | timestamp with time zone | | not null | modified_at | timestamp with time zone | | | withdrawn_at | timestamp with time zone | | | + tenant_id | integer | | | Indexes: "vulnerabilities_pkey" PRIMARY KEY, btree (id) "vulnerabilities_source_id" UNIQUE, btree (source_id) +Foreign-key constraints: + "vulnerabilities_tenant_id_fkey" FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE Referenced by: TABLE "vulnerability_affected_packages" CONSTRAINT "fk_vulnerabilities" FOREIGN KEY (vulnerability_id) REFERENCES vulnerabilities(id) ON DELETE CASCADE @@ -4591,11 +5175,13 @@ Referenced by: version_constraint | text[] | | not null | fixed | boolean | | not null | fixed_in | text | | | + tenant_id | integer | | | Indexes: "vulnerability_affected_packages_pkey" PRIMARY KEY, btree (id) "vulnerability_affected_packages_vulnerability_id_package_name" UNIQUE, btree (vulnerability_id, package_name) Foreign-key constraints: "fk_vulnerabilities" FOREIGN KEY (vulnerability_id) REFERENCES vulnerabilities(id) ON DELETE CASCADE + "vulnerability_affected_packages_tenant_id_fkey" FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE Referenced by: TABLE "vulnerability_affected_symbols" CONSTRAINT "fk_vulnerability_affected_packages" FOREIGN KEY (vulnerability_affected_package_id) REFERENCES vulnerability_affected_packages(id) ON DELETE CASCADE TABLE "vulnerability_matches" CONSTRAINT "fk_vulnerability_affected_packages" FOREIGN KEY (vulnerability_affected_package_id) REFERENCES vulnerability_affected_packages(id) ON DELETE CASCADE @@ -4610,11 +5196,13 @@ Referenced by: vulnerability_affected_package_id | integer | | not null | path | text | | not null | symbols | text[] | | not null | + tenant_id | integer | | | Indexes: "vulnerability_affected_symbols_pkey" PRIMARY KEY, btree (id) "vulnerability_affected_symbols_vulnerability_affected_package_i" UNIQUE, btree (vulnerability_affected_package_id, path) Foreign-key constraints: "fk_vulnerability_affected_packages" FOREIGN KEY (vulnerability_affected_package_id) REFERENCES vulnerability_affected_packages(id) ON DELETE CASCADE + "vulnerability_affected_symbols_tenant_id_fkey" FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE ``` @@ -4625,6 +5213,7 @@ Foreign-key constraints: id | integer | | not null | nextval('vulnerability_matches_id_seq'::regclass) upload_id | integer | | not null | vulnerability_affected_package_id | integer | | not null | + tenant_id | integer | | | Indexes: "vulnerability_matches_pkey" PRIMARY KEY, btree (id) "vulnerability_matches_upload_id_vulnerability_affected_package_" UNIQUE, btree (upload_id, vulnerability_affected_package_id) @@ -4632,6 +5221,7 @@ Indexes: Foreign-key constraints: "fk_upload" FOREIGN KEY (upload_id) REFERENCES lsif_uploads(id) ON DELETE CASCADE "fk_vulnerability_affected_packages" FOREIGN KEY (vulnerability_affected_package_id) REFERENCES vulnerability_affected_packages(id) ON DELETE CASCADE + "vulnerability_matches_tenant_id_fkey" FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE ``` @@ -4647,6 +5237,7 @@ Foreign-key constraints: response | bytea | | not null | encryption_key_id | text | | not null | webhook_id | integer | | | + tenant_id | integer | | | Indexes: "webhook_logs_pkey" PRIMARY KEY, btree (id) "webhook_logs_external_service_id_idx" btree (external_service_id) @@ -4654,6 +5245,7 @@ Indexes: "webhook_logs_status_code_idx" btree (status_code) Foreign-key constraints: "webhook_logs_external_service_id_fkey" FOREIGN KEY (external_service_id) REFERENCES external_services(id) ON UPDATE CASCADE ON DELETE CASCADE + "webhook_logs_tenant_id_fkey" FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE "webhook_logs_webhook_id_fkey" FOREIGN KEY (webhook_id) REFERENCES webhooks(id) ON DELETE CASCADE ``` @@ -4673,11 +5265,13 @@ Foreign-key constraints: created_by_user_id | integer | | | updated_by_user_id | integer | | | name | text | | not null | + tenant_id | integer | | | Indexes: "webhooks_pkey" PRIMARY KEY, btree (id) "webhooks_uuid_key" UNIQUE CONSTRAINT, btree (uuid) Foreign-key constraints: "webhooks_created_by_user_id_fkey" FOREIGN KEY (created_by_user_id) REFERENCES users(id) ON DELETE SET NULL + "webhooks_tenant_id_fkey" FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE "webhooks_updated_by_user_id_fkey" FOREIGN KEY (updated_by_user_id) REFERENCES users(id) ON DELETE SET NULL Referenced by: TABLE "github_apps" CONSTRAINT "github_apps_webhook_id_fkey" FOREIGN KEY (webhook_id) REFERENCES webhooks(id) ON DELETE SET NULL @@ -4709,11 +5303,13 @@ Webhooks registered in Sourcegraph instance. updated_at | timestamp with time zone | | not null | now() created_at | timestamp with time zone | | not null | now() last_indexed_at | timestamp with time zone | | | + tenant_id | integer | | | Indexes: "zoekt_repos_pkey" PRIMARY KEY, btree (repo_id) "zoekt_repos_index_status" btree (index_status) Foreign-key constraints: "zoekt_repos_repo_id_fkey" FOREIGN KEY (repo_id) REFERENCES repo(id) ON DELETE CASCADE + "zoekt_repos_tenant_id_fkey" FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE ``` diff --git a/internal/insights/store/dashboard_store.go b/internal/insights/store/dashboard_store.go index 715229c193e..6783c080596 100644 --- a/internal/insights/store/dashboard_store.go +++ b/internal/insights/store/dashboard_store.go @@ -417,7 +417,7 @@ WHERE div.dashboard_id = %s AND iv.unique_id = %s ` const getDashboardGrantsSql = ` -SELECT * FROM dashboard_grants where dashboard_id = %s +SELECT id, dashboard_id, user_id, org_id, global FROM dashboard_grants where dashboard_id = %s ` const getDashboardGrantsByPermissionsSql = ` diff --git a/migrations/codeinsights/1723127349_add_tenant_id_to_most_tables/down.sql b/migrations/codeinsights/1723127349_add_tenant_id_to_most_tables/down.sql new file mode 100644 index 00000000000..f8481fc282d --- /dev/null +++ b/migrations/codeinsights/1723127349_add_tenant_id_to_most_tables/down.sql @@ -0,0 +1,30 @@ +-- Temporary function to deduplicate the logic required for each table: +CREATE OR REPLACE FUNCTION migrate_add_tenant_id_codeinsights(table_name text) +RETURNS void AS $$ +BEGIN + EXECUTE format('ALTER TABLE %I DROP COLUMN IF EXISTS tenant_id;', table_name); +END; +$$ LANGUAGE plpgsql; + +SELECT migrate_add_tenant_id_codeinsights('archived_insight_series_recording_times'); +SELECT migrate_add_tenant_id_codeinsights('archived_series_points'); +SELECT migrate_add_tenant_id_codeinsights('dashboard'); +SELECT migrate_add_tenant_id_codeinsights('dashboard_grants'); +SELECT migrate_add_tenant_id_codeinsights('dashboard_insight_view'); +SELECT migrate_add_tenant_id_codeinsights('insight_series'); +SELECT migrate_add_tenant_id_codeinsights('insight_series_backfill'); +SELECT migrate_add_tenant_id_codeinsights('insight_series_incomplete_points'); +SELECT migrate_add_tenant_id_codeinsights('insight_series_recording_times'); +SELECT migrate_add_tenant_id_codeinsights('insight_view'); +SELECT migrate_add_tenant_id_codeinsights('insight_view_grants'); +SELECT migrate_add_tenant_id_codeinsights('insight_view_series'); +SELECT migrate_add_tenant_id_codeinsights('insights_background_jobs'); +SELECT migrate_add_tenant_id_codeinsights('insights_data_retention_jobs'); +SELECT migrate_add_tenant_id_codeinsights('metadata'); +SELECT migrate_add_tenant_id_codeinsights('repo_iterator'); +SELECT migrate_add_tenant_id_codeinsights('repo_iterator_errors'); +SELECT migrate_add_tenant_id_codeinsights('repo_names'); +SELECT migrate_add_tenant_id_codeinsights('series_points'); +SELECT migrate_add_tenant_id_codeinsights('series_points_snapshots'); + +DROP FUNCTION migrate_add_tenant_id_codeinsights(text); diff --git a/migrations/codeinsights/1723127349_add_tenant_id_to_most_tables/metadata.yaml b/migrations/codeinsights/1723127349_add_tenant_id_to_most_tables/metadata.yaml new file mode 100644 index 00000000000..32362bd973e --- /dev/null +++ b/migrations/codeinsights/1723127349_add_tenant_id_to_most_tables/metadata.yaml @@ -0,0 +1,3 @@ +name: add tenant id to most tables +noTransaction: true +parents: [1719914228] diff --git a/migrations/codeinsights/1723127349_add_tenant_id_to_most_tables/up.sql b/migrations/codeinsights/1723127349_add_tenant_id_to_most_tables/up.sql new file mode 100644 index 00000000000..c0678916879 --- /dev/null +++ b/migrations/codeinsights/1723127349_add_tenant_id_to_most_tables/up.sql @@ -0,0 +1,37 @@ +-- This migration adds the tenant_id column in a way which doesn't require +-- updating every row. The value is null and an out of band migration will set +-- it to the default. A later migration will enforce tenant_id to be set. + +-- Temporary function to deduplicate the logic required for each table: +CREATE OR REPLACE FUNCTION migrate_add_tenant_id_codeinsights(table_name text) +RETURNS void AS $$ +BEGIN + EXECUTE format('ALTER TABLE %I ADD COLUMN IF NOT EXISTS tenant_id integer REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE;', table_name); +END; +$$ LANGUAGE plpgsql; + +SELECT migrate_add_tenant_id_codeinsights('archived_insight_series_recording_times'); +SELECT migrate_add_tenant_id_codeinsights('archived_series_points'); +SELECT migrate_add_tenant_id_codeinsights('dashboard'); +SELECT migrate_add_tenant_id_codeinsights('dashboard_grants'); +SELECT migrate_add_tenant_id_codeinsights('dashboard_insight_view'); +SELECT migrate_add_tenant_id_codeinsights('insight_series'); +SELECT migrate_add_tenant_id_codeinsights('insight_series_backfill'); +SELECT migrate_add_tenant_id_codeinsights('insight_series_incomplete_points'); +SELECT migrate_add_tenant_id_codeinsights('insight_series_recording_times'); +SELECT migrate_add_tenant_id_codeinsights('insight_view'); +SELECT migrate_add_tenant_id_codeinsights('insight_view_grants'); +SELECT migrate_add_tenant_id_codeinsights('insight_view_series'); +SELECT migrate_add_tenant_id_codeinsights('insights_background_jobs'); +SELECT migrate_add_tenant_id_codeinsights('insights_data_retention_jobs'); +SELECT migrate_add_tenant_id_codeinsights('metadata'); +SELECT migrate_add_tenant_id_codeinsights('repo_iterator'); +SELECT migrate_add_tenant_id_codeinsights('repo_iterator_errors'); +SELECT migrate_add_tenant_id_codeinsights('repo_names'); +SELECT migrate_add_tenant_id_codeinsights('series_points'); +SELECT migrate_add_tenant_id_codeinsights('series_points_snapshots'); + +-- Explicitly excluded tables +-- migration_logs :: about DB + +DROP FUNCTION migrate_add_tenant_id_codeinsights(text); diff --git a/migrations/codeinsights/squashed.sql b/migrations/codeinsights/squashed.sql index 0fc82f4c163..564a37119e0 100644 --- a/migrations/codeinsights/squashed.sql +++ b/migrations/codeinsights/squashed.sql @@ -33,7 +33,8 @@ CREATE TYPE time_unit AS ENUM ( CREATE TABLE archived_insight_series_recording_times ( insight_series_id integer NOT NULL, recording_time timestamp with time zone NOT NULL, - snapshot boolean NOT NULL + snapshot boolean NOT NULL, + tenant_id integer ); CREATE TABLE archived_series_points ( @@ -44,6 +45,7 @@ CREATE TABLE archived_series_points ( repo_name_id integer, original_repo_name_id integer, capture text, + tenant_id integer, CONSTRAINT check_repo_fields_specifity CHECK ((((repo_id IS NULL) AND (repo_name_id IS NULL) AND (original_repo_name_id IS NULL)) OR ((repo_id IS NOT NULL) AND (repo_name_id IS NOT NULL) AND (original_repo_name_id IS NOT NULL)))) ); @@ -55,7 +57,8 @@ CREATE TABLE dashboard ( last_updated_at timestamp without time zone DEFAULT now() NOT NULL, deleted_at timestamp without time zone, save boolean DEFAULT false NOT NULL, - type text DEFAULT 'standard'::text NOT NULL + type text DEFAULT 'standard'::text NOT NULL, + tenant_id integer ); COMMENT ON TABLE dashboard IS 'Metadata for dashboards of insights'; @@ -77,7 +80,8 @@ CREATE TABLE dashboard_grants ( dashboard_id integer NOT NULL, user_id integer, org_id integer, - global boolean + global boolean, + tenant_id integer ); COMMENT ON TABLE dashboard_grants IS 'Permission grants for dashboards. Each row should represent a unique principal (user, org, etc).'; @@ -111,7 +115,8 @@ ALTER SEQUENCE dashboard_id_seq OWNED BY dashboard.id; CREATE TABLE dashboard_insight_view ( id integer NOT NULL, dashboard_id integer NOT NULL, - insight_view_id integer NOT NULL + insight_view_id integer NOT NULL, + tenant_id integer ); CREATE SEQUENCE dashboard_insight_view_id_seq @@ -148,7 +153,8 @@ CREATE TABLE insight_series ( backfill_completed_at timestamp without time zone, supports_augmentation boolean DEFAULT true NOT NULL, repository_criteria text, - query_old text + query_old text, + tenant_id integer ); COMMENT ON TABLE insight_series IS 'Data series that comprise code insights.'; @@ -182,7 +188,8 @@ CREATE TABLE insight_series_backfill ( series_id integer NOT NULL, repo_iterator_id integer, estimated_cost double precision, - state text DEFAULT 'new'::text NOT NULL + state text DEFAULT 'new'::text NOT NULL, + tenant_id integer ); CREATE SEQUENCE insight_series_backfill_id_seq @@ -210,7 +217,8 @@ CREATE TABLE insight_series_incomplete_points ( series_id integer NOT NULL, reason text NOT NULL, "time" timestamp without time zone NOT NULL, - repo_id integer + repo_id integer, + tenant_id integer ); CREATE SEQUENCE insight_series_incomplete_points_id_seq @@ -226,7 +234,8 @@ ALTER SEQUENCE insight_series_incomplete_points_id_seq OWNED BY insight_series_i CREATE TABLE insight_series_recording_times ( insight_series_id integer, recording_time timestamp with time zone, - snapshot boolean + snapshot boolean, + tenant_id integer ); CREATE TABLE insight_view ( @@ -243,7 +252,8 @@ CREATE TABLE insight_view ( series_sort_mode series_sort_mode_enum, series_sort_direction series_sort_direction_enum, series_limit integer, - series_num_samples integer + series_num_samples integer, + tenant_id integer ); COMMENT ON TABLE insight_view IS 'Views for insight data series. An insight view is an abstraction on top of an insight data series that allows for lightweight modifications to filters or metadata without regenerating the underlying series.'; @@ -265,7 +275,8 @@ CREATE TABLE insight_view_grants ( insight_view_id integer NOT NULL, user_id integer, org_id integer, - global boolean + global boolean, + tenant_id integer ); COMMENT ON TABLE insight_view_grants IS 'Permission grants for insight views. Each row should represent a unique principal (user, org, etc).'; @@ -300,7 +311,8 @@ CREATE TABLE insight_view_series ( insight_view_id integer NOT NULL, insight_series_id integer NOT NULL, label text, - stroke text + stroke text, + tenant_id integer ); COMMENT ON TABLE insight_view_series IS 'Join table to correlate data series with insight views'; @@ -327,7 +339,8 @@ CREATE TABLE insights_background_jobs ( execution_logs json[], worker_hostname text DEFAULT ''::text NOT NULL, cancel boolean DEFAULT false NOT NULL, - backfill_id integer + backfill_id integer, + tenant_id integer ); CREATE SEQUENCE insights_background_jobs_id_seq @@ -355,7 +368,8 @@ CREATE TABLE insights_data_retention_jobs ( worker_hostname text DEFAULT ''::text NOT NULL, cancel boolean DEFAULT false NOT NULL, series_id integer NOT NULL, - series_id_string text DEFAULT ''::text NOT NULL + series_id_string text DEFAULT ''::text NOT NULL, + tenant_id integer ); CREATE SEQUENCE insights_data_retention_jobs_id_seq @@ -413,7 +427,8 @@ CREATE VIEW insights_jobs_backfill_new AS CREATE TABLE metadata ( id bigint NOT NULL, - metadata jsonb NOT NULL + metadata jsonb NOT NULL, + tenant_id integer ); COMMENT ON TABLE metadata IS 'Records arbitrary metadata about events. Stored in a separate table as it is often repeated for multiple events.'; @@ -442,7 +457,8 @@ CREATE TABLE repo_iterator ( total_count integer DEFAULT 0 NOT NULL, success_count integer DEFAULT 0 NOT NULL, repos integer[], - repo_cursor integer DEFAULT 0 + repo_cursor integer DEFAULT 0, + tenant_id integer ); CREATE TABLE repo_iterator_errors ( @@ -450,7 +466,8 @@ CREATE TABLE repo_iterator_errors ( repo_iterator_id integer NOT NULL, repo_id integer NOT NULL, error_message text[] NOT NULL, - failure_count integer DEFAULT 1 + failure_count integer DEFAULT 1, + tenant_id integer ); CREATE SEQUENCE repo_iterator_errors_id_seq @@ -476,6 +493,7 @@ ALTER SEQUENCE repo_iterator_id_seq OWNED BY repo_iterator.id; CREATE TABLE repo_names ( id bigint NOT NULL, name citext NOT NULL, + tenant_id integer, CONSTRAINT check_name_nonempty CHECK ((name OPERATOR(<>) ''::citext)) ); @@ -503,6 +521,7 @@ CREATE TABLE series_points ( repo_name_id integer, original_repo_name_id integer, capture text, + tenant_id integer, CONSTRAINT check_repo_fields_specifity CHECK ((((repo_id IS NULL) AND (repo_name_id IS NULL) AND (original_repo_name_id IS NULL)) OR ((repo_id IS NOT NULL) AND (repo_name_id IS NOT NULL) AND (original_repo_name_id IS NOT NULL)))) ); @@ -531,6 +550,7 @@ CREATE TABLE series_points_snapshots ( repo_name_id integer, original_repo_name_id integer, capture text, + tenant_id integer, CONSTRAINT check_repo_fields_specifity CHECK ((((repo_id IS NULL) AND (repo_name_id IS NULL) AND (original_repo_name_id IS NULL)) OR ((repo_id IS NOT NULL) AND (repo_name_id IS NOT NULL) AND (original_repo_name_id IS NOT NULL)))) ); @@ -701,18 +721,36 @@ CREATE INDEX series_points_snapshots_series_id_idx ON series_points_snapshots US CREATE INDEX series_points_snapshots_series_id_repo_id_time_idx ON series_points_snapshots USING btree (series_id, repo_id, "time"); +ALTER TABLE ONLY archived_insight_series_recording_times + ADD CONSTRAINT archived_insight_series_recording_times_tenant_id_fkey FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE; + +ALTER TABLE ONLY archived_series_points + ADD CONSTRAINT archived_series_points_tenant_id_fkey FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE; + ALTER TABLE ONLY dashboard_grants ADD CONSTRAINT dashboard_grants_dashboard_id_fk FOREIGN KEY (dashboard_id) REFERENCES dashboard(id) ON DELETE CASCADE; +ALTER TABLE ONLY dashboard_grants + ADD CONSTRAINT dashboard_grants_tenant_id_fkey FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE; + ALTER TABLE ONLY dashboard_insight_view ADD CONSTRAINT dashboard_insight_view_dashboard_id_fk FOREIGN KEY (dashboard_id) REFERENCES dashboard(id) ON DELETE CASCADE; ALTER TABLE ONLY dashboard_insight_view ADD CONSTRAINT dashboard_insight_view_insight_view_id_fk FOREIGN KEY (insight_view_id) REFERENCES insight_view(id) ON DELETE CASCADE; +ALTER TABLE ONLY dashboard_insight_view + ADD CONSTRAINT dashboard_insight_view_tenant_id_fkey FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE; + +ALTER TABLE ONLY dashboard + ADD CONSTRAINT dashboard_tenant_id_fkey FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE; + ALTER TABLE ONLY insight_series_backfill ADD CONSTRAINT insight_series_backfill_series_id_fk FOREIGN KEY (series_id) REFERENCES insight_series(id) ON DELETE CASCADE; +ALTER TABLE ONLY insight_series_backfill + ADD CONSTRAINT insight_series_backfill_tenant_id_fkey FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE; + ALTER TABLE ONLY insight_series_recording_times ADD CONSTRAINT insight_series_id_fkey FOREIGN KEY (insight_series_id) REFERENCES insight_series(id) ON DELETE CASCADE; @@ -722,24 +760,60 @@ ALTER TABLE ONLY archived_insight_series_recording_times ALTER TABLE ONLY insight_series_incomplete_points ADD CONSTRAINT insight_series_incomplete_points_series_id_fk FOREIGN KEY (series_id) REFERENCES insight_series(id) ON DELETE CASCADE; +ALTER TABLE ONLY insight_series_incomplete_points + ADD CONSTRAINT insight_series_incomplete_points_tenant_id_fkey FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE; + +ALTER TABLE ONLY insight_series_recording_times + ADD CONSTRAINT insight_series_recording_times_tenant_id_fkey FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE; + ALTER TABLE ONLY archived_series_points ADD CONSTRAINT insight_series_series_id_fkey FOREIGN KEY (series_id) REFERENCES insight_series(series_id) ON DELETE CASCADE; +ALTER TABLE ONLY insight_series + ADD CONSTRAINT insight_series_tenant_id_fkey FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE; + ALTER TABLE ONLY insight_view_grants ADD CONSTRAINT insight_view_grants_insight_view_id_fk FOREIGN KEY (insight_view_id) REFERENCES insight_view(id) ON DELETE CASCADE; +ALTER TABLE ONLY insight_view_grants + ADD CONSTRAINT insight_view_grants_tenant_id_fkey FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE; + ALTER TABLE ONLY insight_view_series ADD CONSTRAINT insight_view_series_insight_series_id_fkey FOREIGN KEY (insight_series_id) REFERENCES insight_series(id); ALTER TABLE ONLY insight_view_series ADD CONSTRAINT insight_view_series_insight_view_id_fkey FOREIGN KEY (insight_view_id) REFERENCES insight_view(id) ON DELETE CASCADE; +ALTER TABLE ONLY insight_view_series + ADD CONSTRAINT insight_view_series_tenant_id_fkey FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE; + +ALTER TABLE ONLY insight_view + ADD CONSTRAINT insight_view_tenant_id_fkey FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE; + ALTER TABLE ONLY insights_background_jobs ADD CONSTRAINT insights_background_jobs_backfill_id_fkey FOREIGN KEY (backfill_id) REFERENCES insight_series_backfill(id) ON DELETE CASCADE; +ALTER TABLE ONLY insights_background_jobs + ADD CONSTRAINT insights_background_jobs_tenant_id_fkey FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE; + +ALTER TABLE ONLY insights_data_retention_jobs + ADD CONSTRAINT insights_data_retention_jobs_tenant_id_fkey FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE; + +ALTER TABLE ONLY metadata + ADD CONSTRAINT metadata_tenant_id_fkey FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE; + +ALTER TABLE ONLY repo_iterator_errors + ADD CONSTRAINT repo_iterator_errors_tenant_id_fkey FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE; + ALTER TABLE ONLY repo_iterator_errors ADD CONSTRAINT repo_iterator_fk FOREIGN KEY (repo_iterator_id) REFERENCES repo_iterator(id); +ALTER TABLE ONLY repo_iterator + ADD CONSTRAINT repo_iterator_tenant_id_fkey FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE; + +ALTER TABLE ONLY repo_names + ADD CONSTRAINT repo_names_tenant_id_fkey FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE; + ALTER TABLE ONLY series_points ADD CONSTRAINT series_points_metadata_id_fkey FOREIGN KEY (metadata_id) REFERENCES metadata(id) ON DELETE CASCADE DEFERRABLE; @@ -747,4 +821,10 @@ ALTER TABLE ONLY series_points ADD CONSTRAINT series_points_original_repo_name_id_fkey FOREIGN KEY (original_repo_name_id) REFERENCES repo_names(id) ON DELETE CASCADE DEFERRABLE; ALTER TABLE ONLY series_points - ADD CONSTRAINT series_points_repo_name_id_fkey FOREIGN KEY (repo_name_id) REFERENCES repo_names(id) ON DELETE CASCADE DEFERRABLE; \ No newline at end of file + ADD CONSTRAINT series_points_repo_name_id_fkey FOREIGN KEY (repo_name_id) REFERENCES repo_names(id) ON DELETE CASCADE DEFERRABLE; + +ALTER TABLE ONLY series_points_snapshots + ADD CONSTRAINT series_points_snapshots_tenant_id_fkey FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE; + +ALTER TABLE ONLY series_points + ADD CONSTRAINT series_points_tenant_id_fkey FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE; \ No newline at end of file diff --git a/migrations/codeintel/1723127341_add_tenant_id_to_most_tables/down.sql b/migrations/codeintel/1723127341_add_tenant_id_to_most_tables/down.sql new file mode 100644 index 00000000000..40d395823a0 --- /dev/null +++ b/migrations/codeintel/1723127341_add_tenant_id_to_most_tables/down.sql @@ -0,0 +1,22 @@ +-- Temporary function to deduplicate the logic required for each table: +CREATE OR REPLACE FUNCTION migrate_add_tenant_id_codeintel(table_name text) +RETURNS void AS $$ +BEGIN + EXECUTE format('ALTER TABLE %I DROP COLUMN IF EXISTS tenant_id;', table_name); +END; +$$ LANGUAGE plpgsql; + +SELECT migrate_add_tenant_id_codeintel('codeintel_last_reconcile'); +SELECT migrate_add_tenant_id_codeintel('codeintel_scip_document_lookup'); +SELECT migrate_add_tenant_id_codeintel('codeintel_scip_document_lookup_schema_versions'); +SELECT migrate_add_tenant_id_codeintel('codeintel_scip_documents'); +SELECT migrate_add_tenant_id_codeintel('codeintel_scip_documents_dereference_logs'); +SELECT migrate_add_tenant_id_codeintel('codeintel_scip_metadata'); +SELECT migrate_add_tenant_id_codeintel('codeintel_scip_symbol_names'); +SELECT migrate_add_tenant_id_codeintel('codeintel_scip_symbols'); +SELECT migrate_add_tenant_id_codeintel('codeintel_scip_symbols_schema_versions'); +SELECT migrate_add_tenant_id_codeintel('rockskip_ancestry'); +SELECT migrate_add_tenant_id_codeintel('rockskip_repos'); +SELECT migrate_add_tenant_id_codeintel('rockskip_symbols'); + +DROP FUNCTION migrate_add_tenant_id_codeintel(text); diff --git a/migrations/codeintel/1723127341_add_tenant_id_to_most_tables/metadata.yaml b/migrations/codeintel/1723127341_add_tenant_id_to_most_tables/metadata.yaml new file mode 100644 index 00000000000..c8837ecc571 --- /dev/null +++ b/migrations/codeintel/1723127341_add_tenant_id_to_most_tables/metadata.yaml @@ -0,0 +1,3 @@ +name: add tenant id to most tables +noTransaction: true +parents: [1686315964] diff --git a/migrations/codeintel/1723127341_add_tenant_id_to_most_tables/up.sql b/migrations/codeintel/1723127341_add_tenant_id_to_most_tables/up.sql new file mode 100644 index 00000000000..cc70aa48783 --- /dev/null +++ b/migrations/codeintel/1723127341_add_tenant_id_to_most_tables/up.sql @@ -0,0 +1,29 @@ +-- This migration adds the tenant_id column in a way which doesn't require +-- updating every row. The value is null and an out of band migration will set +-- it to the default. A later migration will enforce tenant_id to be set. + +-- Temporary function to deduplicate the logic required for each table: +CREATE OR REPLACE FUNCTION migrate_add_tenant_id_codeintel(table_name text) +RETURNS void AS $$ +BEGIN + EXECUTE format('ALTER TABLE %I ADD COLUMN IF NOT EXISTS tenant_id integer REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE;', table_name); +END; +$$ LANGUAGE plpgsql; + +SELECT migrate_add_tenant_id_codeintel('codeintel_last_reconcile'); +SELECT migrate_add_tenant_id_codeintel('codeintel_scip_document_lookup'); +SELECT migrate_add_tenant_id_codeintel('codeintel_scip_document_lookup_schema_versions'); +SELECT migrate_add_tenant_id_codeintel('codeintel_scip_documents'); +SELECT migrate_add_tenant_id_codeintel('codeintel_scip_documents_dereference_logs'); +SELECT migrate_add_tenant_id_codeintel('codeintel_scip_metadata'); +SELECT migrate_add_tenant_id_codeintel('codeintel_scip_symbol_names'); +SELECT migrate_add_tenant_id_codeintel('codeintel_scip_symbols'); +SELECT migrate_add_tenant_id_codeintel('codeintel_scip_symbols_schema_versions'); +SELECT migrate_add_tenant_id_codeintel('rockskip_ancestry'); +SELECT migrate_add_tenant_id_codeintel('rockskip_repos'); +SELECT migrate_add_tenant_id_codeintel('rockskip_symbols'); + +-- Explicitly excluded tables +-- migration_logs :: about DB + +DROP FUNCTION migrate_add_tenant_id_codeintel(text); diff --git a/migrations/codeintel/squashed.sql b/migrations/codeintel/squashed.sql index 538cea6b262..55e153612b6 100644 --- a/migrations/codeintel/squashed.sql +++ b/migrations/codeintel/squashed.sql @@ -84,7 +84,8 @@ END $$; CREATE TABLE codeintel_last_reconcile ( dump_id integer NOT NULL, - last_reconcile_at timestamp with time zone NOT NULL + last_reconcile_at timestamp with time zone NOT NULL, + tenant_id integer ); COMMENT ON TABLE codeintel_last_reconcile IS 'Stores the last time processed LSIF data was reconciled with the other database.'; @@ -93,7 +94,8 @@ CREATE TABLE codeintel_scip_document_lookup ( id bigint NOT NULL, upload_id integer NOT NULL, document_path text NOT NULL, - document_id bigint NOT NULL + document_id bigint NOT NULL, + tenant_id integer ); COMMENT ON TABLE codeintel_scip_document_lookup IS 'A mapping from file paths to document references within a particular SCIP index.'; @@ -118,7 +120,8 @@ ALTER SEQUENCE codeintel_scip_document_lookup_id_seq OWNED BY codeintel_scip_doc CREATE TABLE codeintel_scip_document_lookup_schema_versions ( upload_id integer NOT NULL, min_schema_version integer, - max_schema_version integer + max_schema_version integer, + tenant_id integer ); COMMENT ON TABLE codeintel_scip_document_lookup_schema_versions IS 'Tracks the range of `schema_versions` values associated with each SCIP index in the [`codeintel_scip_document_lookup`](#table-publiccodeintel_scip_document_lookup) table.'; @@ -133,7 +136,8 @@ CREATE TABLE codeintel_scip_documents ( id bigint NOT NULL, payload_hash bytea NOT NULL, schema_version integer NOT NULL, - raw_scip_payload bytea NOT NULL + raw_scip_payload bytea NOT NULL, + tenant_id integer ); COMMENT ON TABLE codeintel_scip_documents IS 'A lookup of SCIP [Document](https://sourcegraph.com/search?q=context:%40sourcegraph/all+repo:%5Egithub%5C.com/sourcegraph/scip%24+file:%5Escip%5C.proto+message+Document&patternType=standard) payloads by their hash.'; @@ -149,7 +153,8 @@ COMMENT ON COLUMN codeintel_scip_documents.raw_scip_payload IS 'The raw, canonic CREATE TABLE codeintel_scip_documents_dereference_logs ( id bigint NOT NULL, document_id bigint NOT NULL, - last_removal_time timestamp with time zone DEFAULT now() NOT NULL + last_removal_time timestamp with time zone DEFAULT now() NOT NULL, + tenant_id integer ); COMMENT ON TABLE codeintel_scip_documents_dereference_logs IS 'A list of document rows that were recently dereferenced by the deletion of an index.'; @@ -183,7 +188,8 @@ CREATE TABLE codeintel_scip_metadata ( tool_version text NOT NULL, tool_arguments text[] NOT NULL, text_document_encoding text NOT NULL, - protocol_version integer NOT NULL + protocol_version integer NOT NULL, + tenant_id integer ); COMMENT ON TABLE codeintel_scip_metadata IS 'Global metadatadata about a single processed upload.'; @@ -215,7 +221,8 @@ CREATE TABLE codeintel_scip_symbol_names ( id integer NOT NULL, upload_id integer NOT NULL, name_segment text NOT NULL, - prefix_id integer + prefix_id integer, + tenant_id integer ); COMMENT ON TABLE codeintel_scip_symbol_names IS 'Stores a prefix tree of symbol names within a particular upload.'; @@ -236,7 +243,8 @@ CREATE TABLE codeintel_scip_symbols ( reference_ranges bytea, implementation_ranges bytea, type_definition_ranges bytea, - symbol_id integer NOT NULL + symbol_id integer NOT NULL, + tenant_id integer ); COMMENT ON TABLE codeintel_scip_symbols IS 'A mapping from SCIP [Symbol names](https://sourcegraph.com/search?q=context:%40sourcegraph/all+repo:%5Egithub%5C.com/sourcegraph/scip%24+file:%5Escip%5C.proto+message+Symbol&patternType=standard) to path and ranges where that symbol occurs within a particular SCIP index.'; @@ -260,7 +268,8 @@ COMMENT ON COLUMN codeintel_scip_symbols.symbol_id IS 'The identifier of the seg CREATE TABLE codeintel_scip_symbols_schema_versions ( upload_id integer NOT NULL, min_schema_version integer, - max_schema_version integer + max_schema_version integer, + tenant_id integer ); COMMENT ON TABLE codeintel_scip_symbols_schema_versions IS 'Tracks the range of `schema_versions` for each index in the [`codeintel_scip_symbols`](#table-publiccodeintel_scip_symbols) table.'; @@ -276,7 +285,8 @@ CREATE TABLE rockskip_ancestry ( repo_id integer NOT NULL, commit_id character varying(40) NOT NULL, height integer NOT NULL, - ancestor integer NOT NULL + ancestor integer NOT NULL, + tenant_id integer ); CREATE SEQUENCE rockskip_ancestry_id_seq @@ -292,7 +302,8 @@ ALTER SEQUENCE rockskip_ancestry_id_seq OWNED BY rockskip_ancestry.id; CREATE TABLE rockskip_repos ( id integer NOT NULL, repo text NOT NULL, - last_accessed_at timestamp with time zone NOT NULL + last_accessed_at timestamp with time zone NOT NULL, + tenant_id integer ); CREATE SEQUENCE rockskip_repos_id_seq @@ -311,7 +322,8 @@ CREATE TABLE rockskip_symbols ( deleted integer[] NOT NULL, repo_id integer NOT NULL, path text NOT NULL, - name text NOT NULL + name text NOT NULL, + tenant_id integer ); CREATE SEQUENCE rockskip_symbols_id_seq @@ -437,8 +449,44 @@ CREATE TRIGGER codeintel_scip_documents_dereference_logs_insert AFTER DELETE ON CREATE TRIGGER codeintel_scip_symbols_schema_versions_insert AFTER INSERT ON codeintel_scip_symbols REFERENCING NEW TABLE AS newtab FOR EACH STATEMENT EXECUTE FUNCTION update_codeintel_scip_symbols_schema_versions_insert(); +ALTER TABLE ONLY codeintel_last_reconcile + ADD CONSTRAINT codeintel_last_reconcile_tenant_id_fkey FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE; + ALTER TABLE ONLY codeintel_scip_document_lookup ADD CONSTRAINT codeintel_scip_document_lookup_document_id_fk FOREIGN KEY (document_id) REFERENCES codeintel_scip_documents(id); +ALTER TABLE ONLY codeintel_scip_document_lookup_schema_versions + ADD CONSTRAINT codeintel_scip_document_lookup_schema_versions_tenant_id_fkey FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE; + +ALTER TABLE ONLY codeintel_scip_document_lookup + ADD CONSTRAINT codeintel_scip_document_lookup_tenant_id_fkey FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE; + +ALTER TABLE ONLY codeintel_scip_documents_dereference_logs + ADD CONSTRAINT codeintel_scip_documents_dereference_logs_tenant_id_fkey FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE; + +ALTER TABLE ONLY codeintel_scip_documents + ADD CONSTRAINT codeintel_scip_documents_tenant_id_fkey FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE; + +ALTER TABLE ONLY codeintel_scip_metadata + ADD CONSTRAINT codeintel_scip_metadata_tenant_id_fkey FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE; + +ALTER TABLE ONLY codeintel_scip_symbol_names + ADD CONSTRAINT codeintel_scip_symbol_names_tenant_id_fkey FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE; + ALTER TABLE ONLY codeintel_scip_symbols - ADD CONSTRAINT codeintel_scip_symbols_document_lookup_id_fk FOREIGN KEY (document_lookup_id) REFERENCES codeintel_scip_document_lookup(id) ON DELETE CASCADE; \ No newline at end of file + ADD CONSTRAINT codeintel_scip_symbols_document_lookup_id_fk FOREIGN KEY (document_lookup_id) REFERENCES codeintel_scip_document_lookup(id) ON DELETE CASCADE; + +ALTER TABLE ONLY codeintel_scip_symbols_schema_versions + ADD CONSTRAINT codeintel_scip_symbols_schema_versions_tenant_id_fkey FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE; + +ALTER TABLE ONLY codeintel_scip_symbols + ADD CONSTRAINT codeintel_scip_symbols_tenant_id_fkey FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE; + +ALTER TABLE ONLY rockskip_ancestry + ADD CONSTRAINT rockskip_ancestry_tenant_id_fkey FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE; + +ALTER TABLE ONLY rockskip_repos + ADD CONSTRAINT rockskip_repos_tenant_id_fkey FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE; + +ALTER TABLE ONLY rockskip_symbols + ADD CONSTRAINT rockskip_symbols_tenant_id_fkey FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE; \ No newline at end of file diff --git a/migrations/frontend/1723016879_add_tenant_id_to_most_tables/down.sql b/migrations/frontend/1723016879_add_tenant_id_to_most_tables/down.sql new file mode 100644 index 00000000000..0c88eac080b --- /dev/null +++ b/migrations/frontend/1723016879_add_tenant_id_to_most_tables/down.sql @@ -0,0 +1,187 @@ +-- Temporary function to deduplicate the logic required for each table: +CREATE OR REPLACE FUNCTION migrate_add_tenant_id_frontend(table_name text) +RETURNS void AS $$ +BEGIN + EXECUTE format('ALTER TABLE %I DROP COLUMN IF EXISTS tenant_id;', table_name); +END; +$$ LANGUAGE plpgsql; + +SELECT migrate_add_tenant_id_frontend('access_requests'); +SELECT migrate_add_tenant_id_frontend('access_tokens'); +SELECT migrate_add_tenant_id_frontend('aggregated_user_statistics'); +SELECT migrate_add_tenant_id_frontend('assigned_owners'); +SELECT migrate_add_tenant_id_frontend('assigned_teams'); +SELECT migrate_add_tenant_id_frontend('batch_changes'); +SELECT migrate_add_tenant_id_frontend('batch_changes_site_credentials'); +SELECT migrate_add_tenant_id_frontend('batch_spec_execution_cache_entries'); +SELECT migrate_add_tenant_id_frontend('batch_spec_resolution_jobs'); +SELECT migrate_add_tenant_id_frontend('batch_spec_workspace_execution_jobs'); +SELECT migrate_add_tenant_id_frontend('batch_spec_workspace_execution_last_dequeues'); +SELECT migrate_add_tenant_id_frontend('batch_spec_workspace_files'); +SELECT migrate_add_tenant_id_frontend('batch_spec_workspaces'); +SELECT migrate_add_tenant_id_frontend('batch_specs'); +SELECT migrate_add_tenant_id_frontend('cached_available_indexers'); +SELECT migrate_add_tenant_id_frontend('changeset_events'); +SELECT migrate_add_tenant_id_frontend('changeset_jobs'); +SELECT migrate_add_tenant_id_frontend('changeset_specs'); +SELECT migrate_add_tenant_id_frontend('changesets'); +SELECT migrate_add_tenant_id_frontend('cm_action_jobs'); +SELECT migrate_add_tenant_id_frontend('cm_emails'); +SELECT migrate_add_tenant_id_frontend('cm_last_searched'); +SELECT migrate_add_tenant_id_frontend('cm_monitors'); +SELECT migrate_add_tenant_id_frontend('cm_queries'); +SELECT migrate_add_tenant_id_frontend('cm_recipients'); +SELECT migrate_add_tenant_id_frontend('cm_slack_webhooks'); +SELECT migrate_add_tenant_id_frontend('cm_trigger_jobs'); +SELECT migrate_add_tenant_id_frontend('cm_webhooks'); +SELECT migrate_add_tenant_id_frontend('code_hosts'); +SELECT migrate_add_tenant_id_frontend('codeintel_autoindex_queue'); +SELECT migrate_add_tenant_id_frontend('codeintel_autoindexing_exceptions'); +SELECT migrate_add_tenant_id_frontend('codeintel_commit_dates'); +SELECT migrate_add_tenant_id_frontend('codeintel_inference_scripts'); +SELECT migrate_add_tenant_id_frontend('codeintel_initial_path_ranks'); +SELECT migrate_add_tenant_id_frontend('codeintel_initial_path_ranks_processed'); +SELECT migrate_add_tenant_id_frontend('codeintel_langugage_support_requests'); +SELECT migrate_add_tenant_id_frontend('codeintel_path_ranks'); +SELECT migrate_add_tenant_id_frontend('codeintel_ranking_definitions'); +SELECT migrate_add_tenant_id_frontend('codeintel_ranking_exports'); +SELECT migrate_add_tenant_id_frontend('codeintel_ranking_graph_keys'); +SELECT migrate_add_tenant_id_frontend('codeintel_ranking_path_counts_inputs'); +SELECT migrate_add_tenant_id_frontend('codeintel_ranking_progress'); +SELECT migrate_add_tenant_id_frontend('codeintel_ranking_references'); +SELECT migrate_add_tenant_id_frontend('codeintel_ranking_references_processed'); +SELECT migrate_add_tenant_id_frontend('codeowners'); +SELECT migrate_add_tenant_id_frontend('codeowners_individual_stats'); +SELECT migrate_add_tenant_id_frontend('codeowners_owners'); +SELECT migrate_add_tenant_id_frontend('commit_authors'); +SELECT migrate_add_tenant_id_frontend('configuration_policies_audit_logs'); +SELECT migrate_add_tenant_id_frontend('context_detection_embedding_jobs'); +SELECT migrate_add_tenant_id_frontend('discussion_comments'); +SELECT migrate_add_tenant_id_frontend('discussion_mail_reply_tokens'); +SELECT migrate_add_tenant_id_frontend('discussion_threads'); +SELECT migrate_add_tenant_id_frontend('discussion_threads_target_repo'); +SELECT migrate_add_tenant_id_frontend('event_logs'); +SELECT migrate_add_tenant_id_frontend('event_logs_export_allowlist'); +SELECT migrate_add_tenant_id_frontend('event_logs_scrape_state'); +SELECT migrate_add_tenant_id_frontend('event_logs_scrape_state_own'); +SELECT migrate_add_tenant_id_frontend('executor_heartbeats'); +SELECT migrate_add_tenant_id_frontend('executor_job_tokens'); +SELECT migrate_add_tenant_id_frontend('executor_secret_access_logs'); +SELECT migrate_add_tenant_id_frontend('executor_secrets'); +SELECT migrate_add_tenant_id_frontend('exhaustive_search_jobs'); +SELECT migrate_add_tenant_id_frontend('exhaustive_search_repo_jobs'); +SELECT migrate_add_tenant_id_frontend('exhaustive_search_repo_revision_jobs'); +SELECT migrate_add_tenant_id_frontend('explicit_permissions_bitbucket_projects_jobs'); +SELECT migrate_add_tenant_id_frontend('external_service_repos'); +SELECT migrate_add_tenant_id_frontend('external_service_sync_jobs'); +SELECT migrate_add_tenant_id_frontend('external_services'); +SELECT migrate_add_tenant_id_frontend('feature_flag_overrides'); +SELECT migrate_add_tenant_id_frontend('feature_flags'); +SELECT migrate_add_tenant_id_frontend('github_app_installs'); +SELECT migrate_add_tenant_id_frontend('github_apps'); +SELECT migrate_add_tenant_id_frontend('gitserver_relocator_jobs'); +SELECT migrate_add_tenant_id_frontend('gitserver_repos'); +SELECT migrate_add_tenant_id_frontend('gitserver_repos_statistics'); +SELECT migrate_add_tenant_id_frontend('gitserver_repos_sync_output'); +SELECT migrate_add_tenant_id_frontend('global_state'); +SELECT migrate_add_tenant_id_frontend('insights_query_runner_jobs'); +SELECT migrate_add_tenant_id_frontend('insights_query_runner_jobs_dependencies'); +SELECT migrate_add_tenant_id_frontend('insights_settings_migration_jobs'); +SELECT migrate_add_tenant_id_frontend('lsif_configuration_policies'); +SELECT migrate_add_tenant_id_frontend('lsif_configuration_policies_repository_pattern_lookup'); +SELECT migrate_add_tenant_id_frontend('lsif_dependency_indexing_jobs'); +SELECT migrate_add_tenant_id_frontend('lsif_dependency_repos'); +SELECT migrate_add_tenant_id_frontend('lsif_dependency_syncing_jobs'); +SELECT migrate_add_tenant_id_frontend('lsif_dirty_repositories'); +SELECT migrate_add_tenant_id_frontend('lsif_index_configuration'); +SELECT migrate_add_tenant_id_frontend('lsif_indexes'); +SELECT migrate_add_tenant_id_frontend('lsif_last_index_scan'); +SELECT migrate_add_tenant_id_frontend('lsif_last_retention_scan'); +SELECT migrate_add_tenant_id_frontend('lsif_nearest_uploads'); +SELECT migrate_add_tenant_id_frontend('lsif_nearest_uploads_links'); +SELECT migrate_add_tenant_id_frontend('lsif_packages'); +SELECT migrate_add_tenant_id_frontend('lsif_references'); +SELECT migrate_add_tenant_id_frontend('lsif_retention_configuration'); +SELECT migrate_add_tenant_id_frontend('lsif_uploads'); +SELECT migrate_add_tenant_id_frontend('lsif_uploads_audit_logs'); +SELECT migrate_add_tenant_id_frontend('lsif_uploads_reference_counts'); +SELECT migrate_add_tenant_id_frontend('lsif_uploads_visible_at_tip'); +SELECT migrate_add_tenant_id_frontend('lsif_uploads_vulnerability_scan'); +SELECT migrate_add_tenant_id_frontend('names'); +SELECT migrate_add_tenant_id_frontend('namespace_permissions'); +SELECT migrate_add_tenant_id_frontend('notebook_stars'); +SELECT migrate_add_tenant_id_frontend('notebooks'); +SELECT migrate_add_tenant_id_frontend('org_invitations'); +SELECT migrate_add_tenant_id_frontend('org_members'); +SELECT migrate_add_tenant_id_frontend('org_stats'); +SELECT migrate_add_tenant_id_frontend('orgs'); +SELECT migrate_add_tenant_id_frontend('orgs_open_beta_stats'); +SELECT migrate_add_tenant_id_frontend('out_of_band_migrations'); +SELECT migrate_add_tenant_id_frontend('out_of_band_migrations_errors'); +SELECT migrate_add_tenant_id_frontend('outbound_webhook_event_types'); +SELECT migrate_add_tenant_id_frontend('outbound_webhook_jobs'); +SELECT migrate_add_tenant_id_frontend('outbound_webhook_logs'); +SELECT migrate_add_tenant_id_frontend('outbound_webhooks'); +SELECT migrate_add_tenant_id_frontend('own_aggregate_recent_contribution'); +SELECT migrate_add_tenant_id_frontend('own_aggregate_recent_view'); +SELECT migrate_add_tenant_id_frontend('own_background_jobs'); +SELECT migrate_add_tenant_id_frontend('own_signal_configurations'); +SELECT migrate_add_tenant_id_frontend('own_signal_recent_contribution'); +SELECT migrate_add_tenant_id_frontend('ownership_path_stats'); +SELECT migrate_add_tenant_id_frontend('package_repo_filters'); +SELECT migrate_add_tenant_id_frontend('package_repo_versions'); +SELECT migrate_add_tenant_id_frontend('permission_sync_jobs'); +SELECT migrate_add_tenant_id_frontend('permissions'); +SELECT migrate_add_tenant_id_frontend('phabricator_repos'); +SELECT migrate_add_tenant_id_frontend('product_licenses'); +SELECT migrate_add_tenant_id_frontend('product_subscriptions'); +SELECT migrate_add_tenant_id_frontend('prompts'); +SELECT migrate_add_tenant_id_frontend('query_runner_state'); +SELECT migrate_add_tenant_id_frontend('redis_key_value'); +SELECT migrate_add_tenant_id_frontend('registry_extension_releases'); +SELECT migrate_add_tenant_id_frontend('registry_extensions'); +SELECT migrate_add_tenant_id_frontend('repo'); +SELECT migrate_add_tenant_id_frontend('repo_commits_changelists'); +SELECT migrate_add_tenant_id_frontend('repo_embedding_job_stats'); +SELECT migrate_add_tenant_id_frontend('repo_embedding_jobs'); +SELECT migrate_add_tenant_id_frontend('repo_kvps'); +SELECT migrate_add_tenant_id_frontend('repo_paths'); +SELECT migrate_add_tenant_id_frontend('repo_pending_permissions'); +SELECT migrate_add_tenant_id_frontend('repo_permissions'); +SELECT migrate_add_tenant_id_frontend('repo_statistics'); +SELECT migrate_add_tenant_id_frontend('role_permissions'); +SELECT migrate_add_tenant_id_frontend('roles'); +SELECT migrate_add_tenant_id_frontend('saved_searches'); +SELECT migrate_add_tenant_id_frontend('search_context_default'); +SELECT migrate_add_tenant_id_frontend('search_context_repos'); +SELECT migrate_add_tenant_id_frontend('search_context_stars'); +SELECT migrate_add_tenant_id_frontend('search_contexts'); +SELECT migrate_add_tenant_id_frontend('security_event_logs'); +SELECT migrate_add_tenant_id_frontend('settings'); +SELECT migrate_add_tenant_id_frontend('sub_repo_permissions'); +SELECT migrate_add_tenant_id_frontend('survey_responses'); +SELECT migrate_add_tenant_id_frontend('syntactic_scip_indexing_jobs'); +SELECT migrate_add_tenant_id_frontend('syntactic_scip_last_index_scan'); +SELECT migrate_add_tenant_id_frontend('team_members'); +SELECT migrate_add_tenant_id_frontend('teams'); +SELECT migrate_add_tenant_id_frontend('telemetry_events_export_queue'); +SELECT migrate_add_tenant_id_frontend('temporary_settings'); +SELECT migrate_add_tenant_id_frontend('user_credentials'); +SELECT migrate_add_tenant_id_frontend('user_emails'); +SELECT migrate_add_tenant_id_frontend('user_external_accounts'); +SELECT migrate_add_tenant_id_frontend('user_onboarding_tour'); +SELECT migrate_add_tenant_id_frontend('user_pending_permissions'); +SELECT migrate_add_tenant_id_frontend('user_permissions'); +SELECT migrate_add_tenant_id_frontend('user_public_repos'); +SELECT migrate_add_tenant_id_frontend('user_repo_permissions'); +SELECT migrate_add_tenant_id_frontend('user_roles'); +SELECT migrate_add_tenant_id_frontend('users'); +SELECT migrate_add_tenant_id_frontend('vulnerabilities'); +SELECT migrate_add_tenant_id_frontend('vulnerability_affected_packages'); +SELECT migrate_add_tenant_id_frontend('vulnerability_affected_symbols'); +SELECT migrate_add_tenant_id_frontend('vulnerability_matches'); +SELECT migrate_add_tenant_id_frontend('webhook_logs'); +SELECT migrate_add_tenant_id_frontend('webhooks'); +SELECT migrate_add_tenant_id_frontend('zoekt_repos'); + +DROP FUNCTION migrate_add_tenant_id_frontend(text); diff --git a/migrations/frontend/1723016879_add_tenant_id_to_most_tables/metadata.yaml b/migrations/frontend/1723016879_add_tenant_id_to_most_tables/metadata.yaml new file mode 100644 index 00000000000..5fcb1abf8bd --- /dev/null +++ b/migrations/frontend/1723016879_add_tenant_id_to_most_tables/metadata.yaml @@ -0,0 +1,3 @@ +name: Add tenant ID to most tables +noTransaction: true +parents: [1722961262] diff --git a/migrations/frontend/1723016879_add_tenant_id_to_most_tables/up.sql b/migrations/frontend/1723016879_add_tenant_id_to_most_tables/up.sql new file mode 100644 index 00000000000..9c7dcfa7301 --- /dev/null +++ b/migrations/frontend/1723016879_add_tenant_id_to_most_tables/up.sql @@ -0,0 +1,197 @@ +-- This migration adds the tenant_id column in a way which doesn't require +-- updating every row. The value is null and an out of band migration will set +-- it to the default. A later migration will enforce tenant_id to be set. + +-- Temporary function to deduplicate the logic required for each table: +CREATE OR REPLACE FUNCTION migrate_add_tenant_id_frontend(table_name text) +RETURNS void AS $$ +BEGIN + EXECUTE format('ALTER TABLE %I ADD COLUMN IF NOT EXISTS tenant_id integer REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE;', table_name); +END; +$$ LANGUAGE plpgsql; + +SELECT migrate_add_tenant_id_frontend('access_requests'); +SELECT migrate_add_tenant_id_frontend('access_tokens'); +SELECT migrate_add_tenant_id_frontend('aggregated_user_statistics'); +SELECT migrate_add_tenant_id_frontend('assigned_owners'); +SELECT migrate_add_tenant_id_frontend('assigned_teams'); +SELECT migrate_add_tenant_id_frontend('batch_changes'); +SELECT migrate_add_tenant_id_frontend('batch_changes_site_credentials'); +SELECT migrate_add_tenant_id_frontend('batch_spec_execution_cache_entries'); +SELECT migrate_add_tenant_id_frontend('batch_spec_resolution_jobs'); +SELECT migrate_add_tenant_id_frontend('batch_spec_workspace_execution_jobs'); +SELECT migrate_add_tenant_id_frontend('batch_spec_workspace_execution_last_dequeues'); +SELECT migrate_add_tenant_id_frontend('batch_spec_workspace_files'); +SELECT migrate_add_tenant_id_frontend('batch_spec_workspaces'); +SELECT migrate_add_tenant_id_frontend('batch_specs'); +SELECT migrate_add_tenant_id_frontend('cached_available_indexers'); +SELECT migrate_add_tenant_id_frontend('changeset_events'); +SELECT migrate_add_tenant_id_frontend('changeset_jobs'); +SELECT migrate_add_tenant_id_frontend('changeset_specs'); +SELECT migrate_add_tenant_id_frontend('changesets'); +SELECT migrate_add_tenant_id_frontend('cm_action_jobs'); +SELECT migrate_add_tenant_id_frontend('cm_emails'); +SELECT migrate_add_tenant_id_frontend('cm_last_searched'); +SELECT migrate_add_tenant_id_frontend('cm_monitors'); +SELECT migrate_add_tenant_id_frontend('cm_queries'); +SELECT migrate_add_tenant_id_frontend('cm_recipients'); +SELECT migrate_add_tenant_id_frontend('cm_slack_webhooks'); +SELECT migrate_add_tenant_id_frontend('cm_trigger_jobs'); +SELECT migrate_add_tenant_id_frontend('cm_webhooks'); +SELECT migrate_add_tenant_id_frontend('code_hosts'); +SELECT migrate_add_tenant_id_frontend('codeintel_autoindex_queue'); +SELECT migrate_add_tenant_id_frontend('codeintel_autoindexing_exceptions'); +SELECT migrate_add_tenant_id_frontend('codeintel_commit_dates'); +SELECT migrate_add_tenant_id_frontend('codeintel_inference_scripts'); +SELECT migrate_add_tenant_id_frontend('codeintel_initial_path_ranks'); +SELECT migrate_add_tenant_id_frontend('codeintel_initial_path_ranks_processed'); +SELECT migrate_add_tenant_id_frontend('codeintel_langugage_support_requests'); +SELECT migrate_add_tenant_id_frontend('codeintel_path_ranks'); +SELECT migrate_add_tenant_id_frontend('codeintel_ranking_definitions'); +SELECT migrate_add_tenant_id_frontend('codeintel_ranking_exports'); +SELECT migrate_add_tenant_id_frontend('codeintel_ranking_graph_keys'); +SELECT migrate_add_tenant_id_frontend('codeintel_ranking_path_counts_inputs'); +SELECT migrate_add_tenant_id_frontend('codeintel_ranking_progress'); +SELECT migrate_add_tenant_id_frontend('codeintel_ranking_references'); +SELECT migrate_add_tenant_id_frontend('codeintel_ranking_references_processed'); +SELECT migrate_add_tenant_id_frontend('codeowners'); +SELECT migrate_add_tenant_id_frontend('codeowners_individual_stats'); +SELECT migrate_add_tenant_id_frontend('codeowners_owners'); +SELECT migrate_add_tenant_id_frontend('commit_authors'); +SELECT migrate_add_tenant_id_frontend('configuration_policies_audit_logs'); +SELECT migrate_add_tenant_id_frontend('context_detection_embedding_jobs'); +SELECT migrate_add_tenant_id_frontend('discussion_comments'); +SELECT migrate_add_tenant_id_frontend('discussion_mail_reply_tokens'); +SELECT migrate_add_tenant_id_frontend('discussion_threads'); +SELECT migrate_add_tenant_id_frontend('discussion_threads_target_repo'); +SELECT migrate_add_tenant_id_frontend('event_logs'); +SELECT migrate_add_tenant_id_frontend('event_logs_export_allowlist'); +SELECT migrate_add_tenant_id_frontend('event_logs_scrape_state'); +SELECT migrate_add_tenant_id_frontend('event_logs_scrape_state_own'); +SELECT migrate_add_tenant_id_frontend('executor_heartbeats'); +SELECT migrate_add_tenant_id_frontend('executor_job_tokens'); +SELECT migrate_add_tenant_id_frontend('executor_secret_access_logs'); +SELECT migrate_add_tenant_id_frontend('executor_secrets'); +SELECT migrate_add_tenant_id_frontend('exhaustive_search_jobs'); +SELECT migrate_add_tenant_id_frontend('exhaustive_search_repo_jobs'); +SELECT migrate_add_tenant_id_frontend('exhaustive_search_repo_revision_jobs'); +SELECT migrate_add_tenant_id_frontend('explicit_permissions_bitbucket_projects_jobs'); +SELECT migrate_add_tenant_id_frontend('external_service_repos'); +SELECT migrate_add_tenant_id_frontend('external_service_sync_jobs'); +SELECT migrate_add_tenant_id_frontend('external_services'); +SELECT migrate_add_tenant_id_frontend('feature_flag_overrides'); +SELECT migrate_add_tenant_id_frontend('feature_flags'); +SELECT migrate_add_tenant_id_frontend('github_app_installs'); +SELECT migrate_add_tenant_id_frontend('github_apps'); +SELECT migrate_add_tenant_id_frontend('gitserver_relocator_jobs'); +SELECT migrate_add_tenant_id_frontend('gitserver_repos'); +SELECT migrate_add_tenant_id_frontend('gitserver_repos_statistics'); +SELECT migrate_add_tenant_id_frontend('gitserver_repos_sync_output'); +SELECT migrate_add_tenant_id_frontend('global_state'); +SELECT migrate_add_tenant_id_frontend('insights_query_runner_jobs'); +SELECT migrate_add_tenant_id_frontend('insights_query_runner_jobs_dependencies'); +SELECT migrate_add_tenant_id_frontend('insights_settings_migration_jobs'); +SELECT migrate_add_tenant_id_frontend('lsif_configuration_policies'); +SELECT migrate_add_tenant_id_frontend('lsif_configuration_policies_repository_pattern_lookup'); +SELECT migrate_add_tenant_id_frontend('lsif_dependency_indexing_jobs'); +SELECT migrate_add_tenant_id_frontend('lsif_dependency_repos'); +SELECT migrate_add_tenant_id_frontend('lsif_dependency_syncing_jobs'); +SELECT migrate_add_tenant_id_frontend('lsif_dirty_repositories'); +SELECT migrate_add_tenant_id_frontend('lsif_index_configuration'); +SELECT migrate_add_tenant_id_frontend('lsif_indexes'); +SELECT migrate_add_tenant_id_frontend('lsif_last_index_scan'); +SELECT migrate_add_tenant_id_frontend('lsif_last_retention_scan'); +SELECT migrate_add_tenant_id_frontend('lsif_nearest_uploads'); +SELECT migrate_add_tenant_id_frontend('lsif_nearest_uploads_links'); +SELECT migrate_add_tenant_id_frontend('lsif_packages'); +SELECT migrate_add_tenant_id_frontend('lsif_references'); +SELECT migrate_add_tenant_id_frontend('lsif_retention_configuration'); +SELECT migrate_add_tenant_id_frontend('lsif_uploads'); +SELECT migrate_add_tenant_id_frontend('lsif_uploads_audit_logs'); +SELECT migrate_add_tenant_id_frontend('lsif_uploads_reference_counts'); +SELECT migrate_add_tenant_id_frontend('lsif_uploads_visible_at_tip'); +SELECT migrate_add_tenant_id_frontend('lsif_uploads_vulnerability_scan'); +SELECT migrate_add_tenant_id_frontend('names'); +SELECT migrate_add_tenant_id_frontend('namespace_permissions'); +SELECT migrate_add_tenant_id_frontend('notebook_stars'); +SELECT migrate_add_tenant_id_frontend('notebooks'); +SELECT migrate_add_tenant_id_frontend('org_invitations'); +SELECT migrate_add_tenant_id_frontend('org_members'); +SELECT migrate_add_tenant_id_frontend('org_stats'); +SELECT migrate_add_tenant_id_frontend('orgs'); +SELECT migrate_add_tenant_id_frontend('orgs_open_beta_stats'); +SELECT migrate_add_tenant_id_frontend('out_of_band_migrations'); +SELECT migrate_add_tenant_id_frontend('out_of_band_migrations_errors'); +SELECT migrate_add_tenant_id_frontend('outbound_webhook_event_types'); +SELECT migrate_add_tenant_id_frontend('outbound_webhook_jobs'); +SELECT migrate_add_tenant_id_frontend('outbound_webhook_logs'); +SELECT migrate_add_tenant_id_frontend('outbound_webhooks'); +SELECT migrate_add_tenant_id_frontend('own_aggregate_recent_contribution'); +SELECT migrate_add_tenant_id_frontend('own_aggregate_recent_view'); +SELECT migrate_add_tenant_id_frontend('own_background_jobs'); +SELECT migrate_add_tenant_id_frontend('own_signal_configurations'); +SELECT migrate_add_tenant_id_frontend('own_signal_recent_contribution'); +SELECT migrate_add_tenant_id_frontend('ownership_path_stats'); +SELECT migrate_add_tenant_id_frontend('package_repo_filters'); +SELECT migrate_add_tenant_id_frontend('package_repo_versions'); +SELECT migrate_add_tenant_id_frontend('permission_sync_jobs'); +SELECT migrate_add_tenant_id_frontend('permissions'); +SELECT migrate_add_tenant_id_frontend('phabricator_repos'); +SELECT migrate_add_tenant_id_frontend('product_licenses'); +SELECT migrate_add_tenant_id_frontend('product_subscriptions'); +SELECT migrate_add_tenant_id_frontend('prompts'); +SELECT migrate_add_tenant_id_frontend('query_runner_state'); +SELECT migrate_add_tenant_id_frontend('redis_key_value'); +SELECT migrate_add_tenant_id_frontend('registry_extension_releases'); +SELECT migrate_add_tenant_id_frontend('registry_extensions'); +SELECT migrate_add_tenant_id_frontend('repo'); +SELECT migrate_add_tenant_id_frontend('repo_commits_changelists'); +SELECT migrate_add_tenant_id_frontend('repo_embedding_job_stats'); +SELECT migrate_add_tenant_id_frontend('repo_embedding_jobs'); +SELECT migrate_add_tenant_id_frontend('repo_kvps'); +SELECT migrate_add_tenant_id_frontend('repo_paths'); +SELECT migrate_add_tenant_id_frontend('repo_pending_permissions'); +SELECT migrate_add_tenant_id_frontend('repo_permissions'); +SELECT migrate_add_tenant_id_frontend('repo_statistics'); +SELECT migrate_add_tenant_id_frontend('role_permissions'); +SELECT migrate_add_tenant_id_frontend('roles'); +SELECT migrate_add_tenant_id_frontend('saved_searches'); +SELECT migrate_add_tenant_id_frontend('search_context_default'); +SELECT migrate_add_tenant_id_frontend('search_context_repos'); +SELECT migrate_add_tenant_id_frontend('search_context_stars'); +SELECT migrate_add_tenant_id_frontend('search_contexts'); +SELECT migrate_add_tenant_id_frontend('security_event_logs'); +SELECT migrate_add_tenant_id_frontend('settings'); +SELECT migrate_add_tenant_id_frontend('sub_repo_permissions'); +SELECT migrate_add_tenant_id_frontend('survey_responses'); +SELECT migrate_add_tenant_id_frontend('syntactic_scip_indexing_jobs'); +SELECT migrate_add_tenant_id_frontend('syntactic_scip_last_index_scan'); +SELECT migrate_add_tenant_id_frontend('team_members'); +SELECT migrate_add_tenant_id_frontend('teams'); +SELECT migrate_add_tenant_id_frontend('telemetry_events_export_queue'); +SELECT migrate_add_tenant_id_frontend('temporary_settings'); +SELECT migrate_add_tenant_id_frontend('user_credentials'); +SELECT migrate_add_tenant_id_frontend('user_emails'); +SELECT migrate_add_tenant_id_frontend('user_external_accounts'); +SELECT migrate_add_tenant_id_frontend('user_onboarding_tour'); +SELECT migrate_add_tenant_id_frontend('user_pending_permissions'); +SELECT migrate_add_tenant_id_frontend('user_permissions'); +SELECT migrate_add_tenant_id_frontend('user_public_repos'); +SELECT migrate_add_tenant_id_frontend('user_repo_permissions'); +SELECT migrate_add_tenant_id_frontend('user_roles'); +SELECT migrate_add_tenant_id_frontend('users'); +SELECT migrate_add_tenant_id_frontend('vulnerabilities'); +SELECT migrate_add_tenant_id_frontend('vulnerability_affected_packages'); +SELECT migrate_add_tenant_id_frontend('vulnerability_affected_symbols'); +SELECT migrate_add_tenant_id_frontend('vulnerability_matches'); +SELECT migrate_add_tenant_id_frontend('webhook_logs'); +SELECT migrate_add_tenant_id_frontend('webhooks'); +SELECT migrate_add_tenant_id_frontend('zoekt_repos'); + +-- Explicitly excluded tables +-- critical_and_site_config :: for instance not tenant +-- migration_logs :: about DB +-- tenants :: it is the foreign table +-- versions :: about the instance not the tenant + +DROP FUNCTION migrate_add_tenant_id_frontend(text); diff --git a/migrations/frontend/squashed.sql b/migrations/frontend/squashed.sql index cdc2f043020..091154bd714 100644 --- a/migrations/frontend/squashed.sql +++ b/migrations/frontend/squashed.sql @@ -877,7 +877,8 @@ CREATE TABLE access_requests ( email text NOT NULL, additional_info text, status text NOT NULL, - decision_by_user_id integer + decision_by_user_id integer, + tenant_id integer ); CREATE SEQUENCE access_requests_id_seq @@ -901,7 +902,8 @@ CREATE TABLE access_tokens ( creator_user_id integer NOT NULL, scopes text[] NOT NULL, internal boolean DEFAULT false, - expires_at timestamp with time zone + expires_at timestamp with time zone, + tenant_id integer ); CREATE SEQUENCE access_tokens_id_seq @@ -918,7 +920,8 @@ CREATE TABLE aggregated_user_statistics ( created_at timestamp with time zone DEFAULT now() NOT NULL, updated_at timestamp with time zone DEFAULT now() NOT NULL, user_last_active_at timestamp with time zone, - user_events_count bigint + user_events_count bigint, + tenant_id integer ); CREATE TABLE assigned_owners ( @@ -926,7 +929,8 @@ CREATE TABLE assigned_owners ( owner_user_id integer NOT NULL, file_path_id integer NOT NULL, who_assigned_user_id integer, - assigned_at timestamp without time zone DEFAULT now() NOT NULL + assigned_at timestamp without time zone DEFAULT now() NOT NULL, + tenant_id integer ); COMMENT ON TABLE assigned_owners IS 'Table for ownership assignments, one entry contains an assigned user ID, which repo_path is assigned and the date and user who assigned the owner.'; @@ -946,7 +950,8 @@ CREATE TABLE assigned_teams ( owner_team_id integer NOT NULL, file_path_id integer NOT NULL, who_assigned_team_id integer, - assigned_at timestamp without time zone DEFAULT now() NOT NULL + assigned_at timestamp without time zone DEFAULT now() NOT NULL, + tenant_id integer ); COMMENT ON TABLE assigned_teams IS 'Table for team ownership assignments, one entry contains an assigned team ID, which repo_path is assigned and the date and user who assigned the owner team.'; @@ -974,6 +979,7 @@ CREATE TABLE batch_changes ( batch_spec_id bigint NOT NULL, last_applier_id bigint, last_applied_at timestamp with time zone, + tenant_id integer, CONSTRAINT batch_change_name_is_valid CHECK ((name ~ '^[\w.-]+$'::text)), CONSTRAINT batch_changes_has_1_namespace CHECK (((namespace_user_id IS NULL) <> (namespace_org_id IS NULL))), CONSTRAINT batch_changes_name_not_blank CHECK ((name <> ''::text)) @@ -997,6 +1003,7 @@ CREATE TABLE batch_changes_site_credentials ( credential bytea NOT NULL, encryption_key_id text DEFAULT ''::text NOT NULL, github_app_id integer, + tenant_id integer, CONSTRAINT check_github_app_id_and_external_service_type_site_credentials CHECK (((github_app_id IS NULL) OR (external_service_type = 'github'::text))) ); @@ -1016,7 +1023,8 @@ CREATE TABLE batch_spec_execution_cache_entries ( version integer NOT NULL, last_used_at timestamp with time zone, created_at timestamp with time zone DEFAULT now() NOT NULL, - user_id integer NOT NULL + user_id integer NOT NULL, + tenant_id integer ); CREATE SEQUENCE batch_spec_execution_cache_entries_id_seq @@ -1045,7 +1053,8 @@ CREATE TABLE batch_spec_resolution_jobs ( updated_at timestamp with time zone DEFAULT now() NOT NULL, queued_at timestamp with time zone DEFAULT now(), initiator_id integer NOT NULL, - cancel boolean DEFAULT false NOT NULL + cancel boolean DEFAULT false NOT NULL, + tenant_id integer ); CREATE SEQUENCE batch_spec_resolution_jobs_id_seq @@ -1075,7 +1084,8 @@ CREATE TABLE batch_spec_workspace_execution_jobs ( cancel boolean DEFAULT false NOT NULL, queued_at timestamp with time zone DEFAULT now(), user_id integer NOT NULL, - version integer DEFAULT 1 NOT NULL + version integer DEFAULT 1 NOT NULL, + tenant_id integer ); CREATE SEQUENCE batch_spec_workspace_execution_jobs_id_seq @@ -1089,7 +1099,8 @@ ALTER SEQUENCE batch_spec_workspace_execution_jobs_id_seq OWNED BY batch_spec_wo CREATE TABLE batch_spec_workspace_execution_last_dequeues ( user_id integer NOT NULL, - latest_dequeue timestamp with time zone + latest_dequeue timestamp with time zone, + tenant_id integer ); CREATE VIEW batch_spec_workspace_execution_queue AS @@ -1140,7 +1151,8 @@ CREATE TABLE batch_spec_workspace_files ( content bytea NOT NULL, modified_at timestamp with time zone NOT NULL, created_at timestamp with time zone DEFAULT now() NOT NULL, - updated_at timestamp with time zone DEFAULT now() NOT NULL + updated_at timestamp with time zone DEFAULT now() NOT NULL, + tenant_id integer ); CREATE SEQUENCE batch_spec_workspace_files_id_seq @@ -1169,7 +1181,8 @@ CREATE TABLE batch_spec_workspaces ( unsupported boolean DEFAULT false NOT NULL, skipped boolean DEFAULT false NOT NULL, cached_result_found boolean DEFAULT false NOT NULL, - step_cache_results jsonb DEFAULT '{}'::jsonb NOT NULL + step_cache_results jsonb DEFAULT '{}'::jsonb NOT NULL, + tenant_id integer ); CREATE SEQUENCE batch_spec_workspaces_id_seq @@ -1196,6 +1209,7 @@ CREATE TABLE batch_specs ( allow_ignored boolean DEFAULT false NOT NULL, no_cache boolean DEFAULT false NOT NULL, batch_change_id bigint, + tenant_id integer, CONSTRAINT batch_specs_has_1_namespace CHECK (((namespace_user_id IS NULL) <> (namespace_org_id IS NULL))) ); @@ -1232,6 +1246,7 @@ CREATE TABLE changeset_specs ( commit_author_name text, commit_author_email text, type text NOT NULL, + tenant_id integer, CONSTRAINT changeset_specs_published_valid_values CHECK (((published = 'true'::text) OR (published = 'false'::text) OR (published = '"draft"'::text) OR (published IS NULL))) ); @@ -1280,6 +1295,7 @@ CREATE TABLE changesets ( external_fork_name citext, previous_failure_message text, commit_verification jsonb DEFAULT '{}'::jsonb NOT NULL, + tenant_id integer, CONSTRAINT changesets_batch_change_ids_check CHECK ((jsonb_typeof(batch_change_ids) = 'object'::text)), CONSTRAINT changesets_external_id_check CHECK ((external_id <> ''::text)), CONSTRAINT changesets_external_service_type_not_blank CHECK ((external_service_type <> ''::text)), @@ -1307,6 +1323,7 @@ CREATE TABLE repo ( stars integer DEFAULT 0 NOT NULL, blocked jsonb, topics text[] GENERATED ALWAYS AS (extract_topics_from_metadata(external_service_type, metadata)) STORED, + tenant_id integer, CONSTRAINT check_name_nonempty CHECK ((name OPERATOR(<>) ''::citext)), CONSTRAINT repo_metadata_check CHECK ((jsonb_typeof(metadata) = 'object'::text)) ); @@ -1334,7 +1351,8 @@ CREATE TABLE cached_available_indexers ( id integer NOT NULL, repository_id integer NOT NULL, num_events integer NOT NULL, - available_indexers jsonb NOT NULL + available_indexers jsonb NOT NULL, + tenant_id integer ); CREATE SEQUENCE cached_available_indexers_id_seq @@ -1355,6 +1373,7 @@ CREATE TABLE changeset_events ( created_at timestamp with time zone DEFAULT now() NOT NULL, metadata jsonb DEFAULT '{}'::jsonb NOT NULL, updated_at timestamp with time zone DEFAULT now() NOT NULL, + tenant_id integer, CONSTRAINT changeset_events_key_check CHECK ((key <> ''::text)), CONSTRAINT changeset_events_kind_check CHECK ((kind <> ''::text)), CONSTRAINT changeset_events_metadata_check CHECK ((jsonb_typeof(metadata) = 'object'::text)) @@ -1391,6 +1410,7 @@ CREATE TABLE changeset_jobs ( last_heartbeat_at timestamp with time zone, queued_at timestamp with time zone DEFAULT now(), cancel boolean DEFAULT false NOT NULL, + tenant_id integer, CONSTRAINT changeset_jobs_payload_check CHECK ((jsonb_typeof(payload) = 'object'::text)) ); @@ -1440,6 +1460,7 @@ CREATE TABLE cm_action_jobs ( slack_webhook bigint, queued_at timestamp with time zone DEFAULT now(), cancel boolean DEFAULT false NOT NULL, + tenant_id integer, CONSTRAINT cm_action_jobs_only_one_action_type CHECK (((( CASE WHEN (email IS NULL) THEN 0 @@ -1483,7 +1504,8 @@ CREATE TABLE cm_emails ( created_at timestamp with time zone DEFAULT now() NOT NULL, changed_by integer NOT NULL, changed_at timestamp with time zone DEFAULT now() NOT NULL, - include_results boolean DEFAULT false NOT NULL + include_results boolean DEFAULT false NOT NULL, + tenant_id integer ); CREATE SEQUENCE cm_emails_id_seq @@ -1498,7 +1520,8 @@ ALTER SEQUENCE cm_emails_id_seq OWNED BY cm_emails.id; CREATE TABLE cm_last_searched ( monitor_id bigint NOT NULL, commit_oids text[] NOT NULL, - repo_id integer NOT NULL + repo_id integer NOT NULL, + tenant_id integer ); COMMENT ON TABLE cm_last_searched IS 'The last searched commit hashes for the given code monitor and unique set of search arguments'; @@ -1514,7 +1537,8 @@ CREATE TABLE cm_monitors ( changed_by integer NOT NULL, enabled boolean DEFAULT true NOT NULL, namespace_user_id integer NOT NULL, - namespace_org_id integer + namespace_org_id integer, + tenant_id integer ); COMMENT ON COLUMN cm_monitors.namespace_org_id IS 'DEPRECATED: code monitors cannot be owned by an org'; @@ -1537,7 +1561,8 @@ CREATE TABLE cm_queries ( changed_by integer NOT NULL, changed_at timestamp with time zone DEFAULT now() NOT NULL, next_run timestamp with time zone DEFAULT now(), - latest_result timestamp with time zone + latest_result timestamp with time zone, + tenant_id integer ); CREATE SEQUENCE cm_queries_id_seq @@ -1553,7 +1578,8 @@ CREATE TABLE cm_recipients ( id bigint NOT NULL, email bigint NOT NULL, namespace_user_id integer, - namespace_org_id integer + namespace_org_id integer, + tenant_id integer ); CREATE SEQUENCE cm_recipients_id_seq @@ -1574,7 +1600,8 @@ CREATE TABLE cm_slack_webhooks ( created_at timestamp with time zone DEFAULT now() NOT NULL, changed_by integer NOT NULL, changed_at timestamp with time zone DEFAULT now() NOT NULL, - include_results boolean DEFAULT false NOT NULL + include_results boolean DEFAULT false NOT NULL, + tenant_id integer ); COMMENT ON TABLE cm_slack_webhooks IS 'Slack webhook actions configured on code monitors'; @@ -1611,6 +1638,7 @@ CREATE TABLE cm_trigger_jobs ( queued_at timestamp with time zone DEFAULT now(), cancel boolean DEFAULT false NOT NULL, logs json[], + tenant_id integer, CONSTRAINT search_results_is_array CHECK ((jsonb_typeof(search_results) = 'array'::text)) ); @@ -1633,7 +1661,8 @@ CREATE TABLE cm_webhooks ( created_at timestamp with time zone DEFAULT now() NOT NULL, changed_by integer NOT NULL, changed_at timestamp with time zone DEFAULT now() NOT NULL, - include_results boolean DEFAULT false NOT NULL + include_results boolean DEFAULT false NOT NULL, + tenant_id integer ); COMMENT ON TABLE cm_webhooks IS 'Webhook actions configured on code monitors'; @@ -1662,7 +1691,8 @@ CREATE TABLE code_hosts ( git_rate_limit_quota integer, git_rate_limit_interval_seconds integer, created_at timestamp with time zone DEFAULT now() NOT NULL, - updated_at timestamp with time zone DEFAULT now() NOT NULL + updated_at timestamp with time zone DEFAULT now() NOT NULL, + tenant_id integer ); CREATE SEQUENCE code_hosts_id_seq @@ -1680,7 +1710,8 @@ CREATE TABLE codeintel_autoindex_queue ( repository_id integer NOT NULL, rev text NOT NULL, queued_at timestamp with time zone DEFAULT now() NOT NULL, - processed_at timestamp with time zone + processed_at timestamp with time zone, + tenant_id integer ); CREATE SEQUENCE codeintel_autoindex_queue_id_seq @@ -1697,7 +1728,8 @@ CREATE TABLE codeintel_autoindexing_exceptions ( id integer NOT NULL, repository_id integer NOT NULL, disable_scheduling boolean DEFAULT false NOT NULL, - disable_inference boolean DEFAULT false NOT NULL + disable_inference boolean DEFAULT false NOT NULL, + tenant_id integer ); CREATE SEQUENCE codeintel_autoindexing_exceptions_id_seq @@ -1713,7 +1745,8 @@ ALTER SEQUENCE codeintel_autoindexing_exceptions_id_seq OWNED BY codeintel_autoi CREATE TABLE codeintel_commit_dates ( repository_id integer NOT NULL, commit_bytea bytea NOT NULL, - committed_at timestamp with time zone + committed_at timestamp with time zone, + tenant_id integer ); COMMENT ON TABLE codeintel_commit_dates IS 'Maps commits within a repository to the commit date as reported by gitserver.'; @@ -1740,7 +1773,8 @@ CREATE TABLE lsif_configuration_policies ( repository_patterns text[], last_resolved_at timestamp with time zone, embeddings_enabled boolean DEFAULT false NOT NULL, - syntactic_indexing_enabled boolean DEFAULT false NOT NULL + syntactic_indexing_enabled boolean DEFAULT false NOT NULL, + tenant_id integer ); COMMENT ON COLUMN lsif_configuration_policies.repository_id IS 'The identifier of the repository to which this configuration policy applies. If absent, this policy is applied globally.'; @@ -1785,7 +1819,8 @@ CREATE VIEW codeintel_configuration_policies AS CREATE TABLE lsif_configuration_policies_repository_pattern_lookup ( policy_id integer NOT NULL, - repo_id integer NOT NULL + repo_id integer NOT NULL, + tenant_id integer ); COMMENT ON TABLE lsif_configuration_policies_repository_pattern_lookup IS 'A lookup table to get all the repository patterns by repository id that apply to a configuration policy.'; @@ -1801,7 +1836,8 @@ CREATE VIEW codeintel_configuration_policies_repository_pattern_lookup AS CREATE TABLE codeintel_inference_scripts ( insert_timestamp timestamp with time zone DEFAULT now() NOT NULL, - script text NOT NULL + script text NOT NULL, + tenant_id integer ); COMMENT ON TABLE codeintel_inference_scripts IS 'Contains auto-index job inference Lua scripts as an alternative to setting via environment variables.'; @@ -1811,7 +1847,8 @@ CREATE TABLE codeintel_initial_path_ranks ( document_path text DEFAULT ''::text NOT NULL, graph_key text NOT NULL, document_paths text[] DEFAULT '{}'::text[] NOT NULL, - exported_upload_id integer NOT NULL + exported_upload_id integer NOT NULL, + tenant_id integer ); CREATE SEQUENCE codeintel_initial_path_ranks_id_seq @@ -1826,7 +1863,8 @@ ALTER SEQUENCE codeintel_initial_path_ranks_id_seq OWNED BY codeintel_initial_pa CREATE TABLE codeintel_initial_path_ranks_processed ( id bigint NOT NULL, graph_key text NOT NULL, - codeintel_initial_path_ranks_id bigint NOT NULL + codeintel_initial_path_ranks_id bigint NOT NULL, + tenant_id integer ); CREATE SEQUENCE codeintel_initial_path_ranks_processed_id_seq @@ -1841,7 +1879,8 @@ ALTER SEQUENCE codeintel_initial_path_ranks_processed_id_seq OWNED BY codeintel_ CREATE TABLE codeintel_langugage_support_requests ( id integer NOT NULL, user_id integer NOT NULL, - language_id text NOT NULL + language_id text NOT NULL, + tenant_id integer ); CREATE SEQUENCE codeintel_langugage_support_requests_id_seq @@ -1861,7 +1900,8 @@ CREATE TABLE codeintel_path_ranks ( graph_key text NOT NULL, num_paths integer, refcount_logsum double precision, - id bigint NOT NULL + id bigint NOT NULL, + tenant_id integer ); CREATE SEQUENCE codeintel_path_ranks_id_seq @@ -1879,7 +1919,8 @@ CREATE TABLE codeintel_ranking_definitions ( document_path text NOT NULL, graph_key text NOT NULL, exported_upload_id integer NOT NULL, - symbol_checksum bytea DEFAULT '\x'::bytea NOT NULL + symbol_checksum bytea DEFAULT '\x'::bytea NOT NULL, + tenant_id integer ); CREATE SEQUENCE codeintel_ranking_definitions_id_seq @@ -1898,7 +1939,8 @@ CREATE TABLE codeintel_ranking_exports ( id integer NOT NULL, last_scanned_at timestamp with time zone, deleted_at timestamp with time zone, - upload_key text + upload_key text, + tenant_id integer ); CREATE SEQUENCE codeintel_ranking_exports_id_seq @@ -1914,7 +1956,8 @@ ALTER SEQUENCE codeintel_ranking_exports_id_seq OWNED BY codeintel_ranking_expor CREATE TABLE codeintel_ranking_graph_keys ( id integer NOT NULL, graph_key text NOT NULL, - created_at timestamp with time zone DEFAULT now() + created_at timestamp with time zone DEFAULT now(), + tenant_id integer ); CREATE SEQUENCE codeintel_ranking_graph_keys_id_seq @@ -1932,7 +1975,8 @@ CREATE TABLE codeintel_ranking_path_counts_inputs ( count integer NOT NULL, graph_key text NOT NULL, processed boolean DEFAULT false NOT NULL, - definition_id bigint + definition_id bigint, + tenant_id integer ); CREATE SEQUENCE codeintel_ranking_path_counts_inputs_id_seq @@ -1962,7 +2006,8 @@ CREATE TABLE codeintel_ranking_progress ( reference_cursor_export_deleted_at timestamp with time zone, reference_cursor_export_id integer, path_cursor_deleted_export_at timestamp with time zone, - path_cursor_export_id integer + path_cursor_export_id integer, + tenant_id integer ); CREATE SEQUENCE codeintel_ranking_progress_id_seq @@ -1979,7 +2024,8 @@ CREATE TABLE codeintel_ranking_references ( symbol_names text[] NOT NULL, graph_key text NOT NULL, exported_upload_id integer NOT NULL, - symbol_checksums bytea[] DEFAULT '{}'::bytea[] NOT NULL + symbol_checksums bytea[] DEFAULT '{}'::bytea[] NOT NULL, + tenant_id integer ); COMMENT ON TABLE codeintel_ranking_references IS 'References for a given upload proceduced by background job consuming SCIP indexes.'; @@ -1996,7 +2042,8 @@ ALTER SEQUENCE codeintel_ranking_references_id_seq OWNED BY codeintel_ranking_re CREATE TABLE codeintel_ranking_references_processed ( graph_key text NOT NULL, codeintel_ranking_reference_id integer NOT NULL, - id bigint NOT NULL + id bigint NOT NULL, + tenant_id integer ); CREATE SEQUENCE codeintel_ranking_references_processed_id_seq @@ -2014,7 +2061,8 @@ CREATE TABLE codeowners ( contents_proto bytea NOT NULL, repo_id integer NOT NULL, created_at timestamp with time zone DEFAULT now() NOT NULL, - updated_at timestamp with time zone DEFAULT now() NOT NULL + updated_at timestamp with time zone DEFAULT now() NOT NULL, + tenant_id integer ); CREATE SEQUENCE codeowners_id_seq @@ -2031,7 +2079,8 @@ CREATE TABLE codeowners_individual_stats ( file_path_id integer NOT NULL, owner_id integer NOT NULL, tree_owned_files_count integer NOT NULL, - updated_at timestamp without time zone NOT NULL + updated_at timestamp without time zone NOT NULL, + tenant_id integer ); COMMENT ON TABLE codeowners_individual_stats IS 'Data on how many files in given tree are owned by given owner. @@ -2046,7 +2095,8 @@ COMMENT ON COLUMN codeowners_individual_stats.updated_at IS 'When the last backg CREATE TABLE codeowners_owners ( id integer NOT NULL, - reference text NOT NULL + reference text NOT NULL, + tenant_id integer ); COMMENT ON TABLE codeowners_owners IS 'Text reference in CODEOWNERS entry to use in codeowners_individual_stats. Reference is either email or handle without @ in front.'; @@ -2067,7 +2117,8 @@ ALTER SEQUENCE codeowners_owners_id_seq OWNED BY codeowners_owners.id; CREATE TABLE commit_authors ( id integer NOT NULL, email text NOT NULL, - name text NOT NULL + name text NOT NULL, + tenant_id integer ); CREATE SEQUENCE commit_authors_id_seq @@ -2086,7 +2137,8 @@ CREATE TABLE configuration_policies_audit_logs ( policy_id integer NOT NULL, transition_columns hstore[], sequence bigint NOT NULL, - operation audit_log_operation NOT NULL + operation audit_log_operation NOT NULL, + tenant_id integer ); COMMENT ON COLUMN configuration_policies_audit_logs.log_timestamp IS 'Timestamp for this log entry.'; @@ -2117,7 +2169,8 @@ CREATE TABLE context_detection_embedding_jobs ( last_heartbeat_at timestamp with time zone, execution_logs json[], worker_hostname text DEFAULT ''::text NOT NULL, - cancel boolean DEFAULT false NOT NULL + cancel boolean DEFAULT false NOT NULL, + tenant_id integer ); CREATE SEQUENCE context_detection_embedding_jobs_id_seq @@ -2161,7 +2214,8 @@ CREATE TABLE discussion_comments ( created_at timestamp with time zone DEFAULT now() NOT NULL, updated_at timestamp with time zone DEFAULT now() NOT NULL, deleted_at timestamp with time zone, - reports text[] DEFAULT '{}'::text[] NOT NULL + reports text[] DEFAULT '{}'::text[] NOT NULL, + tenant_id integer ); CREATE SEQUENCE discussion_comments_id_seq @@ -2177,7 +2231,8 @@ CREATE TABLE discussion_mail_reply_tokens ( token text NOT NULL, user_id integer NOT NULL, thread_id bigint NOT NULL, - deleted_at timestamp with time zone + deleted_at timestamp with time zone, + tenant_id integer ); CREATE TABLE discussion_threads ( @@ -2188,7 +2243,8 @@ CREATE TABLE discussion_threads ( created_at timestamp with time zone DEFAULT now() NOT NULL, archived_at timestamp with time zone, updated_at timestamp with time zone DEFAULT now() NOT NULL, - deleted_at timestamp with time zone + deleted_at timestamp with time zone, + tenant_id integer ); CREATE SEQUENCE discussion_threads_id_seq @@ -2213,7 +2269,8 @@ CREATE TABLE discussion_threads_target_repo ( end_character integer, lines_before text, lines text, - lines_after text + lines_after text, + tenant_id integer ); CREATE SEQUENCE discussion_threads_target_repo_id_seq @@ -2246,6 +2303,7 @@ CREATE TABLE event_logs ( billing_product_category text, billing_event_id text, client text, + tenant_id integer, CONSTRAINT event_logs_check_has_user CHECK ((((user_id = 0) AND (anonymous_user_id <> ''::text)) OR ((user_id <> 0) AND (anonymous_user_id = ''::text)) OR ((user_id <> 0) AND (anonymous_user_id <> ''::text)))), CONSTRAINT event_logs_check_name_not_empty CHECK ((name <> ''::text)), CONSTRAINT event_logs_check_source_not_empty CHECK ((source <> ''::text)), @@ -2254,7 +2312,8 @@ CREATE TABLE event_logs ( CREATE TABLE event_logs_export_allowlist ( id integer NOT NULL, - event_name text NOT NULL + event_name text NOT NULL, + tenant_id integer ); COMMENT ON TABLE event_logs_export_allowlist IS 'An allowlist of events that are approved for export if the scraping job is enabled'; @@ -2282,7 +2341,8 @@ ALTER SEQUENCE event_logs_id_seq OWNED BY event_logs.id; CREATE TABLE event_logs_scrape_state ( id integer NOT NULL, - bookmark_id integer NOT NULL + bookmark_id integer NOT NULL, + tenant_id integer ); COMMENT ON TABLE event_logs_scrape_state IS 'Contains state for the periodic telemetry job that scrapes events if enabled.'; @@ -2302,7 +2362,8 @@ ALTER SEQUENCE event_logs_scrape_state_id_seq OWNED BY event_logs_scrape_state.i CREATE TABLE event_logs_scrape_state_own ( id integer NOT NULL, bookmark_id integer NOT NULL, - job_type integer NOT NULL + job_type integer NOT NULL, + tenant_id integer ); COMMENT ON TABLE event_logs_scrape_state_own IS 'Contains state for own jobs that scrape events if enabled.'; @@ -2333,6 +2394,7 @@ CREATE TABLE executor_heartbeats ( first_seen_at timestamp with time zone DEFAULT now() NOT NULL, last_seen_at timestamp with time zone DEFAULT now() NOT NULL, queue_names text[], + tenant_id integer, CONSTRAINT one_of_queue_name_queue_names CHECK ((((queue_name IS NOT NULL) AND (queue_names IS NULL)) OR ((queue_names IS NOT NULL) AND (queue_name IS NULL)))) ); @@ -2379,7 +2441,8 @@ CREATE TABLE executor_job_tokens ( queue text NOT NULL, repo_id bigint NOT NULL, created_at timestamp with time zone DEFAULT now() NOT NULL, - updated_at timestamp with time zone DEFAULT now() NOT NULL + updated_at timestamp with time zone DEFAULT now() NOT NULL, + tenant_id integer ); CREATE SEQUENCE executor_job_tokens_id_seq @@ -2398,6 +2461,7 @@ CREATE TABLE executor_secret_access_logs ( user_id integer, created_at timestamp with time zone DEFAULT now() NOT NULL, machine_user text DEFAULT ''::text NOT NULL, + tenant_id integer, CONSTRAINT user_id_or_machine_user CHECK ((((user_id IS NULL) AND (machine_user <> ''::text)) OR ((user_id IS NOT NULL) AND (machine_user = ''::text)))) ); @@ -2421,7 +2485,8 @@ CREATE TABLE executor_secrets ( namespace_org_id integer, created_at timestamp with time zone DEFAULT now() NOT NULL, updated_at timestamp with time zone DEFAULT now() NOT NULL, - creator_id integer + creator_id integer, + tenant_id integer ); COMMENT ON COLUMN executor_secrets.creator_id IS 'NULL, if the user has been deleted.'; @@ -2454,7 +2519,8 @@ CREATE TABLE exhaustive_search_jobs ( created_at timestamp with time zone DEFAULT now() NOT NULL, updated_at timestamp with time zone DEFAULT now() NOT NULL, queued_at timestamp with time zone DEFAULT now(), - is_aggregated boolean DEFAULT false NOT NULL + is_aggregated boolean DEFAULT false NOT NULL, + tenant_id integer ); CREATE SEQUENCE exhaustive_search_jobs_id_seq @@ -2485,7 +2551,8 @@ CREATE TABLE exhaustive_search_repo_jobs ( cancel boolean DEFAULT false NOT NULL, created_at timestamp with time zone DEFAULT now() NOT NULL, updated_at timestamp with time zone DEFAULT now() NOT NULL, - queued_at timestamp with time zone DEFAULT now() + queued_at timestamp with time zone DEFAULT now(), + tenant_id integer ); CREATE SEQUENCE exhaustive_search_repo_jobs_id_seq @@ -2515,7 +2582,8 @@ CREATE TABLE exhaustive_search_repo_revision_jobs ( cancel boolean DEFAULT false NOT NULL, created_at timestamp with time zone DEFAULT now() NOT NULL, updated_at timestamp with time zone DEFAULT now() NOT NULL, - queued_at timestamp with time zone DEFAULT now() + queued_at timestamp with time zone DEFAULT now(), + tenant_id integer ); CREATE SEQUENCE exhaustive_search_repo_revision_jobs_id_seq @@ -2546,6 +2614,7 @@ CREATE TABLE explicit_permissions_bitbucket_projects_jobs ( permissions json[], unrestricted boolean DEFAULT false NOT NULL, cancel boolean DEFAULT false NOT NULL, + tenant_id integer, CONSTRAINT explicit_permissions_bitbucket_projects_jobs_check CHECK ((((permissions IS NOT NULL) AND (unrestricted IS FALSE)) OR ((permissions IS NULL) AND (unrestricted IS TRUE)))) ); @@ -2563,7 +2632,8 @@ CREATE TABLE external_service_repos ( external_service_id bigint NOT NULL, repo_id integer NOT NULL, clone_url text NOT NULL, - created_at timestamp with time zone DEFAULT transaction_timestamp() NOT NULL + created_at timestamp with time zone DEFAULT transaction_timestamp() NOT NULL, + tenant_id integer ); CREATE SEQUENCE external_service_sync_jobs_id_seq @@ -2594,7 +2664,8 @@ CREATE TABLE external_service_sync_jobs ( repos_added integer DEFAULT 0 NOT NULL, repos_deleted integer DEFAULT 0 NOT NULL, repos_modified integer DEFAULT 0 NOT NULL, - repos_unmodified integer DEFAULT 0 NOT NULL + repos_unmodified integer DEFAULT 0 NOT NULL, + tenant_id integer ); COMMENT ON COLUMN external_service_sync_jobs.repos_synced IS 'The number of repos synced during this sync job.'; @@ -2627,6 +2698,7 @@ CREATE TABLE external_services ( code_host_id integer, creator_id integer, last_updater_id integer, + tenant_id integer, CONSTRAINT check_non_empty_config CHECK ((btrim(config) <> ''::text)) ); @@ -2663,6 +2735,7 @@ CREATE TABLE feature_flag_overrides ( created_at timestamp with time zone DEFAULT now() NOT NULL, updated_at timestamp with time zone DEFAULT now() NOT NULL, deleted_at timestamp with time zone, + tenant_id integer, CONSTRAINT feature_flag_overrides_has_org_or_user_id CHECK (((namespace_org_id IS NOT NULL) OR (namespace_user_id IS NOT NULL))) ); @@ -2674,6 +2747,7 @@ CREATE TABLE feature_flags ( created_at timestamp with time zone DEFAULT now() NOT NULL, updated_at timestamp with time zone DEFAULT now() NOT NULL, deleted_at timestamp with time zone, + tenant_id integer, CONSTRAINT feature_flags_rollout_check CHECK (((rollout >= 0) AND (rollout <= 10000))), CONSTRAINT required_bool_fields CHECK ((1 = CASE @@ -2707,7 +2781,8 @@ CREATE TABLE github_app_installs ( account_avatar_url text, account_url text, account_type text, - updated_at timestamp with time zone DEFAULT now() NOT NULL + updated_at timestamp with time zone DEFAULT now() NOT NULL, + tenant_id integer ); CREATE SEQUENCE github_app_installs_id_seq @@ -2737,7 +2812,8 @@ CREATE TABLE github_apps ( webhook_id integer, domain text DEFAULT 'repos'::text NOT NULL, kind github_app_kind DEFAULT 'REPO_SYNC'::github_app_kind NOT NULL, - creator_id bigint DEFAULT 0 NOT NULL + creator_id bigint DEFAULT 0 NOT NULL, + tenant_id integer ); CREATE SEQUENCE github_apps_id_seq @@ -2767,7 +2843,8 @@ CREATE TABLE gitserver_relocator_jobs ( source_hostname text NOT NULL, dest_hostname text NOT NULL, delete_source boolean DEFAULT false NOT NULL, - cancel boolean DEFAULT false NOT NULL + cancel boolean DEFAULT false NOT NULL, + tenant_id integer ); CREATE SEQUENCE gitserver_relocator_jobs_id_seq @@ -2812,7 +2889,8 @@ CREATE TABLE gitserver_repos ( repo_size_bytes bigint, corrupted_at timestamp with time zone, corruption_logs jsonb DEFAULT '[]'::jsonb NOT NULL, - cloning_progress text DEFAULT ''::text + cloning_progress text DEFAULT ''::text, + tenant_id integer ); COMMENT ON COLUMN gitserver_repos.corrupted_at IS 'Timestamp of when repo corruption was detected'; @@ -2826,7 +2904,8 @@ CREATE TABLE gitserver_repos_statistics ( cloning bigint DEFAULT 0 NOT NULL, cloned bigint DEFAULT 0 NOT NULL, failed_fetch bigint DEFAULT 0 NOT NULL, - corrupted bigint DEFAULT 0 NOT NULL + corrupted bigint DEFAULT 0 NOT NULL, + tenant_id integer ); COMMENT ON COLUMN gitserver_repos_statistics.shard_id IS 'ID of this gitserver shard. If an empty string then the repositories havent been assigned a shard.'; @@ -2846,14 +2925,16 @@ COMMENT ON COLUMN gitserver_repos_statistics.corrupted IS 'Number of repositorie CREATE TABLE gitserver_repos_sync_output ( repo_id integer NOT NULL, last_output text DEFAULT ''::text NOT NULL, - updated_at timestamp with time zone DEFAULT now() NOT NULL + updated_at timestamp with time zone DEFAULT now() NOT NULL, + tenant_id integer ); COMMENT ON TABLE gitserver_repos_sync_output IS 'Contains the most recent output from gitserver repository sync jobs.'; CREATE TABLE global_state ( site_id uuid NOT NULL, - initialized boolean DEFAULT false NOT NULL + initialized boolean DEFAULT false NOT NULL, + tenant_id integer ); CREATE TABLE insights_query_runner_jobs ( @@ -2876,7 +2957,8 @@ CREATE TABLE insights_query_runner_jobs ( persist_mode persistmode DEFAULT 'record'::persistmode NOT NULL, queued_at timestamp with time zone DEFAULT now(), cancel boolean DEFAULT false NOT NULL, - trace_id text + trace_id text, + tenant_id integer ); COMMENT ON TABLE insights_query_runner_jobs IS 'See [internal/insights/background/queryrunner/worker.go:Job](https://sourcegraph.com/search?q=repo:%5Egithub%5C.com/sourcegraph/sourcegraph%24+file:internal/insights/background/queryrunner/worker.go+type+Job&patternType=literal)'; @@ -2890,7 +2972,8 @@ COMMENT ON COLUMN insights_query_runner_jobs.persist_mode IS 'The persistence le CREATE TABLE insights_query_runner_jobs_dependencies ( id integer NOT NULL, job_id integer NOT NULL, - recording_time timestamp without time zone NOT NULL + recording_time timestamp without time zone NOT NULL, + tenant_id integer ); COMMENT ON TABLE insights_query_runner_jobs_dependencies IS 'Stores data points for a code insight that do not need to be queried directly, but depend on the result of a query at a different point'; @@ -2930,7 +3013,8 @@ CREATE TABLE insights_settings_migration_jobs ( total_dashboards integer DEFAULT 0 NOT NULL, migrated_dashboards integer DEFAULT 0 NOT NULL, runs integer DEFAULT 0 NOT NULL, - completed_at timestamp without time zone + completed_at timestamp without time zone, + tenant_id integer ); CREATE SEQUENCE insights_settings_migration_jobs_id_seq @@ -2969,7 +3053,8 @@ CREATE TABLE lsif_dependency_indexing_jobs ( upload_id integer, external_service_kind text DEFAULT ''::text NOT NULL, external_service_sync timestamp with time zone, - cancel boolean DEFAULT false NOT NULL + cancel boolean DEFAULT false NOT NULL, + tenant_id integer ); COMMENT ON COLUMN lsif_dependency_indexing_jobs.external_service_kind IS 'Filter the external services for this kind to wait to have synced. If empty, external_service_sync is ignored and no external services are polled for their last sync time.'; @@ -2990,7 +3075,8 @@ CREATE TABLE lsif_dependency_syncing_jobs ( upload_id integer, worker_hostname text DEFAULT ''::text NOT NULL, last_heartbeat_at timestamp with time zone, - cancel boolean DEFAULT false NOT NULL + cancel boolean DEFAULT false NOT NULL, + tenant_id integer ); COMMENT ON TABLE lsif_dependency_syncing_jobs IS 'Tracks jobs that scan imports of indexes to schedule auto-index jobs.'; @@ -3022,7 +3108,8 @@ CREATE TABLE lsif_dependency_repos ( name text NOT NULL, scheme text NOT NULL, blocked boolean DEFAULT false NOT NULL, - last_checked_at timestamp with time zone + last_checked_at timestamp with time zone, + tenant_id integer ); CREATE SEQUENCE lsif_dependency_repos_id_seq @@ -3039,7 +3126,8 @@ CREATE TABLE lsif_dirty_repositories ( dirty_token integer NOT NULL, update_token integer NOT NULL, updated_at timestamp with time zone, - set_dirty_at timestamp with time zone DEFAULT now() NOT NULL + set_dirty_at timestamp with time zone DEFAULT now() NOT NULL, + tenant_id integer ); COMMENT ON TABLE lsif_dirty_repositories IS 'Stores whether or not the nearest upload data for a repository is out of date (when update_token > dirty_token).'; @@ -3086,6 +3174,7 @@ CREATE TABLE lsif_uploads ( last_reconcile_at timestamp with time zone, content_type text DEFAULT 'application/x-ndjson+lsif'::text NOT NULL, should_reindex boolean DEFAULT false NOT NULL, + tenant_id integer, CONSTRAINT lsif_uploads_commit_valid_chars CHECK ((commit ~ '^[a-z0-9]{40}$'::text)) ); @@ -3188,7 +3277,8 @@ CREATE TABLE lsif_index_configuration ( id bigint NOT NULL, repository_id integer NOT NULL, data bytea NOT NULL, - autoindex_enabled boolean DEFAULT true NOT NULL + autoindex_enabled boolean DEFAULT true NOT NULL, + tenant_id integer ); COMMENT ON TABLE lsif_index_configuration IS 'Stores the configuration used for code intel index jobs for a repository.'; @@ -3233,6 +3323,7 @@ CREATE TABLE lsif_indexes ( should_reindex boolean DEFAULT false NOT NULL, requested_envvars text[], enqueuer_user_id integer DEFAULT 0 NOT NULL, + tenant_id integer, CONSTRAINT lsif_uploads_commit_valid_chars CHECK ((commit ~ '^[a-z0-9]{40}$'::text)) ); @@ -3295,7 +3386,8 @@ CREATE VIEW lsif_indexes_with_repository_name AS CREATE TABLE lsif_last_index_scan ( repository_id integer NOT NULL, - last_index_scan_at timestamp with time zone NOT NULL + last_index_scan_at timestamp with time zone NOT NULL, + tenant_id integer ); COMMENT ON TABLE lsif_last_index_scan IS 'Tracks the last time repository was checked for auto-indexing job scheduling.'; @@ -3304,7 +3396,8 @@ COMMENT ON COLUMN lsif_last_index_scan.last_index_scan_at IS 'The last time uplo CREATE TABLE lsif_last_retention_scan ( repository_id integer NOT NULL, - last_retention_scan_at timestamp with time zone NOT NULL + last_retention_scan_at timestamp with time zone NOT NULL, + tenant_id integer ); COMMENT ON TABLE lsif_last_retention_scan IS 'Tracks the last time uploads a repository were checked against data retention policies.'; @@ -3314,7 +3407,8 @@ COMMENT ON COLUMN lsif_last_retention_scan.last_retention_scan_at IS 'The last t CREATE TABLE lsif_nearest_uploads ( repository_id integer NOT NULL, commit_bytea bytea NOT NULL, - uploads jsonb NOT NULL + uploads jsonb NOT NULL, + tenant_id integer ); COMMENT ON TABLE lsif_nearest_uploads IS 'Associates commits with the complete set of uploads visible from that commit. Every commit with upload data is present in this table.'; @@ -3327,7 +3421,8 @@ CREATE TABLE lsif_nearest_uploads_links ( repository_id integer NOT NULL, commit_bytea bytea NOT NULL, ancestor_commit_bytea bytea NOT NULL, - distance integer NOT NULL + distance integer NOT NULL, + tenant_id integer ); COMMENT ON TABLE lsif_nearest_uploads_links IS 'Associates commits with the closest ancestor commit with usable upload data. Together, this table and lsif_nearest_uploads cover all commits with resolvable code intelligence.'; @@ -3344,7 +3439,8 @@ CREATE TABLE lsif_packages ( name text NOT NULL, version text, dump_id integer NOT NULL, - manager text DEFAULT ''::text NOT NULL + manager text DEFAULT ''::text NOT NULL, + tenant_id integer ); COMMENT ON TABLE lsif_packages IS 'Associates an upload with the set of packages they provide within a given packages management scheme.'; @@ -3374,7 +3470,8 @@ CREATE TABLE lsif_references ( name text NOT NULL, version text, dump_id integer NOT NULL, - manager text DEFAULT ''::text NOT NULL + manager text DEFAULT ''::text NOT NULL, + tenant_id integer ); COMMENT ON TABLE lsif_references IS 'Associates an upload with the set of packages they require within a given packages management scheme.'; @@ -3402,7 +3499,8 @@ CREATE TABLE lsif_retention_configuration ( id integer NOT NULL, repository_id integer NOT NULL, max_age_for_non_stale_branches_seconds integer NOT NULL, - max_age_for_non_stale_tags_seconds integer NOT NULL + max_age_for_non_stale_tags_seconds integer NOT NULL, + tenant_id integer ); COMMENT ON TABLE lsif_retention_configuration IS 'Stores the retention policy of code intellience data for a repository.'; @@ -3437,7 +3535,8 @@ CREATE TABLE lsif_uploads_audit_logs ( reason text DEFAULT ''::text, sequence bigint NOT NULL, operation audit_log_operation NOT NULL, - content_type text DEFAULT 'application/x-ndjson+lsif'::text NOT NULL + content_type text DEFAULT 'application/x-ndjson+lsif'::text NOT NULL, + tenant_id integer ); COMMENT ON COLUMN lsif_uploads_audit_logs.log_timestamp IS 'Timestamp for this log entry.'; @@ -3459,7 +3558,8 @@ ALTER SEQUENCE lsif_uploads_audit_logs_seq OWNED BY lsif_uploads_audit_logs.sequ CREATE TABLE lsif_uploads_reference_counts ( upload_id integer NOT NULL, - reference_count integer NOT NULL + reference_count integer NOT NULL, + tenant_id integer ); COMMENT ON TABLE lsif_uploads_reference_counts IS 'A less hot-path reference count for upload records.'; @@ -3472,7 +3572,8 @@ CREATE TABLE lsif_uploads_visible_at_tip ( repository_id integer NOT NULL, upload_id integer NOT NULL, branch_or_tag_name text DEFAULT ''::text NOT NULL, - is_default_branch boolean DEFAULT false NOT NULL + is_default_branch boolean DEFAULT false NOT NULL, + tenant_id integer ); COMMENT ON TABLE lsif_uploads_visible_at_tip IS 'Associates a repository with the set of LSIF upload identifiers that can serve intelligence for the tip of the default branch.'; @@ -3486,7 +3587,8 @@ COMMENT ON COLUMN lsif_uploads_visible_at_tip.is_default_branch IS 'Whether the CREATE TABLE lsif_uploads_vulnerability_scan ( id bigint NOT NULL, upload_id integer NOT NULL, - last_scanned_at timestamp without time zone DEFAULT now() NOT NULL + last_scanned_at timestamp without time zone DEFAULT now() NOT NULL, + tenant_id integer ); CREATE SEQUENCE lsif_uploads_vulnerability_scan_id_seq @@ -3533,6 +3635,7 @@ CREATE TABLE names ( user_id integer, org_id integer, team_id integer, + tenant_id integer, CONSTRAINT names_check CHECK (((user_id IS NOT NULL) OR (org_id IS NOT NULL) OR (team_id IS NOT NULL))) ); @@ -3542,6 +3645,7 @@ CREATE TABLE namespace_permissions ( resource_id integer NOT NULL, user_id integer NOT NULL, created_at timestamp with time zone DEFAULT now() NOT NULL, + tenant_id integer, CONSTRAINT namespace_not_blank CHECK ((namespace <> ''::text)) ); @@ -3558,7 +3662,8 @@ ALTER SEQUENCE namespace_permissions_id_seq OWNED BY namespace_permissions.id; CREATE TABLE notebook_stars ( notebook_id integer NOT NULL, user_id integer NOT NULL, - created_at timestamp with time zone DEFAULT now() NOT NULL + created_at timestamp with time zone DEFAULT now() NOT NULL, + tenant_id integer ); CREATE TABLE notebooks ( @@ -3574,6 +3679,7 @@ CREATE TABLE notebooks ( namespace_org_id integer, updater_user_id integer, pattern_type pattern_type DEFAULT 'keyword'::pattern_type NOT NULL, + tenant_id integer, CONSTRAINT blocks_is_array CHECK ((jsonb_typeof(blocks) = 'array'::text)), CONSTRAINT notebooks_has_max_1_namespace CHECK ((((namespace_user_id IS NULL) AND (namespace_org_id IS NULL)) OR ((namespace_user_id IS NULL) <> (namespace_org_id IS NULL)))) ); @@ -3600,6 +3706,7 @@ CREATE TABLE org_invitations ( deleted_at timestamp with time zone, recipient_email citext, expires_at timestamp with time zone, + tenant_id integer, CONSTRAINT check_atomic_response CHECK (((responded_at IS NULL) = (response_type IS NULL))), CONSTRAINT check_single_use CHECK ((((responded_at IS NULL) AND (response_type IS NULL)) OR (revoked_at IS NULL))), CONSTRAINT either_user_id_or_email_defined CHECK (((recipient_user_id IS NULL) <> (recipient_email IS NULL))) @@ -3619,7 +3726,8 @@ CREATE TABLE org_members ( org_id integer NOT NULL, created_at timestamp with time zone DEFAULT now() NOT NULL, updated_at timestamp with time zone DEFAULT now() NOT NULL, - user_id integer NOT NULL + user_id integer NOT NULL, + tenant_id integer ); CREATE SEQUENCE org_members_id_seq @@ -3634,7 +3742,8 @@ ALTER SEQUENCE org_members_id_seq OWNED BY org_members.id; CREATE TABLE org_stats ( org_id integer NOT NULL, code_host_repo_count integer DEFAULT 0, - updated_at timestamp with time zone DEFAULT now() NOT NULL + updated_at timestamp with time zone DEFAULT now() NOT NULL, + tenant_id integer ); COMMENT ON TABLE org_stats IS 'Business statistics for organizations'; @@ -3651,6 +3760,7 @@ CREATE TABLE orgs ( display_name text, slack_webhook_url text, deleted_at timestamp with time zone, + tenant_id integer, CONSTRAINT orgs_display_name_max_length CHECK ((char_length(display_name) <= 255)), CONSTRAINT orgs_name_max_length CHECK ((char_length((name)::text) <= 255)), CONSTRAINT orgs_name_valid_chars CHECK ((name OPERATOR(~) '^[a-zA-Z0-9](?:[a-zA-Z0-9]|[-.](?=[a-zA-Z0-9]))*-?$'::citext)) @@ -3670,7 +3780,8 @@ CREATE TABLE orgs_open_beta_stats ( user_id integer, org_id integer, created_at timestamp with time zone DEFAULT now(), - data jsonb DEFAULT '{}'::jsonb NOT NULL + data jsonb DEFAULT '{}'::jsonb NOT NULL, + tenant_id integer ); CREATE TABLE out_of_band_migrations ( @@ -3689,6 +3800,7 @@ CREATE TABLE out_of_band_migrations ( deprecated_version_major integer, deprecated_version_minor integer, metadata jsonb DEFAULT '{}'::jsonb NOT NULL, + tenant_id integer, CONSTRAINT out_of_band_migrations_component_nonempty CHECK ((component <> ''::text)), CONSTRAINT out_of_band_migrations_description_nonempty CHECK ((description <> ''::text)), CONSTRAINT out_of_band_migrations_progress_range CHECK (((progress >= (0)::double precision) AND (progress <= (1)::double precision))), @@ -3730,6 +3842,7 @@ CREATE TABLE out_of_band_migrations_errors ( migration_id integer NOT NULL, message text NOT NULL, created timestamp with time zone DEFAULT now() NOT NULL, + tenant_id integer, CONSTRAINT out_of_band_migrations_errors_message_nonempty CHECK ((message <> ''::text)) ); @@ -3767,7 +3880,8 @@ CREATE TABLE outbound_webhook_event_types ( id bigint NOT NULL, outbound_webhook_id bigint NOT NULL, event_type text NOT NULL, - scope text + scope text, + tenant_id integer ); CREATE SEQUENCE outbound_webhook_event_types_id_seq @@ -3796,7 +3910,8 @@ CREATE TABLE outbound_webhook_jobs ( last_heartbeat_at timestamp with time zone, execution_logs json[], worker_hostname text DEFAULT ''::text NOT NULL, - cancel boolean DEFAULT false NOT NULL + cancel boolean DEFAULT false NOT NULL, + tenant_id integer ); CREATE SEQUENCE outbound_webhook_jobs_id_seq @@ -3817,7 +3932,8 @@ CREATE TABLE outbound_webhook_logs ( encryption_key_id text, request bytea NOT NULL, response bytea NOT NULL, - error bytea NOT NULL + error bytea NOT NULL, + tenant_id integer ); CREATE SEQUENCE outbound_webhook_logs_id_seq @@ -3837,7 +3953,8 @@ CREATE TABLE outbound_webhooks ( updated_at timestamp with time zone DEFAULT now() NOT NULL, encryption_key_id text, url bytea NOT NULL, - secret bytea NOT NULL + secret bytea NOT NULL, + tenant_id integer ); CREATE SEQUENCE outbound_webhooks_id_seq @@ -3867,7 +3984,8 @@ CREATE TABLE own_aggregate_recent_contribution ( id integer NOT NULL, commit_author_id integer NOT NULL, changed_file_path_id integer NOT NULL, - contributions_count integer DEFAULT 0 + contributions_count integer DEFAULT 0, + tenant_id integer ); CREATE SEQUENCE own_aggregate_recent_contribution_id_seq @@ -3884,7 +4002,8 @@ CREATE TABLE own_aggregate_recent_view ( id integer NOT NULL, viewer_id integer NOT NULL, viewed_file_path_id integer NOT NULL, - views_count integer DEFAULT 0 + views_count integer DEFAULT 0, + tenant_id integer ); COMMENT ON TABLE own_aggregate_recent_view IS 'One entry contains a number of views of a single file by a given viewer.'; @@ -3914,7 +4033,8 @@ CREATE TABLE own_background_jobs ( worker_hostname text DEFAULT ''::text NOT NULL, cancel boolean DEFAULT false NOT NULL, repo_id integer NOT NULL, - job_type integer NOT NULL + job_type integer NOT NULL, + tenant_id integer ); CREATE TABLE own_signal_configurations ( @@ -3922,7 +4042,8 @@ CREATE TABLE own_signal_configurations ( name text NOT NULL, description text DEFAULT ''::text NOT NULL, excluded_repo_patterns text[], - enabled boolean DEFAULT false NOT NULL + enabled boolean DEFAULT false NOT NULL, + tenant_id integer ); CREATE VIEW own_background_jobs_config_aware AS @@ -3971,7 +4092,8 @@ CREATE TABLE own_signal_recent_contribution ( commit_author_id integer NOT NULL, changed_file_path_id integer NOT NULL, commit_timestamp timestamp without time zone NOT NULL, - commit_id bytea NOT NULL + commit_id bytea NOT NULL, + tenant_id integer ); COMMENT ON TABLE own_signal_recent_contribution IS 'One entry per file changed in every commit that classifies as a contribution signal.'; @@ -3991,7 +4113,8 @@ CREATE TABLE ownership_path_stats ( tree_codeowned_files_count integer, last_updated_at timestamp without time zone NOT NULL, tree_assigned_ownership_files_count integer, - tree_any_ownership_files_count integer + tree_any_ownership_files_count integer, + tenant_id integer ); COMMENT ON TABLE ownership_path_stats IS 'Data on how many files in given tree are owned by anyone. @@ -4010,6 +4133,7 @@ CREATE TABLE package_repo_filters ( matcher jsonb NOT NULL, deleted_at timestamp with time zone, updated_at timestamp with time zone DEFAULT statement_timestamp() NOT NULL, + tenant_id integer, CONSTRAINT package_repo_filters_behaviour_is_allow_or_block CHECK ((behaviour = ANY ('{BLOCK,ALLOW}'::text[]))), CONSTRAINT package_repo_filters_is_pkgrepo_scheme CHECK ((scheme = ANY ('{semanticdb,npm,go,python,rust-analyzer,scip-ruby}'::text[]))), CONSTRAINT package_repo_filters_valid_oneof_glob CHECK ((((matcher ? 'VersionGlob'::text) AND ((matcher ->> 'VersionGlob'::text) <> ''::text) AND ((matcher ->> 'PackageName'::text) <> ''::text) AND (NOT (matcher ? 'PackageGlob'::text))) OR ((matcher ? 'PackageGlob'::text) AND ((matcher ->> 'PackageGlob'::text) <> ''::text) AND (NOT (matcher ? 'VersionGlob'::text))))) @@ -4030,7 +4154,8 @@ CREATE TABLE package_repo_versions ( package_id bigint NOT NULL, version text NOT NULL, blocked boolean DEFAULT false NOT NULL, - last_checked_at timestamp with time zone + last_checked_at timestamp with time zone, + tenant_id integer ); CREATE SEQUENCE package_repo_versions_id_seq @@ -4069,6 +4194,7 @@ CREATE TABLE permission_sync_jobs ( permissions_found integer DEFAULT 0 NOT NULL, code_host_states json[], is_partial_success boolean DEFAULT false, + tenant_id integer, CONSTRAINT permission_sync_jobs_for_repo_or_user CHECK (((user_id IS NULL) <> (repository_id IS NULL))) ); @@ -4095,6 +4221,7 @@ CREATE TABLE permissions ( namespace text NOT NULL, action text NOT NULL, created_at timestamp with time zone DEFAULT now() NOT NULL, + tenant_id integer, CONSTRAINT action_not_blank CHECK ((action <> ''::text)), CONSTRAINT namespace_not_blank CHECK ((namespace <> ''::text)) ); @@ -4116,7 +4243,8 @@ CREATE TABLE phabricator_repos ( created_at timestamp with time zone DEFAULT now() NOT NULL, updated_at timestamp with time zone DEFAULT now() NOT NULL, deleted_at timestamp with time zone, - url text DEFAULT ''::text NOT NULL + url text DEFAULT ''::text NOT NULL, + tenant_id integer ); CREATE SEQUENCE phabricator_repos_id_seq @@ -4143,7 +4271,8 @@ CREATE TABLE product_licenses ( revoked_at timestamp with time zone, salesforce_sub_id text, salesforce_opp_id text, - revoke_reason text + revoke_reason text, + tenant_id integer ); COMMENT ON COLUMN product_licenses.access_token_enabled IS 'Whether this license key can be used as an access token to authenticate API requests'; @@ -4165,7 +4294,8 @@ CREATE TABLE product_subscriptions ( cody_gateway_chat_rate_limit_allowed_models text[], cody_gateway_code_rate_limit bigint, cody_gateway_code_rate_interval_seconds integer, - cody_gateway_code_rate_limit_allowed_models text[] + cody_gateway_code_rate_limit_allowed_models text[], + tenant_id integer ); COMMENT ON COLUMN product_subscriptions.cody_gateway_embeddings_api_rate_limit IS 'Custom requests per time interval allowed for embeddings'; @@ -4187,6 +4317,7 @@ CREATE TABLE prompts ( created_at timestamp with time zone DEFAULT now() NOT NULL, updated_by integer, updated_at timestamp with time zone DEFAULT now() NOT NULL, + tenant_id integer, CONSTRAINT prompts_definition_text_max_length CHECK ((char_length(definition_text) <= (1024 * 100))), CONSTRAINT prompts_description_max_length CHECK ((char_length(description) <= (1024 * 50))), CONSTRAINT prompts_has_valid_owner CHECK ((((owner_user_id IS NOT NULL) AND (owner_org_id IS NULL)) OR ((owner_org_id IS NOT NULL) AND (owner_user_id IS NULL)))), @@ -4226,6 +4357,7 @@ CREATE TABLE users ( code_completions_quota integer, completed_post_signup boolean DEFAULT false NOT NULL, cody_pro_enabled_at timestamp with time zone, + tenant_id integer, CONSTRAINT users_display_name_max_length CHECK ((char_length(display_name) <= 255)), CONSTRAINT users_username_max_length CHECK ((char_length((username)::text) <= 255)), CONSTRAINT users_username_valid_chars CHECK ((username OPERATOR(~) '^\w(?:\w|[-.](?=\w))*-?$'::citext)) @@ -4253,7 +4385,8 @@ CREATE TABLE query_runner_state ( query text, last_executed timestamp with time zone, latest_result timestamp with time zone, - exec_duration_ns bigint + exec_duration_ns bigint, + tenant_id integer ); CREATE VIEW reconciler_changesets AS @@ -4311,7 +4444,8 @@ CREATE VIEW reconciler_changesets AS CREATE TABLE redis_key_value ( namespace text NOT NULL, key text NOT NULL, - value bytea NOT NULL + value bytea NOT NULL, + tenant_id integer ); CREATE TABLE registry_extension_releases ( @@ -4324,7 +4458,8 @@ CREATE TABLE registry_extension_releases ( bundle text, created_at timestamp with time zone DEFAULT now() NOT NULL, deleted_at timestamp with time zone, - source_map text + source_map text, + tenant_id integer ); CREATE SEQUENCE registry_extension_releases_id_seq @@ -4346,6 +4481,7 @@ CREATE TABLE registry_extensions ( created_at timestamp with time zone DEFAULT now() NOT NULL, updated_at timestamp with time zone DEFAULT now() NOT NULL, deleted_at timestamp with time zone, + tenant_id integer, CONSTRAINT registry_extensions_name_length CHECK (((char_length((name)::text) > 0) AND (char_length((name)::text) <= 128))), CONSTRAINT registry_extensions_name_valid_chars CHECK ((name OPERATOR(~) '^[a-zA-Z0-9](?:[a-zA-Z0-9]|[_.-](?=[a-zA-Z0-9]))*$'::citext)), CONSTRAINT registry_extensions_single_publisher CHECK (((publisher_user_id IS NULL) <> (publisher_org_id IS NULL))) @@ -4365,7 +4501,8 @@ CREATE TABLE repo_commits_changelists ( repo_id integer NOT NULL, commit_sha bytea NOT NULL, perforce_changelist_id integer NOT NULL, - created_at timestamp with time zone DEFAULT now() NOT NULL + created_at timestamp with time zone DEFAULT now() NOT NULL, + tenant_id integer ); CREATE SEQUENCE repo_commits_changelists_id_seq @@ -4392,7 +4529,8 @@ CREATE TABLE repo_embedding_job_stats ( text_files_skipped jsonb DEFAULT '{}'::jsonb NOT NULL, text_bytes_embedded bigint DEFAULT 0 NOT NULL, code_chunks_excluded integer DEFAULT 0 NOT NULL, - text_chunks_excluded integer DEFAULT 0 NOT NULL + text_chunks_excluded integer DEFAULT 0 NOT NULL, + tenant_id integer ); CREATE TABLE repo_embedding_jobs ( @@ -4410,7 +4548,8 @@ CREATE TABLE repo_embedding_jobs ( worker_hostname text DEFAULT ''::text NOT NULL, cancel boolean DEFAULT false NOT NULL, repo_id integer NOT NULL, - revision text NOT NULL + revision text NOT NULL, + tenant_id integer ); CREATE SEQUENCE repo_embedding_jobs_id_seq @@ -4435,7 +4574,8 @@ ALTER SEQUENCE repo_id_seq OWNED BY repo.id; CREATE TABLE repo_kvps ( repo_id integer NOT NULL, key text NOT NULL, - value text + value text, + tenant_id integer ); CREATE TABLE repo_paths ( @@ -4444,7 +4584,8 @@ CREATE TABLE repo_paths ( absolute_path text NOT NULL, parent_id integer, tree_files_count integer, - tree_files_counts_updated_at timestamp without time zone + tree_files_counts_updated_at timestamp without time zone, + tenant_id integer ); COMMENT ON COLUMN repo_paths.absolute_path IS 'Absolute path does not start or end with forward slash. Example: "a/b/c". Root directory is empty path "".'; @@ -4467,7 +4608,8 @@ CREATE TABLE repo_pending_permissions ( repo_id integer NOT NULL, permission text NOT NULL, updated_at timestamp with time zone NOT NULL, - user_ids_ints bigint[] DEFAULT '{}'::integer[] NOT NULL + user_ids_ints bigint[] DEFAULT '{}'::integer[] NOT NULL, + tenant_id integer ); CREATE TABLE repo_permissions ( @@ -4476,7 +4618,8 @@ CREATE TABLE repo_permissions ( updated_at timestamp with time zone NOT NULL, synced_at timestamp with time zone, user_ids_ints integer[] DEFAULT '{}'::integer[] NOT NULL, - unrestricted boolean DEFAULT false NOT NULL + unrestricted boolean DEFAULT false NOT NULL, + tenant_id integer ); CREATE TABLE repo_statistics ( @@ -4486,7 +4629,8 @@ CREATE TABLE repo_statistics ( cloning bigint DEFAULT 0 NOT NULL, cloned bigint DEFAULT 0 NOT NULL, failed_fetch bigint DEFAULT 0 NOT NULL, - corrupted bigint DEFAULT 0 NOT NULL + corrupted bigint DEFAULT 0 NOT NULL, + tenant_id integer ); COMMENT ON COLUMN repo_statistics.total IS 'Number of repositories that are not soft-deleted and not blocked'; @@ -4506,14 +4650,16 @@ COMMENT ON COLUMN repo_statistics.corrupted IS 'Number of repositories that are CREATE TABLE role_permissions ( role_id integer NOT NULL, permission_id integer NOT NULL, - created_at timestamp with time zone DEFAULT now() NOT NULL + created_at timestamp with time zone DEFAULT now() NOT NULL, + tenant_id integer ); CREATE TABLE roles ( id integer NOT NULL, created_at timestamp with time zone DEFAULT now() NOT NULL, system boolean DEFAULT false NOT NULL, - name citext NOT NULL + name citext NOT NULL, + tenant_id integer ); COMMENT ON COLUMN roles.system IS 'This is used to indicate whether a role is read-only or can be modified.'; @@ -4543,6 +4689,7 @@ CREATE TABLE saved_searches ( updated_by integer, draft boolean DEFAULT false NOT NULL, visibility_secret boolean DEFAULT true NOT NULL, + tenant_id integer, CONSTRAINT saved_searches_notifications_disabled CHECK (((notify_owner = false) AND (notify_slack = false))), CONSTRAINT user_or_org_id_not_null CHECK ((((user_id IS NOT NULL) AND (org_id IS NULL)) OR ((org_id IS NOT NULL) AND (user_id IS NULL)))) ); @@ -4558,7 +4705,8 @@ ALTER SEQUENCE saved_searches_id_seq OWNED BY saved_searches.id; CREATE TABLE search_context_default ( user_id integer NOT NULL, - search_context_id bigint NOT NULL + search_context_id bigint NOT NULL, + tenant_id integer ); COMMENT ON TABLE search_context_default IS 'When a user sets a search context as default, a row is inserted into this table. A user can only have one default search context. If the user has not set their default search context, it will fall back to `global`.'; @@ -4566,13 +4714,15 @@ COMMENT ON TABLE search_context_default IS 'When a user sets a search context as CREATE TABLE search_context_repos ( search_context_id bigint NOT NULL, repo_id integer NOT NULL, - revision text NOT NULL + revision text NOT NULL, + tenant_id integer ); CREATE TABLE search_context_stars ( search_context_id bigint NOT NULL, user_id integer NOT NULL, - created_at timestamp with time zone DEFAULT now() NOT NULL + created_at timestamp with time zone DEFAULT now() NOT NULL, + tenant_id integer ); COMMENT ON TABLE search_context_stars IS 'When a user stars a search context, a row is inserted into this table. If the user unstars the search context, the row is deleted. The global context is not in the database, and therefore cannot be starred.'; @@ -4588,6 +4738,7 @@ CREATE TABLE search_contexts ( updated_at timestamp with time zone DEFAULT now() NOT NULL, deleted_at timestamp with time zone, query text, + tenant_id integer, CONSTRAINT search_contexts_has_one_or_no_namespace CHECK (((namespace_user_id IS NULL) OR (namespace_org_id IS NULL))) ); @@ -4612,6 +4763,7 @@ CREATE TABLE security_event_logs ( argument jsonb NOT NULL, version text NOT NULL, "timestamp" timestamp with time zone NOT NULL, + tenant_id integer, CONSTRAINT security_event_logs_check_has_user CHECK ((((user_id = 0) AND (anonymous_user_id <> ''::text)) OR ((user_id <> 0) AND (anonymous_user_id = ''::text)) OR ((user_id <> 0) AND (anonymous_user_id <> ''::text)))), CONSTRAINT security_event_logs_check_name_not_empty CHECK ((name <> ''::text)), CONSTRAINT security_event_logs_check_source_not_empty CHECK ((source <> ''::text)), @@ -4650,6 +4802,7 @@ CREATE TABLE settings ( created_at timestamp with time zone DEFAULT now() NOT NULL, user_id integer, author_user_id integer, + tenant_id integer, CONSTRAINT settings_no_empty_contents CHECK ((contents <> ''::text)) ); @@ -4674,6 +4827,7 @@ CREATE TABLE sub_repo_permissions ( updated_at timestamp with time zone DEFAULT now() NOT NULL, paths text[], ips text[], + tenant_id integer, CONSTRAINT ips_paths_length_check CHECK (((ips IS NULL) OR ((array_length(ips, 1) = array_length(paths, 1)) AND (NOT (''::text = ANY (ips)))))) ); @@ -4692,7 +4846,8 @@ CREATE TABLE survey_responses ( better text, created_at timestamp with time zone DEFAULT now() NOT NULL, use_cases text[], - other_use_case text + other_use_case text, + tenant_id integer ); CREATE SEQUENCE survey_responses_id_seq @@ -4723,6 +4878,7 @@ CREATE TABLE syntactic_scip_indexing_jobs ( cancel boolean DEFAULT false NOT NULL, should_reindex boolean DEFAULT false NOT NULL, enqueuer_user_id integer DEFAULT 0 NOT NULL, + tenant_id integer, CONSTRAINT syntactic_scip_indexing_jobs_commit_valid_chars CHECK ((commit ~ '^[a-f0-9]{40}$'::text)) ); @@ -4765,7 +4921,8 @@ CREATE VIEW syntactic_scip_indexing_jobs_with_repository_name AS CREATE TABLE syntactic_scip_last_index_scan ( repository_id integer NOT NULL, - last_index_scan_at timestamp with time zone NOT NULL + last_index_scan_at timestamp with time zone NOT NULL, + tenant_id integer ); COMMENT ON TABLE syntactic_scip_last_index_scan IS 'Tracks the last time repository was checked for syntactic indexing job scheduling.'; @@ -4776,7 +4933,8 @@ CREATE TABLE team_members ( team_id integer NOT NULL, user_id integer NOT NULL, created_at timestamp with time zone DEFAULT now() NOT NULL, - updated_at timestamp with time zone DEFAULT now() NOT NULL + updated_at timestamp with time zone DEFAULT now() NOT NULL, + tenant_id integer ); CREATE TABLE teams ( @@ -4788,6 +4946,7 @@ CREATE TABLE teams ( creator_id integer, created_at timestamp with time zone DEFAULT now() NOT NULL, updated_at timestamp with time zone DEFAULT now() NOT NULL, + tenant_id integer, CONSTRAINT teams_display_name_max_length CHECK ((char_length(display_name) <= 255)), CONSTRAINT teams_name_max_length CHECK ((char_length((name)::text) <= 255)), CONSTRAINT teams_name_valid_chars CHECK ((name OPERATOR(~) '^[a-zA-Z0-9](?:[a-zA-Z0-9]|[-.](?=[a-zA-Z0-9]))*-?$'::citext)) @@ -4807,7 +4966,8 @@ CREATE TABLE telemetry_events_export_queue ( id text NOT NULL, "timestamp" timestamp with time zone NOT NULL, payload_pb bytea NOT NULL, - exported_at timestamp with time zone + exported_at timestamp with time zone, + tenant_id integer ); CREATE TABLE temporary_settings ( @@ -4815,7 +4975,8 @@ CREATE TABLE temporary_settings ( user_id integer NOT NULL, contents jsonb, created_at timestamp with time zone DEFAULT now() NOT NULL, - updated_at timestamp with time zone DEFAULT now() NOT NULL + updated_at timestamp with time zone DEFAULT now() NOT NULL, + tenant_id integer ); COMMENT ON TABLE temporary_settings IS 'Stores per-user temporary settings used in the UI, for example, which modals have been dimissed or what theme is preferred.'; @@ -4877,6 +5038,7 @@ CREATE TABLE user_credentials ( ssh_migration_applied boolean DEFAULT false NOT NULL, encryption_key_id text DEFAULT ''::text NOT NULL, github_app_id integer, + tenant_id integer, CONSTRAINT check_github_app_id_and_external_service_type_user_credentials CHECK (((github_app_id IS NULL) OR (external_service_type = 'github'::text))) ); @@ -4896,7 +5058,8 @@ CREATE TABLE user_emails ( verification_code text, verified_at timestamp with time zone, last_verification_sent_at timestamp with time zone, - is_primary boolean DEFAULT false NOT NULL + is_primary boolean DEFAULT false NOT NULL, + tenant_id integer ); CREATE TABLE user_external_accounts ( @@ -4913,7 +5076,8 @@ CREATE TABLE user_external_accounts ( client_id text NOT NULL, expired_at timestamp with time zone, last_valid_at timestamp with time zone, - encryption_key_id text DEFAULT ''::text NOT NULL + encryption_key_id text DEFAULT ''::text NOT NULL, + tenant_id integer ); CREATE SEQUENCE user_external_accounts_id_seq @@ -4929,7 +5093,8 @@ CREATE TABLE user_onboarding_tour ( id integer NOT NULL, raw_json text NOT NULL, created_at timestamp without time zone DEFAULT now() NOT NULL, - updated_by integer + updated_by integer, + tenant_id integer ); CREATE SEQUENCE user_onboarding_tour_id_seq @@ -4950,7 +5115,8 @@ CREATE TABLE user_pending_permissions ( updated_at timestamp with time zone NOT NULL, service_type text NOT NULL, service_id text NOT NULL, - object_ids_ints integer[] DEFAULT '{}'::integer[] NOT NULL + object_ids_ints integer[] DEFAULT '{}'::integer[] NOT NULL, + tenant_id integer ); CREATE SEQUENCE user_pending_permissions_id_seq @@ -4969,13 +5135,15 @@ CREATE TABLE user_permissions ( updated_at timestamp with time zone NOT NULL, synced_at timestamp with time zone, object_ids_ints integer[] DEFAULT '{}'::integer[] NOT NULL, - migrated boolean DEFAULT true + migrated boolean DEFAULT true, + tenant_id integer ); CREATE TABLE user_public_repos ( user_id integer NOT NULL, repo_uri text NOT NULL, - repo_id integer NOT NULL + repo_id integer NOT NULL, + tenant_id integer ); CREATE TABLE user_repo_permissions ( @@ -4985,7 +5153,8 @@ CREATE TABLE user_repo_permissions ( user_external_account_id integer, created_at timestamp with time zone DEFAULT now() NOT NULL, updated_at timestamp with time zone DEFAULT now() NOT NULL, - source text DEFAULT 'sync'::text NOT NULL + source text DEFAULT 'sync'::text NOT NULL, + tenant_id integer ); CREATE SEQUENCE user_repo_permissions_id_seq @@ -5000,7 +5169,8 @@ ALTER SEQUENCE user_repo_permissions_id_seq OWNED BY user_repo_permissions.id; CREATE TABLE user_roles ( user_id integer NOT NULL, role_id integer NOT NULL, - created_at timestamp with time zone DEFAULT now() NOT NULL + created_at timestamp with time zone DEFAULT now() NOT NULL, + tenant_id integer ); CREATE SEQUENCE users_id_seq @@ -5036,7 +5206,8 @@ CREATE TABLE vulnerabilities ( cvss_score text NOT NULL, published_at timestamp with time zone NOT NULL, modified_at timestamp with time zone, - withdrawn_at timestamp with time zone + withdrawn_at timestamp with time zone, + tenant_id integer ); CREATE SEQUENCE vulnerabilities_id_seq @@ -5057,7 +5228,8 @@ CREATE TABLE vulnerability_affected_packages ( namespace text NOT NULL, version_constraint text[] NOT NULL, fixed boolean NOT NULL, - fixed_in text + fixed_in text, + tenant_id integer ); CREATE SEQUENCE vulnerability_affected_packages_id_seq @@ -5074,7 +5246,8 @@ CREATE TABLE vulnerability_affected_symbols ( id integer NOT NULL, vulnerability_affected_package_id integer NOT NULL, path text NOT NULL, - symbols text[] NOT NULL + symbols text[] NOT NULL, + tenant_id integer ); CREATE SEQUENCE vulnerability_affected_symbols_id_seq @@ -5090,7 +5263,8 @@ ALTER SEQUENCE vulnerability_affected_symbols_id_seq OWNED BY vulnerability_affe CREATE TABLE vulnerability_matches ( id integer NOT NULL, upload_id integer NOT NULL, - vulnerability_affected_package_id integer NOT NULL + vulnerability_affected_package_id integer NOT NULL, + tenant_id integer ); CREATE SEQUENCE vulnerability_matches_id_seq @@ -5111,7 +5285,8 @@ CREATE TABLE webhook_logs ( request bytea NOT NULL, response bytea NOT NULL, encryption_key_id text NOT NULL, - webhook_id integer + webhook_id integer, + tenant_id integer ); CREATE SEQUENCE webhook_logs_id_seq @@ -5134,7 +5309,8 @@ CREATE TABLE webhooks ( uuid uuid DEFAULT gen_random_uuid() NOT NULL, created_by_user_id integer, updated_by_user_id integer, - name text NOT NULL + name text NOT NULL, + tenant_id integer ); COMMENT ON TABLE webhooks IS 'Webhooks registered in Sourcegraph instance.'; @@ -5167,7 +5343,8 @@ CREATE TABLE zoekt_repos ( index_status text DEFAULT 'not_indexed'::text NOT NULL, updated_at timestamp with time zone DEFAULT now() NOT NULL, created_at timestamp with time zone DEFAULT now() NOT NULL, - last_indexed_at timestamp with time zone + last_indexed_at timestamp with time zone, + tenant_id integer ); ALTER TABLE ONLY access_requests ALTER COLUMN id SET DEFAULT nextval('access_requests_id_seq'::regclass); @@ -6585,12 +6762,21 @@ CREATE TRIGGER versions_insert BEFORE INSERT ON versions FOR EACH ROW EXECUTE FU ALTER TABLE ONLY access_requests ADD CONSTRAINT access_requests_decision_by_user_id_fkey FOREIGN KEY (decision_by_user_id) REFERENCES users(id) ON DELETE SET NULL; +ALTER TABLE ONLY access_requests + ADD CONSTRAINT access_requests_tenant_id_fkey FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE; + ALTER TABLE ONLY access_tokens ADD CONSTRAINT access_tokens_creator_user_id_fkey FOREIGN KEY (creator_user_id) REFERENCES users(id); ALTER TABLE ONLY access_tokens ADD CONSTRAINT access_tokens_subject_user_id_fkey FOREIGN KEY (subject_user_id) REFERENCES users(id); +ALTER TABLE ONLY access_tokens + ADD CONSTRAINT access_tokens_tenant_id_fkey FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE; + +ALTER TABLE ONLY aggregated_user_statistics + ADD CONSTRAINT aggregated_user_statistics_tenant_id_fkey FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE; + ALTER TABLE ONLY aggregated_user_statistics ADD CONSTRAINT aggregated_user_statistics_user_id_fkey FOREIGN KEY (user_id) REFERENCES users(id) ON DELETE CASCADE; @@ -6600,6 +6786,9 @@ ALTER TABLE ONLY assigned_owners ALTER TABLE ONLY assigned_owners ADD CONSTRAINT assigned_owners_owner_user_id_fkey FOREIGN KEY (owner_user_id) REFERENCES users(id) ON DELETE CASCADE DEFERRABLE; +ALTER TABLE ONLY assigned_owners + ADD CONSTRAINT assigned_owners_tenant_id_fkey FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE; + ALTER TABLE ONLY assigned_owners ADD CONSTRAINT assigned_owners_who_assigned_user_id_fkey FOREIGN KEY (who_assigned_user_id) REFERENCES users(id) ON DELETE SET NULL DEFERRABLE; @@ -6609,6 +6798,9 @@ ALTER TABLE ONLY assigned_teams ALTER TABLE ONLY assigned_teams ADD CONSTRAINT assigned_teams_owner_team_id_fkey FOREIGN KEY (owner_team_id) REFERENCES teams(id) ON DELETE CASCADE DEFERRABLE; +ALTER TABLE ONLY assigned_teams + ADD CONSTRAINT assigned_teams_tenant_id_fkey FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE; + ALTER TABLE ONLY assigned_teams ADD CONSTRAINT assigned_teams_who_assigned_team_id_fkey FOREIGN KEY (who_assigned_team_id) REFERENCES users(id) ON DELETE SET NULL DEFERRABLE; @@ -6630,6 +6822,15 @@ ALTER TABLE ONLY batch_changes ALTER TABLE ONLY batch_changes_site_credentials ADD CONSTRAINT batch_changes_site_credentials_github_app_id_fkey FOREIGN KEY (github_app_id) REFERENCES github_apps(id) ON DELETE CASCADE; +ALTER TABLE ONLY batch_changes_site_credentials + ADD CONSTRAINT batch_changes_site_credentials_tenant_id_fkey FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE; + +ALTER TABLE ONLY batch_changes + ADD CONSTRAINT batch_changes_tenant_id_fkey FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE; + +ALTER TABLE ONLY batch_spec_execution_cache_entries + ADD CONSTRAINT batch_spec_execution_cache_entries_tenant_id_fkey FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE; + ALTER TABLE ONLY batch_spec_execution_cache_entries ADD CONSTRAINT batch_spec_execution_cache_entries_user_id_fkey FOREIGN KEY (user_id) REFERENCES users(id) ON DELETE CASCADE DEFERRABLE; @@ -6639,36 +6840,63 @@ ALTER TABLE ONLY batch_spec_resolution_jobs ALTER TABLE ONLY batch_spec_resolution_jobs ADD CONSTRAINT batch_spec_resolution_jobs_initiator_id_fkey FOREIGN KEY (initiator_id) REFERENCES users(id) ON UPDATE CASCADE ON DELETE CASCADE DEFERRABLE; +ALTER TABLE ONLY batch_spec_resolution_jobs + ADD CONSTRAINT batch_spec_resolution_jobs_tenant_id_fkey FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE; + ALTER TABLE ONLY batch_spec_workspace_execution_jobs ADD CONSTRAINT batch_spec_workspace_execution_job_batch_spec_workspace_id_fkey FOREIGN KEY (batch_spec_workspace_id) REFERENCES batch_spec_workspaces(id) ON DELETE CASCADE DEFERRABLE; +ALTER TABLE ONLY batch_spec_workspace_execution_jobs + ADD CONSTRAINT batch_spec_workspace_execution_jobs_tenant_id_fkey FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE; + +ALTER TABLE ONLY batch_spec_workspace_execution_last_dequeues + ADD CONSTRAINT batch_spec_workspace_execution_last_dequeues_tenant_id_fkey FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE; + ALTER TABLE ONLY batch_spec_workspace_execution_last_dequeues ADD CONSTRAINT batch_spec_workspace_execution_last_dequeues_user_id_fkey FOREIGN KEY (user_id) REFERENCES users(id) ON UPDATE CASCADE ON DELETE CASCADE DEFERRABLE INITIALLY DEFERRED; ALTER TABLE ONLY batch_spec_workspace_files ADD CONSTRAINT batch_spec_workspace_files_batch_spec_id_fkey FOREIGN KEY (batch_spec_id) REFERENCES batch_specs(id) ON DELETE CASCADE; +ALTER TABLE ONLY batch_spec_workspace_files + ADD CONSTRAINT batch_spec_workspace_files_tenant_id_fkey FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE; + ALTER TABLE ONLY batch_spec_workspaces ADD CONSTRAINT batch_spec_workspaces_batch_spec_id_fkey FOREIGN KEY (batch_spec_id) REFERENCES batch_specs(id) ON DELETE CASCADE DEFERRABLE; ALTER TABLE ONLY batch_spec_workspaces ADD CONSTRAINT batch_spec_workspaces_repo_id_fkey FOREIGN KEY (repo_id) REFERENCES repo(id) DEFERRABLE; +ALTER TABLE ONLY batch_spec_workspaces + ADD CONSTRAINT batch_spec_workspaces_tenant_id_fkey FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE; + ALTER TABLE ONLY batch_specs ADD CONSTRAINT batch_specs_batch_change_id_fkey FOREIGN KEY (batch_change_id) REFERENCES batch_changes(id) ON DELETE SET NULL DEFERRABLE; +ALTER TABLE ONLY batch_specs + ADD CONSTRAINT batch_specs_tenant_id_fkey FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE; + ALTER TABLE ONLY batch_specs ADD CONSTRAINT batch_specs_user_id_fkey FOREIGN KEY (user_id) REFERENCES users(id) ON DELETE SET NULL DEFERRABLE; +ALTER TABLE ONLY cached_available_indexers + ADD CONSTRAINT cached_available_indexers_tenant_id_fkey FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE; + ALTER TABLE ONLY changeset_events ADD CONSTRAINT changeset_events_changeset_id_fkey FOREIGN KEY (changeset_id) REFERENCES changesets(id) ON DELETE CASCADE DEFERRABLE; +ALTER TABLE ONLY changeset_events + ADD CONSTRAINT changeset_events_tenant_id_fkey FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE; + ALTER TABLE ONLY changeset_jobs ADD CONSTRAINT changeset_jobs_batch_change_id_fkey FOREIGN KEY (batch_change_id) REFERENCES batch_changes(id) ON DELETE CASCADE DEFERRABLE; ALTER TABLE ONLY changeset_jobs ADD CONSTRAINT changeset_jobs_changeset_id_fkey FOREIGN KEY (changeset_id) REFERENCES changesets(id) ON DELETE CASCADE DEFERRABLE; +ALTER TABLE ONLY changeset_jobs + ADD CONSTRAINT changeset_jobs_tenant_id_fkey FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE; + ALTER TABLE ONLY changeset_jobs ADD CONSTRAINT changeset_jobs_user_id_fkey FOREIGN KEY (user_id) REFERENCES users(id) ON DELETE CASCADE DEFERRABLE; @@ -6678,6 +6906,9 @@ ALTER TABLE ONLY changeset_specs ALTER TABLE ONLY changeset_specs ADD CONSTRAINT changeset_specs_repo_id_fkey FOREIGN KEY (repo_id) REFERENCES repo(id) DEFERRABLE; +ALTER TABLE ONLY changeset_specs + ADD CONSTRAINT changeset_specs_tenant_id_fkey FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE; + ALTER TABLE ONLY changeset_specs ADD CONSTRAINT changeset_specs_user_id_fkey FOREIGN KEY (user_id) REFERENCES users(id) ON DELETE SET NULL DEFERRABLE; @@ -6693,12 +6924,18 @@ ALTER TABLE ONLY changesets ALTER TABLE ONLY changesets ADD CONSTRAINT changesets_repo_id_fkey FOREIGN KEY (repo_id) REFERENCES repo(id) ON DELETE CASCADE DEFERRABLE; +ALTER TABLE ONLY changesets + ADD CONSTRAINT changesets_tenant_id_fkey FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE; + ALTER TABLE ONLY cm_action_jobs ADD CONSTRAINT cm_action_jobs_email_fk FOREIGN KEY (email) REFERENCES cm_emails(id) ON DELETE CASCADE; ALTER TABLE ONLY cm_action_jobs ADD CONSTRAINT cm_action_jobs_slack_webhook_fkey FOREIGN KEY (slack_webhook) REFERENCES cm_slack_webhooks(id) ON DELETE CASCADE; +ALTER TABLE ONLY cm_action_jobs + ADD CONSTRAINT cm_action_jobs_tenant_id_fkey FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE; + ALTER TABLE ONLY cm_action_jobs ADD CONSTRAINT cm_action_jobs_trigger_event_fk FOREIGN KEY (trigger_event) REFERENCES cm_trigger_jobs(id) ON DELETE CASCADE; @@ -6714,12 +6951,18 @@ ALTER TABLE ONLY cm_emails ALTER TABLE ONLY cm_emails ADD CONSTRAINT cm_emails_monitor FOREIGN KEY (monitor) REFERENCES cm_monitors(id) ON DELETE CASCADE; +ALTER TABLE ONLY cm_emails + ADD CONSTRAINT cm_emails_tenant_id_fkey FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE; + ALTER TABLE ONLY cm_last_searched ADD CONSTRAINT cm_last_searched_monitor_id_fkey FOREIGN KEY (monitor_id) REFERENCES cm_monitors(id) ON DELETE CASCADE; ALTER TABLE ONLY cm_last_searched ADD CONSTRAINT cm_last_searched_repo_id_fkey FOREIGN KEY (repo_id) REFERENCES repo(id) ON DELETE CASCADE; +ALTER TABLE ONLY cm_last_searched + ADD CONSTRAINT cm_last_searched_tenant_id_fkey FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE; + ALTER TABLE ONLY cm_monitors ADD CONSTRAINT cm_monitors_changed_by_fk FOREIGN KEY (changed_by) REFERENCES users(id) ON DELETE CASCADE; @@ -6729,15 +6972,24 @@ ALTER TABLE ONLY cm_monitors ALTER TABLE ONLY cm_monitors ADD CONSTRAINT cm_monitors_org_id_fk FOREIGN KEY (namespace_org_id) REFERENCES orgs(id) ON DELETE CASCADE; +ALTER TABLE ONLY cm_monitors + ADD CONSTRAINT cm_monitors_tenant_id_fkey FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE; + ALTER TABLE ONLY cm_monitors ADD CONSTRAINT cm_monitors_user_id_fk FOREIGN KEY (namespace_user_id) REFERENCES users(id) ON DELETE CASCADE; +ALTER TABLE ONLY cm_queries + ADD CONSTRAINT cm_queries_tenant_id_fkey FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE; + ALTER TABLE ONLY cm_recipients ADD CONSTRAINT cm_recipients_emails FOREIGN KEY (email) REFERENCES cm_emails(id) ON DELETE CASCADE; ALTER TABLE ONLY cm_recipients ADD CONSTRAINT cm_recipients_org_id_fk FOREIGN KEY (namespace_org_id) REFERENCES orgs(id) ON DELETE CASCADE; +ALTER TABLE ONLY cm_recipients + ADD CONSTRAINT cm_recipients_tenant_id_fkey FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE; + ALTER TABLE ONLY cm_recipients ADD CONSTRAINT cm_recipients_user_id_fk FOREIGN KEY (namespace_user_id) REFERENCES users(id) ON DELETE CASCADE; @@ -6750,9 +7002,15 @@ ALTER TABLE ONLY cm_slack_webhooks ALTER TABLE ONLY cm_slack_webhooks ADD CONSTRAINT cm_slack_webhooks_monitor_fkey FOREIGN KEY (monitor) REFERENCES cm_monitors(id) ON DELETE CASCADE; +ALTER TABLE ONLY cm_slack_webhooks + ADD CONSTRAINT cm_slack_webhooks_tenant_id_fkey FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE; + ALTER TABLE ONLY cm_trigger_jobs ADD CONSTRAINT cm_trigger_jobs_query_fk FOREIGN KEY (query) REFERENCES cm_queries(id) ON DELETE CASCADE; +ALTER TABLE ONLY cm_trigger_jobs + ADD CONSTRAINT cm_trigger_jobs_tenant_id_fkey FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE; + ALTER TABLE ONLY cm_queries ADD CONSTRAINT cm_triggers_changed_by_fk FOREIGN KEY (changed_by) REFERENCES users(id) ON DELETE CASCADE; @@ -6771,36 +7029,111 @@ ALTER TABLE ONLY cm_webhooks ALTER TABLE ONLY cm_webhooks ADD CONSTRAINT cm_webhooks_monitor_fkey FOREIGN KEY (monitor) REFERENCES cm_monitors(id) ON DELETE CASCADE; +ALTER TABLE ONLY cm_webhooks + ADD CONSTRAINT cm_webhooks_tenant_id_fkey FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE; + +ALTER TABLE ONLY code_hosts + ADD CONSTRAINT code_hosts_tenant_id_fkey FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE; + +ALTER TABLE ONLY codeintel_autoindex_queue + ADD CONSTRAINT codeintel_autoindex_queue_tenant_id_fkey FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE; + ALTER TABLE ONLY codeintel_autoindexing_exceptions ADD CONSTRAINT codeintel_autoindexing_exceptions_repository_id_fkey FOREIGN KEY (repository_id) REFERENCES repo(id) ON DELETE CASCADE; +ALTER TABLE ONLY codeintel_autoindexing_exceptions + ADD CONSTRAINT codeintel_autoindexing_exceptions_tenant_id_fkey FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE; + +ALTER TABLE ONLY codeintel_commit_dates + ADD CONSTRAINT codeintel_commit_dates_tenant_id_fkey FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE; + +ALTER TABLE ONLY codeintel_inference_scripts + ADD CONSTRAINT codeintel_inference_scripts_tenant_id_fkey FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE; + ALTER TABLE ONLY codeintel_initial_path_ranks ADD CONSTRAINT codeintel_initial_path_ranks_exported_upload_id_fkey FOREIGN KEY (exported_upload_id) REFERENCES codeintel_ranking_exports(id) ON DELETE CASCADE; +ALTER TABLE ONLY codeintel_initial_path_ranks_processed + ADD CONSTRAINT codeintel_initial_path_ranks_processed_tenant_id_fkey FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE; + +ALTER TABLE ONLY codeintel_initial_path_ranks + ADD CONSTRAINT codeintel_initial_path_ranks_tenant_id_fkey FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE; + +ALTER TABLE ONLY codeintel_langugage_support_requests + ADD CONSTRAINT codeintel_langugage_support_requests_tenant_id_fkey FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE; + +ALTER TABLE ONLY codeintel_path_ranks + ADD CONSTRAINT codeintel_path_ranks_tenant_id_fkey FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE; + ALTER TABLE ONLY codeintel_ranking_definitions ADD CONSTRAINT codeintel_ranking_definitions_exported_upload_id_fkey FOREIGN KEY (exported_upload_id) REFERENCES codeintel_ranking_exports(id) ON DELETE CASCADE; +ALTER TABLE ONLY codeintel_ranking_definitions + ADD CONSTRAINT codeintel_ranking_definitions_tenant_id_fkey FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE; + +ALTER TABLE ONLY codeintel_ranking_exports + ADD CONSTRAINT codeintel_ranking_exports_tenant_id_fkey FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE; + ALTER TABLE ONLY codeintel_ranking_exports ADD CONSTRAINT codeintel_ranking_exports_upload_id_fkey FOREIGN KEY (upload_id) REFERENCES lsif_uploads(id) ON DELETE SET NULL; +ALTER TABLE ONLY codeintel_ranking_graph_keys + ADD CONSTRAINT codeintel_ranking_graph_keys_tenant_id_fkey FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE; + +ALTER TABLE ONLY codeintel_ranking_path_counts_inputs + ADD CONSTRAINT codeintel_ranking_path_counts_inputs_tenant_id_fkey FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE; + +ALTER TABLE ONLY codeintel_ranking_progress + ADD CONSTRAINT codeintel_ranking_progress_tenant_id_fkey FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE; + ALTER TABLE ONLY codeintel_ranking_references ADD CONSTRAINT codeintel_ranking_references_exported_upload_id_fkey FOREIGN KEY (exported_upload_id) REFERENCES codeintel_ranking_exports(id) ON DELETE CASCADE; +ALTER TABLE ONLY codeintel_ranking_references_processed + ADD CONSTRAINT codeintel_ranking_references_processed_tenant_id_fkey FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE; + +ALTER TABLE ONLY codeintel_ranking_references + ADD CONSTRAINT codeintel_ranking_references_tenant_id_fkey FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE; + ALTER TABLE ONLY codeowners_individual_stats ADD CONSTRAINT codeowners_individual_stats_file_path_id_fkey FOREIGN KEY (file_path_id) REFERENCES repo_paths(id); ALTER TABLE ONLY codeowners_individual_stats ADD CONSTRAINT codeowners_individual_stats_owner_id_fkey FOREIGN KEY (owner_id) REFERENCES codeowners_owners(id); +ALTER TABLE ONLY codeowners_individual_stats + ADD CONSTRAINT codeowners_individual_stats_tenant_id_fkey FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE; + +ALTER TABLE ONLY codeowners_owners + ADD CONSTRAINT codeowners_owners_tenant_id_fkey FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE; + ALTER TABLE ONLY codeowners ADD CONSTRAINT codeowners_repo_id_fkey FOREIGN KEY (repo_id) REFERENCES repo(id) ON DELETE CASCADE; +ALTER TABLE ONLY codeowners + ADD CONSTRAINT codeowners_tenant_id_fkey FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE; + +ALTER TABLE ONLY commit_authors + ADD CONSTRAINT commit_authors_tenant_id_fkey FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE; + +ALTER TABLE ONLY configuration_policies_audit_logs + ADD CONSTRAINT configuration_policies_audit_logs_tenant_id_fkey FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE; + +ALTER TABLE ONLY context_detection_embedding_jobs + ADD CONSTRAINT context_detection_embedding_jobs_tenant_id_fkey FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE; + ALTER TABLE ONLY discussion_comments ADD CONSTRAINT discussion_comments_author_user_id_fkey FOREIGN KEY (author_user_id) REFERENCES users(id) ON DELETE RESTRICT; +ALTER TABLE ONLY discussion_comments + ADD CONSTRAINT discussion_comments_tenant_id_fkey FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE; + ALTER TABLE ONLY discussion_comments ADD CONSTRAINT discussion_comments_thread_id_fkey FOREIGN KEY (thread_id) REFERENCES discussion_threads(id) ON DELETE CASCADE; +ALTER TABLE ONLY discussion_mail_reply_tokens + ADD CONSTRAINT discussion_mail_reply_tokens_tenant_id_fkey FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE; + ALTER TABLE ONLY discussion_mail_reply_tokens ADD CONSTRAINT discussion_mail_reply_tokens_thread_id_fkey FOREIGN KEY (thread_id) REFERENCES discussion_threads(id) ON DELETE CASCADE; @@ -6816,12 +7149,39 @@ ALTER TABLE ONLY discussion_threads ALTER TABLE ONLY discussion_threads_target_repo ADD CONSTRAINT discussion_threads_target_repo_repo_id_fkey FOREIGN KEY (repo_id) REFERENCES repo(id) ON DELETE CASCADE; +ALTER TABLE ONLY discussion_threads_target_repo + ADD CONSTRAINT discussion_threads_target_repo_tenant_id_fkey FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE; + ALTER TABLE ONLY discussion_threads_target_repo ADD CONSTRAINT discussion_threads_target_repo_thread_id_fkey FOREIGN KEY (thread_id) REFERENCES discussion_threads(id) ON DELETE CASCADE; +ALTER TABLE ONLY discussion_threads + ADD CONSTRAINT discussion_threads_tenant_id_fkey FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE; + +ALTER TABLE ONLY event_logs_export_allowlist + ADD CONSTRAINT event_logs_export_allowlist_tenant_id_fkey FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE; + +ALTER TABLE ONLY event_logs_scrape_state_own + ADD CONSTRAINT event_logs_scrape_state_own_tenant_id_fkey FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE; + +ALTER TABLE ONLY event_logs_scrape_state + ADD CONSTRAINT event_logs_scrape_state_tenant_id_fkey FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE; + +ALTER TABLE ONLY event_logs + ADD CONSTRAINT event_logs_tenant_id_fkey FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE; + +ALTER TABLE ONLY executor_heartbeats + ADD CONSTRAINT executor_heartbeats_tenant_id_fkey FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE; + +ALTER TABLE ONLY executor_job_tokens + ADD CONSTRAINT executor_job_tokens_tenant_id_fkey FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE; + ALTER TABLE ONLY executor_secret_access_logs ADD CONSTRAINT executor_secret_access_logs_executor_secret_id_fkey FOREIGN KEY (executor_secret_id) REFERENCES executor_secrets(id) ON DELETE CASCADE; +ALTER TABLE ONLY executor_secret_access_logs + ADD CONSTRAINT executor_secret_access_logs_tenant_id_fkey FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE; + ALTER TABLE ONLY executor_secret_access_logs ADD CONSTRAINT executor_secret_access_logs_user_id_fkey FOREIGN KEY (user_id) REFERENCES users(id) ON DELETE CASCADE; @@ -6834,24 +7194,45 @@ ALTER TABLE ONLY executor_secrets ALTER TABLE ONLY executor_secrets ADD CONSTRAINT executor_secrets_namespace_user_id_fkey FOREIGN KEY (namespace_user_id) REFERENCES users(id) ON DELETE CASCADE; +ALTER TABLE ONLY executor_secrets + ADD CONSTRAINT executor_secrets_tenant_id_fkey FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE; + ALTER TABLE ONLY exhaustive_search_jobs ADD CONSTRAINT exhaustive_search_jobs_initiator_id_fkey FOREIGN KEY (initiator_id) REFERENCES users(id) ON UPDATE CASCADE ON DELETE CASCADE DEFERRABLE; +ALTER TABLE ONLY exhaustive_search_jobs + ADD CONSTRAINT exhaustive_search_jobs_tenant_id_fkey FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE; + ALTER TABLE ONLY exhaustive_search_repo_jobs ADD CONSTRAINT exhaustive_search_repo_jobs_repo_id_fkey FOREIGN KEY (repo_id) REFERENCES repo(id) ON DELETE CASCADE; ALTER TABLE ONLY exhaustive_search_repo_jobs ADD CONSTRAINT exhaustive_search_repo_jobs_search_job_id_fkey FOREIGN KEY (search_job_id) REFERENCES exhaustive_search_jobs(id) ON DELETE CASCADE; +ALTER TABLE ONLY exhaustive_search_repo_jobs + ADD CONSTRAINT exhaustive_search_repo_jobs_tenant_id_fkey FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE; + ALTER TABLE ONLY exhaustive_search_repo_revision_jobs ADD CONSTRAINT exhaustive_search_repo_revision_jobs_search_repo_job_id_fkey FOREIGN KEY (search_repo_job_id) REFERENCES exhaustive_search_repo_jobs(id) ON DELETE CASCADE; +ALTER TABLE ONLY exhaustive_search_repo_revision_jobs + ADD CONSTRAINT exhaustive_search_repo_revision_jobs_tenant_id_fkey FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE; + +ALTER TABLE ONLY explicit_permissions_bitbucket_projects_jobs + ADD CONSTRAINT explicit_permissions_bitbucket_projects_jobs_tenant_id_fkey FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE; + ALTER TABLE ONLY external_service_repos ADD CONSTRAINT external_service_repos_external_service_id_fkey FOREIGN KEY (external_service_id) REFERENCES external_services(id) ON DELETE CASCADE DEFERRABLE; ALTER TABLE ONLY external_service_repos ADD CONSTRAINT external_service_repos_repo_id_fkey FOREIGN KEY (repo_id) REFERENCES repo(id) ON DELETE CASCADE DEFERRABLE; +ALTER TABLE ONLY external_service_repos + ADD CONSTRAINT external_service_repos_tenant_id_fkey FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE; + +ALTER TABLE ONLY external_service_sync_jobs + ADD CONSTRAINT external_service_sync_jobs_tenant_id_fkey FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE; + ALTER TABLE ONLY external_services ADD CONSTRAINT external_services_code_host_id_fkey FOREIGN KEY (code_host_id) REFERENCES code_hosts(id) ON UPDATE CASCADE ON DELETE SET NULL DEFERRABLE INITIALLY DEFERRED; @@ -6864,12 +7245,21 @@ ALTER TABLE ONLY external_service_sync_jobs ALTER TABLE ONLY external_services ADD CONSTRAINT external_services_last_updater_id_fkey FOREIGN KEY (last_updater_id) REFERENCES users(id) ON DELETE SET NULL DEFERRABLE; +ALTER TABLE ONLY external_services + ADD CONSTRAINT external_services_tenant_id_fkey FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE; + ALTER TABLE ONLY feature_flag_overrides ADD CONSTRAINT feature_flag_overrides_namespace_org_id_fkey FOREIGN KEY (namespace_org_id) REFERENCES orgs(id) ON DELETE CASCADE; ALTER TABLE ONLY feature_flag_overrides ADD CONSTRAINT feature_flag_overrides_namespace_user_id_fkey FOREIGN KEY (namespace_user_id) REFERENCES users(id) ON DELETE CASCADE; +ALTER TABLE ONLY feature_flag_overrides + ADD CONSTRAINT feature_flag_overrides_tenant_id_fkey FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE; + +ALTER TABLE ONLY feature_flags + ADD CONSTRAINT feature_flags_tenant_id_fkey FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE; + ALTER TABLE ONLY codeintel_initial_path_ranks_processed ADD CONSTRAINT fk_codeintel_initial_path_ranks FOREIGN KEY (codeintel_initial_path_ranks_id) REFERENCES codeintel_initial_path_ranks(id) ON DELETE CASCADE; @@ -6894,54 +7284,153 @@ ALTER TABLE ONLY vulnerability_matches ALTER TABLE ONLY github_app_installs ADD CONSTRAINT github_app_installs_app_id_fkey FOREIGN KEY (app_id) REFERENCES github_apps(id) ON DELETE CASCADE; +ALTER TABLE ONLY github_app_installs + ADD CONSTRAINT github_app_installs_tenant_id_fkey FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE; + +ALTER TABLE ONLY github_apps + ADD CONSTRAINT github_apps_tenant_id_fkey FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE; + ALTER TABLE ONLY github_apps ADD CONSTRAINT github_apps_webhook_id_fkey FOREIGN KEY (webhook_id) REFERENCES webhooks(id) ON DELETE SET NULL; +ALTER TABLE ONLY gitserver_relocator_jobs + ADD CONSTRAINT gitserver_relocator_jobs_tenant_id_fkey FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE; + ALTER TABLE ONLY gitserver_repos ADD CONSTRAINT gitserver_repos_repo_id_fkey FOREIGN KEY (repo_id) REFERENCES repo(id) ON DELETE CASCADE; +ALTER TABLE ONLY gitserver_repos_statistics + ADD CONSTRAINT gitserver_repos_statistics_tenant_id_fkey FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE; + ALTER TABLE ONLY gitserver_repos_sync_output ADD CONSTRAINT gitserver_repos_sync_output_repo_id_fkey FOREIGN KEY (repo_id) REFERENCES repo(id) ON DELETE CASCADE; +ALTER TABLE ONLY gitserver_repos_sync_output + ADD CONSTRAINT gitserver_repos_sync_output_tenant_id_fkey FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE; + +ALTER TABLE ONLY gitserver_repos + ADD CONSTRAINT gitserver_repos_tenant_id_fkey FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE; + +ALTER TABLE ONLY global_state + ADD CONSTRAINT global_state_tenant_id_fkey FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE; + ALTER TABLE ONLY insights_query_runner_jobs_dependencies ADD CONSTRAINT insights_query_runner_jobs_dependencies_fk_job_id FOREIGN KEY (job_id) REFERENCES insights_query_runner_jobs(id) ON DELETE CASCADE; +ALTER TABLE ONLY insights_query_runner_jobs_dependencies + ADD CONSTRAINT insights_query_runner_jobs_dependencies_tenant_id_fkey FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE; + +ALTER TABLE ONLY insights_query_runner_jobs + ADD CONSTRAINT insights_query_runner_jobs_tenant_id_fkey FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE; + +ALTER TABLE ONLY insights_settings_migration_jobs + ADD CONSTRAINT insights_settings_migration_jobs_tenant_id_fkey FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE; + +ALTER TABLE ONLY lsif_configuration_policies_repository_pattern_lookup + ADD CONSTRAINT lsif_configuration_policies_repository_pattern_l_tenant_id_fkey FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE; + +ALTER TABLE ONLY lsif_configuration_policies + ADD CONSTRAINT lsif_configuration_policies_tenant_id_fkey FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE; + +ALTER TABLE ONLY lsif_dependency_indexing_jobs + ADD CONSTRAINT lsif_dependency_indexing_jobs_tenant_id_fkey FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE; + ALTER TABLE ONLY lsif_dependency_syncing_jobs ADD CONSTRAINT lsif_dependency_indexing_jobs_upload_id_fkey FOREIGN KEY (upload_id) REFERENCES lsif_uploads(id) ON DELETE CASCADE; ALTER TABLE ONLY lsif_dependency_indexing_jobs ADD CONSTRAINT lsif_dependency_indexing_jobs_upload_id_fkey1 FOREIGN KEY (upload_id) REFERENCES lsif_uploads(id) ON DELETE CASCADE; +ALTER TABLE ONLY lsif_dependency_repos + ADD CONSTRAINT lsif_dependency_repos_tenant_id_fkey FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE; + +ALTER TABLE ONLY lsif_dependency_syncing_jobs + ADD CONSTRAINT lsif_dependency_syncing_jobs_tenant_id_fkey FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE; + +ALTER TABLE ONLY lsif_dirty_repositories + ADD CONSTRAINT lsif_dirty_repositories_tenant_id_fkey FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE; + ALTER TABLE ONLY lsif_index_configuration ADD CONSTRAINT lsif_index_configuration_repository_id_fkey FOREIGN KEY (repository_id) REFERENCES repo(id) ON DELETE CASCADE; +ALTER TABLE ONLY lsif_index_configuration + ADD CONSTRAINT lsif_index_configuration_tenant_id_fkey FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE; + +ALTER TABLE ONLY lsif_indexes + ADD CONSTRAINT lsif_indexes_tenant_id_fkey FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE; + +ALTER TABLE ONLY lsif_last_index_scan + ADD CONSTRAINT lsif_last_index_scan_tenant_id_fkey FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE; + +ALTER TABLE ONLY lsif_last_retention_scan + ADD CONSTRAINT lsif_last_retention_scan_tenant_id_fkey FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE; + +ALTER TABLE ONLY lsif_nearest_uploads_links + ADD CONSTRAINT lsif_nearest_uploads_links_tenant_id_fkey FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE; + +ALTER TABLE ONLY lsif_nearest_uploads + ADD CONSTRAINT lsif_nearest_uploads_tenant_id_fkey FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE; + ALTER TABLE ONLY lsif_packages ADD CONSTRAINT lsif_packages_dump_id_fkey FOREIGN KEY (dump_id) REFERENCES lsif_uploads(id) ON DELETE CASCADE; +ALTER TABLE ONLY lsif_packages + ADD CONSTRAINT lsif_packages_tenant_id_fkey FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE; + ALTER TABLE ONLY lsif_references ADD CONSTRAINT lsif_references_dump_id_fkey FOREIGN KEY (dump_id) REFERENCES lsif_uploads(id) ON DELETE CASCADE; +ALTER TABLE ONLY lsif_references + ADD CONSTRAINT lsif_references_tenant_id_fkey FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE; + ALTER TABLE ONLY lsif_retention_configuration ADD CONSTRAINT lsif_retention_configuration_repository_id_fkey FOREIGN KEY (repository_id) REFERENCES repo(id) ON DELETE CASCADE; +ALTER TABLE ONLY lsif_retention_configuration + ADD CONSTRAINT lsif_retention_configuration_tenant_id_fkey FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE; + +ALTER TABLE ONLY lsif_uploads_audit_logs + ADD CONSTRAINT lsif_uploads_audit_logs_tenant_id_fkey FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE; + +ALTER TABLE ONLY lsif_uploads_reference_counts + ADD CONSTRAINT lsif_uploads_reference_counts_tenant_id_fkey FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE; + ALTER TABLE ONLY lsif_uploads_reference_counts ADD CONSTRAINT lsif_uploads_reference_counts_upload_id_fk FOREIGN KEY (upload_id) REFERENCES lsif_uploads(id) ON DELETE CASCADE; +ALTER TABLE ONLY lsif_uploads + ADD CONSTRAINT lsif_uploads_tenant_id_fkey FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE; + +ALTER TABLE ONLY lsif_uploads_visible_at_tip + ADD CONSTRAINT lsif_uploads_visible_at_tip_tenant_id_fkey FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE; + +ALTER TABLE ONLY lsif_uploads_vulnerability_scan + ADD CONSTRAINT lsif_uploads_vulnerability_scan_tenant_id_fkey FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE; + ALTER TABLE ONLY names ADD CONSTRAINT names_org_id_fkey FOREIGN KEY (org_id) REFERENCES orgs(id) ON UPDATE CASCADE ON DELETE CASCADE; ALTER TABLE ONLY names ADD CONSTRAINT names_team_id_fkey FOREIGN KEY (team_id) REFERENCES teams(id) ON UPDATE CASCADE ON DELETE CASCADE; +ALTER TABLE ONLY names + ADD CONSTRAINT names_tenant_id_fkey FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE; + ALTER TABLE ONLY names ADD CONSTRAINT names_user_id_fkey FOREIGN KEY (user_id) REFERENCES users(id) ON UPDATE CASCADE ON DELETE CASCADE; +ALTER TABLE ONLY namespace_permissions + ADD CONSTRAINT namespace_permissions_tenant_id_fkey FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE; + ALTER TABLE ONLY namespace_permissions ADD CONSTRAINT namespace_permissions_user_id_fkey FOREIGN KEY (user_id) REFERENCES users(id) ON DELETE CASCADE DEFERRABLE; ALTER TABLE ONLY notebook_stars ADD CONSTRAINT notebook_stars_notebook_id_fkey FOREIGN KEY (notebook_id) REFERENCES notebooks(id) ON DELETE CASCADE DEFERRABLE; +ALTER TABLE ONLY notebook_stars + ADD CONSTRAINT notebook_stars_tenant_id_fkey FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE; + ALTER TABLE ONLY notebook_stars ADD CONSTRAINT notebook_stars_user_id_fkey FOREIGN KEY (user_id) REFERENCES users(id) ON DELETE CASCADE DEFERRABLE; @@ -6954,6 +7443,9 @@ ALTER TABLE ONLY notebooks ALTER TABLE ONLY notebooks ADD CONSTRAINT notebooks_namespace_user_id_fkey FOREIGN KEY (namespace_user_id) REFERENCES users(id) ON DELETE SET NULL DEFERRABLE; +ALTER TABLE ONLY notebooks + ADD CONSTRAINT notebooks_tenant_id_fkey FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE; + ALTER TABLE ONLY notebooks ADD CONSTRAINT notebooks_updater_user_id_fkey FOREIGN KEY (updater_user_id) REFERENCES users(id) ON DELETE SET NULL DEFERRABLE; @@ -6966,30 +7458,63 @@ ALTER TABLE ONLY org_invitations ALTER TABLE ONLY org_invitations ADD CONSTRAINT org_invitations_sender_user_id_fkey FOREIGN KEY (sender_user_id) REFERENCES users(id); +ALTER TABLE ONLY org_invitations + ADD CONSTRAINT org_invitations_tenant_id_fkey FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE; + ALTER TABLE ONLY org_members ADD CONSTRAINT org_members_references_orgs FOREIGN KEY (org_id) REFERENCES orgs(id) ON DELETE RESTRICT; +ALTER TABLE ONLY org_members + ADD CONSTRAINT org_members_tenant_id_fkey FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE; + ALTER TABLE ONLY org_members ADD CONSTRAINT org_members_user_id_fkey FOREIGN KEY (user_id) REFERENCES users(id) ON DELETE RESTRICT; ALTER TABLE ONLY org_stats ADD CONSTRAINT org_stats_org_id_fkey FOREIGN KEY (org_id) REFERENCES orgs(id) ON DELETE CASCADE DEFERRABLE; +ALTER TABLE ONLY org_stats + ADD CONSTRAINT org_stats_tenant_id_fkey FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE; + +ALTER TABLE ONLY orgs_open_beta_stats + ADD CONSTRAINT orgs_open_beta_stats_tenant_id_fkey FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE; + +ALTER TABLE ONLY orgs + ADD CONSTRAINT orgs_tenant_id_fkey FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE; + ALTER TABLE ONLY out_of_band_migrations_errors ADD CONSTRAINT out_of_band_migrations_errors_migration_id_fkey FOREIGN KEY (migration_id) REFERENCES out_of_band_migrations(id) ON DELETE CASCADE; +ALTER TABLE ONLY out_of_band_migrations_errors + ADD CONSTRAINT out_of_band_migrations_errors_tenant_id_fkey FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE; + +ALTER TABLE ONLY out_of_band_migrations + ADD CONSTRAINT out_of_band_migrations_tenant_id_fkey FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE; + ALTER TABLE ONLY outbound_webhook_event_types ADD CONSTRAINT outbound_webhook_event_types_outbound_webhook_id_fkey FOREIGN KEY (outbound_webhook_id) REFERENCES outbound_webhooks(id) ON UPDATE CASCADE ON DELETE CASCADE; +ALTER TABLE ONLY outbound_webhook_event_types + ADD CONSTRAINT outbound_webhook_event_types_tenant_id_fkey FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE; + +ALTER TABLE ONLY outbound_webhook_jobs + ADD CONSTRAINT outbound_webhook_jobs_tenant_id_fkey FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE; + ALTER TABLE ONLY outbound_webhook_logs ADD CONSTRAINT outbound_webhook_logs_job_id_fkey FOREIGN KEY (job_id) REFERENCES outbound_webhook_jobs(id) ON UPDATE CASCADE ON DELETE CASCADE; ALTER TABLE ONLY outbound_webhook_logs ADD CONSTRAINT outbound_webhook_logs_outbound_webhook_id_fkey FOREIGN KEY (outbound_webhook_id) REFERENCES outbound_webhooks(id) ON UPDATE CASCADE ON DELETE CASCADE; +ALTER TABLE ONLY outbound_webhook_logs + ADD CONSTRAINT outbound_webhook_logs_tenant_id_fkey FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE; + ALTER TABLE ONLY outbound_webhooks ADD CONSTRAINT outbound_webhooks_created_by_fkey FOREIGN KEY (created_by) REFERENCES users(id) ON DELETE SET NULL; +ALTER TABLE ONLY outbound_webhooks + ADD CONSTRAINT outbound_webhooks_tenant_id_fkey FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE; + ALTER TABLE ONLY outbound_webhooks ADD CONSTRAINT outbound_webhooks_updated_by_fkey FOREIGN KEY (updated_by) REFERENCES users(id) ON DELETE SET NULL; @@ -6999,36 +7524,75 @@ ALTER TABLE ONLY own_aggregate_recent_contribution ALTER TABLE ONLY own_aggregate_recent_contribution ADD CONSTRAINT own_aggregate_recent_contribution_commit_author_id_fkey FOREIGN KEY (commit_author_id) REFERENCES commit_authors(id); +ALTER TABLE ONLY own_aggregate_recent_contribution + ADD CONSTRAINT own_aggregate_recent_contribution_tenant_id_fkey FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE; + +ALTER TABLE ONLY own_aggregate_recent_view + ADD CONSTRAINT own_aggregate_recent_view_tenant_id_fkey FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE; + ALTER TABLE ONLY own_aggregate_recent_view ADD CONSTRAINT own_aggregate_recent_view_viewed_file_path_id_fkey FOREIGN KEY (viewed_file_path_id) REFERENCES repo_paths(id); ALTER TABLE ONLY own_aggregate_recent_view ADD CONSTRAINT own_aggregate_recent_view_viewer_id_fkey FOREIGN KEY (viewer_id) REFERENCES users(id) ON DELETE CASCADE DEFERRABLE; +ALTER TABLE ONLY own_background_jobs + ADD CONSTRAINT own_background_jobs_tenant_id_fkey FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE; + +ALTER TABLE ONLY own_signal_configurations + ADD CONSTRAINT own_signal_configurations_tenant_id_fkey FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE; + ALTER TABLE ONLY own_signal_recent_contribution ADD CONSTRAINT own_signal_recent_contribution_changed_file_path_id_fkey FOREIGN KEY (changed_file_path_id) REFERENCES repo_paths(id); ALTER TABLE ONLY own_signal_recent_contribution ADD CONSTRAINT own_signal_recent_contribution_commit_author_id_fkey FOREIGN KEY (commit_author_id) REFERENCES commit_authors(id); +ALTER TABLE ONLY own_signal_recent_contribution + ADD CONSTRAINT own_signal_recent_contribution_tenant_id_fkey FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE; + ALTER TABLE ONLY ownership_path_stats ADD CONSTRAINT ownership_path_stats_file_path_id_fkey FOREIGN KEY (file_path_id) REFERENCES repo_paths(id); +ALTER TABLE ONLY ownership_path_stats + ADD CONSTRAINT ownership_path_stats_tenant_id_fkey FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE; + ALTER TABLE ONLY package_repo_versions ADD CONSTRAINT package_id_fk FOREIGN KEY (package_id) REFERENCES lsif_dependency_repos(id) ON DELETE CASCADE; +ALTER TABLE ONLY package_repo_filters + ADD CONSTRAINT package_repo_filters_tenant_id_fkey FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE; + +ALTER TABLE ONLY package_repo_versions + ADD CONSTRAINT package_repo_versions_tenant_id_fkey FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE; + ALTER TABLE ONLY permission_sync_jobs ADD CONSTRAINT permission_sync_jobs_repository_id_fkey FOREIGN KEY (repository_id) REFERENCES repo(id) ON DELETE CASCADE; +ALTER TABLE ONLY permission_sync_jobs + ADD CONSTRAINT permission_sync_jobs_tenant_id_fkey FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE; + ALTER TABLE ONLY permission_sync_jobs ADD CONSTRAINT permission_sync_jobs_triggered_by_user_id_fkey FOREIGN KEY (triggered_by_user_id) REFERENCES users(id) ON DELETE SET NULL DEFERRABLE; ALTER TABLE ONLY permission_sync_jobs ADD CONSTRAINT permission_sync_jobs_user_id_fkey FOREIGN KEY (user_id) REFERENCES users(id) ON DELETE CASCADE; +ALTER TABLE ONLY permissions + ADD CONSTRAINT permissions_tenant_id_fkey FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE; + +ALTER TABLE ONLY phabricator_repos + ADD CONSTRAINT phabricator_repos_tenant_id_fkey FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE; + ALTER TABLE ONLY product_licenses ADD CONSTRAINT product_licenses_product_subscription_id_fkey FOREIGN KEY (product_subscription_id) REFERENCES product_subscriptions(id); +ALTER TABLE ONLY product_licenses + ADD CONSTRAINT product_licenses_tenant_id_fkey FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE; + +ALTER TABLE ONLY product_subscriptions + ADD CONSTRAINT product_subscriptions_tenant_id_fkey FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE; + ALTER TABLE ONLY product_subscriptions ADD CONSTRAINT product_subscriptions_user_id_fkey FOREIGN KEY (user_id) REFERENCES users(id); @@ -7041,48 +7605,99 @@ ALTER TABLE ONLY prompts ALTER TABLE ONLY prompts ADD CONSTRAINT prompts_owner_user_id_fkey FOREIGN KEY (owner_user_id) REFERENCES users(id) ON DELETE CASCADE; +ALTER TABLE ONLY prompts + ADD CONSTRAINT prompts_tenant_id_fkey FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE; + ALTER TABLE ONLY prompts ADD CONSTRAINT prompts_updated_by_fkey FOREIGN KEY (updated_by) REFERENCES users(id) ON DELETE SET NULL; +ALTER TABLE ONLY query_runner_state + ADD CONSTRAINT query_runner_state_tenant_id_fkey FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE; + +ALTER TABLE ONLY redis_key_value + ADD CONSTRAINT redis_key_value_tenant_id_fkey FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE; + ALTER TABLE ONLY registry_extension_releases ADD CONSTRAINT registry_extension_releases_creator_user_id_fkey FOREIGN KEY (creator_user_id) REFERENCES users(id); ALTER TABLE ONLY registry_extension_releases ADD CONSTRAINT registry_extension_releases_registry_extension_id_fkey FOREIGN KEY (registry_extension_id) REFERENCES registry_extensions(id) ON UPDATE CASCADE ON DELETE CASCADE; +ALTER TABLE ONLY registry_extension_releases + ADD CONSTRAINT registry_extension_releases_tenant_id_fkey FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE; + ALTER TABLE ONLY registry_extensions ADD CONSTRAINT registry_extensions_publisher_org_id_fkey FOREIGN KEY (publisher_org_id) REFERENCES orgs(id); ALTER TABLE ONLY registry_extensions ADD CONSTRAINT registry_extensions_publisher_user_id_fkey FOREIGN KEY (publisher_user_id) REFERENCES users(id); +ALTER TABLE ONLY registry_extensions + ADD CONSTRAINT registry_extensions_tenant_id_fkey FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE; + ALTER TABLE ONLY repo_commits_changelists ADD CONSTRAINT repo_commits_changelists_repo_id_fkey FOREIGN KEY (repo_id) REFERENCES repo(id) ON DELETE CASCADE DEFERRABLE; +ALTER TABLE ONLY repo_commits_changelists + ADD CONSTRAINT repo_commits_changelists_tenant_id_fkey FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE; + ALTER TABLE ONLY repo_embedding_job_stats ADD CONSTRAINT repo_embedding_job_stats_job_id_fkey FOREIGN KEY (job_id) REFERENCES repo_embedding_jobs(id) ON DELETE CASCADE DEFERRABLE; +ALTER TABLE ONLY repo_embedding_job_stats + ADD CONSTRAINT repo_embedding_job_stats_tenant_id_fkey FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE; + +ALTER TABLE ONLY repo_embedding_jobs + ADD CONSTRAINT repo_embedding_jobs_tenant_id_fkey FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE; + ALTER TABLE ONLY repo_kvps ADD CONSTRAINT repo_kvps_repo_id_fkey FOREIGN KEY (repo_id) REFERENCES repo(id) ON DELETE CASCADE; +ALTER TABLE ONLY repo_kvps + ADD CONSTRAINT repo_kvps_tenant_id_fkey FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE; + ALTER TABLE ONLY repo_paths ADD CONSTRAINT repo_paths_parent_id_fkey FOREIGN KEY (parent_id) REFERENCES repo_paths(id); ALTER TABLE ONLY repo_paths ADD CONSTRAINT repo_paths_repo_id_fkey FOREIGN KEY (repo_id) REFERENCES repo(id) ON DELETE CASCADE DEFERRABLE; +ALTER TABLE ONLY repo_paths + ADD CONSTRAINT repo_paths_tenant_id_fkey FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE; + +ALTER TABLE ONLY repo_pending_permissions + ADD CONSTRAINT repo_pending_permissions_tenant_id_fkey FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE; + +ALTER TABLE ONLY repo_permissions + ADD CONSTRAINT repo_permissions_tenant_id_fkey FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE; + +ALTER TABLE ONLY repo_statistics + ADD CONSTRAINT repo_statistics_tenant_id_fkey FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE; + +ALTER TABLE ONLY repo + ADD CONSTRAINT repo_tenant_id_fkey FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE; + ALTER TABLE ONLY role_permissions ADD CONSTRAINT role_permissions_permission_id_fkey FOREIGN KEY (permission_id) REFERENCES permissions(id) ON DELETE CASCADE DEFERRABLE; ALTER TABLE ONLY role_permissions ADD CONSTRAINT role_permissions_role_id_fkey FOREIGN KEY (role_id) REFERENCES roles(id) ON DELETE CASCADE DEFERRABLE; +ALTER TABLE ONLY role_permissions + ADD CONSTRAINT role_permissions_tenant_id_fkey FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE; + +ALTER TABLE ONLY roles + ADD CONSTRAINT roles_tenant_id_fkey FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE; + ALTER TABLE ONLY saved_searches ADD CONSTRAINT saved_searches_created_by_fkey FOREIGN KEY (created_by) REFERENCES users(id) ON DELETE SET NULL; ALTER TABLE ONLY saved_searches ADD CONSTRAINT saved_searches_org_id_fkey FOREIGN KEY (org_id) REFERENCES orgs(id); +ALTER TABLE ONLY saved_searches + ADD CONSTRAINT saved_searches_tenant_id_fkey FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE; + ALTER TABLE ONLY saved_searches ADD CONSTRAINT saved_searches_updated_by_fkey FOREIGN KEY (updated_by) REFERENCES users(id) ON DELETE SET NULL; @@ -7092,6 +7707,9 @@ ALTER TABLE ONLY saved_searches ALTER TABLE ONLY search_context_default ADD CONSTRAINT search_context_default_search_context_id_fkey FOREIGN KEY (search_context_id) REFERENCES search_contexts(id) ON DELETE CASCADE DEFERRABLE; +ALTER TABLE ONLY search_context_default + ADD CONSTRAINT search_context_default_tenant_id_fkey FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE; + ALTER TABLE ONLY search_context_default ADD CONSTRAINT search_context_default_user_id_fkey FOREIGN KEY (user_id) REFERENCES users(id) ON DELETE CASCADE DEFERRABLE; @@ -7101,9 +7719,15 @@ ALTER TABLE ONLY search_context_repos ALTER TABLE ONLY search_context_repos ADD CONSTRAINT search_context_repos_search_context_id_fk FOREIGN KEY (search_context_id) REFERENCES search_contexts(id) ON DELETE CASCADE; +ALTER TABLE ONLY search_context_repos + ADD CONSTRAINT search_context_repos_tenant_id_fkey FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE; + ALTER TABLE ONLY search_context_stars ADD CONSTRAINT search_context_stars_search_context_id_fkey FOREIGN KEY (search_context_id) REFERENCES search_contexts(id) ON DELETE CASCADE DEFERRABLE; +ALTER TABLE ONLY search_context_stars + ADD CONSTRAINT search_context_stars_tenant_id_fkey FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE; + ALTER TABLE ONLY search_context_stars ADD CONSTRAINT search_context_stars_user_id_fkey FOREIGN KEY (user_id) REFERENCES users(id) ON DELETE CASCADE DEFERRABLE; @@ -7113,27 +7737,51 @@ ALTER TABLE ONLY search_contexts ALTER TABLE ONLY search_contexts ADD CONSTRAINT search_contexts_namespace_user_id_fk FOREIGN KEY (namespace_user_id) REFERENCES users(id) ON DELETE CASCADE; +ALTER TABLE ONLY search_contexts + ADD CONSTRAINT search_contexts_tenant_id_fkey FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE; + +ALTER TABLE ONLY security_event_logs + ADD CONSTRAINT security_event_logs_tenant_id_fkey FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE; + ALTER TABLE ONLY settings ADD CONSTRAINT settings_author_user_id_fkey FOREIGN KEY (author_user_id) REFERENCES users(id) ON DELETE RESTRICT; ALTER TABLE ONLY settings ADD CONSTRAINT settings_references_orgs FOREIGN KEY (org_id) REFERENCES orgs(id) ON DELETE RESTRICT; +ALTER TABLE ONLY settings + ADD CONSTRAINT settings_tenant_id_fkey FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE; + ALTER TABLE ONLY settings ADD CONSTRAINT settings_user_id_fkey FOREIGN KEY (user_id) REFERENCES users(id) ON DELETE RESTRICT; ALTER TABLE ONLY sub_repo_permissions ADD CONSTRAINT sub_repo_permissions_repo_id_fk FOREIGN KEY (repo_id) REFERENCES repo(id) ON DELETE CASCADE; +ALTER TABLE ONLY sub_repo_permissions + ADD CONSTRAINT sub_repo_permissions_tenant_id_fkey FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE; + ALTER TABLE ONLY sub_repo_permissions ADD CONSTRAINT sub_repo_permissions_users_id_fk FOREIGN KEY (user_id) REFERENCES users(id) ON DELETE CASCADE; +ALTER TABLE ONLY survey_responses + ADD CONSTRAINT survey_responses_tenant_id_fkey FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE; + ALTER TABLE ONLY survey_responses ADD CONSTRAINT survey_responses_user_id_fkey FOREIGN KEY (user_id) REFERENCES users(id); +ALTER TABLE ONLY syntactic_scip_indexing_jobs + ADD CONSTRAINT syntactic_scip_indexing_jobs_tenant_id_fkey FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE; + +ALTER TABLE ONLY syntactic_scip_last_index_scan + ADD CONSTRAINT syntactic_scip_last_index_scan_tenant_id_fkey FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE; + ALTER TABLE ONLY team_members ADD CONSTRAINT team_members_team_id_fkey FOREIGN KEY (team_id) REFERENCES teams(id) ON DELETE CASCADE; +ALTER TABLE ONLY team_members + ADD CONSTRAINT team_members_tenant_id_fkey FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE; + ALTER TABLE ONLY team_members ADD CONSTRAINT team_members_user_id_fkey FOREIGN KEY (user_id) REFERENCES users(id) ON DELETE CASCADE; @@ -7143,33 +7791,66 @@ ALTER TABLE ONLY teams ALTER TABLE ONLY teams ADD CONSTRAINT teams_parent_team_id_fkey FOREIGN KEY (parent_team_id) REFERENCES teams(id) ON DELETE CASCADE; +ALTER TABLE ONLY teams + ADD CONSTRAINT teams_tenant_id_fkey FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE; + +ALTER TABLE ONLY telemetry_events_export_queue + ADD CONSTRAINT telemetry_events_export_queue_tenant_id_fkey FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE; + +ALTER TABLE ONLY temporary_settings + ADD CONSTRAINT temporary_settings_tenant_id_fkey FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE; + ALTER TABLE ONLY temporary_settings ADD CONSTRAINT temporary_settings_user_id_fkey FOREIGN KEY (user_id) REFERENCES users(id) ON DELETE CASCADE; ALTER TABLE ONLY user_credentials ADD CONSTRAINT user_credentials_github_app_id_fkey FOREIGN KEY (github_app_id) REFERENCES github_apps(id) ON DELETE CASCADE; +ALTER TABLE ONLY user_credentials + ADD CONSTRAINT user_credentials_tenant_id_fkey FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE; + ALTER TABLE ONLY user_credentials ADD CONSTRAINT user_credentials_user_id_fkey FOREIGN KEY (user_id) REFERENCES users(id) ON DELETE CASCADE DEFERRABLE; +ALTER TABLE ONLY user_emails + ADD CONSTRAINT user_emails_tenant_id_fkey FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE; + ALTER TABLE ONLY user_emails ADD CONSTRAINT user_emails_user_id_fkey FOREIGN KEY (user_id) REFERENCES users(id); +ALTER TABLE ONLY user_external_accounts + ADD CONSTRAINT user_external_accounts_tenant_id_fkey FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE; + ALTER TABLE ONLY user_external_accounts ADD CONSTRAINT user_external_accounts_user_id_fkey FOREIGN KEY (user_id) REFERENCES users(id); +ALTER TABLE ONLY user_onboarding_tour + ADD CONSTRAINT user_onboarding_tour_tenant_id_fkey FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE; + ALTER TABLE ONLY user_onboarding_tour ADD CONSTRAINT user_onboarding_tour_users_fk FOREIGN KEY (updated_by) REFERENCES users(id); +ALTER TABLE ONLY user_pending_permissions + ADD CONSTRAINT user_pending_permissions_tenant_id_fkey FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE; + +ALTER TABLE ONLY user_permissions + ADD CONSTRAINT user_permissions_tenant_id_fkey FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE; + ALTER TABLE ONLY user_public_repos ADD CONSTRAINT user_public_repos_repo_id_fkey FOREIGN KEY (repo_id) REFERENCES repo(id) ON DELETE CASCADE; +ALTER TABLE ONLY user_public_repos + ADD CONSTRAINT user_public_repos_tenant_id_fkey FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE; + ALTER TABLE ONLY user_public_repos ADD CONSTRAINT user_public_repos_user_id_fkey FOREIGN KEY (user_id) REFERENCES users(id) ON DELETE CASCADE; ALTER TABLE ONLY user_repo_permissions ADD CONSTRAINT user_repo_permissions_repo_id_fkey FOREIGN KEY (repo_id) REFERENCES repo(id) ON DELETE CASCADE; +ALTER TABLE ONLY user_repo_permissions + ADD CONSTRAINT user_repo_permissions_tenant_id_fkey FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE; + ALTER TABLE ONLY user_repo_permissions ADD CONSTRAINT user_repo_permissions_user_external_account_id_fkey FOREIGN KEY (user_external_account_id) REFERENCES user_external_accounts(id) ON DELETE CASCADE; @@ -7179,31 +7860,58 @@ ALTER TABLE ONLY user_repo_permissions ALTER TABLE ONLY user_roles ADD CONSTRAINT user_roles_role_id_fkey FOREIGN KEY (role_id) REFERENCES roles(id) ON DELETE CASCADE DEFERRABLE; +ALTER TABLE ONLY user_roles + ADD CONSTRAINT user_roles_tenant_id_fkey FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE; + ALTER TABLE ONLY user_roles ADD CONSTRAINT user_roles_user_id_fkey FOREIGN KEY (user_id) REFERENCES users(id) ON DELETE CASCADE DEFERRABLE; +ALTER TABLE ONLY users + ADD CONSTRAINT users_tenant_id_fkey FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE; + +ALTER TABLE ONLY vulnerabilities + ADD CONSTRAINT vulnerabilities_tenant_id_fkey FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE; + +ALTER TABLE ONLY vulnerability_affected_packages + ADD CONSTRAINT vulnerability_affected_packages_tenant_id_fkey FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE; + +ALTER TABLE ONLY vulnerability_affected_symbols + ADD CONSTRAINT vulnerability_affected_symbols_tenant_id_fkey FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE; + +ALTER TABLE ONLY vulnerability_matches + ADD CONSTRAINT vulnerability_matches_tenant_id_fkey FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE; + ALTER TABLE ONLY webhook_logs ADD CONSTRAINT webhook_logs_external_service_id_fkey FOREIGN KEY (external_service_id) REFERENCES external_services(id) ON UPDATE CASCADE ON DELETE CASCADE; +ALTER TABLE ONLY webhook_logs + ADD CONSTRAINT webhook_logs_tenant_id_fkey FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE; + ALTER TABLE ONLY webhook_logs ADD CONSTRAINT webhook_logs_webhook_id_fkey FOREIGN KEY (webhook_id) REFERENCES webhooks(id) ON DELETE CASCADE; ALTER TABLE ONLY webhooks ADD CONSTRAINT webhooks_created_by_user_id_fkey FOREIGN KEY (created_by_user_id) REFERENCES users(id) ON DELETE SET NULL; +ALTER TABLE ONLY webhooks + ADD CONSTRAINT webhooks_tenant_id_fkey FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE; + ALTER TABLE ONLY webhooks ADD CONSTRAINT webhooks_updated_by_user_id_fkey FOREIGN KEY (updated_by_user_id) REFERENCES users(id) ON DELETE SET NULL; ALTER TABLE ONLY zoekt_repos ADD CONSTRAINT zoekt_repos_repo_id_fkey FOREIGN KEY (repo_id) REFERENCES repo(id) ON DELETE CASCADE; -INSERT INTO lsif_configuration_policies VALUES (1, NULL, 'Default tip-of-branch retention policy', 'GIT_TREE', '*', true, 2016, false, false, 0, false, true, NULL, NULL, false, false); -INSERT INTO lsif_configuration_policies VALUES (2, NULL, 'Default tag retention policy', 'GIT_TAG', '*', true, 8064, false, false, 0, false, true, NULL, NULL, false, false); -INSERT INTO lsif_configuration_policies VALUES (3, NULL, 'Default commit retention policy', 'GIT_TREE', '*', true, 168, true, false, 0, false, true, NULL, NULL, false, false); +ALTER TABLE ONLY zoekt_repos + ADD CONSTRAINT zoekt_repos_tenant_id_fkey FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON UPDATE CASCADE ON DELETE CASCADE; + +INSERT INTO lsif_configuration_policies VALUES (1, NULL, 'Default tip-of-branch retention policy', 'GIT_TREE', '*', true, 2016, false, false, 0, false, true, NULL, NULL, false, false, NULL); +INSERT INTO lsif_configuration_policies VALUES (2, NULL, 'Default tag retention policy', 'GIT_TAG', '*', true, 8064, false, false, 0, false, true, NULL, NULL, false, false, NULL); +INSERT INTO lsif_configuration_policies VALUES (3, NULL, 'Default commit retention policy', 'GIT_TREE', '*', true, 168, true, false, 0, false, true, NULL, NULL, false, false, NULL); SELECT pg_catalog.setval('lsif_configuration_policies_id_seq', 3, true); -INSERT INTO roles VALUES (1, '2023-01-04 16:29:41.195966+00', true, 'USER'); -INSERT INTO roles VALUES (2, '2023-01-04 16:29:41.195966+00', true, 'SITE_ADMINISTRATOR'); +INSERT INTO roles VALUES (1, '2023-01-04 16:29:41.195966+00', true, 'USER', NULL); +INSERT INTO roles VALUES (2, '2023-01-04 16:29:41.195966+00', true, 'SITE_ADMINISTRATOR', NULL); SELECT pg_catalog.setval('roles_id_seq', 3, true); \ No newline at end of file