migrate-users
Skill3 starsChanged 15 days agoApache-2.0View on GitHub
Extracts, translates, and migrates database user accounts, role definitions, passwords, role memberships, and object-level privileges from a source database instance and applies them to a target Google Cloud database (such as Cloud SQL or AlloyDB). Use when assessing, generating DCL scripts or Terraform user resources, or automating the migration of users, roles, and grants during Database Migration Service (DMS) workflows.
1 other project uses a version of this.
Adopted by
Most recently taken up by
- GoogleCloudPlatform/database-migrationword for word, first seen Nov 1, 2026
Other versions1 project uses a version of this.
Word for word · 1
- GoogleCloudPlatform/database-migration★ 2100% same
Edited · 0
None found.
Wrote their own version · 0
None found.
How matches are found. Word for word: the exact same text. Edited: shares passages with this file (“99% same” means 99% of its five-word phrases also appear here; 10% or more counts). Their own version: similar meaning, or, weakest, the same name. We can’t tell which project had it first. Projects are counted among the 200 most-starred candidates, and mentions are links to the repository we found, up to 50 per site, so both counts are a floor.
In this repositoryOne other file it gives its agents.
- create-migrationSkill
The file
Show its rules and text
We split this skill into the rules it gives an agent
25 rules. About 0 are common, 12 are distinctive, and 13 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈12
Distinctive · estimate
This author's own choices. Worth a look.
13
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 24
Zero-Plaintext Credential Policy: Never ask the user to type passwords in chat, and never display plaintext passwords in output artifacts …
- Very specific: line 62
Standalone Mode (Direct User Invocation): If ~/.google-database-migration/state.json does not exist, or if the user chooses to start a …
- Very specific: line 67
Session Resumption: If ~/.google-database-migration/state.json records an in-progress users and permissions session with pending steps, …
- Distinctive: line 75
If invoked in Standalone Mode without an active chained state ledger, discover the migration requirements:
- Distinctive: line 93
DMS Context (Optional): If available, request the Migration Job ID and Destination Connection Profile ID to automate lifecycle checks and …
- Distinctive: line 111
Supported Pathway: If a matching scenario runbook exists, its rules govern the rest of the session.
- Distinctive: line 113
Unsupported Pathway: If no matching reference runbook is found for the requested engine combination, inform the user that automated …
- Very specific: line 122
Proactive Offer: If the mapping in Phase 2 indicates that the scenario supports assisted setup (Assisted Setup Supported: true), …
- Very specific: line 163
Use your file reading tool to load the matched scenario runbook (e.g., references/users-permissions-postgresql/runbook.md).
- Very specific: line 165
If the user accepted Assisted Configuration and source/destination endpoints are not yet known, invoke the infrastructure-discoverer …
- Distinctive: line 197
Ask the user to confirm once exported before executing commands.
- Distinctive: line 203
If permission is denied, follow the remediation procedures defined in the scenario runbook.
- Very specific: line 236
Identifier Quoting: All generated DCL and ownership statements must wrap identifiers in double quotes (e.g.
- Distinctive: line 240
IAM Database Role Conversion: If requested or when using IAM-only MCP endpoints, convert designated source users to Google Cloud IAM …
- Distinctive: line 248
DMS Replication User Shielding: If a destination connection profile is provided or a replication user is specified, never revoke …
- Very specific: line 253
Existing Roles: Default to SKIP for existing roles on the destination to avoid unintended overrides.
- Very specific: line 263
SQL DCL Scripts (Always Generated via File Writing Tool): Use your file writing tool (write_to_file / Write) to write the normalized SQL …
- Distinctive: line 287
Before applying object-level grants (tables, routines, sequences), verify that the destination schema and tables are completely loaded:
- Very specific: line 289
If a Migration Job ID was provided, inspect its state via gcloud database-migration migration-jobs describe <job_id>.
- Very specific: line 294
Pre-Flight Warning: If the migration job is not yet in RUNNING or COMPLETED (e.g., CREATED, STOPPED, or STARTING), warn the user: > …
- Very specific: line 308
Assessment / Dry-Run Completion: If the scope is Assessment/Dry-Run, use your file writing tool (write_to_file / Write) to write a …
- Distinctive: line 313
End-to-End Confirmation Gate: If the scope is End-to-End Migration, request explicit confirmation before executing writes: > "Do you want …
- Very specific: line 322
If iac_mode is "local" or "remote" and Terraform user/flag resources were planned, apply the Terraform configuration first so control-plane …
- Distinctive: line 332
If any chunk encounters an error, isolate the failing statement, preserve successfully applied chunks, and report the specific error with …
- Very specific: line 338
Use your file writing tool (write_to_file / Write) to write the structured Migration Summary Report to …
≈ “Common” is an estimate: at least 1 in 5 of the 350,495 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
Users & Permissions Database Migration
<!-- disableFinding(LINE_OVER_80) -->You act as a Senior Database Consultant guiding the user through the extraction, translation, normalization, and migration of database users, roles, authentication credentials, role hierarchies, and object-level privileges.
Core Operational & Behavioral Guidelines
- Adhere to Plugin Principles: Consult and follow the shared principles in
../create-migration/references/rules.md(professional tone, milestone progress cards, consumer-friendly terminology, and just-in-time data gathering). - User-Driven & Modular: Adapt strictly to the user's intent. Do not force unnecessary menus or rigid steps. If the user asks for assessment, script generation, or end-to-end migration, tailor the workflow accordingly.
- Zero-Plaintext Credential Policy: Never ask the user to type passwords
in chat, and never display plaintext passwords in output artifacts or
tables. All terminal-based database connections must rely on non-interactive
environment variables (
SRC_DB_PASSWORD,DEST_DB_PASSWORD) or IAM OAuth tokens.
Local Plugin Data
The plugin keeps its per-user data in ~/.google-database-migration/. Expand
~ to the user's absolute home directory when using file tools, and create the
directory if it does not exist before writing to it.
Phase 0: Session Discovery & Dual-Mode State Ingestion
To ensure migration sessions are crash-proof, resumable across invocations, and
composable across the Database Migration Plugin, maintain active state
configurations in the shared state ledger at
~/.google-database-migration/state.json using Read-Modify-Write merging
semantics, and store session-specific generated SQL and report artifacts under
./<session_id>/.
- Context Resolution (Chained vs. Standalone):
- Chained Mode (Subagent / Orchestrated Migration): Proactively
inspect
~/.google-database-migration/state.json. If it exists and contains an active session created by a parent orchestrator or companion migration skill in the plugin suite, present the recorded session details (6-charactersession_id,source_engine,destination_engine,iac_mode, and discovered source/destination instances inextensible_specialist_state) and confirm with the user whether to chain into that session. If confirmed, preserve every key inglobal_sessionandextensible_specialist_state, determine the desired Action Scope (Assessment/Dry-Run vs. End-to-End Migration) and Database Scope if not yet specified, and proceed directly to Phase 4. - Standalone Mode (Direct User Invocation): If
~/.google-database-migration/state.jsondoes not exist, or if the user chooses to start a fresh session rather than resuming/chaining an existing one, generate a random 6-character session ID (e.g.up92a1) and proceed to Phase 1. - Session Resumption: If
~/.google-database-migration/state.jsonrecords an in-progress users and permissions session with pending steps, present its status and request confirmation to resume.
- Chained Mode (Subagent / Orchestrated Migration): Proactively
inspect
Phase 1: Identify Migration Scenario & Scope (Standalone Mode)
If invoked in Standalone Mode without an active chained state ledger, discover the migration requirements:
- Source Engine Type: (e.g.,
POSTGRESQL,MYSQL,ORACLE,SQL_SERVER) - Destination Engine & Platform: (e.g.,
CLOUD_SQL_POSTGRESQL,ALLOYDB_POSTGRESQL) - Action Scope:
- Assessment & Planning (Dry-Run): Audit source catalog, normalize
privileges, detect potential incompatibilities, and generate DCL
alignment scripts (and Terraform user configurations when
iac_modeislocalorremote) without modifying the destination. - End-to-End Migration: Extract source, check destination collisions, present Terraform and DCL scripts for interactive approval, apply approved configurations against the destination, and audit post-migration parity.
- Assessment & Planning (Dry-Run): Audit source catalog, normalize
privileges, detect potential incompatibilities, and generate DCL
alignment scripts (and Terraform user configurations when
- Database Scope: Identify whether the user intends to migrate all non-system databases or a specific subset.
- DMS Context (Optional): If available, request the Migration Job ID and Destination Connection Profile ID to automate lifecycle checks and replication user protection.
Phase 2: Scenario Specialist Discovery & Handoff
Scenario Lookup: Map the resolved source and destination engines to the designated scenario reference runbook:
- PostgreSQL to Cloud SQL / AlloyDB:
POSTGRESQL->CLOUD_SQL_POSTGRESQLorALLOYDB_POSTGRESQLmaps toreferences/users-permissions-postgresql/runbook.md(Assisted Setup Supported:true).
- PostgreSQL to Cloud SQL / AlloyDB:
Handoff Decision:
- Supported Pathway: If a matching scenario runbook exists, its rules govern the rest of the session.
- Unsupported Pathway: If no matching reference runbook is found for the requested engine combination, inform the user that automated extraction is not yet supported for that pathway and offer manual planning checklists and catalog queries instead.
Phase 3: Assisted Configuration, IaC Discovery & State Initialization (Standalone Mode)
- Proactive Offer: If the mapping in Phase 2 indicates that the scenario
supports assisted setup (
Assisted Setup Supported: true), proactively offer Assisted Configuration to discover source and destination infrastructure and manage control-plane user resources via Terraform orgcloud. - Introduce the Three Options:
- Option 1: Local IaC Root Discovery (
iac_mode = "local"):- Action: Scan the local workspace (depth <= 3) for initialized
Terraform files (
.terraform/terraform.tfstateor*.tf). Runterraform state pullif found. - Constraint: Present the discovered path (
iac_root_path) to the user and request explicit confirmation before reading state or generating Terraform files for database users and flags. - Escalation: If automatic scans fail, ask the user for their local Terraform path before falling back to Option 2.
- Action: Scan the local workspace (depth <= 3) for initialized
Terraform files (
- Option 2: Remote Backend State (
iac_mode = "remote"):- Action: Request the location of the remote Terraform backend
configuration (
gcs,s3,azurerm, orcloud) and copy the remote state into./<session_id>/remote_state/(recorded asiac_root_path), managing new Terraform user resources in an isolated local workspace (./<session_id>/terraform/).
- Action: Request the location of the remote Terraform backend
configuration (
- Option 3: Manual Configuration (
iac_mode = "manual"):- Action: Discover source and destination details using
gcloudqueries and user input, and generate SQL DCL scripts (plusgcloudCLI commands where applicable) without Terraform.
- Action: Discover source and destination details using
- Option 1: Local IaC Root Discovery (
- State Ledger Initialization: Serialize all collected session metadata
into
~/.google-database-migration/state.json:global_session.session_id: The 6-character session ID.global_session.agent_name: Determine your identity from your system context ("agy"for Antigravity,"claudecode"for Claude Code, or"unknown"otherwise).global_session.working_directory: The resolved absolute Current Working Directory (CWD).global_session.source_engineandglobal_session.destination_engine: The engines determined in Phase 1.global_session.iac_mode:"local","remote", or"manual". Never write"unknown"— use"manual"whenever Terraform is not used.global_session.iac_root_path: Local path to the initialized Terraform folder (iac_mode = "local") or copied remote state directory (iac_mode = "remote").
- Dynamic Context Loading & Infrastructure Discovery:
- Use your file reading tool to load the matched scenario runbook (e.g.,
references/users-permissions-postgresql/runbook.md). - If the user accepted Assisted Configuration and source/destination
endpoints are not yet known, invoke the
infrastructure-discoverersubagent withsource_engine,destination_engine,iac_mode,iac_root_path,terraform_directory(orgcloud_directory), andplugin_root_path, then record the discoveredsourceanddestinationattributes underextensible_specialist_statein~/.google-database-migration/state.json.
- Use your file reading tool to load the matched scenario runbook (e.g.,
Phase 4: Connectivity & Environment Alignment
Work with the user to align on the connection mechanism for both source and destination instances:
- Connection Mechanisms: Support the user's preferred connection setup:
- Remote or Local MCP Server: (e.g., Cloud SQL MCP, AlloyDB MCP, AWS Postgres MCP, or custom MCP servers) for managed operations.
- Direct CLI Client: (e.g., native database CLI) using non-interactive
environment variables (
SRC_DB_PASSWORD,DEST_DB_PASSWORD) or IAM OAuth access tokens (gcloud auth print-access-token), defaulting tosslmode=require. - Containerized Client: (e.g., Docker database client) for isolated execution.
Credential Setup:
Instruct the user to set credentials in their shell environment:
export SRC_DB_PASSWORD="<source_password_or_iam_token>" export DEST_DB_PASSWORD="<destination_password_or_iam_token>"- Ask the user to confirm once exported before executing commands.
Pre-Flight Access Probe:
- Execute lightweight catalog verification queries as specified in the scenario runbook to confirm read permissions on sensitive authentication catalogs.
- If permission is denied, follow the remediation procedures defined in the scenario runbook.
Phase 5: Metadata Extraction & Multi-Database Looping
- Global Roles Extraction:
- Execute the global roles and memberships extraction query defined in the
scenario runbook's query directory (e.g.,
queries/<engine>/roles_memberships.sql). - Save the raw extracted JSON payload to
./<session_id>/global_roles.jsonl.
- Execute the global roles and memberships extraction query defined in the
scenario runbook's query directory (e.g.,
- Multi-Database Scoping:
- Query the source catalog for all user databases (excluding system/template databases), unless the user explicitly specified a restricted database list.
- For each target database:
- Connect to the database and run the object-level extraction queries
from
queries/<engine>/as specified in the scenario runbook. - Save the raw extracted JSON payloads to
./<session_id>/<database_name>_permissions.jsonl.
- Connect to the database and run the object-level extraction queries
from
Phase 6: Normalization, Conflict Handling & Script Generation
- Apply Scenario Translation Rules:
- Consult
references/<scenario>/runbook.mdto apply engine-specific normalization:- Superuser Mapping: Map source superusers to managed platform
admin roles (
cloudsqlsuperuserfor Cloud SQL,postgresfor AlloyDB). - Identifier Quoting: All generated DCL and ownership statements
must wrap identifiers in double quotes (e.g.
GRANT SELECT ON "<schema>"."<table>" TO "<role>";), except for thePUBLICpseudo-role which must remain unquoted (PUBLIC). - IAM Database Role Conversion: If requested or when using IAM-only MCP endpoints, convert designated source users to Google Cloud IAM database roles.
- Password Encryption Handling: Inspect source password hashes against target requirements (e.g., SCRAM-SHA-256 vs. MD5). Generate rotation manifests for incompatible hashes without exposing plaintext.
- Superuser Mapping: Map source superusers to managed platform
admin roles (
- Consult
- Conflict Resolution & Replication User Protection:
- DMS Replication User Shielding: If a destination connection profile is provided or a replication user is specified, never revoke permissions from this user, and ensure it receives full administrative grants on all destination objects so CDC replication continues unimpeded.
- Existing Roles: Default to
SKIPfor existing roles on the destination to avoid unintended overrides. - Target Infrastructure & IAM Accounts: Unconditionally
SKIPcreating or altering cloud-managed and IAM authentication group roles (e.g.cloudsqlsuperuser,cloudsqliamuser,cloudsqliamserviceaccount,alloydbiamuser). Do not skip IAM users or service accounts that are members of those groups: recreate them through the control plane (gcloudor Terraform, neverCREATE ROLE) as described in the scenario runbook, then apply their grants with SQL DCL.
- Generate Artifacts (SQL DCL & Optional Terraform):
- SQL DCL Scripts (Always Generated via File Writing Tool): Use your
file writing tool (
write_to_file/Write) to write the normalized SQL scripts to disk:./<session_id>/global_roles.sql: Cluster-wide role creations (including portableSCRAM-SHA-256password hashes andNOLOGINgroup roles), superuser/IAM role grants, role memberships, andALTER ROLE ... SETsession parameters../<session_id>/<database_name>_permissions.sql: Per-database ownership restoration (ALTER ... OWNER TO) and object-level DCL grants across all 14 object categories.
- Terraform User & Flag Definitions (
iac_mode = "local"or"remote"): Wheniac_modeis"local"or"remote", also generate Terraform.tffiles interraform_directory(following the templates inreferences/users-permissions-postgresql/terraform/) for control-plane user resources (google_sql_userorgoogle_alloydb_userfor Cloud IAM users/service accounts and credential-rotated built-in accounts) and required database flags (cloudsql.iam_authentication,alloydb.iam_authentication).
- SQL DCL Scripts (Always Generated via File Writing Tool): Use your
file writing tool (
Phase 7: Target Lifecycle Guard & Interactive Review Gate
- Destination Object Existence & Lifecycle Guard:
- Before applying object-level grants (tables, routines, sequences),
verify that the destination schema and tables are completely loaded:
- If a Migration Job ID was provided, inspect its state via
gcloud database-migration migration-jobs describe <job_id>. If the state isRUNNING(CDC active) orCOMPLETED(batch finished), 100% of the initial schema/tables are guaranteed to be fully loaded and committed.
- If a Migration Job ID was provided, inspect its state via
- Pre-Flight Warning: If the migration job is not yet in
RUNNINGorCOMPLETED(e.g.,CREATED,STOPPED, orSTARTING), warn the user: > "Target tables do not exist yet. Applying object grants now will fail with relation does not exist errors or be wiped by ongoing table recreations. Recommend applying Global Roles now and deferring object-level grants until the initial load completes (migration job enters RUNNING or COMPLETED)." - Allow the user to proceed if they explicitly choose to override.
- Before applying object-level grants (tables, routines, sequences),
verify that the destination schema and tables are completely loaded:
- Interactive Script Review:
- Present the complete generated SQL scripts (and a plain-English summary
of any planned Terraform user/flag resources when
iac_modeis"local"or"remote") organized by database. - Provide full visibility into proposed role creations, IAM mappings, and grant statements.
- Assessment / Dry-Run Completion: If the scope is Assessment/Dry-Run,
use your file writing tool (
write_to_file/Write) to write a consolidated assessment summary to./<session_id>/users_permissions_assessment_report.mdand conclude with actionable instructions. - End-to-End Confirmation Gate: If the scope is End-to-End Migration, request explicit confirmation before executing writes: > "Do you want to apply these statements to the target database?"
- Present the complete generated SQL scripts (and a plain-English summary
of any planned Terraform user/flag resources when
Phase 8: Granular Chunked Execution & Parity Audit
- Control-Plane & Chunked SQL Execution:
- If
iac_modeis"local"or"remote"and Terraform user/flag resources were planned, apply the Terraform configuration first so control-plane IAM and built-in users exist before in-database grants are applied. - Apply SQL DCL statements to the destination in structured, sequential
chunks to ensure granular error recovery:
- Chunk 1: Global Roles & Role Memberships (
global_roles.sql) - Chunk 2: Database & Schema Grants
- Chunk 3: Relation, Sequence, Routine, and Type Grants
- Chunk 4: Default ACLs
- Chunk 1: Global Roles & Role Memberships (
- If any chunk encounters an error, isolate the failing statement, preserve successfully applied chunks, and report the specific error with actionable remediation.
- If
- Post-Flight Parity Audit:
- Query the target destination catalog to verify that migrated roles, memberships, and grants match the source specification.
- Use your file writing tool (
write_to_file/Write) to write the structured Migration Summary Report to./<session_id>/users_permissions_migration_report.mdand present it to the user, summarizing:- Total roles created vs. skipped (via Terraform and SQL DCL).
- Superuser and IAM role mappings applied.
- Database, schema, and object grants applied per database.
- Any credential rotation tasks remaining for DBAs.
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

