graphile-migrate
Version:
Opinionated SQL-powered migration tool for PostgreSQL
79 lines (78 loc) • 3.35 kB
TypeScript
import { Client, Context } from "./pg";
import { ParsedSettings } from "./settings";
export interface Migration {
/**
* The filename without the message slug in it, used for storing to the database.
*/
filename: string;
/**
* A hash of the content of the migration.
*/
hash: string;
/**
* The hash of the previous migration, or null if there was no previous migration
*/
previousHash: string | null;
/**
* True if we should allow the hash to be invalid; false otherwise.
*/
allowInvalidHash: boolean;
}
export interface DbMigration extends Migration {
date: Date;
}
export interface FileMigration extends Migration {
/**
* The actual filename on disk
*/
realFilename: string;
/**
* The content of the migration
*/
body: string;
/**
* The message the migration was committed with
*/
message: string | null;
/**
* The slugified message, stored as part of the file name
*/
messageSlug: string | null;
/**
* The full path to this migration on disk
*/
fullPath: string;
/**
* If there was a previous migration, that
*/
previous: FileMigration | null;
}
export declare const slowGeneratePlaceholderReplacement: (parsedSettings: ParsedSettings, { database }: Context) => (str: string) => string;
export declare const generatePlaceholderReplacement: (parsedSettings: ParsedSettings, __1: Context) => (str: string) => string;
export declare function compilePlaceholders(parsedSettings: ParsedSettings, content: string, shadow?: boolean): string;
export declare function _migrateMigrationSchema(pgClient: Client, parsedSettings: ParsedSettings): Promise<void>;
export declare function parseMigrationText(fullPath: string, contents: string,
/**
* Should be set true for committed migrations - requires that there is a \n\n divide after the header
*/
strict?: boolean): {
headers: {
[key: string]: string | null;
};
body: string;
};
export declare function serializeHeader(key: string, value: string | null): string;
export declare function serializeMigration(body: string, headers: {
[key: string]: string | null | undefined;
}): string;
export declare const isMigrationFilename: (filename: string) => RegExpMatchArray | null;
export declare function getLastMigration(pgClient: Client, parsedSettings: ParsedSettings): Promise<DbMigration | null>;
export declare function getAllMigrations(parsedSettings: ParsedSettings): Promise<Array<FileMigration>>;
export declare function getMigrationsAfter(parsedSettings: ParsedSettings, previousMigration: Migration | null): Promise<Array<FileMigration>>;
export declare function runStringMigration(pgClient: Client, parsedSettings: ParsedSettings, context: Context, rawBody: string, filename: string, committedMigration?: FileMigration, dryRun?: boolean): Promise<{
sql: string;
transaction: boolean;
}>;
export declare function undoMigration(parsedSettings: ParsedSettings, committedMigration: FileMigration): Promise<void>;
export declare function runCommittedMigration(pgClient: Client, parsedSettings: ParsedSettings, context: Context, committedMigration: FileMigration, logSuffix: string): Promise<void>;
export declare function reverseMigration(pgClient: Client, _body: string): Promise<void>;