From 59b78766ee80e9fe1c05842ed02b0adde64470f1 Mon Sep 17 00:00:00 2001 From: einhornimmond Date: Thu, 4 Dec 2025 08:29:34 +0100 Subject: [PATCH] sort rows from db additional by id if the dates are the same because of faster seeding --- .../migrations/db-v2.7.0_to_blockchain-v3.5/database.ts | 9 +++++---- .../db-v2.7.0_to_blockchain-v3.5/drizzle.schema.ts | 1 + 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/dlt-connector/src/migrations/db-v2.7.0_to_blockchain-v3.5/database.ts b/dlt-connector/src/migrations/db-v2.7.0_to_blockchain-v3.5/database.ts index 58a5d364e..87cb3eb4a 100644 --- a/dlt-connector/src/migrations/db-v2.7.0_to_blockchain-v3.5/database.ts +++ b/dlt-connector/src/migrations/db-v2.7.0_to_blockchain-v3.5/database.ts @@ -40,6 +40,7 @@ export async function loadCommunities(db: MySql2Database): Promise() @@ -65,7 +66,7 @@ export async function loadUsers( const result = await db .select() .from(usersTable) - .orderBy(asc(usersTable.createdAt)) + .orderBy(asc(usersTable.createdAt), asc(usersTable.id)) .limit(count) .offset(offset) @@ -98,7 +99,7 @@ export async function loadTransactions( transactionLinksTable, eq(transactionsTable.transactionLinkId, transactionLinksTable.id), ) - .orderBy(asc(transactionsTable.balanceDate)) + .orderBy(asc(transactionsTable.balanceDate), asc(transactionsTable.id)) .limit(count) .offset(offset) @@ -148,7 +149,7 @@ export async function loadTransactionLinks( .select() .from(transactionLinksTable) .leftJoin(usersTable, eq(transactionLinksTable.userId, usersTable.id)) - .orderBy(asc(transactionLinksTable.createdAt)) + .orderBy(asc(transactionLinksTable.createdAt), asc(transactionLinksTable.id)) .limit(count) .offset(offset) @@ -170,7 +171,7 @@ export async function loadDeletedTransactionLinks( .from(transactionLinksTable) .leftJoin(usersTable, eq(transactionLinksTable.userId, usersTable.id)) .where(isNotNull(transactionLinksTable.deletedAt)) - .orderBy(asc(transactionLinksTable.deletedAt)) + .orderBy(asc(transactionLinksTable.deletedAt), asc(transactionLinksTable.id)) .limit(count) .offset(offset) diff --git a/dlt-connector/src/migrations/db-v2.7.0_to_blockchain-v3.5/drizzle.schema.ts b/dlt-connector/src/migrations/db-v2.7.0_to_blockchain-v3.5/drizzle.schema.ts index 59cc6573c..e08231f4d 100644 --- a/dlt-connector/src/migrations/db-v2.7.0_to_blockchain-v3.5/drizzle.schema.ts +++ b/dlt-connector/src/migrations/db-v2.7.0_to_blockchain-v3.5/drizzle.schema.ts @@ -15,6 +15,7 @@ import { export const communitiesTable = mysqlTable( 'communities', { + id: int().autoincrement().notNull(), foreign: tinyint().default(1).notNull(), communityUuid: char('community_uuid', { length: 36 }).default(sql`NULL`), name: varchar({ length: 40 }).default(sql`NULL`),