Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/lib/file-generators/generated/[schema_name]/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ export const createSchemaGeneratedTypeIndexFile = (
config: Config,
): SourceFile => {
const { project, schema } = args
const { output_dir } = config
const { output_dir, main_schema } = config

const pascal_schema_name = pascalCase(schema.name)

Expand Down Expand Up @@ -80,7 +80,7 @@ export const createSchemaGeneratedTypeIndexFile = (
name: 'KnexSchemaTypeMap',
properties: tables.map((table) => ({
name:
schema.name === 'seam'
schema.name === main_schema
? table.name
: `"${schema.name}.${table.name}"`,
type: table.is_affected_by_pgtui_bugs
Expand Down
20 changes: 19 additions & 1 deletion src/lib/file-generators/generated/knex.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ export const createKnexIndexFile = (
config: Config,
): SourceFile => {
const { project, schemas } = args
const { output_dir } = config
const { output_dir, main_schema } = config

const statements: StatementedNodeStructure['statements'] = []
const module_interface_statements: StatementedNodeStructure['statements'] = []
Expand All @@ -35,12 +35,30 @@ export const createKnexIndexFile = (
],
})

if (schema.name === main_schema) {
statements.push({
kind: StructureKind.TypeAlias,
name: `Prefixed${pascalCase(schema.name)}TypeMap`,
type: `{ [K in keyof ${pascalCase(schema.name)}TypeMap as \`${schema.name}.\${K}\`]: ${pascalCase(schema.name)}TypeMap[K] }`,
isExported: false,
})
}

module_interface_statements.push({
kind: StructureKind.Interface,
name: 'Tables',
extends: [`${pascalCase(schema.name)}TypeMap`],
properties: [],
})

if (schema.name === main_schema) {
module_interface_statements.push({
kind: StructureKind.Interface,
name: 'Tables',
extends: [`Prefixed${pascalCase(schema.name)}TypeMap`],
properties: [],
})
}
}

// Create the module declaration
Expand Down