import { CommandModule } from 'yargs'; import { generate } from './generate'; import { PgDumpOptions } from './pg-dump-options'; export const pgDump: CommandModule = { command: 'pg-dump', describe: 'Development command that uses a default PostgreSQL pg_dump utility to create a schema dump file of a specific database based on an existing docker-compose.yml file.', builder: (yargs) => yargs .option('composeFolderPath', { alias: 'c', default: 'infra', describe: 'Relative path to docker-compose.y(a)ml file, e.g. `infra` or `scripts/infra`. Script will look for such directory starting from current project, traversing directories closer to root, so no need to specify a path like `../../../infra`', string: true, }) .option('composeFilePath', { alias: 'f', describe: 'Relative or Absolute file path to the y(a)ml file. This option would override any composeFolderPath setting.', string: true, }) .option('dumpPath', { alias: 'd', default: 'src/generated/db/schema.sql', describe: 'Relative path from working directory to a schema SQL file which will be created by pg_dump utility, e.g. `src/generated/db/schema.sql`', string: true, }) .option('excludeSchemas', { alias: 'e', default: 'graphile_migrate,graphile_worker', describe: 'A comma-separated string of database schema names that should be excluded from pg_dump, e.g. `schema_one,schema_two`', string: true, }) .option('connectionString', { alias: 's', describe: 'The connection string to the database to be used to take a schema dump. Can be omitted if database-related environment variables are preloaded', string: true, }), handler: generate, };