mirror of
https://github.com/sourcegraph/sourcegraph.git
synced 2026-02-06 15:31:48 +00:00
database: run tenant_id migration outside of a transaction (#64410)
We hit a deadlock when deploying this migration to s2. This is because within our transaction of the migration we likely didn't obtain table locks in the same order as a transaction in our application code. So this commit introduces a new migration metadata field "noTransaction". The documentation for migrator says you should create a migration per needed transactions. However, this would require us to create 100s of migrations. We believe the better approach is introducing this field and barely advertising it. When reading the code which actually runs migrations, there is no extra logic done outside of BEGIN; run_migration; COMMIT; so this change is safe. We update the migrations to avoid duplicating the function name we introduce in case something goes wrong (now that the transaction could leak out the function name). Test Plan: The actual migrations are tested by go test. I added a test assertion that we don't call Transact, but to be honest that is super sketchy. However, we couldn't actually find any test fixtures which actually run against the DB. So that would require a much deeper investment for how simple the code change is. Co-authored-by: Erik Seliger <erikseliger@me.com>
This commit is contained in:
parent
20f22d29f0
commit
cbd12608b5
@ -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 *"
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
@ -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).
|
||||
|
||||
|
||||
@ -15,6 +15,7 @@ type Definition struct {
|
||||
NonIdempotent bool
|
||||
Parents []int
|
||||
IsCreateIndexConcurrently bool
|
||||
NoTransaction bool
|
||||
IndexMetadata *IndexMetadata
|
||||
}
|
||||
|
||||
|
||||
@ -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
|
||||
}
|
||||
|
||||
@ -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 {
|
||||
|
||||
@ -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
|
||||
|
||||
@ -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) {
|
||||
|
||||
@ -1,2 +1,3 @@
|
||||
name: 'third or fourth (2)'
|
||||
parent: 10002
|
||||
noTransaction: true
|
||||
|
||||
@ -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": []
|
||||
|
||||
@ -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
|
||||
|
||||
```
|
||||
|
||||
|
||||
@ -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": []
|
||||
},
|
||||
{
|
||||
|
||||
@ -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
|
||||
|
||||
```
|
||||
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@ -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 = `
|
||||
|
||||
@ -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);
|
||||
@ -0,0 +1,3 @@
|
||||
name: add tenant id to most tables
|
||||
noTransaction: true
|
||||
parents: [1719914228]
|
||||
@ -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);
|
||||
@ -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;
|
||||
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;
|
||||
@ -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);
|
||||
@ -0,0 +1,3 @@
|
||||
name: add tenant id to most tables
|
||||
noTransaction: true
|
||||
parents: [1686315964]
|
||||
@ -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);
|
||||
@ -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;
|
||||
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;
|
||||
@ -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);
|
||||
@ -0,0 +1,3 @@
|
||||
name: Add tenant ID to most tables
|
||||
noTransaction: true
|
||||
parents: [1722961262]
|
||||
@ -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);
|
||||
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue
Block a user