generateGelSnapshot() — drizzle-orm Function Reference
Architecture documentation for the generateGelSnapshot() function in gelSerializer.ts from the drizzle-orm codebase.
Entity Profile
Dependency Diagram
graph TD 1b08e484_fe62_7d00_e0d5_3ca64286e7c0["generateGelSnapshot()"] 33990744_4141_72e3_2ae9_3c695bf71d75["gelSerializer.ts"] 1b08e484_fe62_7d00_e0d5_3ca64286e7c0 -->|defined in| 33990744_4141_72e3_2ae9_3c695bf71d75 0f6bcec9_496e_3388_a2d6_2f3af1e12d53["getColumnCasing()"] 1b08e484_fe62_7d00_e0d5_3ca64286e7c0 -->|calls| 0f6bcec9_496e_3388_a2d6_2f3af1e12d53 0546f46b_58be_4c12_a807_f17354873cc2["stringFromIdentityProperty()"] 1b08e484_fe62_7d00_e0d5_3ca64286e7c0 -->|calls| 0546f46b_58be_4c12_a807_f17354873cc2 1ed9d4bb_6bd4_7461_691d_8eaf6f2fe88b["minRangeForIdentityBasedOn()"] 1b08e484_fe62_7d00_e0d5_3ca64286e7c0 -->|calls| 1ed9d4bb_6bd4_7461_691d_8eaf6f2fe88b 0cd538a7_7db2_61a1_179e_ae783d7fd7d6["maxRangeForIdentityBasedOn()"] 1b08e484_fe62_7d00_e0d5_3ca64286e7c0 -->|calls| 0cd538a7_7db2_61a1_179e_ae783d7fd7d6 5de2ec9b_64d7_f004_04c1_e08f9695c862["sqlToStr()"] 1b08e484_fe62_7d00_e0d5_3ca64286e7c0 -->|calls| 5de2ec9b_64d7_f004_04c1_e08f9695c862 6a0cfd17_5e20_42bb_3596_ae02093b0fda["escapeSingleQuotes()"] 1b08e484_fe62_7d00_e0d5_3ca64286e7c0 -->|calls| 6a0cfd17_5e20_42bb_3596_ae02093b0fda df20eaf7_cb8a_0fa8_5dba_f71d57f9b8b1["indexName()"] 1b08e484_fe62_7d00_e0d5_3ca64286e7c0 -->|calls| df20eaf7_cb8a_0fa8_5dba_f71d57f9b8b1 df649335_4a23_c3d9_4cef_2482f225c115["buildArrayString()"] 1b08e484_fe62_7d00_e0d5_3ca64286e7c0 -->|calls| df649335_4a23_c3d9_4cef_2482f225c115 style 1b08e484_fe62_7d00_e0d5_3ca64286e7c0 fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
drizzle-kit/src/serializer/gelSerializer.ts lines 95–899
const generateGelSnapshot = (
tables: AnyGelTable[],
// enums: GelEnum<any>[],
schemas: GelSchema[],
sequences: GelSequence[],
roles: GelRole[],
policies: GelPolicy[],
views: GelView[],
matViews: GelMaterializedView[],
casing: CasingType | undefined,
schemaFilter?: string[],
): GelSchemaInternal => {
const dialect = new GelDialect({ casing });
const result: Record<string, Table> = {};
const resultViews: Record<string, View> = {};
const sequencesToReturn: Record<string, Sequence> = {};
const rolesToReturn: Record<string, Role> = {};
// this policies are a separate objects that were linked to a table outside of it
const policiesToReturn: Record<string, Policy> = {};
// This object stores unique names for indexes and will be used to detect if you have the same names for indexes
// within the same PostgreSQL schema
const indexesInSchema: Record<string, string[]> = {};
for (const table of tables) {
// This object stores unique names for checks and will be used to detect if you have the same names for checks
// within the same PostgreSQL table
const checksInTable: Record<string, string[]> = {};
const {
name: tableName,
columns,
indexes,
foreignKeys,
checks,
schema,
primaryKeys,
uniqueConstraints,
policies,
enableRLS,
} = getTableConfig(table);
if (schemaFilter && !schemaFilter.includes(schema ?? 'public')) {
continue;
}
const columnsObject: Record<string, Column> = {};
const indexesObject: Record<string, Index> = {};
// const checksObject: Record<string, CheckConstraint> = {};
const foreignKeysObject: Record<string, ForeignKey> = {};
const primaryKeysObject: Record<string, PrimaryKey> = {};
// const uniqueConstraintObject: Record<string, UniqueConstraint> = {};
const policiesObject: Record<string, Policy> = {};
columns.forEach((column) => {
const name = getColumnCasing(column, casing);
const notNull: boolean = column.notNull;
const primaryKey: boolean = column.primary;
const sqlTypeLowered = column.getSQLType().toLowerCase();
// const typeSchema = is(column, GelEnumColumn) ? column.enum.schema || 'public' : undefined;
const generated = column.generated;
const identity = column.generatedIdentity;
const increment = stringFromIdentityProperty(identity?.sequenceOptions?.increment) ?? '1';
const minValue = stringFromIdentityProperty(identity?.sequenceOptions?.minValue)
?? (parseFloat(increment) < 0 ? minRangeForIdentityBasedOn(column.columnType) : '1');
const maxValue = stringFromIdentityProperty(identity?.sequenceOptions?.maxValue)
?? (parseFloat(increment) < 0 ? '-1' : maxRangeForIdentityBasedOn(column.getSQLType()));
const startWith = stringFromIdentityProperty(identity?.sequenceOptions?.startWith)
?? (parseFloat(increment) < 0 ? maxValue : minValue);
const cache = stringFromIdentityProperty(identity?.sequenceOptions?.cache) ?? '1';
const columnToSet: Column = {
name,
type: column.getSQLType(),
typeSchema: undefined,
primaryKey,
notNull,
generated: generated
Domain
Subdomains
Defined In
Calls
Source
Frequently Asked Questions
What does generateGelSnapshot() do?
generateGelSnapshot() is a function in the drizzle-orm codebase, defined in drizzle-kit/src/serializer/gelSerializer.ts.
Where is generateGelSnapshot() defined?
generateGelSnapshot() is defined in drizzle-kit/src/serializer/gelSerializer.ts at line 95.
What does generateGelSnapshot() call?
generateGelSnapshot() calls 8 function(s): buildArrayString, escapeSingleQuotes, getColumnCasing, indexName, maxRangeForIdentityBasedOn, minRangeForIdentityBasedOn, sqlToStr, stringFromIdentityProperty.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free