@highstate/backend 0.9.18 → 0.9.19
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/chunk-5WVU2AK4.js +1535 -0
- package/dist/chunk-5WVU2AK4.js.map +1 -0
- package/dist/{chunk-OU5OQBLB.js → chunk-I7BWSAN6.js} +3 -28
- package/dist/{chunk-OU5OQBLB.js.map → chunk-I7BWSAN6.js.map} +1 -1
- package/dist/chunk-VB4YL327.js +139 -0
- package/dist/chunk-VB4YL327.js.map +1 -0
- package/dist/database/local/prisma.config.js +26 -0
- package/dist/database/local/prisma.config.js.map +1 -0
- package/dist/highstate.manifest.json +2 -1
- package/dist/index.js +7587 -7291
- package/dist/index.js.map +1 -1
- package/dist/library/package-resolution-worker.js +1 -1
- package/dist/library/package-resolution-worker.js.map +1 -1
- package/dist/library/worker/main.js +35 -29
- package/dist/library/worker/main.js.map +1 -1
- package/dist/shared/index.js +2 -2
- package/package.json +18 -9
- package/prisma/backend/_schema/layout.prisma +7 -0
- package/prisma/backend/_schema/library.prisma +17 -0
- package/prisma/backend/_schema/project.prisma +101 -0
- package/prisma/backend/_schema/pulumi.prisma +17 -0
- package/prisma/backend/postgresql/main.prisma +17 -0
- package/prisma/backend/sqlite/main.prisma +17 -0
- package/prisma/backend/sqlite/migrations/20250817070609_initiial/migration.sql +34 -0
- package/prisma/backend/sqlite/migrations/20250817104948_add_fields/migration.sql +59 -0
- package/prisma/backend/sqlite/migrations/20250818082732_add_models/migration.sql +41 -0
- package/prisma/backend/sqlite/migrations/20250818083106_a/migration.sql +19 -0
- package/prisma/backend/sqlite/migrations/20250818101945_hi/migration.sql +1 -0
- package/prisma/backend/sqlite/migrations/20250819082315_a/migration.sql +5 -0
- package/prisma/backend/sqlite/migrations/migration_lock.toml +3 -0
- package/prisma/project/api-key.prisma +27 -0
- package/prisma/project/artifact.prisma +52 -0
- package/prisma/project/custom-status.prisma +46 -0
- package/prisma/project/evaluation.prisma +35 -0
- package/prisma/project/instance.prisma +160 -0
- package/prisma/project/layout.prisma +23 -0
- package/prisma/project/lock.prisma +18 -0
- package/prisma/project/main.prisma +17 -0
- package/prisma/project/migrations/20250816081310_initial/migration.sql +300 -0
- package/prisma/project/migrations/20250816082523_test/migration.sql +72 -0
- package/prisma/project/migrations/20250818065643_update/migration.sql +42 -0
- package/prisma/project/migrations/20250818070758_a/migration.sql +8 -0
- package/prisma/project/migrations/20250818070913_a/migration.sql +8 -0
- package/prisma/project/migrations/20250818082720_add_motels/migration.sql +11 -0
- package/prisma/project/migrations/20250818112523_hello/migration.sql +35 -0
- package/prisma/project/migrations/20250819082305_a/migration.sql +14 -0
- package/prisma/project/migrations/20250819165004_add_missing_fields/migration.sql +216 -0
- package/prisma/project/migrations/20250819171309_a/migration.sql +22 -0
- package/prisma/project/migrations/20250820113949_a/migration.sql +66 -0
- package/prisma/project/migrations/20250820144256_b/migration.sql +31 -0
- package/prisma/project/migrations/20250820145547_a/migration.sql +24 -0
- package/prisma/project/migrations/20250820182517_b/migration.sql +2 -0
- package/prisma/project/migrations/20250821172324_a/migration.sql +2 -0
- package/prisma/project/migrations/20250822081339_a/migration.sql +219 -0
- package/prisma/project/migrations/20250822083742_b/migration.sql +1 -0
- package/prisma/project/migrations/20250822105134_boom/migration.sql +1 -0
- package/prisma/project/migrations/20250822141028_b/migration.sql +1 -0
- package/prisma/project/migrations/20250822142342_b/migration.sql +16 -0
- package/prisma/project/migrations/20250824072720_a/migration.sql +1 -0
- package/prisma/project/migrations/20250824093656_b/migration.sql +21 -0
- package/prisma/project/migrations/20250825082518_a/migration.sql +1 -0
- package/prisma/project/migrations/20250825085343_b/migration.sql +1 -0
- package/prisma/project/migrations/20250825091312_a/migration.sql +1 -0
- package/prisma/project/migrations/20250903095431_hi/migration.sql +44 -0
- package/prisma/project/migrations/20250903174255_a/migration.sql +24 -0
- package/prisma/project/migrations/20250908095205_hi/migration.sql +18 -0
- package/prisma/project/migrations/20250909155857_hi/migration.sql +15 -0
- package/prisma/project/migrations/migration_lock.toml +3 -0
- package/prisma/project/model.prisma +37 -0
- package/prisma/project/operation.prisma +148 -0
- package/prisma/project/page.prisma +41 -0
- package/prisma/project/secret.prisma +42 -0
- package/prisma/project/service-account.prisma +36 -0
- package/prisma/project/terminal.prisma +90 -0
- package/prisma/project/trigger.prisma +31 -0
- package/prisma/project/unlock-method.prisma +32 -0
- package/prisma/project/worker.prisma +138 -0
- package/src/artifact/abstractions.ts +13 -13
- package/src/artifact/encryption.ts +30 -54
- package/src/artifact/factory.ts +6 -9
- package/src/artifact/local.ts +33 -46
- package/src/business/api-key.ts +24 -36
- package/src/business/artifact.test.ts +978 -0
- package/src/business/artifact.ts +136 -216
- package/src/business/evaluation.ts +328 -0
- package/src/business/index.ts +5 -2
- package/src/business/instance-lock.test.ts +1060 -0
- package/src/business/instance-lock.ts +387 -78
- package/src/business/instance-state.test.ts +735 -0
- package/src/business/instance-state.ts +582 -337
- package/src/business/operation.test.ts +439 -0
- package/src/business/operation.ts +174 -208
- package/src/business/project-model.ts +258 -0
- package/src/business/project-unlock.ts +168 -126
- package/src/business/project.ts +287 -179
- package/src/business/secret.test.ts +465 -130
- package/src/business/secret.ts +186 -217
- package/src/business/settings.test.ts +695 -0
- package/src/business/settings.ts +855 -0
- package/src/business/terminal-session.ts +90 -0
- package/src/business/unit-extra.test.ts +539 -0
- package/src/business/unit-extra.ts +160 -0
- package/src/business/worker.test.ts +356 -579
- package/src/business/worker.ts +238 -339
- package/src/common/codebase.ts +65 -0
- package/src/common/index.ts +3 -5
- package/src/common/logger.ts +5 -0
- package/src/common/utils.ts +4 -3
- package/src/config.ts +10 -11
- package/src/database/_generated/backend/postgresql/client.ts +72 -0
- package/src/database/_generated/backend/postgresql/commonInputTypes.ts +350 -0
- package/src/database/_generated/backend/postgresql/enums.ts +13 -0
- package/src/database/_generated/backend/postgresql/internal/class.ts +320 -0
- package/src/database/_generated/backend/postgresql/internal/prismaNamespace.ts +1238 -0
- package/src/database/_generated/backend/postgresql/models/Library.ts +1263 -0
- package/src/database/_generated/backend/postgresql/models/Project.ts +2175 -0
- package/src/database/_generated/backend/postgresql/models/ProjectModelStorage.ts +1263 -0
- package/src/database/_generated/backend/postgresql/models/ProjectSpace.ts +1602 -0
- package/src/database/_generated/backend/postgresql/models/PulumiBackend.ts +1263 -0
- package/src/database/_generated/backend/postgresql/models/UserWorkspaseLayout.ts +1065 -0
- package/src/database/_generated/backend/postgresql/models.ts +16 -0
- package/src/database/_generated/backend/postgresql/pjtg.ts +182 -0
- package/src/database/_generated/backend/sqlite/client.ts +72 -0
- package/src/database/_generated/backend/sqlite/commonInputTypes.ts +331 -0
- package/src/database/_generated/backend/sqlite/enums.ts +13 -0
- package/src/database/_generated/backend/sqlite/internal/class.ts +318 -0
- package/src/database/_generated/backend/sqlite/internal/prismaNamespace.ts +1207 -0
- package/src/database/_generated/backend/sqlite/models/Library.ts +1261 -0
- package/src/database/_generated/backend/sqlite/models/Project.ts +2169 -0
- package/src/database/_generated/backend/sqlite/models/ProjectModelStorage.ts +1261 -0
- package/src/database/_generated/backend/sqlite/models/ProjectSpace.ts +1599 -0
- package/src/database/_generated/backend/sqlite/models/PulumiBackend.ts +1261 -0
- package/src/database/_generated/backend/sqlite/models/UserWorkspaseLayout.ts +1063 -0
- package/src/database/_generated/backend/sqlite/models.ts +16 -0
- package/src/database/_generated/backend/sqlite/pjtg.ts +182 -0
- package/src/database/_generated/project/client.ts +204 -0
- package/src/database/_generated/project/commonInputTypes.ts +827 -0
- package/src/database/_generated/project/enums.ts +104 -0
- package/src/database/_generated/project/internal/class.ts +479 -0
- package/src/database/_generated/project/internal/prismaNamespace.ts +2974 -0
- package/src/database/_generated/project/models/ApiKey.ts +1506 -0
- package/src/database/_generated/project/models/Artifact.ts +2051 -0
- package/src/database/_generated/project/models/HubModel.ts +1125 -0
- package/src/database/_generated/project/models/InstanceCustomStatus.ts +1713 -0
- package/src/database/_generated/project/models/InstanceEvaluationState.ts +1312 -0
- package/src/database/_generated/project/models/InstanceLock.ts +1268 -0
- package/src/database/_generated/project/models/InstanceModel.ts +1125 -0
- package/src/database/_generated/project/models/InstanceOperationState.ts +1707 -0
- package/src/database/_generated/project/models/InstanceState.ts +4613 -0
- package/src/database/_generated/project/models/Operation.ts +1647 -0
- package/src/database/_generated/project/models/OperationLog.ts +1455 -0
- package/src/database/_generated/project/models/Page.ts +1838 -0
- package/src/database/_generated/project/models/Secret.ts +1692 -0
- package/src/database/_generated/project/models/ServiceAccount.ts +2165 -0
- package/src/database/_generated/project/models/Terminal.ts +2038 -0
- package/src/database/_generated/project/models/TerminalSession.ts +1454 -0
- package/src/database/_generated/project/models/TerminalSessionLog.ts +1280 -0
- package/src/database/_generated/project/models/Trigger.ts +1430 -0
- package/src/database/_generated/project/models/UnlockMethod.ts +1220 -0
- package/src/database/_generated/project/models/UserCompositeViewport.ts +1280 -0
- package/src/database/_generated/project/models/UserProjectViewport.ts +1059 -0
- package/src/database/_generated/project/models/Worker.ts +1459 -0
- package/src/database/_generated/project/models/WorkerUnitRegistration.ts +1524 -0
- package/src/database/_generated/project/models/WorkerVersion.ts +1974 -0
- package/src/database/_generated/project/models/WorkerVersionLog.ts +1318 -0
- package/src/database/_generated/project/models.ts +35 -0
- package/src/database/_generated/project/pjtg.ts +182 -0
- package/src/database/abstractions.ts +19 -0
- package/src/database/factory.ts +37 -0
- package/src/database/index.ts +6 -0
- package/src/database/local/backend.ts +134 -0
- package/src/database/local/index.ts +3 -0
- package/src/database/local/meta.ts +46 -0
- package/src/database/local/prisma.config.ts +25 -0
- package/src/database/local/project.ts +39 -0
- package/src/database/manager.ts +181 -0
- package/src/database/migrate.ts +35 -0
- package/src/database/prisma.ts +56 -0
- package/src/database/well-known.ts +38 -0
- package/src/index.ts +4 -4
- package/src/library/abstractions.ts +3 -5
- package/src/library/factory.ts +1 -1
- package/src/library/local.ts +81 -26
- package/src/library/package-resolution-worker.ts +1 -1
- package/src/library/worker/evaluator.ts +40 -23
- package/src/library/worker/loader.lite.ts +1 -1
- package/src/library/worker/main.ts +3 -10
- package/src/library/worker/protocol.ts +0 -1
- package/src/lock/index.ts +0 -1
- package/src/lock/manager.ts +0 -10
- package/src/orchestrator/manager.ts +190 -104
- package/src/orchestrator/operation-context.ts +357 -0
- package/src/orchestrator/operation-plan.destroy.test.md +357 -0
- package/src/orchestrator/operation-plan.destroy.test.ts +775 -0
- package/src/orchestrator/operation-plan.fixtures.ts +213 -0
- package/src/orchestrator/operation-plan.md +198 -0
- package/src/orchestrator/operation-plan.refresh.test.md +199 -0
- package/src/orchestrator/operation-plan.refresh.test.ts +367 -0
- package/src/orchestrator/operation-plan.ts +709 -0
- package/src/orchestrator/operation-plan.update.test.md +485 -0
- package/src/orchestrator/operation-plan.update.test.ts +1066 -0
- package/src/orchestrator/operation-workset.ts +233 -578
- package/src/orchestrator/operation.ts +435 -948
- package/src/orchestrator/plan-test-builder.ts +267 -0
- package/src/project-model/abstractions.ts +118 -0
- package/src/project-model/backends/codebase.ts +365 -0
- package/src/project-model/backends/database.ts +440 -0
- package/src/project-model/errors.ts +81 -0
- package/src/project-model/factory.ts +24 -0
- package/src/project-model/index.ts +4 -0
- package/src/project-model/utils.test.ts +544 -0
- package/src/project-model/utils.ts +242 -0
- package/src/pubsub/abstractions.ts +10 -1
- package/src/pubsub/factory.ts +4 -4
- package/src/pubsub/index.ts +1 -0
- package/src/pubsub/manager.ts +29 -13
- package/src/pubsub/memory.ts +31 -0
- package/src/runner/abstractions.ts +33 -41
- package/src/runner/artifact-env.ts +19 -8
- package/src/runner/factory.ts +6 -6
- package/src/runner/force-abort.ts +3 -6
- package/src/runner/local.ts +64 -67
- package/src/runner/pulumi.ts +23 -63
- package/src/services.ts +181 -123
- package/src/shared/models/backend/index.ts +3 -1
- package/src/shared/models/backend/library.ts +9 -1
- package/src/shared/models/backend/project.ts +43 -42
- package/src/shared/models/backend/pulumi.ts +14 -0
- package/src/shared/models/backend/unlock-method.ts +1 -1
- package/src/shared/models/backend/well-known.ts +58 -0
- package/src/shared/models/base.ts +40 -26
- package/src/shared/models/errors.ts +82 -1
- package/src/shared/models/index.ts +3 -2
- package/src/shared/models/prisma.ts +36 -0
- package/src/shared/models/project/api-key.ts +37 -59
- package/src/shared/models/project/artifact.ts +16 -76
- package/src/shared/models/project/custom-status.ts +12 -0
- package/src/shared/models/project/index.ts +8 -7
- package/src/shared/models/project/lock.ts +10 -78
- package/src/shared/models/project/model.ts +19 -1
- package/src/shared/models/project/operation.ts +222 -99
- package/src/shared/models/project/page.ts +37 -48
- package/src/shared/models/project/secret.ts +29 -89
- package/src/shared/models/project/service-account.ts +12 -17
- package/src/shared/models/project/state.ts +100 -407
- package/src/shared/models/project/terminal.ts +75 -88
- package/src/shared/models/project/trigger.ts +13 -49
- package/src/shared/models/project/unlock-method.ts +20 -26
- package/src/shared/models/project/worker.ts +89 -90
- package/src/shared/resolvers/graph-resolver.ts +21 -0
- package/src/shared/resolvers/index.ts +1 -1
- package/src/shared/resolvers/input-hash.ts +24 -14
- package/src/shared/resolvers/input.ts +1 -1
- package/src/shared/resolvers/registry.ts +5 -4
- package/src/shared/resolvers/state.ts +12 -1
- package/src/shared/resolvers/validation.ts +7 -3
- package/src/shared/utils/index.ts +1 -2
- package/src/shared/utils/promise-tracker.ts +30 -3
- package/src/terminal/abstractions.ts +1 -1
- package/src/terminal/docker.ts +3 -3
- package/src/terminal/manager.ts +102 -118
- package/src/test-utils/database.ts +119 -0
- package/src/test-utils/index.ts +2 -0
- package/src/test-utils/services.ts +134 -0
- package/src/unlock/abstractions.ts +5 -23
- package/src/unlock/memory.ts +9 -14
- package/src/worker/abstractions.ts +7 -4
- package/src/worker/docker.ts +14 -19
- package/src/worker/manager.ts +366 -97
- package/dist/chunk-NAAIDR4U.js +0 -8499
- package/dist/chunk-NAAIDR4U.js.map +0 -1
- package/dist/chunk-Y7DXREVO.js +0 -1745
- package/dist/chunk-Y7DXREVO.js.map +0 -1
- package/dist/magic-string.es-5ABAC4JN.js +0 -1292
- package/dist/magic-string.es-5ABAC4JN.js.map +0 -1
- package/src/business/__traces__/secret/update-instance-secrets/create-and-delete-secrets-simultaneously.md +0 -356
- package/src/business/__traces__/secret/update-instance-secrets/create-new-secrets-for-instance.md +0 -274
- package/src/business/__traces__/secret/update-instance-secrets/delete-existing-secrets.md +0 -223
- package/src/business/__traces__/secret/update-instance-secrets/no-op-when-no-changes.md +0 -147
- package/src/business/__traces__/secret/update-instance-secrets/update-existing-secrets.md +0 -280
- package/src/business/__traces__/worker/update-unit-registrations/add-new-unit-registration-when-other-exists.md +0 -360
- package/src/business/__traces__/worker/update-unit-registrations/add-new-unit-registration.md +0 -215
- package/src/business/__traces__/worker/update-unit-registrations/create-multiple-workers-with-different-identities.md +0 -427
- package/src/business/__traces__/worker/update-unit-registrations/handle-nonexistent-registration-id-gracefully.md +0 -217
- package/src/business/__traces__/worker/update-unit-registrations/no-op-when-no-changes.md +0 -132
- package/src/business/__traces__/worker/update-unit-registrations/recreate-worker-when-image-changes.md +0 -454
- package/src/business/__traces__/worker/update-unit-registrations/recreate-worker-when-image-version-changes.md +0 -426
- package/src/business/__traces__/worker/update-unit-registrations/recreate-worker-with-same-identity-reuses-service-account.md +0 -372
- package/src/business/__traces__/worker/update-unit-registrations/remove-one-of-multiple-unit-registrations.md +0 -383
- package/src/business/__traces__/worker/update-unit-registrations/remove-unit-registration.md +0 -245
- package/src/business/__traces__/worker/update-unit-registrations/update-existing-unit-registration-when-params-change.md +0 -174
- package/src/business/__traces__/worker/update-unit-registrations/update-params-and-image-simultaneously.md +0 -432
- package/src/business/__traces__/worker/update-unit-registrations/worker-with-multiple-registrations-not-deleted-when-one-removed.md +0 -220
- package/src/business/backend-unlock.ts +0 -10
- package/src/common/clock.ts +0 -18
- package/src/common/performance.ts +0 -44
- package/src/common/random.ts +0 -68
- package/src/common/test/index.ts +0 -2
- package/src/common/test/render.ts +0 -98
- package/src/common/test/tracer.ts +0 -359
- package/src/hotstate/abstractions.ts +0 -48
- package/src/hotstate/factory.ts +0 -17
- package/src/hotstate/index.ts +0 -3
- package/src/hotstate/manager.ts +0 -192
- package/src/hotstate/memory.ts +0 -100
- package/src/hotstate/validation.ts +0 -100
- package/src/lock/test.ts +0 -108
- package/src/project/abstractions.ts +0 -78
- package/src/project/evaluation.ts +0 -248
- package/src/project/factory.ts +0 -11
- package/src/project/index.ts +0 -3
- package/src/project/local.ts +0 -417
- package/src/pubsub/local.ts +0 -36
- package/src/pubsub/validation.ts +0 -33
- package/src/shared/utils/args.ts +0 -25
- package/src/state/abstractions.ts +0 -289
- package/src/state/encryption.ts +0 -98
- package/src/state/factory.ts +0 -20
- package/src/state/index.ts +0 -7
- package/src/state/local/backend.ts +0 -106
- package/src/state/local/collection.ts +0 -361
- package/src/state/local/index.ts +0 -2
- package/src/state/manager.ts +0 -890
- package/src/state/memory/backend.ts +0 -70
- package/src/state/memory/collection.ts +0 -270
- package/src/state/memory/index.ts +0 -2
- package/src/state/repository/index.ts +0 -2
- package/src/state/repository/repository.index.ts +0 -193
- package/src/state/repository/repository.ts +0 -507
- package/src/state/test.ts +0 -457
- /package/src/{state → database/local}/keyring.ts +0 -0
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
model ApiKey {
|
|
2
|
+
/// The CUIDv2 of the API key.
|
|
3
|
+
id String @id @default(cuid(2))
|
|
4
|
+
|
|
5
|
+
/// The metadata of the API key managed by the backend.
|
|
6
|
+
///
|
|
7
|
+
/// [ApiKeyMeta]
|
|
8
|
+
meta Json
|
|
9
|
+
|
|
10
|
+
/// The ID of the service account impersonated by this API key.
|
|
11
|
+
serviceAccountId String
|
|
12
|
+
|
|
13
|
+
/// The API token for authentication.
|
|
14
|
+
token String @unique
|
|
15
|
+
|
|
16
|
+
/// The time when the API key was created.
|
|
17
|
+
createdAt DateTime @default(now())
|
|
18
|
+
|
|
19
|
+
/// The time when the API key was last updated.
|
|
20
|
+
updatedAt DateTime @updatedAt
|
|
21
|
+
|
|
22
|
+
/// The worker version that owns this API key.
|
|
23
|
+
worker WorkerVersion?
|
|
24
|
+
|
|
25
|
+
/// The service account which this API key impersonates.
|
|
26
|
+
serviceAccount ServiceAccount @relation(fields: [serviceAccountId], references: [id], onDelete: Cascade)
|
|
27
|
+
}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
/// The artifact represents a file or folder stored in the system.
|
|
2
|
+
///
|
|
3
|
+
/// It can be produced by units or manually uploaded via API by service accounts.
|
|
4
|
+
///
|
|
5
|
+
/// Since different actors can produce the same artifact with the same content and hash,
|
|
6
|
+
/// there is the ownership/usage concept to track which entities produce or use the artifact.
|
|
7
|
+
/// The "ownership" and "usage" are synonymous in this context and often referred to as "usage".
|
|
8
|
+
///
|
|
9
|
+
/// When no usages are present, the artifact will be automatically garbage collected after a certain period.
|
|
10
|
+
model Artifact {
|
|
11
|
+
/// The CUIDv2 of the artifact.
|
|
12
|
+
id String @id @default(cuid(2))
|
|
13
|
+
|
|
14
|
+
/// The metadata of the artifact managed by the backend.
|
|
15
|
+
///
|
|
16
|
+
/// Since multiple actors can produce the same artifact,
|
|
17
|
+
/// this metadata is the last one provided by any actor.
|
|
18
|
+
///
|
|
19
|
+
/// [CommonObjectMeta]
|
|
20
|
+
meta Json
|
|
21
|
+
|
|
22
|
+
/// The SHA256 hash of the artifact content.
|
|
23
|
+
hash String @unique
|
|
24
|
+
|
|
25
|
+
/// The size of the compressed artifact content in bytes.
|
|
26
|
+
///
|
|
27
|
+
/// Does not represent the size of the original file or folder,
|
|
28
|
+
/// but the size used to store the artifact in the system.
|
|
29
|
+
size Int
|
|
30
|
+
|
|
31
|
+
/// The chunk size of the artifact content in bytes.
|
|
32
|
+
/// Used to split the artifact into smaller chunks for storage.
|
|
33
|
+
chunkSize Int
|
|
34
|
+
|
|
35
|
+
/// The timestamp when the artifact fist appeared in the system.
|
|
36
|
+
createdAt DateTime @default(now())
|
|
37
|
+
|
|
38
|
+
/// The timestamp when the artifact was last updated.
|
|
39
|
+
updatedAt DateTime @updatedAt
|
|
40
|
+
|
|
41
|
+
/// The service accounts using this artifact.
|
|
42
|
+
serviceAccounts ServiceAccount[]
|
|
43
|
+
|
|
44
|
+
/// The instances using this artifact.
|
|
45
|
+
instances InstanceState[]
|
|
46
|
+
|
|
47
|
+
/// The terminals using this artifact.
|
|
48
|
+
terminals Terminal[]
|
|
49
|
+
|
|
50
|
+
/// The pages using this artifact.
|
|
51
|
+
pages Page[]
|
|
52
|
+
}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
model InstanceCustomStatus {
|
|
2
|
+
/// The ID of the instance state this status belongs to.
|
|
3
|
+
stateId String
|
|
4
|
+
|
|
5
|
+
/// The ID of the service account which attached this custom status.
|
|
6
|
+
serviceAccountId String
|
|
7
|
+
|
|
8
|
+
/// The name of the custom status unique within the instance and service account.
|
|
9
|
+
name String
|
|
10
|
+
|
|
11
|
+
/// The metadata of the custom status managed by the backend.
|
|
12
|
+
///
|
|
13
|
+
/// [CommonObjectMeta]
|
|
14
|
+
meta Json
|
|
15
|
+
|
|
16
|
+
/// The status value of the custom status.
|
|
17
|
+
value String
|
|
18
|
+
|
|
19
|
+
/// The message describing the instance's custom status.
|
|
20
|
+
///
|
|
21
|
+
/// Can be used to provide additional context or information about the status.
|
|
22
|
+
///
|
|
23
|
+
/// The message will be displayed in the 800x600 ANSI terminal in the UI,
|
|
24
|
+
/// so differenet TUI elements should be drawn within this area.
|
|
25
|
+
message String?
|
|
26
|
+
|
|
27
|
+
/// The order of the custom status in the list of statuses.
|
|
28
|
+
///
|
|
29
|
+
/// Should be values from 0 to 100, where 0 is the highest priority.
|
|
30
|
+
/// By default, the order is 50.
|
|
31
|
+
order Int @default(50)
|
|
32
|
+
|
|
33
|
+
/// The time when the custom status was first attached to the instance.
|
|
34
|
+
createdAt DateTime @default(now())
|
|
35
|
+
|
|
36
|
+
/// The time when the custom status was last updated.
|
|
37
|
+
updatedAt DateTime @updatedAt
|
|
38
|
+
|
|
39
|
+
/// The instance this custom status belongs to.
|
|
40
|
+
state InstanceState @relation(fields: [stateId], references: [id])
|
|
41
|
+
|
|
42
|
+
/// The service account this custom status belongs to.
|
|
43
|
+
serviceAccount ServiceAccount @relation(fields: [serviceAccountId], references: [id])
|
|
44
|
+
|
|
45
|
+
@@id([stateId, serviceAccountId, name]) // the name must be unique within the instance and service account
|
|
46
|
+
}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
enum InstanceEvaluationStatus {
|
|
2
|
+
/// transient statuses (not persisted in the database)
|
|
3
|
+
evaluating
|
|
4
|
+
|
|
5
|
+
/// stable statuses
|
|
6
|
+
evaluated
|
|
7
|
+
error
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
model InstanceEvaluationState {
|
|
11
|
+
/// The ID of the state of the instance.
|
|
12
|
+
stateId String @id
|
|
13
|
+
|
|
14
|
+
/// The status of the instance evaluation.
|
|
15
|
+
status InstanceEvaluationStatus
|
|
16
|
+
|
|
17
|
+
/// The message describing the evaluation status.
|
|
18
|
+
/// If the evaluation is failed, this message will contain the error description.
|
|
19
|
+
message String?
|
|
20
|
+
|
|
21
|
+
/// The model produced by the evaluation.
|
|
22
|
+
///
|
|
23
|
+
/// Will be `null` if the evaluation is failed.
|
|
24
|
+
///
|
|
25
|
+
/// Can be set for both: real composite instances and virtual instances produced by the evaluation.
|
|
26
|
+
///
|
|
27
|
+
/// [InstanceModel]
|
|
28
|
+
model Json?
|
|
29
|
+
|
|
30
|
+
/// The time when the last evaluation was finished.
|
|
31
|
+
evaluatedAt DateTime @updatedAt
|
|
32
|
+
|
|
33
|
+
/// The instance this state belongs to.
|
|
34
|
+
state InstanceState @relation(fields: [stateId], references: [id])
|
|
35
|
+
}
|
|
@@ -0,0 +1,160 @@
|
|
|
1
|
+
enum InstanceStatus {
|
|
2
|
+
/// The instance is exists in the model (resident or virtual), but not yet deployed or was completely destroyed.
|
|
3
|
+
///
|
|
4
|
+
/// "attempted", "deployed" and "failed" instances cannot be transitioned back to "undeployed" after
|
|
5
|
+
/// successful "destroy" operation.
|
|
6
|
+
undeployed
|
|
7
|
+
|
|
8
|
+
/// The instance was tryied to be initially deployed.
|
|
9
|
+
///
|
|
10
|
+
/// Normally, this status is very short-lived, and here to indicate that the instance
|
|
11
|
+
/// cannot be safely deleted from the the model until it will be completely destroyed.
|
|
12
|
+
attempted
|
|
13
|
+
|
|
14
|
+
/// The initial deployment of the instance was successful.
|
|
15
|
+
///
|
|
16
|
+
/// The transition of "deployed -> failed" is not possible, so consequent failed operations
|
|
17
|
+
/// will not affect this status.
|
|
18
|
+
///
|
|
19
|
+
/// Like "attempted", that instance cannot be safely deleted from the model until it will be completely destroyed.
|
|
20
|
+
deployed
|
|
21
|
+
|
|
22
|
+
/// The initial deployment of the instance failed.
|
|
23
|
+
/// It can still be transitioned to "deployed" by a successful operation
|
|
24
|
+
///
|
|
25
|
+
/// Like "attempted", that instance cannot be safely deleted from the model until it will be completely destroyed.
|
|
26
|
+
failed
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
enum InstanceSource {
|
|
30
|
+
/// The instance is defined in the project model.
|
|
31
|
+
resident
|
|
32
|
+
|
|
33
|
+
/// The instance is produced by evaluation of composite instance.
|
|
34
|
+
virtual
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
model InstanceState {
|
|
38
|
+
/// The surrogate CUIDv2 primary key of the instance to allow renaming instances.
|
|
39
|
+
id String @id @default(cuid(2))
|
|
40
|
+
|
|
41
|
+
/// The ID of the instance managed by the system.
|
|
42
|
+
///
|
|
43
|
+
/// [InstanceId]
|
|
44
|
+
instanceId String @unique
|
|
45
|
+
|
|
46
|
+
/// The status of the instance.
|
|
47
|
+
status InstanceStatus
|
|
48
|
+
|
|
49
|
+
/// The source of the instance.
|
|
50
|
+
source InstanceSource
|
|
51
|
+
|
|
52
|
+
/// The kind of the instance.
|
|
53
|
+
///
|
|
54
|
+
/// [InstanceKind]
|
|
55
|
+
kind String
|
|
56
|
+
|
|
57
|
+
/// The ID of the parent instance state, if this instance is a child of another composite instance.
|
|
58
|
+
parentId String?
|
|
59
|
+
|
|
60
|
+
/// The 32-bit nonce used to invalidate the input hash when secrets are updated.
|
|
61
|
+
inputHashNonce Int?
|
|
62
|
+
|
|
63
|
+
/// The status fields produced by the last operation.
|
|
64
|
+
///
|
|
65
|
+
/// [InstanceStatusFields]
|
|
66
|
+
statusFields Json?
|
|
67
|
+
|
|
68
|
+
/// The calculated instance CRC32 input hash at the moment of last operation completion.
|
|
69
|
+
///
|
|
70
|
+
/// This hash covers:
|
|
71
|
+
/// - the instance's configuration (name, args, secret hashes);
|
|
72
|
+
/// - tWorkerVersionponent definition hash;
|
|
73
|
+
/// - the unit's source hash (if applicable);
|
|
74
|
+
/// - the input hashes and output hashes of all input instances.
|
|
75
|
+
inputHash Int?
|
|
76
|
+
|
|
77
|
+
/// The CRC32 of the output produced by the instance at the moment of last operation completion.
|
|
78
|
+
///
|
|
79
|
+
/// Does not depend on anything except the instance's output.
|
|
80
|
+
outputHash Int?
|
|
81
|
+
|
|
82
|
+
/// The calculated CRC32 dependency output hash at the moment of last operation completion.
|
|
83
|
+
///
|
|
84
|
+
/// This hash is calculated as combination of output hashes of all input instances and nothing else.
|
|
85
|
+
///
|
|
86
|
+
/// The primary use case of this hash is to "short-circuit" execution:
|
|
87
|
+
/// if the outputs of input instances have not changed, dependent instances can skip execution,
|
|
88
|
+
/// even if their input hashes changed due to upstream config changes.
|
|
89
|
+
/// This prevents unnecessary re-execution of the entire dependency graph when only non-output-affecting inputs are modified.
|
|
90
|
+
dependencyOutputHash Int?
|
|
91
|
+
|
|
92
|
+
/// The mapping of instance output names to artifact IDs passed via them.
|
|
93
|
+
///
|
|
94
|
+
/// Used to authorize access to artifacts for other instances connected to these outputs.
|
|
95
|
+
///
|
|
96
|
+
/// [InstanceArtifactIds]
|
|
97
|
+
exportedArtifactIds Json?
|
|
98
|
+
|
|
99
|
+
/// The count of Pulumi resources currently managed by this instance.
|
|
100
|
+
currentResourceCount Int?
|
|
101
|
+
|
|
102
|
+
/// The message describing the current state of the instance.
|
|
103
|
+
message String?
|
|
104
|
+
|
|
105
|
+
/// The snapshot of the instance model at the moment of last non-preview operation start.
|
|
106
|
+
///
|
|
107
|
+
/// Null if the instance was never operated on.
|
|
108
|
+
///
|
|
109
|
+
/// [InstanceModel]
|
|
110
|
+
model Json?
|
|
111
|
+
|
|
112
|
+
/// The snapshot of the resolved inputs at the moment of last non-preview operation start.
|
|
113
|
+
///
|
|
114
|
+
/// Null if the instance was never operated on.
|
|
115
|
+
///
|
|
116
|
+
/// [InstanceResolvedInputs]
|
|
117
|
+
resolvedInputs Json?
|
|
118
|
+
|
|
119
|
+
/// The parent instance.
|
|
120
|
+
parent InstanceState? @relation("InstanceHierarchy", fields: [parentId], references: [id])
|
|
121
|
+
|
|
122
|
+
/// The child instances, if any.
|
|
123
|
+
children InstanceState[] @relation("InstanceHierarchy")
|
|
124
|
+
|
|
125
|
+
/// The evaluation state of this instance.
|
|
126
|
+
evaluationState InstanceEvaluationState?
|
|
127
|
+
|
|
128
|
+
/// The operation states associated with this instance.
|
|
129
|
+
operationStates InstanceOperationState[]
|
|
130
|
+
|
|
131
|
+
/// The secrets associated with this instance.
|
|
132
|
+
secrets Secret[]
|
|
133
|
+
|
|
134
|
+
/// The terminals associated with this instance.
|
|
135
|
+
terminals Terminal[]
|
|
136
|
+
|
|
137
|
+
/// The pages associated with this instance.
|
|
138
|
+
pages Page[]
|
|
139
|
+
|
|
140
|
+
/// The triggers associated with this instance.
|
|
141
|
+
triggers Trigger[]
|
|
142
|
+
|
|
143
|
+
/// Custom statuses for this instance.
|
|
144
|
+
customStatuses InstanceCustomStatus[]
|
|
145
|
+
|
|
146
|
+
/// The lock that is currently held on this instance.
|
|
147
|
+
lock InstanceLock?
|
|
148
|
+
|
|
149
|
+
/// Worker registrations associated with this instance.
|
|
150
|
+
workerRegistrations WorkerUnitRegistration[]
|
|
151
|
+
|
|
152
|
+
/// The artifacts produced or used by this instance.
|
|
153
|
+
artifacts Artifact[]
|
|
154
|
+
|
|
155
|
+
/// The operation logs associated with this instance.
|
|
156
|
+
operationLogs OperationLog[]
|
|
157
|
+
|
|
158
|
+
/// The user viewports associated with this instance.
|
|
159
|
+
userViewports UserCompositeViewport[]
|
|
160
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
model UserProjectViewport {
|
|
2
|
+
/// The opaque ID of the user to which this viewport belongs.
|
|
3
|
+
userId String @id
|
|
4
|
+
|
|
5
|
+
/// The viewport of the user project managed by the frontend.
|
|
6
|
+
viewport Json
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
model UserCompositeViewport {
|
|
10
|
+
/// The opaque ID of the user to which this viewport belongs.
|
|
11
|
+
userId String
|
|
12
|
+
|
|
13
|
+
/// The ID of the state of the composite instance to which this viewport belongs.
|
|
14
|
+
stateId String
|
|
15
|
+
|
|
16
|
+
/// The viewport of the user composite instance managed by the frontend.
|
|
17
|
+
viewport Json
|
|
18
|
+
|
|
19
|
+
/// The instance state to which this viewport belongs.
|
|
20
|
+
state InstanceState @relation(fields: [stateId], references: [id])
|
|
21
|
+
|
|
22
|
+
@@id([userId, stateId])
|
|
23
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
model InstanceLock {
|
|
2
|
+
/// The ID of the instance state being locked.
|
|
3
|
+
stateId String @id
|
|
4
|
+
|
|
5
|
+
/// The metadata of the lock managed by the backend.
|
|
6
|
+
///
|
|
7
|
+
/// [CommonObjectMeta]
|
|
8
|
+
meta Json
|
|
9
|
+
|
|
10
|
+
/// The CUIDv2 token to ensure ownership of the lock.
|
|
11
|
+
token String
|
|
12
|
+
|
|
13
|
+
/// The time when the lock was acquired.
|
|
14
|
+
acquiredAt DateTime @default(now())
|
|
15
|
+
|
|
16
|
+
/// The instance being locked.
|
|
17
|
+
state InstanceState @relation(fields: [stateId], references: [id])
|
|
18
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
datasource db {
|
|
2
|
+
provider = "sqlite"
|
|
3
|
+
directUrl = env("HIGHSTATE_MIGRATION_DATABASE_URL")
|
|
4
|
+
}
|
|
5
|
+
|
|
6
|
+
generator client {
|
|
7
|
+
provider = "prisma-client"
|
|
8
|
+
previewFeatures = ["queryCompiler", "driverAdapters"]
|
|
9
|
+
output = "../../src/database/_generated/project"
|
|
10
|
+
moduleFormat = "esm"
|
|
11
|
+
generatedFileExtension = "ts"
|
|
12
|
+
importFileExtension = "ts"
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
generator json {
|
|
16
|
+
provider = "prisma-json-types-generator"
|
|
17
|
+
}
|
|
@@ -0,0 +1,300 @@
|
|
|
1
|
+
-- CreateTable
|
|
2
|
+
CREATE TABLE "ApiKey" (
|
|
3
|
+
"id" TEXT NOT NULL PRIMARY KEY,
|
|
4
|
+
"meta" JSONB NOT NULL,
|
|
5
|
+
"scopes" JSONB NOT NULL,
|
|
6
|
+
"token" TEXT NOT NULL
|
|
7
|
+
);
|
|
8
|
+
|
|
9
|
+
-- CreateTable
|
|
10
|
+
CREATE TABLE "Artifact" (
|
|
11
|
+
"id" TEXT NOT NULL PRIMARY KEY,
|
|
12
|
+
"meta" JSONB NOT NULL,
|
|
13
|
+
"hash" TEXT NOT NULL,
|
|
14
|
+
"size" INTEGER NOT NULL,
|
|
15
|
+
"createdAt" DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
|
16
|
+
"updatedAt" DATETIME NOT NULL
|
|
17
|
+
);
|
|
18
|
+
|
|
19
|
+
-- CreateTable
|
|
20
|
+
CREATE TABLE "InstanceCustomStatus" (
|
|
21
|
+
"instanceId" TEXT NOT NULL,
|
|
22
|
+
"name" TEXT NOT NULL,
|
|
23
|
+
"meta" JSONB NOT NULL,
|
|
24
|
+
"value" TEXT NOT NULL,
|
|
25
|
+
"message" TEXT,
|
|
26
|
+
"order" INTEGER NOT NULL DEFAULT 50,
|
|
27
|
+
|
|
28
|
+
PRIMARY KEY ("instanceId", "name"),
|
|
29
|
+
CONSTRAINT "InstanceCustomStatus_instanceId_fkey" FOREIGN KEY ("instanceId") REFERENCES "InstanceState" ("id") ON DELETE RESTRICT ON UPDATE CASCADE
|
|
30
|
+
);
|
|
31
|
+
|
|
32
|
+
-- CreateTable
|
|
33
|
+
CREATE TABLE "InstanceEvaluationState" (
|
|
34
|
+
"instanceId" TEXT NOT NULL PRIMARY KEY,
|
|
35
|
+
"status" TEXT NOT NULL,
|
|
36
|
+
"message" TEXT,
|
|
37
|
+
"model" JSONB,
|
|
38
|
+
CONSTRAINT "InstanceEvaluationState_instanceId_fkey" FOREIGN KEY ("instanceId") REFERENCES "InstanceState" ("id") ON DELETE RESTRICT ON UPDATE CASCADE
|
|
39
|
+
);
|
|
40
|
+
|
|
41
|
+
-- CreateTable
|
|
42
|
+
CREATE TABLE "InstanceState" (
|
|
43
|
+
"id" TEXT NOT NULL PRIMARY KEY,
|
|
44
|
+
"status" TEXT NOT NULL,
|
|
45
|
+
"kind" TEXT NOT NULL,
|
|
46
|
+
"inputHashNonce" INTEGER,
|
|
47
|
+
"lastOperationId" TEXT,
|
|
48
|
+
"statusFields" JSONB,
|
|
49
|
+
"inputHash" INTEGER,
|
|
50
|
+
"outputHash" INTEGER,
|
|
51
|
+
"dependencyOutputHash" INTEGER,
|
|
52
|
+
CONSTRAINT "InstanceState_lastOperationId_fkey" FOREIGN KEY ("lastOperationId") REFERENCES "Operation" ("id") ON DELETE SET NULL ON UPDATE CASCADE,
|
|
53
|
+
CONSTRAINT "InstanceState_id_lastOperationId_fkey" FOREIGN KEY ("id", "lastOperationId") REFERENCES "InstanceOperationState" ("instanceId", "operationId") ON DELETE RESTRICT ON UPDATE CASCADE
|
|
54
|
+
);
|
|
55
|
+
|
|
56
|
+
-- CreateTable
|
|
57
|
+
CREATE TABLE "InstanceLock" (
|
|
58
|
+
"instanceId" TEXT NOT NULL PRIMARY KEY,
|
|
59
|
+
"meta" JSONB NOT NULL,
|
|
60
|
+
CONSTRAINT "InstanceLock_instanceId_fkey" FOREIGN KEY ("instanceId") REFERENCES "InstanceState" ("id") ON DELETE RESTRICT ON UPDATE CASCADE
|
|
61
|
+
);
|
|
62
|
+
|
|
63
|
+
-- CreateTable
|
|
64
|
+
CREATE TABLE "Operation" (
|
|
65
|
+
"id" TEXT NOT NULL PRIMARY KEY,
|
|
66
|
+
"meta" JSONB NOT NULL,
|
|
67
|
+
"type" TEXT NOT NULL,
|
|
68
|
+
"options" JSONB NOT NULL,
|
|
69
|
+
"requestedInstanceIds" JSONB NOT NULL,
|
|
70
|
+
"startedAt" DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
|
71
|
+
"completedAt" DATETIME
|
|
72
|
+
);
|
|
73
|
+
|
|
74
|
+
-- CreateTable
|
|
75
|
+
CREATE TABLE "InstanceOperationState" (
|
|
76
|
+
"operationId" TEXT NOT NULL,
|
|
77
|
+
"instanceId" TEXT NOT NULL,
|
|
78
|
+
"parentId" TEXT,
|
|
79
|
+
"status" TEXT NOT NULL,
|
|
80
|
+
"message" TEXT,
|
|
81
|
+
"currentResourceCount" INTEGER,
|
|
82
|
+
"totalResourceCount" INTEGER,
|
|
83
|
+
"args" JSONB NOT NULL,
|
|
84
|
+
"resolvedInputs" JSONB NOT NULL,
|
|
85
|
+
|
|
86
|
+
PRIMARY KEY ("operationId", "instanceId"),
|
|
87
|
+
CONSTRAINT "InstanceOperationState_operationId_fkey" FOREIGN KEY ("operationId") REFERENCES "Operation" ("id") ON DELETE RESTRICT ON UPDATE CASCADE,
|
|
88
|
+
CONSTRAINT "InstanceOperationState_instanceId_fkey" FOREIGN KEY ("instanceId") REFERENCES "InstanceState" ("id") ON DELETE RESTRICT ON UPDATE CASCADE
|
|
89
|
+
);
|
|
90
|
+
|
|
91
|
+
-- CreateTable
|
|
92
|
+
CREATE TABLE "OperationLog" (
|
|
93
|
+
"id" TEXT NOT NULL PRIMARY KEY,
|
|
94
|
+
"operationId" TEXT NOT NULL,
|
|
95
|
+
"instanceId" TEXT,
|
|
96
|
+
"content" TEXT NOT NULL,
|
|
97
|
+
CONSTRAINT "OperationLog_operationId_fkey" FOREIGN KEY ("operationId") REFERENCES "Operation" ("id") ON DELETE RESTRICT ON UPDATE CASCADE,
|
|
98
|
+
CONSTRAINT "OperationLog_instanceId_fkey" FOREIGN KEY ("instanceId") REFERENCES "InstanceState" ("id") ON DELETE SET NULL ON UPDATE CASCADE
|
|
99
|
+
);
|
|
100
|
+
|
|
101
|
+
-- CreateTable
|
|
102
|
+
CREATE TABLE "Page" (
|
|
103
|
+
"id" TEXT NOT NULL PRIMARY KEY,
|
|
104
|
+
"meta" JSONB NOT NULL,
|
|
105
|
+
"instanceId" TEXT,
|
|
106
|
+
"serviceAccountId" TEXT,
|
|
107
|
+
"content" JSONB NOT NULL,
|
|
108
|
+
CONSTRAINT "Page_instanceId_fkey" FOREIGN KEY ("instanceId") REFERENCES "InstanceState" ("id") ON DELETE SET NULL ON UPDATE CASCADE,
|
|
109
|
+
CONSTRAINT "Page_serviceAccountId_fkey" FOREIGN KEY ("serviceAccountId") REFERENCES "ServiceAccount" ("id") ON DELETE SET NULL ON UPDATE CASCADE
|
|
110
|
+
);
|
|
111
|
+
|
|
112
|
+
-- CreateTable
|
|
113
|
+
CREATE TABLE "Secret" (
|
|
114
|
+
"id" TEXT NOT NULL PRIMARY KEY,
|
|
115
|
+
"meta" JSONB NOT NULL,
|
|
116
|
+
"instanceId" TEXT,
|
|
117
|
+
"name" TEXT,
|
|
118
|
+
"systemName" TEXT,
|
|
119
|
+
"serviceAccountId" TEXT,
|
|
120
|
+
"content" JSONB NOT NULL,
|
|
121
|
+
CONSTRAINT "Secret_instanceId_fkey" FOREIGN KEY ("instanceId") REFERENCES "InstanceState" ("id") ON DELETE SET NULL ON UPDATE CASCADE,
|
|
122
|
+
CONSTRAINT "Secret_serviceAccountId_fkey" FOREIGN KEY ("serviceAccountId") REFERENCES "ServiceAccount" ("id") ON DELETE SET NULL ON UPDATE CASCADE
|
|
123
|
+
);
|
|
124
|
+
|
|
125
|
+
-- CreateTable
|
|
126
|
+
CREATE TABLE "ServiceAccount" (
|
|
127
|
+
"id" TEXT NOT NULL PRIMARY KEY,
|
|
128
|
+
"meta" JSONB NOT NULL
|
|
129
|
+
);
|
|
130
|
+
|
|
131
|
+
-- CreateTable
|
|
132
|
+
CREATE TABLE "Terminal" (
|
|
133
|
+
"id" TEXT NOT NULL PRIMARY KEY,
|
|
134
|
+
"meta" JSONB NOT NULL,
|
|
135
|
+
"spec" JSONB NOT NULL,
|
|
136
|
+
"instanceId" TEXT,
|
|
137
|
+
"name" TEXT,
|
|
138
|
+
"serviceAccountId" TEXT,
|
|
139
|
+
CONSTRAINT "Terminal_instanceId_fkey" FOREIGN KEY ("instanceId") REFERENCES "InstanceState" ("id") ON DELETE SET NULL ON UPDATE CASCADE,
|
|
140
|
+
CONSTRAINT "Terminal_serviceAccountId_fkey" FOREIGN KEY ("serviceAccountId") REFERENCES "ServiceAccount" ("id") ON DELETE SET NULL ON UPDATE CASCADE
|
|
141
|
+
);
|
|
142
|
+
|
|
143
|
+
-- CreateTable
|
|
144
|
+
CREATE TABLE "TerminalSession" (
|
|
145
|
+
"id" TEXT NOT NULL PRIMARY KEY,
|
|
146
|
+
"meta" JSONB NOT NULL,
|
|
147
|
+
"terminalId" TEXT NOT NULL,
|
|
148
|
+
CONSTRAINT "TerminalSession_terminalId_fkey" FOREIGN KEY ("terminalId") REFERENCES "Terminal" ("id") ON DELETE RESTRICT ON UPDATE CASCADE
|
|
149
|
+
);
|
|
150
|
+
|
|
151
|
+
-- CreateTable
|
|
152
|
+
CREATE TABLE "TerminalSessionLog" (
|
|
153
|
+
"id" TEXT NOT NULL PRIMARY KEY,
|
|
154
|
+
"sessionId" TEXT NOT NULL,
|
|
155
|
+
"content" TEXT NOT NULL,
|
|
156
|
+
CONSTRAINT "TerminalSessionLog_sessionId_fkey" FOREIGN KEY ("sessionId") REFERENCES "TerminalSession" ("id") ON DELETE RESTRICT ON UPDATE CASCADE
|
|
157
|
+
);
|
|
158
|
+
|
|
159
|
+
-- CreateTable
|
|
160
|
+
CREATE TABLE "Trigger" (
|
|
161
|
+
"id" TEXT NOT NULL PRIMARY KEY,
|
|
162
|
+
"meta" JSONB NOT NULL,
|
|
163
|
+
"instanceId" TEXT NOT NULL,
|
|
164
|
+
"name" TEXT NOT NULL,
|
|
165
|
+
"spec" JSONB NOT NULL,
|
|
166
|
+
CONSTRAINT "Trigger_instanceId_fkey" FOREIGN KEY ("instanceId") REFERENCES "InstanceState" ("id") ON DELETE RESTRICT ON UPDATE CASCADE
|
|
167
|
+
);
|
|
168
|
+
|
|
169
|
+
-- CreateTable
|
|
170
|
+
CREATE TABLE "UnlockMethod" (
|
|
171
|
+
"id" TEXT NOT NULL PRIMARY KEY,
|
|
172
|
+
"meta" JSONB NOT NULL,
|
|
173
|
+
"type" TEXT NOT NULL,
|
|
174
|
+
"encryptedIdentity" TEXT NOT NULL,
|
|
175
|
+
"recipient" TEXT NOT NULL
|
|
176
|
+
);
|
|
177
|
+
|
|
178
|
+
-- CreateTable
|
|
179
|
+
CREATE TABLE "Worker" (
|
|
180
|
+
"id" TEXT NOT NULL PRIMARY KEY,
|
|
181
|
+
"identity" TEXT NOT NULL,
|
|
182
|
+
"serviceAccountId" TEXT NOT NULL,
|
|
183
|
+
"createdAt" DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
|
184
|
+
CONSTRAINT "Worker_serviceAccountId_fkey" FOREIGN KEY ("serviceAccountId") REFERENCES "ServiceAccount" ("id") ON DELETE RESTRICT ON UPDATE CASCADE
|
|
185
|
+
);
|
|
186
|
+
|
|
187
|
+
-- CreateTable
|
|
188
|
+
CREATE TABLE "WorkerVersion" (
|
|
189
|
+
"id" TEXT NOT NULL PRIMARY KEY,
|
|
190
|
+
"workerId" TEXT NOT NULL,
|
|
191
|
+
"digest" TEXT NOT NULL,
|
|
192
|
+
"apiKeyId" TEXT NOT NULL,
|
|
193
|
+
"createdAt" DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
|
194
|
+
CONSTRAINT "WorkerVersion_apiKeyId_fkey" FOREIGN KEY ("apiKeyId") REFERENCES "ApiKey" ("id") ON DELETE RESTRICT ON UPDATE CASCADE
|
|
195
|
+
);
|
|
196
|
+
|
|
197
|
+
-- CreateTable
|
|
198
|
+
CREATE TABLE "WorkerUnitRegistration" (
|
|
199
|
+
"workerVersionId" TEXT NOT NULL,
|
|
200
|
+
"instanceId" TEXT NOT NULL,
|
|
201
|
+
"params" JSONB NOT NULL,
|
|
202
|
+
"createdAt" DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
|
203
|
+
"updatedAt" DATETIME NOT NULL,
|
|
204
|
+
|
|
205
|
+
PRIMARY KEY ("workerVersionId", "instanceId"),
|
|
206
|
+
CONSTRAINT "WorkerUnitRegistration_workerVersionId_fkey" FOREIGN KEY ("workerVersionId") REFERENCES "WorkerVersion" ("id") ON DELETE RESTRICT ON UPDATE CASCADE,
|
|
207
|
+
CONSTRAINT "WorkerUnitRegistration_instanceId_fkey" FOREIGN KEY ("instanceId") REFERENCES "InstanceState" ("id") ON DELETE RESTRICT ON UPDATE CASCADE
|
|
208
|
+
);
|
|
209
|
+
|
|
210
|
+
-- CreateTable
|
|
211
|
+
CREATE TABLE "_ArtifactToServiceAccount" (
|
|
212
|
+
"A" TEXT NOT NULL,
|
|
213
|
+
"B" TEXT NOT NULL,
|
|
214
|
+
CONSTRAINT "_ArtifactToServiceAccount_A_fkey" FOREIGN KEY ("A") REFERENCES "Artifact" ("id") ON DELETE CASCADE ON UPDATE CASCADE,
|
|
215
|
+
CONSTRAINT "_ArtifactToServiceAccount_B_fkey" FOREIGN KEY ("B") REFERENCES "ServiceAccount" ("id") ON DELETE CASCADE ON UPDATE CASCADE
|
|
216
|
+
);
|
|
217
|
+
|
|
218
|
+
-- CreateTable
|
|
219
|
+
CREATE TABLE "_ArtifactToInstanceState" (
|
|
220
|
+
"A" TEXT NOT NULL,
|
|
221
|
+
"B" TEXT NOT NULL,
|
|
222
|
+
CONSTRAINT "_ArtifactToInstanceState_A_fkey" FOREIGN KEY ("A") REFERENCES "Artifact" ("id") ON DELETE CASCADE ON UPDATE CASCADE,
|
|
223
|
+
CONSTRAINT "_ArtifactToInstanceState_B_fkey" FOREIGN KEY ("B") REFERENCES "InstanceState" ("id") ON DELETE CASCADE ON UPDATE CASCADE
|
|
224
|
+
);
|
|
225
|
+
|
|
226
|
+
-- CreateTable
|
|
227
|
+
CREATE TABLE "_ArtifactToTerminal" (
|
|
228
|
+
"A" TEXT NOT NULL,
|
|
229
|
+
"B" TEXT NOT NULL,
|
|
230
|
+
CONSTRAINT "_ArtifactToTerminal_A_fkey" FOREIGN KEY ("A") REFERENCES "Artifact" ("id") ON DELETE CASCADE ON UPDATE CASCADE,
|
|
231
|
+
CONSTRAINT "_ArtifactToTerminal_B_fkey" FOREIGN KEY ("B") REFERENCES "Terminal" ("id") ON DELETE CASCADE ON UPDATE CASCADE
|
|
232
|
+
);
|
|
233
|
+
|
|
234
|
+
-- CreateTable
|
|
235
|
+
CREATE TABLE "_ArtifactToPage" (
|
|
236
|
+
"A" TEXT NOT NULL,
|
|
237
|
+
"B" TEXT NOT NULL,
|
|
238
|
+
CONSTRAINT "_ArtifactToPage_A_fkey" FOREIGN KEY ("A") REFERENCES "Artifact" ("id") ON DELETE CASCADE ON UPDATE CASCADE,
|
|
239
|
+
CONSTRAINT "_ArtifactToPage_B_fkey" FOREIGN KEY ("B") REFERENCES "Page" ("id") ON DELETE CASCADE ON UPDATE CASCADE
|
|
240
|
+
);
|
|
241
|
+
|
|
242
|
+
-- CreateIndex
|
|
243
|
+
CREATE UNIQUE INDEX "ApiKey_token_key" ON "ApiKey"("token");
|
|
244
|
+
|
|
245
|
+
-- CreateIndex
|
|
246
|
+
CREATE UNIQUE INDEX "Artifact_hash_key" ON "Artifact"("hash");
|
|
247
|
+
|
|
248
|
+
-- CreateIndex
|
|
249
|
+
CREATE UNIQUE INDEX "InstanceState_id_lastOperationId_key" ON "InstanceState"("id", "lastOperationId");
|
|
250
|
+
|
|
251
|
+
-- CreateIndex
|
|
252
|
+
CREATE INDEX "Page_instanceId_idx" ON "Page"("instanceId");
|
|
253
|
+
|
|
254
|
+
-- CreateIndex
|
|
255
|
+
CREATE INDEX "Page_serviceAccountId_idx" ON "Page"("serviceAccountId");
|
|
256
|
+
|
|
257
|
+
-- CreateIndex
|
|
258
|
+
CREATE INDEX "Terminal_serviceAccountId_idx" ON "Terminal"("serviceAccountId");
|
|
259
|
+
|
|
260
|
+
-- CreateIndex
|
|
261
|
+
CREATE UNIQUE INDEX "Terminal_instanceId_name_key" ON "Terminal"("instanceId", "name");
|
|
262
|
+
|
|
263
|
+
-- CreateIndex
|
|
264
|
+
CREATE UNIQUE INDEX "Trigger_instanceId_name_key" ON "Trigger"("instanceId", "name");
|
|
265
|
+
|
|
266
|
+
-- CreateIndex
|
|
267
|
+
CREATE UNIQUE INDEX "Worker_identity_key" ON "Worker"("identity");
|
|
268
|
+
|
|
269
|
+
-- CreateIndex
|
|
270
|
+
CREATE UNIQUE INDEX "Worker_serviceAccountId_key" ON "Worker"("serviceAccountId");
|
|
271
|
+
|
|
272
|
+
-- CreateIndex
|
|
273
|
+
CREATE UNIQUE INDEX "WorkerVersion_digest_key" ON "WorkerVersion"("digest");
|
|
274
|
+
|
|
275
|
+
-- CreateIndex
|
|
276
|
+
CREATE UNIQUE INDEX "WorkerVersion_apiKeyId_key" ON "WorkerVersion"("apiKeyId");
|
|
277
|
+
|
|
278
|
+
-- CreateIndex
|
|
279
|
+
CREATE UNIQUE INDEX "_ArtifactToServiceAccount_AB_unique" ON "_ArtifactToServiceAccount"("A", "B");
|
|
280
|
+
|
|
281
|
+
-- CreateIndex
|
|
282
|
+
CREATE INDEX "_ArtifactToServiceAccount_B_index" ON "_ArtifactToServiceAccount"("B");
|
|
283
|
+
|
|
284
|
+
-- CreateIndex
|
|
285
|
+
CREATE UNIQUE INDEX "_ArtifactToInstanceState_AB_unique" ON "_ArtifactToInstanceState"("A", "B");
|
|
286
|
+
|
|
287
|
+
-- CreateIndex
|
|
288
|
+
CREATE INDEX "_ArtifactToInstanceState_B_index" ON "_ArtifactToInstanceState"("B");
|
|
289
|
+
|
|
290
|
+
-- CreateIndex
|
|
291
|
+
CREATE UNIQUE INDEX "_ArtifactToTerminal_AB_unique" ON "_ArtifactToTerminal"("A", "B");
|
|
292
|
+
|
|
293
|
+
-- CreateIndex
|
|
294
|
+
CREATE INDEX "_ArtifactToTerminal_B_index" ON "_ArtifactToTerminal"("B");
|
|
295
|
+
|
|
296
|
+
-- CreateIndex
|
|
297
|
+
CREATE UNIQUE INDEX "_ArtifactToPage_AB_unique" ON "_ArtifactToPage"("A", "B");
|
|
298
|
+
|
|
299
|
+
-- CreateIndex
|
|
300
|
+
CREATE INDEX "_ArtifactToPage_B_index" ON "_ArtifactToPage"("B");
|