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

Function prepareFromExports

drizzle-kit/src/serializer/pgImports.ts:16–67  ·  view source on GitHub ↗
(exports: Record<string, unknown>)

Source from the content-addressed store, hash-verified

14import { safeRegister } from '../cli/commands/utils';
15
16export const prepareFromExports = (exports: Record<string, unknown>) => {
17 const tables: AnyPgTable[] = [];
18 const enums: PgEnum<any>[] = [];
19 const schemas: PgSchema[] = [];
20 const sequences: PgSequence[] = [];
21 const roles: PgRole[] = [];
22 const policies: PgPolicy[] = [];
23 const views: PgView[] = [];
24 const matViews: PgMaterializedView[] = [];
25 const relations: Relations[] = [];
26
27 const i0values = Object.values(exports);
28 i0values.forEach((t) => {
29 if (isPgEnum(t)) {
30 enums.push(t);
31 return;
32 }
33 if (is(t, PgTable)) {
34 tables.push(t);
35 }
36
37 if (is(t, PgSchema)) {
38 schemas.push(t);
39 }
40
41 if (isPgView(t)) {
42 views.push(t);
43 }
44
45 if (isPgMaterializedView(t)) {
46 matViews.push(t);
47 }
48
49 if (isPgSequence(t)) {
50 sequences.push(t);
51 }
52
53 if (is(t, PgRole)) {
54 roles.push(t);
55 }
56
57 if (is(t, PgPolicy)) {
58 policies.push(t);
59 }
60
61 if (is(t, Relations)) {
62 relations.push(t);
63 }
64 });
65
66 return { tables, enums, schemas, sequences, views, matViews, roles, policies, relations };
67};
68
69export const prepareFromPgImports = async (imports: string[]) => {
70 const tables: AnyPgTable[] = [];

Callers 5

generateDrizzleJsonFunction · 0.90
generateMySQLDrizzleJsonFunction · 0.90
prepareFromPgImportsFunction · 0.70

Calls 6

isPgEnumFunction · 0.90
isFunction · 0.90
isPgViewFunction · 0.90
isPgMaterializedViewFunction · 0.90
isPgSequenceFunction · 0.90
valuesMethod · 0.45

Tested by

no test coverage detected