Skip to content

Commit

Permalink
Add hash id column to feeds (#3469)
Browse files Browse the repository at this point in the history
  • Loading branch information
DukeManh authored Apr 12, 2022
1 parent 12fed3f commit cd4d285
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 1 deletion.
4 changes: 4 additions & 0 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
-- AlterTable
ALTER TABLE "feeds" ADD COLUMN "id" TEXT NOT NULL DEFAULT E'';
1 change: 1 addition & 0 deletions src/db/prisma/schema.prisma
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ enum FeedType {
// Planet CDOT Feed List, see https://wiki.cdot.senecacollege.ca/wiki/Planet_CDOT_Feed_List
model feeds {
url String @id
id String @default("")
user_id String? // optional, a user can claim an existing feed when they register
wiki_author_name String? // wiki owner of a feed, maybe unused when the feed is linked with an actual user
html_url String? //actual URL the feed refers to, could be a blog URL, a Youtube or Twitch channel
Expand Down
4 changes: 3 additions & 1 deletion tools/migrate/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,12 @@
"author": "",
"private": true,
"dependencies": {
"@senecacdot/satellite": "^1.27.0",
"@supabase/supabase-js": "1.29.4",
"dotenv": "10.0.0",
"jsdom": "18.1.1",
"node-fetch": "2.6.7"
"node-fetch": "2.6.7",
"normalize-url": "6.1.0"
},
"description": "Migrates users from the planet feed wiki list to a JSON file or supabase-db",
"license": "ISC",
Expand Down
3 changes: 3 additions & 0 deletions tools/migrate/to_supabase.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
const { createClient } = require('@supabase/supabase-js');
const { hash } = require('@senecacdot/satellite');
const normalizeUrl = require('normalize-url');
const { parsePlanetFeedList } = require('./feed');

require('dotenv').config();
Expand All @@ -19,6 +21,7 @@ const { SUPABASE_URL, SERVICE_ROLE_KEY } = process.env;
url: feed,
wiki_author_name: `${firstName} ${lastName}`,
type: 'blog',
id: hash(normalizeUrl(feed)),
}));

const { error, count } = await supabase.from('feeds').upsert(feeds, {
Expand Down

0 comments on commit cd4d285

Please sign in to comment.