microsoft/power-platform-skills / plugins/power-pages/skills/migrate-datamodel
migrate-datamodel
VerifiedThis skill should be used when the user asks to "migrate to enhanced data model", "migrate from standard to enhanced", "switch to EDM", "migrate SDM to EDM", "upgrade data model", "migrate site data model", or wants to migrate an existing Power Pages site from the Standard Data Model (SDM) to the Enhanced Data Model (EDM) using PAC CLI.
| File | Kind | Size |
|---|---|---|
| SKILL.md | skill md | 148.5 KB |
| assets/customization-report.html | other | 8.7 KB |
| scripts/apply-remediation.js | script | 9.7 KB |
| scripts/detect-template.js | script | 11.5 KB |
| scripts/diff-snapshots.js | script | 15.0 KB |
| scripts/emit-telemetry.js | script | 7.3 KB |
| scripts/generate-migration-reports.js | script | 65.8 KB |
| scripts/lib/edm-table-classification.js | script | 3.8 KB |
| scripts/lib/migration-state-schema.js | script | 9.7 KB |
| scripts/lib/render-live-report.js | script | 124.4 KB |
| scripts/migration-runtime.js | script | 15.2 KB |
| scripts/prompts/dme-remediation.template.txt | markdown | 10.9 KB |
| scripts/prompts/plugin-remediation.template.txt | markdown | 4.8 KB |
| scripts/snapshot-site.js | script | 20.5 KB |
| scripts/update-state.js | script | 33.7 KB |
scripts/lib/migration-state-schema.js
View on GitHub/**
* migration-state-schema.js
*
* Source of truth for migration-state.json. Three responsibilities:
* 1. `buildInitialState()` — the skeleton the skill writes at startup, before any
* sub-step has run. Defaults to the Authoring Track (more common). Matches stage0-initialized.html.
* 2. Constants for status / kind / track values used by phases, sub-steps, the
* approval gate, and the augmented-prompt cards.
* 3. Canonical phase blueprints per track. Phase 1 and Phase 4 are shared across
* tracks; Phase 2 and Phase 3 differ.
*
* Authoring Track (CLI value `A`) — mode is `configurationData` or `all`
* For Dev / Test / UAT / Single env. Migrates metadata locally, allows a
* customization-remediation pass, then activates EDM.
*
* Downstream Track (CLI value `B`) — mode is `configurationDataReferences`
* For Prod (ALM assumed). Verifies metadata is already in EDM, then migrates
* transactional references and activates.
*
* Kept deliberately small: no I/O, no rendering, no CLI concerns. Pure data.
*/
const SCHEMA_VERSION = 1;
const PHASE_STATUS = Object.freeze({
PENDING: 'pending',
PENDING_APPROVAL: 'pending-approval',
IN_PROGRESS: 'in-progress',
COMPLETED: 'completed',
BLOCKED: 'blocked',
});
const SUB_STEP_STATUS = Object.freeze({
PENDING: 'pending',
IN_PROGRESS: 'in-progress',
COMPLETED: 'completed',
BLOCKED: 'blocked',
});
const APPROVAL_KIND = Object.freeze({
PHASE_START: 'phase-start',
IN_PHASE: 'in-phase',
});
const PROMPT_STATUS = Object.freeze({
PENDING: 'pending',
READY: 'ready',
});
const TRACK = Object.freeze({
A: 'A',
B: 'B',
});
// The Authoring Track defaults to Dev/Test/UAT/Single-env (the most common). Until step 1.7
// runs --set-track, the live report renders against this default.
const DEFAULT_TRACK = TRACK.A;
// ── Phase blueprints ───────────────────────────────────────────────────────
// Phase 1 and Phase 4 are shared across tracks.
const PHASE_1 = {
id: 1,
title: 'Site Discovery & Pre-checks',
subSteps: [
{ id: '1.1', label: 'Establish CLI Context' },
{ id: '1.2', label: 'Identify Site Context' },
{ id: '1.3', label: 'Site Discovery and Validate Data Model' },
{ id: '1.4', label: 'Check Existing Migration Status' },
{ id: '1.5', label: 'Validate Required Dependencies' },
{ id: '1.6', label: 'Validate Site Template and V2 Package' },
{ id: '1.7', label: 'Determine Environment Type and Migration Mode' },
],
};
const PHASE_4 = {
id: 4,
title: 'Post-Migration Validation',
subSteps: [
{ id: '4.1', label: 'Runtime Smoke Test Recommendation (/test-site)' },
{ id: '4.2', label: 'Final Status, Optional Rollback, Summary' },
],
};
const PHASE_2_TRACK_A = {
id: 2,
title: 'Configuration Migration & Customization Remediation',
subSteps: [
{ id: '2.1', label: 'Capture SDM Snapshot' },
{ id: '2.2', label: 'Migrate Metadata' },
{ id: '2.3', label: 'Locate Customization Report' },
{ id: '2.4', label: 'Remediate Customizations' },
],
};
const PHASE_2_TRACK_B = {
id: 2,
title: 'Setting Up Metadata',
subSteps: [
{ id: '2.1', label: 'Verify Site in Target Environment' },
{ id: '2.2', label: 'Import Metadata if Missing' },
{ id: '2.3', label: 'Confirm Metadata Ready' },
],
};
// Phase 3 differs by track. The Authoring Track already cleaned up customizations in Phase 2.3,
// so Phase 3 only needs verify metadata → migrate refs → activate → restart. The Downstream Track
// never ran the customization remediation in Phase 2, so Phase 3 includes locate + remediate
// after refs migrate.
const PHASE_3_TRACK_A = {
id: 3,
title: 'Migration Execution',
subSteps: [
{ id: '3.1', label: 'Data Diff Validation (SDM ↔ EDM Metadata)' },
// When mode=`all`, SKILL.md instructs the agent to mark 3.2 completed with
// output "Skipped — refs already migrated in Phase 2.1 (mode=all)".
{ id: '3.2', label: 'Migrate Transactional References' },
{ id: '3.3', label: 'Activate EDM (Update Data Model Version)' },
{ id: '3.4', label: 'Restart Site' },
],
};
const PHASE_3_TRACK_B = {
id: 3,
title: 'Migration Execution',
subSteps: [
{ id: '3.1', label: 'Data Diff Validation (SDM ↔ EDM Metadata)' },
{ id: '3.2', label: 'Migrate Transactional References' },
{ id: '3.3', label: 'Locate Customization Report' },
{ id: '3.4', label: 'Remediate Customizations' },
{ id: '3.5', label: 'Activate EDM (Update Data Model Version)' },
{ id: '3.6', label: 'Restart Site' },
],
};
const PHASE_BLUEPRINTS_BY_TRACK = Object.freeze({
A: [PHASE_1, PHASE_2_TRACK_A, PHASE_3_TRACK_A, PHASE_4],
B: [PHASE_1, PHASE_2_TRACK_B, PHASE_3_TRACK_B, PHASE_4],
});
function makePhasesFromBlueprint(blueprints) {
return blueprints.map((p) => ({
id: p.id,
title: p.title,
status: PHASE_STATUS.PENDING,
startedAt: null,
completedAt: null,
subSteps: p.subSteps.map((s) => ({
id: s.id,
label: s.label,
status: SUB_STEP_STATUS.PENDING,
output: null,
})),
}));
}
function normalizePendingInput(value) {
if (value == null) return null;
if (typeof value !== 'object' || Array.isArray(value) ||
typeof value.requiredAction !== 'string' || !value.requiredAction.trim()) {
throw new Error('Pending input must be an object with a non-empty "requiredAction" string.');
}
if (value.responseLocation !== undefined &&
(typeof value.responseLocation !== 'string' || !value.responseLocation.trim())) {
throw new Error('Pending input "responseLocation" must be a non-empty string when supplied.');
}
return {
requiredAction: value.requiredAction.trim(),
responseLocation: value.responseLocation?.trim() || 'Return to the migration conversation and provide your response.',
};
}
/**
* Build a fresh migration-state.json skeleton. Defaults to the Authoring Track; the skill
* calls `--set-track A|B` at the end of step 1.7 once env type and migration
* mode are known (`A` = Authoring Track, `B` = Downstream Track).
*/
function buildInitialState({ webSiteId, outputDir, track = DEFAULT_TRACK, startedAt = new Date().toISOString() } = {}) {
if (!webSiteId) throw new Error('buildInitialState: webSiteId is required');
if (!outputDir) throw new Error('buildInitialState: outputDir is required');
if (!PHASE_BLUEPRINTS_BY_TRACK[track]) throw new Error(`buildInitialState: unknown track '${track}'`);
return {
schemaVersion: SCHEMA_VERSION,
skillStartedAt: startedAt,
lastUpdatedAt: startedAt,
track,
site: {
name: null,
webSiteId,
portalId: null,
portalUrl: null,
slug: null,
currentDataModel: null,
template: null,
environment: null,
environmentName: null,
environmentUrl: null,
migrationMode: null,
siteRoot: null,
outputDir,
},
phases: makePhasesFromBlueprint(PHASE_BLUEPRINTS_BY_TRACK[track]),
approvalGate: {
phaseId: 1,
kind: APPROVAL_KIND.PHASE_START,
},
// Informational pauses must not replace or approve a migration gate.
pendingInput: null,
augmentedPrompts: {
plugin: null,
dme: null,
},
customizationReport: null,
refsMigration: null,
// Append-only log of the major migration CHOICES the user makes (env type, mode,
// track, package install/skip, remediation, reset, rollback, restart). Rendered in
// the Migration & Review tab for later review. Entries upsert by `id` so re-running
// a decision point updates in place instead of duplicating. Permission / file
// create-update-read prompts are intentionally NOT recorded here.
decisions: [],
// Structured "now running" pointer for long-running steps (package installs,
// metadata/refs migration polling). null when idle. When set:
// { label, detail, startedAt, expectedDurationSec, poll: { attempt, max } }
// The report renders this as an always-visible banner whose elapsed clock and
// estimate bar are advanced client-side every second — so progress stays visible
// even while a blocking `pac` call prevents the agent from writing new state.
currentOperation: null,
};
}
/**
* Switch the state's track in place. Preserves Phase 1 and Phase 4 (which are
* shared between tracks and may contain completed sub-steps). Replaces Phase 2
* and Phase 3 with the new track's blueprints (pristine).
*
* Called by update-state.js --set-track A|B (`A` = Authoring Track, `B` = Downstream Track),
* typically at the end of step 1.7 when the user confirms env type + migration mode.
*/
function rebuildPhasesForTrack(state, newTrack) {
if (!PHASE_BLUEPRINTS_BY_TRACK[newTrack]) {
throw new Error(`rebuildPhasesForTrack: unknown track '${newTrack}'`);
}
const blueprints = PHASE_BLUEPRINTS_BY_TRACK[newTrack];
state.phases = blueprints.map((blueprint) => {
// Phase 1 and Phase 4 are shared across tracks — preserve any existing
// sub-step status / output. Phase 2 and Phase 3 are track-specific —
// rebuild from blueprint (pristine).
if (blueprint.id === 1 || blueprint.id === 4) {
const existing = state.phases?.find((p) => p.id === blueprint.id);
if (existing) return existing;
}
return makePhasesFromBlueprint([blueprint])[0];
});
state.track = newTrack;
}
module.exports = {
SCHEMA_VERSION,
PHASE_STATUS,
SUB_STEP_STATUS,
APPROVAL_KIND,
PROMPT_STATUS,
TRACK,
normalizePendingInput,
DEFAULT_TRACK,
PHASE_BLUEPRINTS_BY_TRACK,
// Back-compat exports — `PHASE_BLUEPRINT` was the pre-track flat list. We
// alias it to the Authoring Track (CLI value `A`) so any external caller that imported it keeps working.
PHASE_BLUEPRINT: PHASE_BLUEPRINTS_BY_TRACK.A,
buildInitialState,
rebuildPhasesForTrack,
};
Related skills
| Skill | Stars | Updated | Works with | Status | Install |
|---|---|---|---|---|---|
| reverse-engineer-anythingmorluto/reaReverse engineer native, managed, Electron/JavaScript, packaged, firmware, and browser targets with REA, and build agent environments (AgentEnv bundles) of web applications from a live instance or a capture, and of Linux desktop apps with a task from a request. Use shipped-artifact or requested runtime evidence to explain features, compare versions, decompile code, or guide a reconstruction. Skip REA for ordinary source-repository architecture analysis. | Stars: 471k | Updated | Claude CodeCodex | Verified | Install |
| diagnosing-superpowersobra/superpowersUse when a superpowers session went wrong and your human partner wants to know why — repeated work, ignored plans, stumbles, poor results, a skill that didn't fire, "it took too long", "why is it so expensive", "what is it doing" — or wants to build a bug report for the superpowers maintainers, for the current session or a past one identified by id or path, on any harness. | Stars: 322k | Updated | Claude CodeCodex | Verified | Install |
| dispatching-parallel-agentsobra/superpowersUse when facing 2+ independent tasks that can be worked on without shared state or sequential dependencies | Stars: 322k | Updated | Claude CodeCodex | Verified | Install |
| executing-plansobra/superpowersUse when executing an implementation plan in the current session as the implementer yourself — your human partner chose inline execution, or no subagent tool is available | Stars: 322k | Updated | Claude CodeCodex | Verified | Install |