import type { Database } from '..'; export interface BuiltMigrationFile { filename: string; content: string; } export interface RenameColumnOperation { table: string; from: string; to: string; comment?: string; } export interface RenameTableOperation { from: string; to: string; comment?: string; } export interface UpdateRowsOperation { table: string; where: Record; set: Record; guardColumn?: string; comment?: string; } /** * One logical operation per generated file: the composed `origin -> final` * attribute renames of every model that received hops, keyed by model uid. * Dispatched at runtime to the handlers registered on `db.schema` (e.g. admin * field permissions); the database package itself stores nothing by attribute * name. */ export interface AttributeRenamesOperation { renames: Record>; comment?: string; } export type MigrationFileOperation = ({ kind: 'renameColumn'; } & RenameColumnOperation) | ({ kind: 'renameTable'; } & RenameTableOperation) | ({ kind: 'updateRows'; } & UpdateRowsOperation) | ({ kind: 'attributeRenames'; } & AttributeRenamesOperation); export type MigrationFileFormat = 'javascript' | 'typescript'; /** * Produces a sortable, filesystem-safe UTC timestamp (e.g. `2026.06.11T15.16.00.123`). * * Based on the migration generator's format but keeps milliseconds: generated * migrations can be written multiple times in the same second, so second * precision would produce colliding filenames. UTC (not local time) so that * files generated by developers in different time zones still sort in the * order they were created. */ export declare const getFormattedTimestamp: (date?: Date) => string; export declare const getOperationComment: (op: MigrationFileOperation) => string; export declare const renderMigrationFileOperation: (op: MigrationFileOperation) => string; export declare const renderMigrationFile: ({ timestamp, operations, format, }: { timestamp: string; operations: MigrationFileOperation[]; format?: MigrationFileFormat; }) => string; interface BuildOptions { name: string; /** * Module format of the generated file. `typescript` emits an ES module with * typed `up`/`down` signatures and a `.ts` extension so the app's `tsc` build * compiles it into `dist/database/migrations`, which is where migrations are * discovered when `useTypescriptMigrations` is enabled. Defaults to * `javascript` (CommonJS). */ format?: MigrationFileFormat; } interface WriteOptions extends BuildOptions { /** * Directory the migration file is written to. Defaults to the database's * configured migrations directory. The Content-Type Builder passes the app's * source `database/migrations` explicitly so the file is never written into * build output (e.g. `dist/` when `useTypescriptMigrations` is enabled). */ dir?: string; } interface MigrationFileBuilderDeps { db: Database; } export declare const createMigrationFileBuilder: ({ db }: MigrationFileBuilderDeps) => { renameColumn(op: RenameColumnOperation): void; renameTable(op: RenameTableOperation): void; updateRows(op: UpdateRowsOperation): void; attributeRenames(op: AttributeRenamesOperation): void; hasChanges(): boolean; getOperations(): MigrationFileOperation[]; build({ name, format }: BuildOptions, date?: Date): BuiltMigrationFile | null; writeFiles(options: WriteOptions): Promise; }; export type MigrationFileBuilder = ReturnType; export {}; //# sourceMappingURL=file-builder.d.ts.map