mirror of
https://github.com/chartdb/chartdb.git
synced 2025-11-06 15:03:22 +00:00
fix(import-database): for custom types query to import supabase & timescale (#745)
This commit is contained in:
@@ -33,6 +33,10 @@ export const getPostgresQuery = (
|
||||
AND views.schemaname NOT IN ('auth', 'extensions', 'pgsodium', 'realtime', 'storage', 'vault')
|
||||
`;
|
||||
|
||||
const supabaseCustomTypesFilter = `
|
||||
AND n.nspname NOT IN ('auth', 'extensions', 'pgsodium', 'realtime', 'storage', 'vault')
|
||||
`;
|
||||
|
||||
const timescaleFilters = `
|
||||
AND connamespace::regnamespace::text !~ '^(timescaledb_|_timescaledb_)'
|
||||
`;
|
||||
@@ -55,6 +59,10 @@ export const getPostgresQuery = (
|
||||
AND views.schemaname !~ '^(timescaledb_|_timescaledb_)'
|
||||
`;
|
||||
|
||||
const timescaleCustomTypesFilter = `
|
||||
AND n.nspname !~ '^(timescaledb_|_timescaledb_)'
|
||||
`;
|
||||
|
||||
const withExtras = false;
|
||||
|
||||
const withDefault = `COALESCE(replace(replace(cols.column_default, '"', '\\"'), '\\x', '\\\\x'), '')`;
|
||||
@@ -232,7 +240,7 @@ cols AS (
|
||||
FROM pg_stat_user_tables s
|
||||
WHERE tbls.TABLE_SCHEMA = s.schemaname AND tbls.TABLE_NAME = s.relname),
|
||||
0), ', "type":"', tbls.TABLE_TYPE, '",', '"engine":"",', '"collation":"",',
|
||||
'"comment":"', COALESCE(replace(replace(dsc.description, '"', '\\"'), '\\x', '\\\\x'), ''),
|
||||
'"comment":"', ${withExtras ? withComments : withoutComments},
|
||||
'"}'
|
||||
)),
|
||||
',') AS tbls_metadata
|
||||
@@ -282,9 +290,9 @@ cols AS (
|
||||
JOIN pg_namespace n ON n.oid = t.typnamespace
|
||||
WHERE n.nspname NOT IN ('pg_catalog', 'information_schema') ${
|
||||
databaseEdition === DatabaseEdition.POSTGRESQL_TIMESCALE
|
||||
? timescaleViewsFilter
|
||||
? timescaleCustomTypesFilter
|
||||
: databaseEdition === DatabaseEdition.POSTGRESQL_SUPABASE
|
||||
? supabaseViewsFilter
|
||||
? supabaseCustomTypesFilter
|
||||
: ''
|
||||
}
|
||||
GROUP BY n.nspname, t.typname
|
||||
@@ -315,9 +323,9 @@ cols AS (
|
||||
AND a.attnum > 0 AND NOT a.attisdropped
|
||||
AND n.nspname NOT IN ('pg_catalog', 'information_schema') ${
|
||||
databaseEdition === DatabaseEdition.POSTGRESQL_TIMESCALE
|
||||
? timescaleViewsFilter
|
||||
? timescaleCustomTypesFilter
|
||||
: databaseEdition === DatabaseEdition.POSTGRESQL_SUPABASE
|
||||
? supabaseViewsFilter
|
||||
? supabaseCustomTypesFilter
|
||||
: ''
|
||||
}
|
||||
GROUP BY n.nspname, t.typname
|
||||
|
||||
Reference in New Issue
Block a user