MCPcopy
hub / github.com/drizzle-team/drizzle-orm / pgPushIntrospect

Function pgPushIntrospect

drizzle-kit/src/cli/commands/pgIntrospect.ts:10–55  ·  view source on GitHub ↗
(
	db: DB,
	filters: string[],
	schemaFilters: string[],
	entities: Entities,
	tsSchema?: PgSchemaInternal,
)

Source from the content-addressed store, hash-verified

8import { ProgressView } from '../views';
9
10export const pgPushIntrospect = async (
11 db: DB,
12 filters: string[],
13 schemaFilters: string[],
14 entities: Entities,
15 tsSchema?: PgSchemaInternal,
16) => {
17 const matchers = filters.map((it) => {
18 return new Minimatch(it);
19 });
20
21 const filter = (tableName: string) => {
22 if (matchers.length === 0) return true;
23
24 let flags: boolean[] = [];
25
26 for (let matcher of matchers) {
27 if (matcher.negate) {
28 if (!matcher.match(tableName)) {
29 flags.push(false);
30 }
31 }
32
33 if (matcher.match(tableName)) {
34 flags.push(true);
35 }
36 }
37
38 if (flags.length > 0) {
39 return flags.every(Boolean);
40 }
41 return false;
42 };
43 const progress = new ProgressView(
44 'Pulling schema from database...',
45 'Pulling schema from database...',
46 );
47 const res = await renderWithTask(
48 progress,
49 fromDatabase(db, filter, schemaFilters, entities, undefined, tsSchema),
50 );
51
52 const schema = { id: originUUID, prevId: '', ...res } as PgSchema;
53 const { internal, ...schemaWithoutInternals } = schema;
54 return { schema: schemaWithoutInternals };
55};

Callers 2

pushSchemaFunction · 0.90
pgPushFunction · 0.85

Calls 1

fromDatabaseFunction · 0.50

Tested by

no test coverage detected