Add PlanetScale support#17
Conversation
WalkthroughAdds PlanetScale as a database host for MySQL and PostgreSQL, generalizes Neon-specific Postgres operations, introduces Planetscale-specific query operations and driver configurations, and updates DB initialization, import resolution, package dependencies, and DB type generation to handle engine-specific PlanetScale variants. Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20–30 minutes
Possibly related PRs
Suggested reviewers
Poem
Pre-merge checks and finishing touches✅ Passed checks (3 passed)
✨ Finishing touches
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 0
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
src/generators/project/generateDBBlock.ts (1)
41-45: Critical: Update PlanetScale initialization to use Client constructor.Line 43 uses
connect({ url: ... })but the import was changed toClientingenerateImportsBlock.ts(line 85). The generated code will importClientbut notconnect, causing a runtime error. This remoteDrizzleInit entry is used whenorm === 'drizzle'with PlanetScale (see line 77).Apply this diff:
const remoteDrizzleInit: Record<string, string> = { neon: 'new Pool({ connectionString: getEnv("DATABASE_URL") })', - planetscale: 'connect({ url: getEnv("DATABASE_URL") })', + planetscale: 'new Client({ url: getEnv("DATABASE_URL") })', turso: 'createClient({ url: getEnv("DATABASE_URL") })' };
🧹 Nitpick comments (1)
src/generators/db/handlerTemplates.ts (1)
422-426: Consider removing '/dist' from the import path.Line 424 imports from
@planetscale/database/dist. Importing from internal package paths like/distcan be fragile and may break with package updates. Verify that the main package export doesn't provideClientdirectly.- importLines: `import { Client } from '@planetscale/database/dist'`, + importLines: `import { Client } from '@planetscale/database'`,
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (4)
src/generators/db/handlerTemplates.ts(4 hunks)src/generators/project/generateDBBlock.ts(2 hunks)src/generators/project/generateImportsBlock.ts(1 hunks)src/questions/databaseHost.ts(1 hunks)
🧰 Additional context used
🧬 Code graph analysis (2)
src/generators/project/generateImportsBlock.ts (1)
src/generators/db/generateDatabaseTypes.ts (1)
GenerateTypesProps(8-42)
src/questions/databaseHost.ts (1)
src/utils/abort.ts (1)
abort(5-8)
🔇 Additional comments (6)
src/questions/databaseHost.ts (1)
7-18: LGTM! Consistent cancellation handling added.The PostgreSQL branch now includes explicit abort handling and unified return semantics, matching the existing pattern in the MySQL and SQLite branches.
src/generators/db/handlerTemplates.ts (3)
238-253: LGTM! Improved user lookup strategy.The change from uid-based to auth_sub-based lookup after insertion is more deterministic and aligns with the natural key for users. The insertHistory operation correctly continues to use uid since the count_history table doesn't have auth_sub.
294-304: LGTM! Consistent auth_sub-based lookup.The Drizzle variant now uses auth_sub for user lookup instead of uid, matching the SQL variant's approach. Removing
.$returningId()is appropriate since the subsequent query relies on auth_sub rather than the auto-generated uid.
310-365: No issues found — PlanetScale API usage is correct.The code correctly uses the PlanetScale Client API. The
execute()method returns anExecutedQueryobject with the expected properties:insertId(string) for INSERT operations androws(array) for SELECT operations. All parameterized queries follow the correct pattern, and the optional result handling is appropriate.src/generators/project/generateImportsBlock.ts (1)
83-87: LGTM! Aligned with PlanetScale Client constructor pattern.The import change from
connecttoClientaligns with the updated initialization pattern ingenerateDBBlock.ts(line 24) which usesnew Client({ url: ... }).src/generators/project/generateDBBlock.ts (1)
80-85: LGTM! Correct special handling for MySQL/MariaDB.The condition correctly excludes PlanetScale from the
createPoolpath, allowing PlanetScale connections to use the general initialization path (lines 87-90). The explicitmode: 'default'for non-PlanetScale MySQL/MariaDB connections is good practice.
There was a problem hiding this comment.
Actionable comments posted: 2
🧹 Nitpick comments (1)
src/generators/db/handlerTemplates.ts (1)
238-253: Consider removing unused return value from insert result.The insert operation on line 239 captures the
result, but after changing the lookup to useauth_sub(line 247), theresult.lastInsertRowidis no longer accessed. While functionally correct, the result variable could be removed for clarity.Apply this diff to simplify:
- const result = await db` + await db` INSERT INTO users (auth_sub, metadata) VALUES (\${authSub}, \${JSON.stringify(userIdentity)}) `;However, the change to use
auth_subfor lookups is correct and improves consistency.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (2)
src/generators/db/handlerTemplates.ts(5 hunks)src/generators/project/generateDBBlock.ts(3 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
- src/generators/project/generateDBBlock.ts
🔇 Additional comments (2)
src/generators/db/handlerTemplates.ts (2)
422-426: LGTM!The PlanetScale SQL client configuration correctly maps to
mysqlPlanetScaleQueryOperationsand uses the properClienttype from@planetscale/database. The structure is consistent with other driver configurations.
409-416: PlanetScale configuration is correct and ready for use.Drizzle ORM v0.41.0 (from devDependencies) exceeds the v0.17.5 minimum required for PlanetScale serverless support. The configuration correctly imports
PlanetScaleDatabasefrom'drizzle-orm/planetscale-serverless'and uses the appropriate database type. Verification found no syntax errors inmysqlDrizzleQueryOperations, which the configuration properly reuses for query operations.Likely an incorrect or invalid review comment.
There was a problem hiding this comment.
Actionable comments posted: 0
🧹 Nitpick comments (2)
src/generators/project/generateDBBlock.ts (1)
24-25: Planetscale connection expressions and drizzle init paths look consistent; minor cleanup possibleThe new
connectionMapentries and drizzle branches align with the driver configurations you added elsewhere:
mysql+databaseHost === 'planetscale'resolves tonew Client({ url: getEnv("DATABASE_URL") }), matching theClient-based handlers.postgresql+databaseHost === 'planetscale'resolves tonew Pool({ connectionString: getEnv("DATABASE_URL") }), matching thePool-based handlers.- The drizzle branch now correctly:
- Uses
createPool(...); drizzle(pool, { schema, mode: 'default' })only formysql/mariadbwhen the host is not Planetscale.- Falls back to
drizzle(${expr}, { schema })for Planetscale and other remote drivers, which is what the Planetscale and Node‑pg drizzle adapters expect.Two small, non‑blocking nits:
remoteDrizzleInit.planetscalenow duplicatesconnectionMap.mysql.planetscaleandconnectionMap.postgresql.planetscalenever uses it; over time this object is becoming mostly redundant. You could eventually collapse everything intoconnectionMapto simplify the resolution logic.- In the drizzle branch,
const pool = ${expr}will bind aClientfor MySQL/Planetscale; a more generic name likeconnectionwould better reflect that it’s not always an actual pool, though this is cosmetic.Overall, behavior and generated code look correct for all covered engine/host/ORM combinations; just ensure end‑to‑end scaffolding tests cover the new Planetscale paths.
Also applies to: 30-33, 44-48, 80-96
src/generators/db/handlerTemplates.ts (1)
310-365: PlanetScale MySQLClientqueries are parameterized and consistent; small unused-variable nitThe new
mysqlPlanetScaleQueryOperationsset looks solid:
- All queries use
db.execute(sql, [params])with?placeholders, so they’re parameterized.insertHistorycorrectly usesresult.insertIdto fetch the new row byuidand has clear error messages when insert or select fails.- User operations insert and read via
auth_suband JSON‑stringifyuserIdentity, matching the other non‑drizzle MySQL drivers.One minor DX tweak: in
insertUsertheresultvariable is declared but never used. You could simplify the generated code to:- const result = await db.execute( + await db.execute( `INSERT INTO users (auth_sub, metadata) VALUES (?, ?)`, [authSub, JSON.stringify(userIdentity)] );or destructure
insertIdif you want an extra sanity check before the follow‑upSELECT. Functionally things are fine either way.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (7)
src/generators/configurations/generatePackageJson.ts(2 hunks)src/generators/db/generateDatabaseTypes.ts(1 hunks)src/generators/db/handlerTemplates.ts(8 hunks)src/generators/db/scaffoldDatabase.ts(1 hunks)src/generators/project/generateDBBlock.ts(3 hunks)src/generators/project/generateImportsBlock.ts(5 hunks)src/questions/databaseHost.ts(1 hunks)
🧰 Additional context used
🧬 Code graph analysis (4)
src/generators/db/scaffoldDatabase.ts (4)
src/questions/orm.ts (1)
databaseEngine(7-28)src/generators/db/generateHandlers.ts (1)
GenerateDBHandlersProps(9-28)src/generators/db/generateDrizzleSchema.ts (1)
GenerateSchemaProps(61-141)src/generators/db/generateDockerContainer.ts (1)
databaseEngine(95-127)
src/generators/project/generateImportsBlock.ts (3)
src/generators/db/generateDrizzleSchema.ts (1)
GenerateSchemaProps(61-141)src/generators/configurations/generateDrizzleConfig.ts (1)
CreateDrizzleConfigProps(11-34)src/generators/project/generateUseBlock.ts (1)
pluginImport(15-50)
src/questions/databaseHost.ts (3)
src/utils/abort.ts (1)
abort(5-8)src/questions/databaseEngine.ts (1)
databaseDialectResponse(5-26)src/questions/orm.ts (1)
databaseEngine(7-28)
src/generators/db/generateDatabaseTypes.ts (1)
src/types.ts (3)
DatabaseHost(49-49)AuthProvider(40-40)DatabaseEngine(45-47)
🔇 Additional comments (13)
src/generators/db/scaffoldDatabase.ts (1)
101-105: LGTM!The addition of
databaseEngineto thegenerateDatabaseTypescall correctly aligns with the updated function signature and enables proper type generation for PlanetScale variants that need to differentiate between MySQL and PostgreSQL.src/questions/databaseHost.ts (1)
21-32: LGTM!The MySQL branch correctly mirrors the existing PostgreSQL and SQLite patterns, with proper cancel handling via
isCancelandabort(). The PlanetScale option is appropriately offered for MySQL hosts.src/generators/db/generateDatabaseTypes.ts (2)
1-6: LGTM!The addition of
DatabaseEngineto the type imports and props correctly enables engine-specific type generation for PlanetScale variants.
19-28: LGTM - PlanetScale type generation for MySQL and PostgreSQL.The conditional branches correctly differentiate between:
- PlanetScale + MySQL →
PlanetScaleDatabasefromdrizzle-orm/planetscale-serverless- PlanetScale + PostgreSQL →
NodePgDatabasefromdrizzle-orm/node-postgresThis aligns with the import changes in
generateImportsBlock.tswhere PostgreSQL + PlanetScale uses the standardpgPool rather than a serverless adapter.src/generators/project/generateImportsBlock.ts (4)
130-140: LGTM - PostgreSQL import handling for PlanetScale.The extended logic correctly routes PlanetScale-hosted PostgreSQL to use
drizzle-orm/node-postgreswith thepgPool, distinguishing it from local Bun-based PostgreSQL and Neon serverless.
175-189: LGTM - Extended noOrmImports for PostgreSQL hosts.The three-branch logic correctly handles:
- Neon → uses
@neondatabase/serverlessPool- PlanetScale → uses
pgPool- Default/local → uses Bun's
SQL
203-212: LGTM - Exclusion of serverless imports for PostgreSQL+PlanetScale.The condition correctly prevents pushing
drizzle-orm/planetscale-serverlessimports when using PostgreSQL with PlanetScale, since that combination uses the standardpgdriver viadrizzle-orm/node-postgresinstead.
85-85: TheClientimport from@planetscale/databaseis correct.Current PlanetScale SDK documentation confirms
Clientis the correct export, initialized withnew Client({ url: ... }). Usage ingenerateDBBlock.ts(line 24, line 46) aligns with this pattern. No changes needed.src/generators/configurations/generatePackageJson.ts (2)
238-241: LGTM - PostgreSQL client dependencies for PlanetScale.This correctly adds the
pgclient (8.11.0) and its types (8.6.1) when using PlanetScale with PostgreSQL, aligning with thePoolimport from'pg'ingenerateImportsBlock.ts(line 183).
178-183: The @planetscale/database version 1.19.0 is a valid published package with no known security advisories or breaking changes. The version bump from 1.0.0 is safe to proceed.src/generators/db/handlerTemplates.ts (3)
106-129: Generalized PostgresPoolquery ops correctly cover both Neon and pg-backed driversRenaming and reusing the Neon‑specific operations as
postgresPgQueryOperationswired into:
'postgresql:sql:neon'(Poolfrom@neondatabase/serverless), and'postgresql:sql:planetscale'(Poolfrompg),makes sense and the query shapes look correct:
- Parameterization via
$1,$2is standard forPool#query.insertUsernow writes to(auth_sub, metadata)and throws if no row is returned, matching the rest of the templates.- Selects for history and user both return
rows[0] ?? null, which is consistent with the other SQL drivers.This is a solid unification of the Pool‑based Postgres paths; just make sure your dependency versions for
@neondatabase/serverlessandpgmatch thePoolAPI used here in the generated projects.Also applies to: 456-460, 461-465
218-276: MySQL local drizzle/SQL templates now correctly key offauth_subThese MySQL templates look good:
mysqlSqlQueryOperations.selectUsernow filters byWHERE auth_sub = ${authSub}, aligning with howauthSubis constructed in the auth handler and with the column name used in every other driver.mysqlDrizzleQueryOperations.insertUsernow inserts{ auth_sub: authSub, metadata: userIdentity }and uses.where(eq(schema.users.auth_sub, authSub))when re‑selecting, which matches the schema anddrizzleQueryOperations.selectUser.This brings the MySQL paths in line with the rest of the stack’s auth model and fixes the earlier mismatch between insert/select predicates.
Also applies to: 278-308
401-416: New driver configurations for PlanetScale paths are coherent with the query templatesThe added/updated
driverConfigurationsentries look internally consistent:
'mysql:drizzle:planetscale'usesPlanetScaleDatabase<SchemaType>fromdrizzle-orm/planetscale-serverlessand reusesmysqlDrizzleQueryOperations, which already rely on MySQL dialect features like$returningId()and fit the PlanetScale driver.'mysql:sql:planetscale'usesdbType: 'Client'withimport { Client } from '@planetscale/database'and plugs intomysqlPlanetScaleQueryOperations, which are written againstClient#execute.'postgresql:drizzle:planetscale'usesNodePgDatabase<SchemaType>fromdrizzle-orm/node-postgresand the genericdrizzleQueryOperations, matching thePool-based Postgres drizzle adapter.'postgresql:sql:neon'and'postgresql:sql:planetscale'both usedbType: 'Pool'and the sharedpostgresPgQueryOperations, which aredb.query(...)-based.This wiring should give you consistent handler templates across all new PlanetScale and pg-backed variants. It’d be worth generating a project for each new key (e.g.
mysql:sql:planetscale,mysql:drizzle:planetscale,postgresql:sql:planetscale,postgresql:drizzle:planetscale) and running type‑checks to confirm the imported types (Client,PlanetScaleDatabase,NodePgDatabase,Pool) line up with the actual library APIs in your target versions.Also applies to: 422-426, 435-450, 456-465
10f7ed9 to
84f8db3
Compare
There was a problem hiding this comment.
Actionable comments posted: 0
🧹 Nitpick comments (2)
src/generators/project/generateImportsBlock.ts (1)
209-213: Use strict equality (===) for comparison.Line 210 uses loose equality (
==) instead of strict equality (===). For consistency with TypeScript best practices, use===.if ( - orm == 'drizzle' && + orm === 'drizzle' && isRemoteHost && !(databaseEngine === 'postgresql' && databaseHost === 'planetscale') ) {src/generators/project/generateDBBlock.ts (1)
83-96: Consider renamingpooltoconnectionfor semantic clarity.When the host is PlanetScale (MySQL),
exprevaluates tonew Client(...), so the generated variablepoolactually holds aClientinstance—not a pool. While this works functionally, the naming is misleading.-const pool = ${expr} -const db = drizzle(pool, { schema }) +const connection = ${expr} +const db = drizzle(connection, { schema })
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (6)
src/generators/configurations/generatePackageJson.ts(2 hunks)src/generators/db/generateDatabaseTypes.ts(1 hunks)src/generators/db/handlerTemplates.ts(8 hunks)src/generators/project/generateDBBlock.ts(3 hunks)src/generators/project/generateImportsBlock.ts(4 hunks)src/questions/databaseHost.ts(1 hunks)
🚧 Files skipped from review as they are similar to previous changes (2)
- src/generators/db/generateDatabaseTypes.ts
- src/generators/configurations/generatePackageJson.ts
🧰 Additional context used
🧬 Code graph analysis (2)
src/generators/project/generateImportsBlock.ts (1)
src/generators/db/generateDrizzleSchema.ts (1)
GenerateSchemaProps(61-141)
src/questions/databaseHost.ts (1)
src/utils/abort.ts (1)
abort(5-8)
🔇 Additional comments (12)
src/questions/databaseHost.ts (1)
21-32: LGTM!The MySQL branch correctly mirrors the existing PostgreSQL and SQLite branch patterns—handling cancel via
abort()and returningundefinedfor "none" or the selected host otherwise.src/generators/project/generateImportsBlock.ts (3)
85-85: LGTM!The import correctly uses
Clientinstead ofconnect, aligning with thenew Client()instantiation pattern used elsewhere in this PR.
135-140: LGTM!Correctly uses
drizzle-orm/node-postgresandpgPool for PostgreSQL + PlanetScale, since PlanetScale's PostgreSQL offering is compatible with the standard pg driver.
178-192: LGTM!The three-way branching for PostgreSQL (neon → Pool from serverless, planetscale → Pool from pg, default → bun SQL) correctly handles all host combinations with appropriate imports.
src/generators/project/generateDBBlock.ts (2)
22-34: LGTM!The connectionMap correctly distinguishes:
- MySQL + PlanetScale →
new Client()(PlanetScale's native MySQL client)- PostgreSQL + PlanetScale →
new Pool()(standard pg driver)This aligns with the import changes in
generateImportsBlock.ts.
44-48: LGTM!The
remoteDrizzleInitcorrectly usesnew Client()for PlanetScale, consistent with the updated imports and connectionMap.src/generators/db/handlerTemplates.ts (6)
106-129: LGTM!Good rename from
postgresNeonQueryOperationstopostgresPgQueryOperations—the operations are generic to anypg.Poolclient, not Neon-specific.
238-253: LGTM!Correctly retrieves the newly inserted user by
auth_subrather than by auto-increment ID, which is consistent with the insert values and avoids a race condition in high-concurrency scenarios.
294-308: LGTM!The insert statement now correctly terminates with a semicolon, and the subsequent select uses
auth_subfor lookup—consistent with the insert values.
409-426: LGTM!The new PlanetScale configurations are correctly structured:
mysql:drizzle:planetscaleusesPlanetScaleDatabasefromdrizzle-orm/planetscale-serverlessmysql:sql:planetscaleusesClientfrom@planetscale/databasewith the newmysqlPlanetScaleQueryOperations
443-465: LGTM!The PostgreSQL + PlanetScale configurations correctly use the standard
pgdriver:
postgresql:drizzle:planetscaleusesNodePgDatabasefromdrizzle-orm/node-postgrespostgresql:sql:planetscaleusesPoolfrompgwithpostgresPgQueryOperationsThis is appropriate since PlanetScale's PostgreSQL offering is compatible with the standard PostgreSQL protocol.
310-365: Well-structured PlanetScale query operations with proper parameterization and error handling.The implementation correctly uses
db.execute()with?placeholders for parameterized queries, handlesinsertIdfor auto-increment columns, and properly returnsnullfor missing results. The execute() method returns a result object containing bothinsertId(as a string) for INSERT operations androwsfor query results, matching the usage in this code.
| return user ?? null` | ||
| }; | ||
|
|
||
| const postgresNeonQueryOperations: QueryOperations = { |
There was a problem hiding this comment.
dont completely remove neon the pg is solely for planetscale postgresql
| 'postgresql:sql:neon': { | ||
| dbType: 'Pool', | ||
| importLines: `import { Pool } from '@neondatabase/serverless'`, | ||
| queries: postgresNeonQueryOperations |
There was a problem hiding this comment.
neon with postgress doesnt use pg
84f8db3 to
ae4bc9c
Compare
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (1)
src/generators/project/generateImportsBlock.ts (1)
209-213: Use strict equality for consistency.Line 210 uses
==instead of===for theormcomparison. While functionally equivalent here (comparing strings), the rest of the codebase uses strict equality.if ( - orm == 'drizzle' && + orm === 'drizzle' && isRemoteHost && !(databaseEngine === 'postgresql' && databaseHost === 'planetscale') ) {
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (6)
src/generators/configurations/generatePackageJson.ts(2 hunks)src/generators/db/generateDatabaseTypes.ts(1 hunks)src/generators/db/handlerTemplates.ts(8 hunks)src/generators/project/generateDBBlock.ts(3 hunks)src/generators/project/generateImportsBlock.ts(4 hunks)src/questions/databaseHost.ts(1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
- src/generators/db/generateDatabaseTypes.ts
🧰 Additional context used
🧬 Code graph analysis (1)
src/generators/project/generateImportsBlock.ts (1)
src/generators/db/generateDrizzleSchema.ts (1)
GenerateSchemaProps(61-141)
🔇 Additional comments (14)
src/generators/configurations/generatePackageJson.ts (2)
182-186: LGTM!The PlanetScale package version has been correctly updated to 1.19.0 as addressed from prior feedback.
245-248: LGTM!The conditional dependency injection for
pgand@types/pgis correctly scoped to the PostgreSQL + PlanetScale combination, which aligns with PlanetScale's PostgreSQL compatibility requiring the node-postgres driver.src/generators/project/generateImportsBlock.ts (3)
83-87: LGTM!The connector import for PlanetScale correctly uses
Clientinstead ofconnect, which aligns with thenew Client({...})instantiation pattern used ingenerateDBBlock.ts.
135-140: LGTM!The PostgreSQL + PlanetScale drizzle path correctly imports
drizzle-orm/node-postgresand thepgPool, which matches the dependency additions ingeneratePackageJson.ts.
178-192: LGTM!The noOrmImports for PostgreSQL correctly differentiates between Neon (uses
@neondatabase/serverless), PlanetScale (usespgPool), and local/default (uses Bun SQL).src/questions/databaseHost.ts (1)
21-32: LGTM!The MySQL branch correctly follows the established pattern from the PostgreSQL and SQLite branches, with proper cancel handling and consistent return semantics.
src/generators/project/generateDBBlock.ts (3)
22-25: LGTM!The MySQL + PlanetScale connection correctly uses the
Clientconstructor from@planetscale/database.
30-33: LGTM!The PostgreSQL + PlanetScale connection correctly uses the
pgPool, which aligns with the dependency additions and import configuration.
83-90: LGTM!The mode logic correctly applies only to MySQL/MariaDB when not using PlanetScale, since PlanetScale handles the mode internally.
src/generators/db/handlerTemplates.ts (5)
106-129: LGTM!Renaming to
postgresQueryOperationsappropriately reflects that these operations are now shared between Neon and PlanetScale PostgreSQL configurations.
294-304: LGTM!The syntax error has been fixed (semicolon added on line 296), and the selection now correctly uses
auth_subinstead of relying onlastInsertRowid, which addresses the prior review feedback.
310-365: LGTM!The
mysqlPlanetScaleQueryOperationscorrectly uses:
db.execute()with?placeholders (PlanetScale API)result.insertIdfor retrieving the auto-increment ID- Proper null checks and error handling
JSON.stringify(userIdentity)for metadata storage
409-426: LGTM!The MySQL PlanetScale driver configurations correctly reference:
PlanetScaleDatabase<SchemaType>for DrizzleClienttype for raw SQL- Appropriate query operations for each mode
443-464: LGTM!The PostgreSQL PlanetScale configurations correctly use:
NodePgDatabase<SchemaType>anddrizzle-orm/node-postgresfor DrizzlePoolfrompgfor raw SQL- Shared
postgresQueryOperationsanddrizzleQueryOperations
| const remoteDrizzleInit: Record<string, string> = { | ||
| neon: 'new Pool({ connectionString: getEnv("DATABASE_URL") })', | ||
| planetscale: 'connect({ url: getEnv("DATABASE_URL") })', | ||
| planetscale: 'new Client({ url: getEnv("DATABASE_URL") })', | ||
| turso: 'createClient({ url: getEnv("DATABASE_URL") })' | ||
| }; |
There was a problem hiding this comment.
🧩 Analysis chain
🏁 Script executed:
#!/bin/bash
# Check remoteDrizzleInit usage and surrounding context
rg -n "remoteDrizzleInit" src/generators/project/generateDBBlock.ts -A2 -B2Repository: absolutejs/create-absolutejs
Length of output: 439
🏁 Script executed:
#!/bin/bash
# Get file info and read the relevant section around line 44-80
wc -l src/generators/project/generateDBBlock.tsRepository: absolutejs/create-absolutejs
Length of output: 116
🏁 Script executed:
#!/bin/bash
# Read the section containing remoteDrizzleInit and the fallback logic
sed -n '40,85p' src/generators/project/generateDBBlock.tsRepository: absolutejs/create-absolutejs
Length of output: 1309
🏁 Script executed:
#!/bin/bash
# Also check connectionMap structure to understand the explicit entries mentioned
sed -n '1,100p' src/generators/project/generateDBBlock.ts | head -n 100Repository: absolutejs/create-absolutejs
Length of output: 2600
🏁 Script executed:
#!/bin/bash
# Find where availableDrizzleDialects is defined
fd -t f "data" src/ | head -20Repository: absolutejs/create-absolutejs
Length of output: 226
🏁 Script executed:
#!/bin/bash
# Search for availableDrizzleDialects definition
rg -n "availableDrizzleDialects" --type tsRepository: absolutejs/create-absolutejs
Length of output: 844
🏁 Script executed:
#!/bin/bash
# Read the data.ts file to see availableDrizzleDialects definition
sed -n '14,30p' src/data.tsRepository: absolutejs/create-absolutejs
Length of output: 323
🏁 Script executed:
#!/bin/bash
# Check databaseHost.ts to see what hosts are available
cat src/questions/databaseHost.tsRepository: absolutejs/create-absolutejs
Length of output: 1386
Remove the remoteDrizzleInit object or document it as future extensibility.
The remoteDrizzleInit entries (neon, planetscale, turso) are unreachable dead code. Every valid database engine + host combination selectable through the CLI has an explicit entry in connectionMap (postgresql/mysql/sqlite with their respective hosts), and other Drizzle-supported engines (gel, singlestore, mariadb) only support 'none' host, which also exist in connectionMap. The fallback at line 80 will never be triggered. Either remove this object or add a comment explaining it's reserved for future extensibility.
🤖 Prompt for AI Agents
In src/generators/project/generateDBBlock.ts around lines 44 to 48, the
remoteDrizzleInit object contains unreachable dead entries (neon, planetscale,
turso) because all valid engine+host combos are handled by connectionMap and the
fallback is never hit; either remove the remoteDrizzleInit constant entirely or
keep it but add a clear comment that it is reserved for future extensibility and
currently unused — update the file by deleting the object if not needed, or add
a one-line explanatory comment above it and mark with TODO/EXPERIMENTAL to avoid
linter warnings about dead code.
Summary by CodeRabbit
New Features
Chores
✏️ Tip: You can customize this high-level summary in your review settings.