/** * CLI Types * * Type definitions for the postgres.do CLI. * * @module cli/types */ /** * Base CLI options */ export interface BaseCLIOptions { command: string url?: string | undefined help?: boolean | undefined verbose?: boolean | undefined json?: boolean | undefined } /** * Schema generation CLI options */ export interface SchemaCLIOptions extends BaseCLIOptions { input?: string | undefined output?: string | undefined schema?: string | undefined includeRelations?: boolean | undefined includeIndexes?: boolean | undefined includeTables?: string[] | undefined excludeTables?: string[] | undefined generateTypes?: boolean | undefined watch?: boolean | undefined } /** * Migration CLI options */ export interface MigrateCLIOptions extends BaseCLIOptions { // Directory containing migrations migrationsDir?: string | undefined // Migration name (for create command) name?: string | undefined // Target version for migrate:to or rollback:to toVersion?: number | undefined // Number of migrations to rollback steps?: number | undefined // Force rollback of non-reversible migrations force?: boolean | undefined // Dry run mode - show what would happen dryRun?: boolean | undefined // DO instance ID for DO-specific operations doId?: string | undefined // Migration file format (ts or sql) migrationFormat?: 'ts' | 'sql' | undefined } /** * Schema diff CLI options */ export interface SchemaDiffCLIOptions extends BaseCLIOptions { // Source database URL (what we're comparing from) from?: string | undefined // Target database URL (what we're comparing to) to?: string | undefined // Schema to compare schema?: string | undefined // Tables to include includeTables?: string[] | undefined // Tables to exclude excludeTables?: string[] | undefined // Include index comparison includeIndexes?: boolean | undefined // Ignore case differences in names ignoreCase?: boolean | undefined // Generate migration file from diff generateMigration?: boolean | undefined // Migration name migrationName?: string | undefined // Migration format (ts or sql) migrationFormat?: 'ts' | 'sql' | undefined // Migrations directory migrationsDir?: string | undefined // Use safe mode (IF EXISTS/IF NOT EXISTS) safeMode?: boolean | undefined // Wrap migration in transaction wrapInTransaction?: boolean | undefined // Exit with code 1 if schemas differ exitCode?: boolean | undefined // Disable color output noColor?: boolean | undefined } /** * Schema sync (push/pull) CLI options */ export interface SchemaSyncCLIOptions extends BaseCLIOptions { // Input file for schema:push input?: string | undefined // Output file for schema:pull output?: string | undefined // Database schema name schema?: string | undefined // Include relations in generated schema includeRelations?: boolean | undefined // Include indexes in generated schema includeIndexes?: boolean | undefined // Tables to include includeTables?: string[] | undefined // Tables to exclude excludeTables?: string[] | undefined // Generate TypeScript types alongside schema generateTypes?: boolean | undefined // Dry run mode - show what would happen dryRun?: boolean | undefined // Force push even with destructive changes force?: boolean | undefined // Disable color output noColor?: boolean | undefined // DO instance ID for DO-specific operations doId?: string | undefined } /** * Dev server CLI options */ export interface DevCLIOptions extends BaseCLIOptions { // Directory containing migrations migrationsDir?: string | undefined // Directory containing seed files seedsDir?: string | undefined // Port for the dev server (if HTTP interface enabled) port?: number | undefined // Directory to persist data (null = in-memory) dataDir?: string | undefined // Enable persistent storage persist?: boolean | undefined // Enable file watching watch?: boolean | undefined // Enable wrangler integration wrangler?: boolean | undefined // Run seeds after migrations seed?: boolean | undefined // DO instance ID for DO-specific operations doId?: string | undefined } /** * Combined CLI options */ export interface CLIOptions extends SchemaCLIOptions, MigrateCLIOptions, SchemaDiffCLIOptions, SchemaSyncCLIOptions, DevCLIOptions {} /** * Migration progress event for formatting */ export interface MigrationProgressDisplay { migration: { id: string name: string version: number } index: number total: number phase: 'starting' | 'executing' | 'completed' | 'failed' | 'skipped' durationMs?: number error?: string } /** * Rollback progress event for formatting */ export interface RollbackProgressDisplay { migration: { id: string name: string version: number } index: number total: number phase: 'starting' | 'executing' | 'completed' | 'failed' | 'skipped' durationMs?: number error?: string isDryRun?: boolean } /** * Migration dashboard CLI options */ export interface MigrateDashboardCLIOptions extends BaseCLIOptions { // API URL for postgres.do apiUrl?: string | undefined // API key for authentication apiKey?: string | undefined // Watch mode - continuously refresh dashboard watch?: boolean | undefined // Refresh interval in milliseconds (for watch mode) refreshInterval?: number | undefined // Show DOs at specific version showVersion?: number | undefined // Show failed migrations showFailed?: boolean | undefined // List migration operations listOperations?: boolean | undefined // Show specific operation details operationId?: string | undefined // Retry failed migrations for an operation retry?: string | undefined // Limit number of results limit?: number | undefined }