Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"type": "prerelease",
"comment": "indexer: rename pgTable to pgIndexerTable",
"packageName": "@apibara/indexer",
"email": "francesco@ceccon.me",
"dependentChangeType": "patch"
}
4 changes: 2 additions & 2 deletions examples/starknet-indexer/src/indexer.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
import { defineIndexer, useSink } from "@apibara/indexer";
import {
drizzle as drizzleSink,
pgTable,
pgIndexerTable,
} from "@apibara/indexer/sinks/drizzle";
import { StarknetStream } from "@apibara/starknet";
import consola from "consola";
import { bigint } from "drizzle-orm/pg-core";
import { drizzle } from "drizzle-orm/postgres-js";
import postgres from "postgres";

const headers = pgTable("headers", {
const headers = pgIndexerTable("headers", {
number: bigint("number", { mode: "bigint" }),
});

Expand Down
4 changes: 2 additions & 2 deletions packages/indexer/src/sinks/drizzle/drizzle.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@ import { generateMockMessages } from "../../testing";
import { getMockIndexer } from "../../testing/indexer";
import type { Int8Range } from "./Int8Range";
import { drizzle as drizzleSink } from "./drizzle";
import { getDrizzleCursor, pgTable } from "./utils";
import { getDrizzleCursor, pgIndexerTable } from "./utils";

const testTable = pgTable("test_table", {
const testTable = pgIndexerTable("test_table", {
id: serial("id").primaryKey(),
data: text("data"),
});
Expand Down
8 changes: 6 additions & 2 deletions packages/indexer/src/sinks/drizzle/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ export type CursorColumnBuilder = NotNull<
>;

// Redefining the type of `pgTable` to include the `_cursor` column.
export type PgTableWithCursorFn<
export type PgIndexerTableWithCursorFn<
TSchema extends string | undefined = undefined,
> = <
TTableName extends string,
Expand Down Expand Up @@ -66,7 +66,11 @@ export type PgInsertValue<TTable extends PgTable> = Omit<
"_cursor"
>;

export const pgTable: PgTableWithCursorFn = (name, columns, extraConfig?) => {
export const pgIndexerTable: PgIndexerTableWithCursorFn = (
name,
columns,
extraConfig?,
) => {
Comment on lines +69 to +73
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codebase verification

Found remaining usage of pgTable in examples that needs updating

The renaming from pgTable to pgIndexerTable is incomplete. While the implementation file correctly aliases the import from drizzle-orm, there's still direct usage of pgTable in:

  • examples/indexer/src/indexer.ts: Uses the original pgTable from drizzle-orm directly

This example should be updated to use the new pgIndexerTable for consistency with the rest of the codebase.

🔗 Analysis chain

LGTM: Function renaming is consistent with type changes.

The implementation maintains the same functionality while adopting the new naming convention.

Let's verify there are no remaining references to the old name:

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Search for any remaining instances of 'pgTable' that might need updating
rg 'pgTable' --type ts --type tsx --type js --type jsx -g '!*.test.*' -g '!*.spec.*'

Length of output: 112


Script:

#!/bin/bash
# Search for any remaining instances of 'pgTable' using ripgrep with correct file type options
rg 'pgTable' --type typescript --type javascript -g '!*.test.*' -g '!*.spec.*'

Length of output: 113


Script:

#!/bin/bash
# Search for any remaining instances of 'pgTable' using basic ripgrep without file type filters
# but exclude test files using glob patterns
rg 'pgTable' -g '!*.test.*' -g '!*.spec.*' -g '*.ts' -g '*.js'

Length of output: 451

return drizzlePgTable(
name,
{
Expand Down
Loading