Skip to content
1,817 changes: 1,446 additions & 371 deletions alchemy/src/planetscale/api/sdk.gen.ts

Large diffs are not rendered by default.

12,470 changes: 7,813 additions & 4,657 deletions alchemy/src/planetscale/api/types.gen.ts

Large diffs are not rendered by default.

8 changes: 4 additions & 4 deletions alchemy/src/planetscale/branch.ts
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,7 @@ export const Branch = Resource(
path: {
organization,
database,
name: this.output.name,
branch: this.output.name,
},
throwOnError: false,
});
Expand Down Expand Up @@ -236,7 +236,7 @@ export const Branch = Resource(
path: {
organization,
database,
name: branchName,
branch: branchName,
},
throwOnError: false,
});
Expand Down Expand Up @@ -287,7 +287,7 @@ export const Branch = Resource(
path: {
organization,
database,
name: branchName,
branch: branchName,
},
});
}
Expand Down Expand Up @@ -367,7 +367,7 @@ export const Branch = Resource(
path: {
organization,
database,
name: branchName,
branch: branchName,
},
});
}
Expand Down
94 changes: 57 additions & 37 deletions alchemy/src/planetscale/database.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,65 +46,76 @@ interface BaseDatabaseProps extends PlanetScaleProps {
};

/**
* Whether to require approval for deployments
* The number of replicas for the database. 0 for non-HA, 2+ for HA. (create only)
*/
requireApprovalForDeploy?: boolean;
replicas?: number;

/**
* Whether to allow data branching
* The database cluster size (required)
*/
allowDataBranching?: boolean;
clusterSize: PlanetScaleClusterSize;

/**
* The PostgreSQL major version to use for the database. Defaults to the latest available major version. (PostgreSQL only)
*/
majorVersion?: string;

/**
* The engine kind for the database (create only)
* @default "mysql"
*/
kind?: "mysql" | "postgresql";

/**
* Whether to enable automatic migrations
* Whether or not to copy migration data to new branches and in deploy requests. (Vitess only)
*/
automaticMigrations?: boolean;

/**
* Whether to restrict branch creation to the same region as database
* A migration framework to use on the database. (Vitess only)
*/
restrictBranchRegion?: boolean;
migrationFramework?: string;

/**
* Whether to collect full queries from the database
* Name of table to use as migration table for the database. (Vitess only)
*/
insightsRawQueries?: boolean;
migrationTableName?: string;

/**
* Whether web console can be used on production branch
* Whether or not deploy requests must be approved by a database administrator other than the request creator
*/
productionBranchWebConsole?: boolean;
requireApprovalForDeploy?: boolean;

/**
* The default branch of the database
* Whether or not to limit branch creation to the same region as the one selected during database creation.
*/
defaultBranch?: string;
restrictBranchRegion?: boolean;

/**
* Migration framework to use on the database
* Whether or not data branching is allowed on the database. (Vitess only)
*/
migrationFramework?: string;
allowDataBranching?: boolean;

/**
* Name of table to use as migration table
* Whether or not foreign key constraints are allowed on the database. (Vitess only)
*/
migrationTableName?: string;
allowForeignKeyConstraints?: boolean;

/**
* The database cluster size (required)
* Whether or not full queries should be collected from the database
*/
clusterSize: PlanetScaleClusterSize;
insightsRawQueries?: boolean;

/**
* The engine kind for the database
* @default "mysql"
* Whether or not the web console can be used on the production branch of the database
*/
kind?: "mysql" | "postgresql";
productionBranchWebConsole?: boolean;

/**
* The CPU architecture for the database. Only available for PostgreSQL databases.
* The default branch of the database
* @default "main"
*/
arch?: "x86" | "arm";
defaultBranch?: string;
}

/**
Expand All @@ -115,10 +126,16 @@ export type DatabaseProps = BaseDatabaseProps &
| {
kind?: "mysql";
arch?: undefined;
majorVersion?: undefined;
}
| {
kind: "postgresql";
arch?: "x86" | "arm";
automaticMigrations?: undefined;
migrationFramework?: undefined;
migrationTableName?: undefined;
allowDataBranching?: undefined;
allowForeignKeyConstraints?: undefined;
}
);

Expand Down Expand Up @@ -240,7 +257,7 @@ export const Database = Resource(
await api.updateDatabaseSettings({
path: {
organization,
name: this.output.name,
database: this.output.name,
},
body: { new_name: databaseName },
});
Expand All @@ -251,7 +268,7 @@ export const Database = Resource(
const response = await api.deleteDatabase({
path: {
organization,
name: this.output.name,
database: this.output.name,
},
throwOnError: false,
});
Expand All @@ -269,7 +286,7 @@ export const Database = Resource(
const getResponse = await api.getDatabase({
path: {
organization,
name: databaseName,
database: databaseName,
},
throwOnError: false,
});
Expand All @@ -286,7 +303,7 @@ export const Database = Resource(
path: {
organization,
database: databaseName,
name: props.defaultBranch,
branch: props.defaultBranch,
},
throwOnError: false,
});
Expand All @@ -311,18 +328,18 @@ export const Database = Resource(
const { data } = await api.updateDatabaseSettings({
path: {
organization,
name: databaseName,
database: databaseName,
},
body: {
automatic_migrations: props.automaticMigrations,
migration_framework: props.migrationFramework,
migration_table_name: props.migrationTableName,
require_approval_for_deploy: props.requireApprovalForDeploy,
restrict_branch_region: props.restrictBranchRegion,
allow_foreign_key_constraints: props.allowForeignKeyConstraints,
allow_data_branching: props.allowDataBranching,
insights_raw_queries: props.insightsRawQueries,
production_branch_web_console: props.productionBranchWebConsole,
default_branch: props.defaultBranch,
},
});

Expand Down Expand Up @@ -363,24 +380,27 @@ export const Database = Resource(
region: props.region?.slug,
kind: props.kind,
cluster_size: clusterSize,
replicas: props.replicas,
major_version: props.majorVersion,
},
});

// These settings can't be set on creation, so we need to patch them after creation.
const { data } = await api.updateDatabaseSettings({
path: {
organization,
name: databaseName,
database: databaseName,
},
body: {
require_approval_for_deploy: props.requireApprovalForDeploy,
allow_data_branching: props.allowDataBranching,
automatic_migrations: props.automaticMigrations,
migration_framework: props.migrationFramework,
migration_table_name: props.migrationTableName,
require_approval_for_deploy: props.requireApprovalForDeploy,
restrict_branch_region: props.restrictBranchRegion,
allow_foreign_key_constraints: props.allowForeignKeyConstraints,
allow_data_branching: props.allowDataBranching,
insights_raw_queries: props.insightsRawQueries,
production_branch_web_console: props.productionBranchWebConsole,
migration_framework: props.migrationFramework,
migration_table_name: props.migrationTableName,
},
});

Expand All @@ -393,7 +413,7 @@ export const Database = Resource(
path: {
organization,
database: databaseName,
name: props.defaultBranch,
branch: props.defaultBranch,
},
throwOnError: false,
});
Expand Down Expand Up @@ -424,7 +444,7 @@ export const Database = Resource(
const { data: updatedData } = await api.updateDatabaseSettings({
path: {
organization,
name: databaseName,
database: databaseName,
},
body: {
default_branch: props.defaultBranch,
Expand Down
Loading
Loading