import { ModuleContext, ModuleManifest } from '@gzl10/nexus-sdk'; import { Knex } from 'knex'; /** * Create all tables from all modules in FK-dependency order. * Collects all entity definitions, sorts by FK references, and creates inline. * This ensures cross-module FKs work correctly (including SQLite). */ declare function runAllGeneratedMigrations(ctx: ModuleContext, modules: ModuleManifest[]): Promise; /** * @deprecated Use runAllGeneratedMigrations instead. * Kept for backward compatibility with tests that use it directly. */ declare function runGeneratedMigration(ctx: ModuleContext, module: ModuleManifest): Promise; /** * Get the database client type * Returns 'sqlite' as default when client type cannot be determined (e.g., in mocks) */ declare function getDbClient(db: Knex): 'postgres' | 'mysql' | 'sqlite'; /** * Format timestamp for database insert/update * - PostgreSQL: accepts ISO strings directly * - MySQL: requires 'YYYY-MM-DD HH:MM:SS' format * - SQLite: accepts ISO strings (stored as TEXT) * * @param db Knex instance to detect driver * @param date Date object (defaults to now) * @returns Formatted timestamp string */ declare function formatTimestamp(db: Knex, date?: Date): string; /** * Get current timestamp formatted for the database */ declare function nowTimestamp(db: Knex): string; /** * Adds timestamp fields to a table during creation. * - PostgreSQL: uses timestamptz (timestamp with time zone) * - MySQL: uses standard timestamp * - SQLite: uses TEXT with datetime('now') for ISO string consistency */ declare function addTimestamps(table: Knex.CreateTableBuilder, db: Knex): void; /** * Adds audit fields (created_by, updated_by) to an existing table if missing. * Note: SQLite does not support ALTER TABLE ADD COLUMN with a non-constant default. */ declare function addAuditFieldsIfMissing(db: Knex, tableName: string): Promise; /** * Adds is_default field to config tables. * Allows marking which configuration is the default at runtime. */ declare function addConfigDefaultField(db: Knex, tableName: string): Promise; /** * Adds deleted_at field for soft delete support. * Called when entity has softDelete: true. */ declare function addSoftDeleteFieldIfMissing(db: Knex, tableName: string): Promise; /** * Adds a column if it does not exist */ declare function addColumnIfMissing(db: Knex, tableName: string, columnName: string, columnBuilder: (table: Knex.AlterTableBuilder) => void): Promise; export { addAuditFieldsIfMissing, addColumnIfMissing, addConfigDefaultField, addSoftDeleteFieldIfMissing, addTimestamps, formatTimestamp, getDbClient, nowTimestamp, runAllGeneratedMigrations, runGeneratedMigration };