(
imports: Record<string, unknown>,
credentials: PostgresCredentials | {
driver: 'pglite';
client: PGlite;
},
options?: {
host?: string;
port?: number;
casing?: CasingType;
},
)
| 188 | }; |
| 189 | |
| 190 | export const startStudioPostgresServer = async ( |
| 191 | imports: Record<string, unknown>, |
| 192 | credentials: PostgresCredentials | { |
| 193 | driver: 'pglite'; |
| 194 | client: PGlite; |
| 195 | }, |
| 196 | options?: { |
| 197 | host?: string; |
| 198 | port?: number; |
| 199 | casing?: CasingType; |
| 200 | }, |
| 201 | ) => { |
| 202 | const { drizzleForPostgres } = await import('./serializer/studio'); |
| 203 | |
| 204 | const pgSchema: Record<string, Record<string, AnyPgTable>> = {}; |
| 205 | const relations: Record<string, Relations> = {}; |
| 206 | |
| 207 | Object.entries(imports).forEach(([k, t]) => { |
| 208 | if (is(t, PgTable)) { |
| 209 | const schema = pgTableConfig(t).schema || 'public'; |
| 210 | pgSchema[schema] = pgSchema[schema] || {}; |
| 211 | pgSchema[schema][k] = t; |
| 212 | } |
| 213 | |
| 214 | if (is(t, Relations)) { |
| 215 | relations[k] = t; |
| 216 | } |
| 217 | }); |
| 218 | |
| 219 | const setup = await drizzleForPostgres(credentials, pgSchema, relations, [], options?.casing); |
| 220 | await startServerFromSetup(setup, options); |
| 221 | }; |
| 222 | |
| 223 | // SQLite |
| 224 |
nothing calls this directly
no test coverage detected