@adonisjs/lucid
Version:
SQL ORM built on top of Active Record pattern
85 lines (84 loc) • 2.82 kB
TypeScript
/**
* Increment this version whenever the manifest shape changes in a backward
* incompatible way.
*/
export declare const SCHEMA_DUMP_MANIFEST_VERSION = 1;
/**
* Sidecar metadata written next to every SQL dump. The manifest lets Lucid
* reason about intentionally pruned migrations without parsing the SQL file.
*/
export type SchemaDumpManifest = {
version: number;
connection: string;
dumpPath: string;
generatedAt: string;
schemaTableName: string;
schemaVersionsTableName: string;
squashedMigrationNames: string[];
};
/**
* Context used to validate that a schema dump manifest belongs to the current
* migration bookkeeping tables and connection.
*/
export type SchemaDumpManifestContext = {
connection: string;
schemaTableName: string;
schemaVersionsTableName: string;
};
/**
* High-level wrapper around the schema dump sidecar manifest.
*/
export declare class SchemaDumpManifestFile {
#private;
private manifest;
/**
* Returns the default dump path for a given connection.
*/
static defaultDumpPath(connectionName: string): string;
/**
* Returns the manifest path stored next to the SQL dump.
*/
static metaPath(dumpPath: string): string;
/**
* Create a new manifest instance for the provided dump metadata.
*/
static create(payload: Omit<SchemaDumpManifest, 'version' | 'generatedAt'> & {
generatedAt?: string;
}): SchemaDumpManifestFile;
/**
* Convert an unknown JSON value into a manifest instance. Returns `null`
* when the value does not match the expected shape.
*/
static fromJSON(value: unknown): SchemaDumpManifestFile | null;
/**
* Read and validate a manifest file from disk.
*/
static read(path: string): Promise<SchemaDumpManifestFile | null>;
/**
* Read a manifest from disk and return it only when it matches the provided
* migration bookkeeping context.
*/
static readForContext(path: string, context: SchemaDumpManifestContext): Promise<SchemaDumpManifestFile | null>;
constructor(manifest: SchemaDumpManifest);
/**
* Persist the manifest as formatted JSON for readability and diffs.
*/
write(path: string): Promise<void>;
/**
* Returns the raw manifest payload.
*/
toJSON(): SchemaDumpManifest;
/**
* Returns true when the manifest was created for the provided migration
* bookkeeping context.
*/
matchesContext(payload: SchemaDumpManifestContext): boolean;
/**
* Returns true when the given migration name is part of the squashed baseline.
*/
hasSquashedMigration(name: string): boolean;
/**
* Returns the list of migration names stored inside the manifest.
*/
getSquashedMigrationNames(): string[];
}