Commit 094e1277 authored by Grant's avatar Grant
Browse files

create indexes if needed

parent 8117084c
Loading
Loading
Loading
Loading
+7 −0
Original line number Diff line number Diff line
@@ -14,6 +14,13 @@ const MS_PER_FRAME = parseInt(process.env.MS_PER_FRAME);
client.connect().then(async () => {
  console.log("Connected to postgres");

  await client.query(
    `CREATE INDEX IF NOT EXISTS idx_pixel_created_deleted ON "Pixel" ("createdAt", "deletedAt");`,
  );
  await client.query(
    `CREATE INDEX IF NOT EXISTS idx_pixel_xy_created ON "Pixel" (x, y, "createdAt" DESC);`,
  );

  const startDate = (
    await client.query(
      `SELECT "createdAt" FROM "Pixel" ORDER BY "createdAt" ASC LIMIT 1`,