SchemaHistoryManager
Class: SchemaHistoryManager
Manager for schema version history.
Provides:
- Append-only history storage
- Version retrieval and comparison
- Visual diff generation between versions
Constructors
new SchemaHistoryManager()
new SchemaHistoryManager(adapter): SchemaHistoryManagerParameters
| Parameter | Type |
|---|---|
adapter | FlashcoreAdapter<string, unknown> |
Returns
Methods
appendHistory()
appendHistory(entry, namespace?): Promise<void>Append a new history entry.
Parameters
| Parameter | Type | Description |
|---|---|---|
entry | SchemaHistoryEntry | History entry to append |
namespace? | string | Namespace name (undefined for default) |
Returns
Promise<void>
clearHistory()
clearHistory(namespace?): Promise<void>Clear all history for a namespace.
Parameters
| Parameter | Type | Description |
|---|---|---|
namespace? | string | Namespace name (undefined for default) |
Returns
Promise<void>
diffVersions()
diffVersions(
fromVersion,
toVersion,
namespace?): Promise<VersionDiff>Generate a diff between two versions.
Parameters
| Parameter | Type | Description |
|---|---|---|
fromVersion | number | Starting version number |
toVersion | number | Ending version number |
namespace? | string | Namespace name (undefined for default) |
Returns
Promise<VersionDiff>
Version diff or null if versions not found
getChangesBetween()
getChangesBetween(
fromVersion,
toVersion,
namespace?): Promise<SchemaChange[]>Get changes between two versions as a flat list.
Parameters
| Parameter | Type | Description |
|---|---|---|
fromVersion | number | Starting version number |
toVersion | number | Ending version number |
namespace? | string | Namespace name (undefined for default) |
Returns
Promise<SchemaChange[]>
List of changes
getHistory()
getHistory(namespace?): Promise<SchemaHistoryEntry[]>Get the full schema history for a namespace.
Parameters
| Parameter | Type | Description |
|---|---|---|
namespace? | string | Namespace name (undefined for default) |
Returns
Promise<SchemaHistoryEntry[]>
Array of history entries, oldest first
getVersion()
getVersion(namespace?): Promise<number>Get the latest version number for a namespace.
Parameters
| Parameter | Type | Description |
|---|---|---|
namespace? | string | Namespace name (undefined for default) |
Returns
Promise<number>
Latest version number, or 0 if no history
getVersionEntry()
getVersionEntry(version, namespace?): Promise<SchemaHistoryEntry>Get a specific history entry by version.
Parameters
| Parameter | Type | Description |
|---|---|---|
version | number | Version number to retrieve |
namespace? | string | Namespace name (undefined for default) |
Returns
Promise<SchemaHistoryEntry>
History entry or null if not found
createAutoEntry()
static createAutoEntry(
version,
checksum,
changes): SchemaHistoryEntryCreate a history entry for auto-applied changes.
Parameters
| Parameter | Type | Description |
|---|---|---|
version | number | New version number |
checksum | string | New combined checksum |
changes | SchemaChange[] | Changes that were auto-applied |
Returns
History entry
createMigrationEntry()
static createMigrationEntry(
version,
checksum,
changes,
migrationName): SchemaHistoryEntryCreate a history entry for migration-applied changes.
Parameters
| Parameter | Type | Description |
|---|---|---|
version | number | New version number |
checksum | string | New combined checksum |
changes | SchemaChange[] | Changes that were applied |
migrationName | string | Name of the migration |
Returns
History entry
formatHistory()
static formatHistory(entries, options): stringFormat history entries for display.
Parameters
| Parameter | Type | Description |
|---|---|---|
entries | SchemaHistoryEntry[] | History entries to format |
options | { limit: number; showChanges: boolean; } | Formatting options |
options.limit? | number | - |
options.showChanges? | boolean | - |
Returns
string
Formatted string
formatVersionDiff()
static formatVersionDiff(diff): stringFormat a version diff for display.
Parameters
| Parameter | Type | Description |
|---|---|---|
diff | VersionDiff | Version diff to format |
Returns
string
Formatted string
