Skip to content

Commit

Permalink
Rename "count table rows" internal fn
Browse files Browse the repository at this point in the history
  • Loading branch information
EvanHahn committed Oct 30, 2024
1 parent 574dca5 commit f93b4a4
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/lib/drizzle-helpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ const getNumberResult = (queryResult) => {
* @param {string} tableName
* @returns {number}
*/
const tableCountIfExists = (db, tableName) =>
const safeCountTableRows = (db, tableName) =>
db.transaction((tx) => {
const existsQuery = sql`
SELECT EXISTS (
Expand Down Expand Up @@ -64,12 +64,12 @@ const tableCountIfExists = (db, tableName) =>
* @returns {MigrationResult}
*/
export const migrate = (db, { migrationsFolder }) => {
const migrationsBefore = tableCountIfExists(db, DRIZZLE_MIGRATIONS_TABLE)
const migrationsBefore = safeCountTableRows(db, DRIZZLE_MIGRATIONS_TABLE)
drizzleMigrate(db, {
migrationsFolder,
migrationsTable: DRIZZLE_MIGRATIONS_TABLE,
})
const migrationsAfter = tableCountIfExists(db, DRIZZLE_MIGRATIONS_TABLE)
const migrationsAfter = safeCountTableRows(db, DRIZZLE_MIGRATIONS_TABLE)

if (migrationsAfter === migrationsBefore) return 'no migration'

Expand Down

0 comments on commit f93b4a4

Please sign in to comment.