Skip to content

Commit 65f829d

Browse files
committed
Fix bug with storing images; Migrate to timestamps for posts, likes, videos, and images for better query performance; Add images and videos feeds
1 parent cc1dfb2 commit 65f829d

File tree

18 files changed

+373
-236
lines changed

18 files changed

+373
-236
lines changed

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ rand = "0.8.5"
1717
rand_core = "0.6.4"
1818
secp256k1 = { version = "0.28.2", features = ["global-context", "serde", "rand", "hashes","rand-std"] }
1919
serde_json = { version = "1.0.96",features = ["preserve_order"] }
20-
rsky-lexicon = {path = "rsky-lexicon", version = "0.2.5"}
20+
rsky-lexicon = {path = "rsky-lexicon", version = "0.2.7"}
2121
rsky-identity = {path = "rsky-identity", version = "0.1.0"}
2222
rsky-crypto = {path = "rsky-crypto", version = "0.1.1"}
2323
rsky-syntax = {path = "rsky-syntax", version = "0.1.0"}
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
-- This file should undo anything in `up.sql`
22
ALTER TABLE post
3-
DROP COLUMN IF EXISTS createdAt;
3+
DROP COLUMN IF EXISTS "createdAt";
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
-- Revert the post table
2+
ALTER TABLE post
3+
ALTER COLUMN "createdAt" DROP DEFAULT;
4+
5+
-- Convert back to character varying using a text cast
6+
ALTER TABLE post
7+
ALTER COLUMN "createdAt" TYPE character varying USING "createdAt"::text,
8+
ALTER COLUMN "indexedAt" TYPE character varying USING "indexedAt"::text;
9+
10+
-- Reapply the original default for "createdAt"
11+
ALTER TABLE post
12+
ALTER COLUMN "createdAt" SET DEFAULT to_char(now(), 'YYYY-MM-DD"T"HH24:MI:SS.MS"Z"');
13+
14+
UPDATE post
15+
SET "createdAt" = "indexedAt";
16+
17+
-- Set "createdAt" as NOT NULL
18+
ALTER TABLE post
19+
ALTER COLUMN "createdAt" SET NOT NULL;
20+
21+
-- Revert the like table (note the quotes because "like" is a reserved word)
22+
ALTER TABLE "like"
23+
ALTER COLUMN "createdAt" TYPE character varying
24+
USING "createdAt"::text;
25+
ALTER TABLE "like"
26+
ALTER COLUMN "indexedAt" TYPE character varying
27+
USING "indexedAt"::text;
28+
29+
-- Revert the video table
30+
ALTER TABLE video
31+
ALTER COLUMN "createdAt" TYPE character varying
32+
USING "createdAt"::text;
33+
ALTER TABLE video
34+
ALTER COLUMN "indexedAt" TYPE character varying
35+
USING "indexedAt"::text;
36+
37+
-- Revert the image table
38+
ALTER TABLE image
39+
ALTER COLUMN "createdAt" TYPE character varying
40+
USING "createdAt"::text;
41+
ALTER TABLE image
42+
ALTER COLUMN "indexedAt" TYPE character varying
43+
USING "indexedAt"::text;
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
-- Drop defaults on post table so they don’t interfere
2+
ALTER TABLE post ALTER COLUMN "createdAt" DROP DEFAULT;
3+
4+
-- Update the post table
5+
ALTER TABLE post
6+
ALTER COLUMN "createdAt" TYPE timestamptz
7+
USING "createdAt"::timestamptz;
8+
ALTER TABLE post
9+
ALTER COLUMN "indexedAt" TYPE timestamptz
10+
USING "indexedAt"::timestamptz;
11+
ALTER TABLE post ALTER COLUMN "createdAt" SET DEFAULT now();
12+
13+
-- Update the like table (note the quotes because like is reserved)
14+
ALTER TABLE "like"
15+
ALTER COLUMN "createdAt" TYPE timestamptz
16+
USING "createdAt"::timestamptz;
17+
ALTER TABLE "like"
18+
ALTER COLUMN "indexedAt" TYPE timestamptz
19+
USING "indexedAt"::timestamptz;
20+
21+
-- Update the video table
22+
ALTER TABLE video
23+
ALTER COLUMN "createdAt" TYPE timestamptz
24+
USING "createdAt"::timestamptz;
25+
ALTER TABLE video
26+
ALTER COLUMN "indexedAt" TYPE timestamptz
27+
USING "indexedAt"::timestamptz;
28+
29+
-- Update the image table
30+
ALTER TABLE image
31+
ALTER COLUMN "createdAt" TYPE timestamptz
32+
USING "createdAt"::timestamptz;
33+
ALTER TABLE image
34+
ALTER COLUMN "indexedAt" TYPE timestamptz
35+
USING "indexedAt"::timestamptz;
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
-- !no-transaction
2+
DROP INDEX CONCURRENTLY IF EXISTS image_posturi_idx;
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
-- !no-transaction
2+
CREATE INDEX CONCURRENTLY image_posturi_idx ON image("postUri");
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
-- !no-transaction
2+
DROP INDEX CONCURRENTLY IF EXISTS video_postcid_idx;
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
-- !no-transaction
2+
CREATE INDEX CONCURRENTLY video_postcid_idx ON video("postCid");
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
-- !no-transaction
2+
DROP INDEX CONCURRENTLY IF EXISTS video_posturi_idx;
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
-- !no-transaction
2+
CREATE INDEX CONCURRENTLY video_posturi_idx ON video("postUri");

0 commit comments

Comments
 (0)