Skip to content

Commit 89d3cf8

Browse files
committed
Add inserted_at for packages
1 parent ec0d115 commit 89d3cf8

File tree

4 files changed

+28
-7
lines changed

4 files changed

+28
-7
lines changed

Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ COPY packages /packages
1010

1111
RUN cd /build/backend && gleam export erlang-shipment
1212

13-
FROM --platform=x86_64 ghcr.io/gleam-lang/gleam:v1.4.0-erlang-alpine AS runner
13+
FROM --platform=x86_64 ghcr.io/gleam-lang/gleam:v1.4.1-erlang-alpine AS runner
1414
LABEL org.opencontainers.image.source=https://github.com/ghivert/gloogle
1515

1616
RUN apk add build-base ca-certificates inotify-tools
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
-- migrate:up
2+
alter table package_release add column inserted_at timestamp;
3+
4+
-- migrate:down
5+
alter table package_release drop column inserted_at;

apps/backend/db/schema.sql

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -247,7 +247,8 @@ CREATE TABLE public.package_release (
247247
updated_at timestamp with time zone DEFAULT CURRENT_TIMESTAMP NOT NULL,
248248
package_interface text,
249249
gleam_toml text,
250-
retirement jsonb
250+
retirement jsonb,
251+
inserted_at timestamp without time zone
251252
);
252253

253254

@@ -611,4 +612,5 @@ INSERT INTO public.schema_migrations (version) VALUES
611612
('20240801211520'),
612613
('20240801220817'),
613614
('20240902224247'),
614-
('20240902225236');
615+
('20240902225236'),
616+
('20241016151324');

apps/backend/src/backend/postgres/queries.gleam

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -318,19 +318,33 @@ pub fn upsert_release(
318318
let url = pgo.text(release.url)
319319
let package_interface = pgo.nullable(pgo.text, package_interface)
320320
let gleam_toml = pgo.nullable(pgo.text, gleam_toml)
321-
let args = [package_id, version, url, package_interface, gleam_toml]
321+
let inserted_at =
322+
release.inserted_at
323+
|> birl.to_erlang_universal_datetime
324+
|> dynamic.from
325+
|> dynamic.unsafe_coerce
326+
let args = [
327+
package_id,
328+
version,
329+
url,
330+
package_interface,
331+
gleam_toml,
332+
inserted_at,
333+
]
322334
"INSERT INTO package_release (
323335
package_id,
324336
version,
325337
url,
326338
package_interface,
327-
gleam_toml
328-
) VALUES ($1, $2, $3, $4, $5)
339+
gleam_toml,
340+
inserted_at
341+
) VALUES ($1, $2, $3, $4, $5, $6)
329342
ON CONFLICT (package_id, version) DO UPDATE
330343
SET
331344
url = $3,
332345
package_interface = $4,
333-
gleam_toml = $5
346+
gleam_toml = $5,
347+
inserted_at = $6
334348
RETURNING id, package_interface, gleam_toml"
335349
|> pgo.execute(
336350
db,

0 commit comments

Comments
 (0)