Skip to content

Preview, review and apply ​

Read operations and previews do not change settings. Apply is a separate explicit operation with revision, application/lock checks and recovery backups.

Run a preview safely ​

Install @jalsoedesign/heidisql-core, follow language setup and save the synthetic settings. This program plans a new profile in those files but deliberately does not apply the plan. Source and destination profile paths identify saved records, not server directories.

ts
// preview-profile.ts
import {HeidiSqlProfileSource, createHeidiSqlWriter} from '@jalsoedesign/heidisql-core';

const source = await HeidiSqlProfileSource.fromFile(process.argv[2] ?? './portable_settings.txt');
const selected = source.get('Demo');

if (!selected) {
    throw new Error('The demo profile is missing');
}

// Plan a new saved profile in the same synthetic settings; do not apply it.
const targetPath = 'Imported';
const writer = createHeidiSqlWriter(source.source, {mode: 'create'});
const preview = await writer.plan([{
    ...selected,
    path: targetPath,
    name: 'Imported',
}]);

console.log('Source profile: ' + selected.path);
console.log('Destination profile: ' + targetPath);
console.log('Planned operations: ' + preview.changes.map(change => change.operation).join(', '));
console.log('Native settings written: no');
js
// preview-profile.js
import {HeidiSqlProfileSource, createHeidiSqlWriter} from '@jalsoedesign/heidisql-core';

const source = await HeidiSqlProfileSource.fromFile(process.argv[2] ?? './portable_settings.txt');
const selected = source.get('Demo');

if (!selected) {
    throw new Error('The demo profile is missing');
}

// Plan a new saved profile in the same synthetic settings; do not apply it.
const targetPath = 'Imported';
const writer = createHeidiSqlWriter(source.source, {mode: 'create'});
const preview = await writer.plan([{
    ...selected,
    path: targetPath,
    name: 'Imported',
}]);

console.log('Source profile: ' + selected.path);
console.log('Destination profile: ' + targetPath);
console.log('Planned operations: ' + preview.changes.map(change => change.operation).join(', '));
console.log('Native settings written: no');
js
// preview-profile.mjs
import {HeidiSqlProfileSource, createHeidiSqlWriter} from '@jalsoedesign/heidisql-core';

const source = await HeidiSqlProfileSource.fromFile(process.argv[2] ?? './portable_settings.txt');
const selected = source.get('Demo');

if (!selected) {
    throw new Error('The demo profile is missing');
}

// Plan a new saved profile in the same synthetic settings; do not apply it.
const targetPath = 'Imported';
const writer = createHeidiSqlWriter(source.source, {mode: 'create'});
const preview = await writer.plan([{
    ...selected,
    path: targetPath,
    name: 'Imported',
}]);

console.log('Source profile: ' + selected.path);
console.log('Destination profile: ' + targetPath);
console.log('Planned operations: ' + preview.changes.map(change => change.operation).join(', '));
console.log('Native settings written: no');
js
// preview-profile.cjs
async function main() {
    const {HeidiSqlProfileSource, createHeidiSqlWriter} = await import('@jalsoedesign/heidisql-core');

    const source = await HeidiSqlProfileSource.fromFile(process.argv[2] ?? './portable_settings.txt');
    const selected = source.get('Demo');

    if (!selected) {
        throw new Error('The demo profile is missing');
    }

    // Plan a new saved profile in the same synthetic settings; do not apply it.
    const targetPath = 'Imported';
    const writer = createHeidiSqlWriter(source.source, {mode: 'create'});
    const preview = await writer.plan([{
        ...selected,
        path: targetPath,
        name: 'Imported',
    }]);

    console.log('Source profile: ' + selected.path);
    console.log('Destination profile: ' + targetPath);
    console.log('Planned operations: ' + preview.changes.map(change => change.operation).join(', '));
    console.log('Native settings written: no');
}

main().catch(error => {
    console.error(error);
    process.exitCode = 1;
});

Run it ​

sh
npx tsx preview-profile.ts
sh
node preview-profile.js
sh
node preview-profile.mjs
sh
node preview-profile.cjs

Output ​

text
Source profile: Demo
Destination profile: Imported
Planned operations: create
Native settings written: no

Download: TypeScript · JavaScript · MJS · CommonJS

The printed operations are stable; detailed inspection and diagnostics can vary with platform and application availability. Preview output contains sanitized intent rather than stored credentials or native settings bytes.

Apply only after review ​

The following recipe continues the program above. Review the full preview first, close the application and other settings writers, and keep the same destination and policies. Applying changes is Windows-only with the built-in backend; this step is not part of the runnable preview test.

ts
await writer.apply(preview);

console.log(writer.backupPaths);
js
await writer.apply(preview);

console.log(writer.backupPaths);
js
await writer.apply(preview);

console.log(writer.backupPaths);
js
await writer.apply(preview);

console.log(writer.backupPaths);

The default mode is create. Existing paths are refused; updates/upserts require an explicit mode used consistently for preview and apply. Changed settings or edited serialized previews require replanning. See CLI write commands for saved preview files and writer contracts for importing a serialized plan.

One-way sync ​

Install the source application's adapter alongside the destination CLI. Use sync --help for source-specific selectors. A source with multiple connections requires explicit --connection; this is especially relevant to database sessions with SSH tunnels. Sync never infers that a database endpoint is an SSH server, and never prunes unrelated target profiles.

An SSH-only import updates the tunnel of an existing database session; it cannot invent a new database endpoint.

See safeguards and limitations for backups, secrets and registry policies.