Skip to content

Commit

Permalink
ignore postgis tables, prettier ignore file
Browse files Browse the repository at this point in the history
  • Loading branch information
r1tsuu committed Dec 13, 2024
1 parent 2189811 commit cc3861e
Show file tree
Hide file tree
Showing 3 changed files with 57 additions and 74 deletions.
1 change: 1 addition & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,4 @@ packages/payload/*.js
packages/payload/*.d.ts
payload-types.ts
tsconfig.tsbuildinfo
test/database/generated-database-schema.ts
3 changes: 3 additions & 0 deletions packages/drizzle/src/utilities/createSchemaGenerator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -112,10 +112,13 @@ export const createSchemaGenerator = ({
) {
const tempDir = path.resolve(os.tmpdir(), uuid())

const hasPostgis = Boolean((this as any).extensions?.postgis)

const drizzleArgs = {
dialect,
out: tempDir,
schemaFilter,
tablesFilter: hasPostgis ? '!spatial_ref_sys' : undefined,
url,
}

Expand Down
127 changes: 53 additions & 74 deletions test/database/generated-database-schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,16 @@
*/
import {
pgTable,
check,
integer,
varchar,
index,
serial,
varchar,
boolean,
timestamp,
geometry,
jsonb,
foreignKey,
unique,
integer,
text,
uniqueIndex,
numeric,
Expand Down Expand Up @@ -51,25 +50,6 @@ export const enumDefaultValuesSelect = pgEnum('enum_default_values_select', [
export const radioEnum = pgEnum('radioEnum', ['a', 'b', 'c'])
export const selectEnum = pgEnum('selectEnum', ['a', 'b', 'c'])

export const spatialRefSys = pgTable(
'spatial_ref_sys',
{
srid: integer().primaryKey().notNull(),
authName: varchar('auth_name', { length: 256 }),
authSrid: integer('auth_srid'),
srtext: varchar({ length: 2048 }),
proj4Text: varchar({ length: 2048 }),
},
(table) => {
return {
spatialRefSysSridCheck: check(
'spatial_ref_sys_srid_check',
sql`(srid > 0) AND (srid <= 998999)`,
),
}
},
)

export const posts = pgTable(
'posts',
{
Expand Down Expand Up @@ -549,40 +529,6 @@ export const pgMigrationsV = pgTable(
},
)

export const pgMigrationsVBlocksMyBlockLocales = pgTable(
'_pg_migrations_v_blocks_my_block_locales',
{
relation6Id: integer('relation6_id'),
id: serial().primaryKey().notNull(),
locale: locales('_locale').notNull(),
parentId: integer('_parent_id').notNull(),
},
(table) => {
return {
pgMigrationsVBlocksMyBlockRelation6Idx: index(
'_pg_migrations_v_blocks_my_block_relation6_idx',
).using(
'btree',
table.relation6Id.asc().nullsLast().op('int4_ops'),
table.locale.asc().nullsLast().op('int4_ops'),
),
pgMigrationsVBlocksMyBlockLocalesRelation6IdRelation: foreignKey({
columns: [table.relation6Id],
foreignColumns: [relationB.id],
name: '_pg_migrations_v_blocks_my_block_locales_relation6_id_relation_',
}).onDelete('set null'),
pgMigrationsVBlocksMyBlockLocalesParentIdFk: foreignKey({
columns: [table.parentId],
foreignColumns: [pgMigrationsVBlocksMyBlock.id],
name: '_pg_migrations_v_blocks_my_block_locales_parent_id_fk',
}).onDelete('cascade'),
pgMigrationsVBlocksMyBlockLocalesLocaleParentIdUniqu: unique(
'_pg_migrations_v_blocks_my_block_locales_locale_parent_id_uniqu',
).on(table.locale, table.parentId),
}
},
)

export const pgMigrationsVLocales = pgTable(
'_pg_migrations_v_locales',
{
Expand Down Expand Up @@ -1839,6 +1785,40 @@ export const pgMigrationsVVersionMyArrayMySubArray = pgTable(
},
)

export const pgMigrationsVBlocksMyBlockLocales = pgTable(
'_pg_migrations_v_blocks_my_block_locales',
{
relation6Id: integer('relation6_id'),
id: serial().primaryKey().notNull(),
locale: locales('_locale').notNull(),
parentId: integer('_parent_id').notNull(),
},
(table) => {
return {
pgMigrationsVBlocksMyBlockRelation6Idx: index(
'_pg_migrations_v_blocks_my_block_relation6_idx',
).using(
'btree',
table.relation6Id.asc().nullsLast().op('int4_ops'),
table.locale.asc().nullsLast().op('int4_ops'),
),
pgMigrationsVBlocksMyBlockLocalesRelation6IdRelation: foreignKey({
columns: [table.relation6Id],
foreignColumns: [relationB.id],
name: '_pg_migrations_v_blocks_my_block_locales_relation6_id_relation_',
}).onDelete('set null'),
pgMigrationsVBlocksMyBlockLocalesParentIdFk: foreignKey({
columns: [table.parentId],
foreignColumns: [pgMigrationsVBlocksMyBlock.id],
name: '_pg_migrations_v_blocks_my_block_locales_parent_id_fk',
}).onDelete('cascade'),
pgMigrationsVBlocksMyBlockLocalesLocaleParentIdUniqu: unique(
'_pg_migrations_v_blocks_my_block_locales_locale_parent_id_uniqu',
).on(table.locale, table.parentId),
}
},
)

export const customIdsV = pgTable(
'_custom_ids_v',
{
Expand Down Expand Up @@ -1975,13 +1955,13 @@ export const relationBRelations = relations(relationB, ({ one, many }) => ({
pgMigrationsMyArrays: many(pgMigrationsMyArray),
pgMigrationsVVersionMyArrayMySubArrayLocales: many(pgMigrationsVVersionMyArrayMySubArrayLocales),
pgMigrationsVVersionMyArrays: many(pgMigrationsVVersionMyArray),
pgMigrationsVBlocksMyBlockLocales: many(pgMigrationsVBlocksMyBlockLocales),
pgMigrationsVLocales: many(pgMigrationsVLocales),
payloadLockedDocumentsRels: many(payloadLockedDocumentsRels),
relationA: one(relationA, {
fields: [relationB.relationshipId],
references: [relationA.id],
}),
pgMigrationsVBlocksMyBlockLocales: many(pgMigrationsVBlocksMyBlockLocales),
}))

export const pgMigrationsMyArrayMySubArrayRelations = relations(
Expand Down Expand Up @@ -2141,20 +2121,6 @@ export const pgMigrationsVVersionMyArrayRelations = relations(
}),
)

export const pgMigrationsVBlocksMyBlockLocalesRelations = relations(
pgMigrationsVBlocksMyBlockLocales,
({ one }) => ({
relationB: one(relationB, {
fields: [pgMigrationsVBlocksMyBlockLocales.relation6Id],
references: [relationB.id],
}),
pgMigrationsVBlocksMyBlock: one(pgMigrationsVBlocksMyBlock, {
fields: [pgMigrationsVBlocksMyBlockLocales.parentId],
references: [pgMigrationsVBlocksMyBlock.id],
}),
}),
)

export const pgMigrationsVLocalesRelations = relations(pgMigrationsVLocales, ({ one }) => ({
relationB: one(relationB, {
fields: [pgMigrationsVLocales.versionMyGroupRelation4Id],
Expand Down Expand Up @@ -2461,6 +2427,20 @@ export const defaultValuesArrayRelations = relations(defaultValuesArray, ({ one
}),
}))

export const pgMigrationsVBlocksMyBlockLocalesRelations = relations(
pgMigrationsVBlocksMyBlockLocales,
({ one }) => ({
relationB: one(relationB, {
fields: [pgMigrationsVBlocksMyBlockLocales.relation6Id],
references: [relationB.id],
}),
pgMigrationsVBlocksMyBlock: one(pgMigrationsVBlocksMyBlock, {
fields: [pgMigrationsVBlocksMyBlockLocales.parentId],
references: [pgMigrationsVBlocksMyBlock.id],
}),
}),
)

export const customIdsVRelations = relations(customIdsV, ({ one }) => ({
customId: one(customIds, {
fields: [customIdsV.parentId],
Expand Down Expand Up @@ -2494,7 +2474,6 @@ export type DatabaseSchema = {
enumDefaultValuesSelect: typeof enumDefaultValuesSelect
radioEnum: typeof radioEnum
selectEnum: typeof selectEnum
spatialRefSys: typeof spatialRefSys
posts: typeof posts
defaultValues: typeof defaultValues
relationA: typeof relationA
Expand All @@ -2508,7 +2487,6 @@ export type DatabaseSchema = {
pgMigrationsVBlocksMyBlock: typeof pgMigrationsVBlocksMyBlock
pgMigrationsVVersionMyArray: typeof pgMigrationsVVersionMyArray
pgMigrationsV: typeof pgMigrationsV
pgMigrationsVBlocksMyBlockLocales: typeof pgMigrationsVBlocksMyBlockLocales
pgMigrationsVLocales: typeof pgMigrationsVLocales
customsCustomSelect: typeof customsCustomSelect
customBlocks: typeof customBlocks
Expand Down Expand Up @@ -2545,6 +2523,7 @@ export type DatabaseSchema = {
relationB: typeof relationB
pgMigrationsMyArrayMySubArray: typeof pgMigrationsMyArrayMySubArray
pgMigrationsVVersionMyArrayMySubArray: typeof pgMigrationsVVersionMyArrayMySubArray
pgMigrationsVBlocksMyBlockLocales: typeof pgMigrationsVBlocksMyBlockLocales
customIdsV: typeof customIdsV
payloadPreferencesRels: typeof payloadPreferencesRels
pgMigrationsMyArrayMySubArrayLocalesRelations: typeof pgMigrationsMyArrayMySubArrayLocalesRelations
Expand All @@ -2561,7 +2540,6 @@ export type DatabaseSchema = {
pgMigrationsVBlocksMyBlockRelations: typeof pgMigrationsVBlocksMyBlockRelations
pgMigrationsVRelations: typeof pgMigrationsVRelations
pgMigrationsVVersionMyArrayRelations: typeof pgMigrationsVVersionMyArrayRelations
pgMigrationsVBlocksMyBlockLocalesRelations: typeof pgMigrationsVBlocksMyBlockLocalesRelations
pgMigrationsVLocalesRelations: typeof pgMigrationsVLocalesRelations
customsCustomSelectRelations: typeof customsCustomSelectRelations
customsRelations: typeof customsRelations
Expand Down Expand Up @@ -2593,6 +2571,7 @@ export type DatabaseSchema = {
fakeCustomIdsRelations: typeof fakeCustomIdsRelations
usersRelations: typeof usersRelations
defaultValuesArrayRelations: typeof defaultValuesArrayRelations
pgMigrationsVBlocksMyBlockLocalesRelations: typeof pgMigrationsVBlocksMyBlockLocalesRelations
customIdsVRelations: typeof customIdsVRelations
payloadPreferencesRelsRelations: typeof payloadPreferencesRelsRelations
payloadPreferencesRelations: typeof payloadPreferencesRelations
Expand Down

0 comments on commit cc3861e

Please sign in to comment.