Database diagrams editor that allows you to visualize and design your DB with a single query.
TypeScript databasedbdb-migrationeditorerdmariadbmssqlmysqlpostgresqlreactreact-flowschema-migrationssqlsqlitetypescriptvisualizationxyflow
fix(import-database): for custom types query to import supabase & timescale (#745)
Jonathan Fishner2fce8326b67b
diff --git a/src/lib/data/import-metadata/scripts/postgres-script.ts b/src/lib/data/import-metadata/scripts/postgres-script.tsindex 645a1a95..0b0924d0 100644--- a/src/lib/data/import-metadata/scripts/postgres-script.ts+++ b/src/lib/data/import-metadata/scripts/postgres-script.ts@@ -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 sWHERE 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.typnamespaceWHERE 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.attisdroppedAND 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