Skip to content

Commit

Permalink
Refactor table names
Browse files Browse the repository at this point in the history
  • Loading branch information
ruchernchong committed Dec 21, 2024
1 parent 40be00c commit b643507
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 13 deletions.
4 changes: 2 additions & 2 deletions src/lib/updateCOE.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { coeTable } from "@/schema";
import { coe } from "@/schema";
import type { COE } from "@/types";
import { updater } from "./updater";

Expand All @@ -22,7 +22,7 @@ export const updateCOE = async () => {
];

const response = await updater<COE>({
table: coeTable,
table: coe,
zipFileName,
zipUrl,
keyFields,
Expand Down
4 changes: 2 additions & 2 deletions src/lib/updateCars.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { carsTable } from "@/schema";
import { cars } from "@/schema";
import type { Car } from "@/types";
import { updater } from "./updater";

Expand All @@ -8,7 +8,7 @@ export const updateCars = async () => {
const keyFields: Array<keyof Car> = ["month"];

const response = await updater<Car>({
table: carsTable,
table: cars,
zipFileName,
zipUrl,
keyFields,
Expand Down
5 changes: 2 additions & 3 deletions src/lib/updater.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,10 @@ import { createUniqueKey } from "@/utils/createUniqueKey";
import { downloadFile } from "@/utils/downloadFile";
import { type CSVTransformOptions, processCSV } from "@/utils/processCSV";
import { cacheChecksum, getCachedChecksum } from "@/utils/redisCache";
import { getTableName } from "drizzle-orm";
import type { PgTable } from "drizzle-orm/pg-core";
import { type Table, getTableName } from "drizzle-orm";

export interface UpdaterConfig<T> {
table: PgTable;
table: Table;
zipFileName: string;
zipUrl: string;
keyFields: string[];
Expand Down
12 changes: 6 additions & 6 deletions src/schema.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { index, integer, pgTable, text, uuid } from "drizzle-orm/pg-core";

export const carsTable = pgTable(
export const cars = pgTable(
"cars",
{
id: uuid("id").defaultRandom().primaryKey(),
Expand All @@ -21,7 +21,7 @@ export const carsTable = pgTable(
],
);

export const coeTable = pgTable(
export const coe = pgTable(
"coe",
{
id: uuid("id").defaultRandom().primaryKey(),
Expand All @@ -47,8 +47,8 @@ export const coeTable = pgTable(
],
);

export type InsertCar = typeof carsTable.$inferInsert;
export type SelectCar = typeof carsTable.$inferSelect;
export type InsertCar = typeof cars.$inferInsert;
export type SelectCar = typeof cars.$inferSelect;

export type InsertCOE = typeof coeTable.$inferInsert;
export type SelectCOE = typeof coeTable.$inferSelect;
export type InsertCOE = typeof coe.$inferInsert;
export type SelectCOE = typeof coe.$inferSelect;

0 comments on commit b643507

Please sign in to comment.