Skip to content

Commit 0f94306

Browse files
authored
Merge pull request #1 from SiriusCrain/fix/updated-at-value
fix(store): use last publish date as updatedAt
2 parents b580552 + 47c3fce commit 0f94306

4 files changed

Lines changed: 33 additions & 2 deletions

File tree

bun.lock

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
-- RedefineTables
2+
PRAGMA defer_foreign_keys=ON;
3+
PRAGMA foreign_keys=OFF;
4+
CREATE TABLE "new_Extension" (
5+
"id" TEXT NOT NULL PRIMARY KEY,
6+
"name" TEXT NOT NULL,
7+
"title" TEXT NOT NULL,
8+
"description" TEXT NOT NULL,
9+
"downloadCount" INTEGER NOT NULL DEFAULT 0,
10+
"apiVersion" TEXT NOT NULL,
11+
"storageKey" TEXT NOT NULL,
12+
"checksum" TEXT NOT NULL,
13+
"trending" BOOLEAN NOT NULL DEFAULT false,
14+
"iconLight" TEXT,
15+
"iconDark" TEXT,
16+
"createdAt" DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
17+
"updatedAt" DATETIME NOT NULL,
18+
"lastPublishedAt" DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
19+
"authorId" TEXT NOT NULL,
20+
"killListedAt" DATETIME,
21+
CONSTRAINT "Extension_authorId_fkey" FOREIGN KEY ("authorId") REFERENCES "User" ("id") ON DELETE RESTRICT ON UPDATE CASCADE
22+
);
23+
INSERT INTO "new_Extension" ("apiVersion", "authorId", "checksum", "createdAt", "description", "downloadCount", "iconDark", "iconLight", "id", "killListedAt", "name", "storageKey", "title", "trending", "updatedAt") SELECT "apiVersion", "authorId", "checksum", "createdAt", "description", "downloadCount", "iconDark", "iconLight", "id", "killListedAt", "name", "storageKey", "title", "trending", "updatedAt" FROM "Extension";
24+
DROP TABLE "Extension";
25+
ALTER TABLE "new_Extension" RENAME TO "Extension";
26+
CREATE UNIQUE INDEX "Extension_authorId_name_key" ON "Extension"("authorId", "name");
27+
PRAGMA foreign_keys=ON;
28+
PRAGMA defer_foreign_keys=OFF;

prisma/schema.prisma

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ model Extension {
3333
commands Command[]
3434
createdAt DateTime @default(now())
3535
updatedAt DateTime @updatedAt
36+
lastPublishedAt DateTime @default(now())
3637
author User? @relation(fields: [authorId], references: [id])
3738
authorId String
3839
killListedAt DateTime? // to quickly blacklist an extension if for some reason we need to
@@ -65,7 +66,7 @@ model ExtensionPlatform {
6566
}
6667

6768
model ExtensionCategory {
68-
id String @id
69+
id String @id
6970
name String
7071
extensions Extension[]
7172
}

src/routes/v1/store.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@ async function formatExtensionResponse(
147147
readmeUrl,
148148
downloadUrl,
149149
createdAt: extension.createdAt.toISOString(),
150-
updatedAt: extension.updatedAt.toISOString(),
150+
updatedAt: extension.lastPublishedAt.toISOString(),
151151
};
152152
}
153153

@@ -363,6 +363,7 @@ app.post("/upload", async (c) => {
363363
checksum,
364364
iconLight: iconLightKey,
365365
iconDark: iconDarkKey,
366+
lastPublishedAt: new Date(),
366367
categories: {
367368
set: categoryIds,
368369
},

0 commit comments

Comments
 (0)