-
Notifications
You must be signed in to change notification settings - Fork 454
feat: persist and expose sandbox provider name in settings #800
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
thesujai
wants to merge
5
commits into
main
Choose a base branch
from
feat/add-provider-name
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
0d515e8
feat: persist and expose sandbox provider name in settings
thesujai 372c42d
Regenerate OpenAPI document and SDKs
trueforge-dev-bot[bot] 94aabf5
fix: correct property access for manifest type in wireResponse function
thesujai 1dc68ae
test: add sandbox provider name to response in sandboxProviderCatalog…
thesujai 8229f0a
fix: unique (tenant_id, name) on sandbox_provider; rename migration a…
thesujai File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| --- | ||
| "@truefoundry/trueforge-sdk": patch | ||
| --- | ||
|
|
||
| Regenerate SDK from updated OpenAPI spec. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| --- | ||
| "@truefoundry/trueforge": patch | ||
| --- | ||
|
|
||
| Persist sandbox provider `name` column (= `manifest.type` on write) and expose it on configured settings responses. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
35 changes: 35 additions & 0 deletions
35
packages/trueforge/src/db/postgres/migrations/20260918_000002_sandbox_provider_name.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,35 @@ | ||
| import { sql, type Kysely } from 'kysely'; | ||
|
|
||
| import { SANDBOX_PROVIDER_TENANT_NAME_UQ } from '../../indexes'; | ||
|
|
||
| /** | ||
| * Persist sandbox provider identity `name` (always equal to `manifest.type` for now). | ||
| * Backfill existing rows from the jsonb type, then require NOT NULL and | ||
| * UNIQUE (tenant_id, name). | ||
| */ | ||
| export async function up(db: Kysely<unknown>): Promise<void> { | ||
| await sql`SET LOCAL lock_timeout = '5s'`.execute(db); | ||
| await db.schema.alterTable('sandbox_provider').addColumn('name', 'text').execute(); | ||
|
|
||
| await sql` | ||
| UPDATE sandbox_provider | ||
| SET name = manifest ->> 'type' | ||
| WHERE name IS NULL | ||
| `.execute(db); | ||
|
|
||
| await sql` | ||
| ALTER TABLE sandbox_provider | ||
| ALTER COLUMN name SET NOT NULL | ||
| `.execute(db); | ||
|
|
||
| await db.schema | ||
| .alterTable('sandbox_provider') | ||
| .addUniqueConstraint(SANDBOX_PROVIDER_TENANT_NAME_UQ, ['tenant_id', 'name']) | ||
| .execute(); | ||
| } | ||
|
|
||
| export async function down(db: Kysely<unknown>): Promise<void> { | ||
| await sql`SET LOCAL lock_timeout = '5s'`.execute(db); | ||
| await db.schema.alterTable('sandbox_provider').dropConstraint(SANDBOX_PROVIDER_TENANT_NAME_UQ).execute(); | ||
| await db.schema.alterTable('sandbox_provider').dropColumn('name').execute(); | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
74 changes: 74 additions & 0 deletions
74
packages/trueforge/src/db/sqlite/migrations/20260918_000002_sandbox_provider_name.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,74 @@ | ||
| import { sql, type Kysely } from 'kysely'; | ||
|
|
||
| /** | ||
| * Persist sandbox provider identity `name` (always equal to `manifest.type` for now). | ||
| * Rebuilds the table so `name` is NOT NULL without a leftover DEFAULT (SQLite cannot | ||
| * drop a column default in place), with UNIQUE (tenant_id, name). Also drops the | ||
| * temporary `status` DEFAULT from the earlier status migration. | ||
| */ | ||
| export async function up(db: Kysely<unknown>): Promise<void> { | ||
| await db.transaction().execute(async trx => { | ||
| await sql` | ||
| CREATE TABLE sandbox_provider__with_name ( | ||
| tenant_id TEXT NOT NULL, | ||
| name TEXT NOT NULL, | ||
| manifest BLOB NOT NULL, | ||
| status TEXT NOT NULL, | ||
| status_reason TEXT, | ||
| build_metadata BLOB, | ||
| created_at TEXT NOT NULL, | ||
| updated_at TEXT NOT NULL, | ||
| PRIMARY KEY (tenant_id), | ||
| UNIQUE (tenant_id, name) | ||
| ) STRICT | ||
| `.execute(trx); | ||
|
|
||
| await sql` | ||
| INSERT INTO sandbox_provider__with_name ( | ||
| tenant_id, name, manifest, status, status_reason, build_metadata, created_at, updated_at | ||
| ) | ||
| SELECT | ||
| tenant_id, | ||
| json_extract(json(manifest), '$.type'), | ||
| manifest, | ||
| status, | ||
| status_reason, | ||
| build_metadata, | ||
| created_at, | ||
| updated_at | ||
| FROM sandbox_provider | ||
| `.execute(trx); | ||
|
|
||
| await sql`DROP TABLE sandbox_provider`.execute(trx); | ||
| await sql`ALTER TABLE sandbox_provider__with_name RENAME TO sandbox_provider`.execute(trx); | ||
| }); | ||
| } | ||
|
|
||
| export async function down(db: Kysely<unknown>): Promise<void> { | ||
| await db.transaction().execute(async trx => { | ||
| await sql` | ||
| CREATE TABLE sandbox_provider__without_name ( | ||
| tenant_id TEXT NOT NULL, | ||
| manifest BLOB NOT NULL, | ||
| status TEXT NOT NULL DEFAULT 'pending', | ||
| status_reason TEXT, | ||
| build_metadata BLOB, | ||
| created_at TEXT NOT NULL, | ||
| updated_at TEXT NOT NULL, | ||
| PRIMARY KEY (tenant_id) | ||
| ) STRICT | ||
| `.execute(trx); | ||
|
|
||
| await sql` | ||
| INSERT INTO sandbox_provider__without_name ( | ||
| tenant_id, manifest, status, status_reason, build_metadata, created_at, updated_at | ||
| ) | ||
| SELECT | ||
| tenant_id, manifest, status, status_reason, build_metadata, created_at, updated_at | ||
| FROM sandbox_provider | ||
| `.execute(trx); | ||
|
|
||
| await sql`DROP TABLE sandbox_provider`.execute(trx); | ||
| await sql`ALTER TABLE sandbox_provider__without_name RENAME TO sandbox_provider`.execute(trx); | ||
| }); | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
tenant_id and name will be a unique constraint