/* eslint-disable @typescript-eslint/camelcase */ import { v4 as uuidv4 } from 'uuid'; import bcrypt from 'bcrypt'; import { VersionedSeedsConfig, ColumnSeedsOptions } from '@bmd-studio/genstack-pg'; import environment from '@bmd-studio/genstack-environment'; const { POSTGRES_PUBLIC_SCHEMA_NAME, } = environment.env; const IDENTITIES_PER_APP = 1000; const PROJECTS_PER_IDENTITY = [10, 50]; const BCRYPT_SALT_ROUNDS = 1; const seedsConfig: VersionedSeedsConfig = { version: 1, config: { name: 'default', debugPerRowAmount: 10000, maxRowsPerFile: 10000, maxRowsPerInsert: 2000, disableTriggers: true, schemas: [{ name: POSTGRES_PUBLIC_SCHEMA_NAME, tables: [{ name: 'identities', amount: IDENTITIES_PER_APP, columns: [ { name: 'name', value: (): string => `name_${uuidv4()}` }, { name: 'username', value: ({ row }: ColumnSeedsOptions): string => `${row.name}@gmail.com` }, { name: 'password', value: async (): Promise => { const hashedPassword = await bcrypt.hash('test', BCRYPT_SALT_ROUNDS); return hashedPassword; } }, ], tables: [{ name: 'projects', amount: PROJECTS_PER_IDENTITY, columns: [ { name: 'name', value: (): string => `name_${uuidv4()}` }, { name: 'description', value: (): string => `description of ${uuidv4()}` }, ], tables: [{ name: 'project_permissions', amount: 1, columns: [ { name: 'project_id', value: ({ row }: ColumnSeedsOptions): string => row.getParent('projects')?.id }, { name: 'identity_id', value: ({ row }: ColumnSeedsOptions): string => row.getParent('identities')?.id }, ], }], }], }], }], }, }; export default seedsConfig;