Skip to content

GCP.DataMigration reference

Source: packages/gcp/src/DataMigration/ConnectionProfile.ts

A Database Migration Service connection profile: credentials and connectivity for a source database, or settings used to provision a Cloud SQL / AlloyDB destination.

connectionProfileId, location, and the engine kind (mysql / postgresql / oracle / sqlserver / cloudsql / alloydb) plus immutable Cloud SQL / AlloyDB settings are replacement triggers. Display name, labels, role, provider, and credential fields update in place. Passwords are input-only and never returned.

ConnectionProfile: Creating a Connection Profile

Section titled “ConnectionProfile: Creating a Connection Profile”

MySQL source

const source = yield* GCP.DataMigration.ConnectionProfile("MysqlSrc", {
mysql: {
host: "10.0.0.8",
port: 3306,
username: "dms",
password: process.env.MYSQL_PASSWORD,
},
labels: { env: "test" },
});

Cloud SQL destination

const dest = yield* GCP.DataMigration.ConnectionProfile("MysqlDest", {
cloudsql: {
settings: {
sourceId: source.name,
databaseVersion: "MYSQL_8_0",
tier: "db-n1-standard-1",
rootPassword: process.env.MYSQL_ROOT_PASSWORD,
},
},
});

ConnectionProfile: Looking up an existing connection profile

Section titled “ConnectionProfile: Looking up an existing connection profile”

ConnectionProfile.lookup references a connection profile Alchemy doesn’t manage (created in the console or by another stack). It is read during plan/deploy, never created, updated or deleted, and binds like a declared connection profile.

const connectionProfile = GCP.DataMigration.ConnectionProfile.lookup({
connectionProfileId: "my-connection-profile",
});

Source: packages/gcp/src/DataMigration/ConversionWorkspace.ts

A Database Migration Service conversion workspace: source and destination engines plus optional mapping-engine settings used by heterogeneous migrations.

Conversion workspaces have no labels field — Alchemy stamps ownership into the display name so list / nuke can find them. source, destination, and their providers are replacement triggers. Display name and globalSettings update in place.

ConversionWorkspace: Creating a Conversion Workspace

Section titled “ConversionWorkspace: Creating a Conversion Workspace”

MySQL to PostgreSQL

const workspace = yield* GCP.DataMigration.ConversionWorkspace("MysqlToPg", {
displayName: "mysql-to-pg",
source: { engine: "MYSQL", version: "8.0" },
destination: { engine: "POSTGRESQL", version: "14" },
});

Oracle to PostgreSQL with settings

const workspace = yield* GCP.DataMigration.ConversionWorkspace("OraToPg", {
source: { engine: "ORACLE", version: "19" },
destination: { engine: "POSTGRESQL", version: "15" },
globalSettings: { skip_triggers: "true" },
});

ConversionWorkspace: Looking up an existing conversion workspace

Section titled “ConversionWorkspace: Looking up an existing conversion workspace”

ConversionWorkspace.lookup references a conversion workspace Alchemy doesn’t manage (created in the console or by another stack). It is read during plan/deploy, never created, updated or deleted, and binds like a declared conversion workspace.

const conversionWorkspace = GCP.DataMigration.ConversionWorkspace.lookup({
conversionWorkspaceId: "my-conversion-workspace",
});

Source: packages/gcp/src/DataMigration/ConversionWorkspacesMappingRule.ts

A mapping rule attached to a Database Migration Service conversion workspace. Rules transform source schema entities into the destination schema (rename, move, type change, …).

Mapping rules have no labels field and no patch method — Alchemy stamps ownership into the display name, and any change to the rule body replaces the rule.

ConversionWorkspacesMappingRule: Creating a Mapping Rule

Section titled “ConversionWorkspacesMappingRule: Creating a Mapping Rule”
const workspace = yield* GCP.DataMigration.ConversionWorkspace("MysqlToPg", {
source: { engine: "MYSQL", version: "8.0" },
destination: { engine: "POSTGRESQL", version: "14" },
});
const rule = yield* GCP.DataMigration.ConversionWorkspacesMappingRule("Rename", {
conversionWorkspace: workspace.name,
ruleScope: "DATABASE_ENTITY_TYPE_SCHEMA",
filter: { entities: ["src_schema"] },
singleEntityRename: { newName: "dst_schema" },
});

ConversionWorkspacesMappingRule: Looking up an existing conversion workspaces mapping rule

Section titled “ConversionWorkspacesMappingRule: Looking up an existing conversion workspaces mapping rule”

ConversionWorkspacesMappingRule.lookup references a conversion workspaces mapping rule Alchemy doesn’t manage (created in the console or by another stack). It is read during plan/deploy, never created, updated or deleted, and binds like a declared conversion workspaces mapping rule.

const conversionWorkspacesMappingRule = GCP.DataMigration.ConversionWorkspacesMappingRule.lookup({
mappingRuleId: "my-mapping-rule",
conversionWorkspace: "my-conversion-workspace",
});

Source: packages/gcp/src/DataMigration/MigrationJob.ts

A Database Migration Service migration job: copies data from a source connection profile to a destination (Cloud SQL or AlloyDB).

migrationJobId, location, type, source, destination, and cmekKeyName are replacement triggers. Display name, labels, dump flags, connectivity, and performance config update in place. Delete force-deletes the destination Cloud SQL replica.

const source = yield* GCP.DataMigration.ConnectionProfile("MysqlSrc", {
mysql: {
host: "10.0.0.8",
port: 3306,
username: "dms",
password: process.env.MYSQL_PASSWORD,
},
});
const dest = yield* GCP.DataMigration.ConnectionProfile("MysqlDest", {
cloudsql: {
settings: {
sourceId: source.name,
databaseVersion: "MYSQL_8_0",
tier: "db-n1-standard-1",
rootPassword: process.env.MYSQL_ROOT_PASSWORD,
},
},
});
const job = yield* GCP.DataMigration.MigrationJob("Replica", {
type: "CONTINUOUS",
source: source.name,
destination: dest.name,
staticIpConnectivity: {},
});

MigrationJob: Looking up an existing migration job

Section titled “MigrationJob: Looking up an existing migration job”

MigrationJob.lookup references a migration job Alchemy doesn’t manage (created in the console or by another stack). It is read during plan/deploy, never created, updated or deleted, and binds like a declared migration job.

const migrationJob = GCP.DataMigration.MigrationJob.lookup({
migrationJobId: "my-migration-job",
});

Source: packages/gcp/src/DataMigration/PrivateConnection.ts

A Database Migration Service private connection: VPC peering or a PSC interface between DMS and a consumer network.

The API has no patch method. privateConnectionId, location, vpcPeeringConfig, pscInterfaceConfig, display name, and labels are replacement triggers.

PrivateConnection: Creating a Private Connection

Section titled “PrivateConnection: Creating a Private Connection”
const network = yield* GCP.Compute.Network("DmsVpc", {
autoCreateSubnetworks: false,
});
const peering = yield* GCP.DataMigration.PrivateConnection("DmsPeer", {
displayName: "dms-peer",
vpcPeeringConfig: {
vpcName: network.selfLink ?? network.networkName,
subnet: "10.8.0.0/29",
},
labels: { env: "test" },
});

PrivateConnection: Looking up an existing private connection

Section titled “PrivateConnection: Looking up an existing private connection”

PrivateConnection.lookup references a private connection Alchemy doesn’t manage (created in the console or by another stack). It is read during plan/deploy, never created, updated or deleted, and binds like a declared private connection.

const privateConnection = GCP.DataMigration.PrivateConnection.lookup({
privateConnectionId: "my-private-connection",
});