Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(rethinkdb): Notification: Phase 2 #10356

Merged
merged 143 commits into from
Oct 17, 2024
Merged
Changes from all commits
Commits
Show all changes
143 commits
Select commit Hold shift + click to select a range
bbd3d12
chore: write to PG
mattkrick Aug 27, 2024
217606e
fix: refactor comment to SDL
mattkrick Aug 27, 2024
fd13993
add comment
mattkrick Aug 27, 2024
918b493
Merge branch 'master' into chore/Comment-phase1
mattkrick Aug 28, 2024
424a54b
migrate existing Comments
mattkrick Aug 29, 2024
c0278ae
switch reads to PG
mattkrick Aug 29, 2024
4cf9c8f
fix replies
mattkrick Aug 29, 2024
d61559a
Merge branch 'master' into chore/Comment-phase3
mattkrick Sep 6, 2024
da853e7
init migration
mattkrick Sep 6, 2024
fb941f6
add writes to PG
mattkrick Sep 9, 2024
0efe604
Merge branch 'master' into chore/ReflectPrompt-phase1
mattkrick Sep 9, 2024
814d9ef
refactor add/move reflect template prompt to sdl
mattkrick Sep 9, 2024
134b3b6
refactor 4 mutations to sdl
mattkrick Sep 9, 2024
2f8cf27
fix downmigration
mattkrick Sep 9, 2024
9f372a1
Merge branch 'master' into chore/ReflectPrompt-phase1
mattkrick Sep 9, 2024
171ded7
use explicit columns
mattkrick Sep 9, 2024
a38beb4
migrate existing rows
mattkrick Sep 9, 2024
8a64083
progress
mattkrick Sep 9, 2024
fcc66a9
use explicit props
mattkrick Sep 9, 2024
c44f72c
use explicit props nullable
mattkrick Sep 9, 2024
9c2b951
Merge branch 'chore/ReflectPrompt-phase1' into chore/ReflectPrompt-ph…
mattkrick Sep 9, 2024
e628e0b
remove writes to R
mattkrick Sep 10, 2024
21fc97c
fix tsc
mattkrick Sep 10, 2024
ec73789
fix bad old migrations referencing types
mattkrick Sep 10, 2024
d18a710
Merge branch 'chore/ReflectPrompt-phase1' into chore/ReflectPrompt-ph…
mattkrick Sep 10, 2024
551ce33
Merge branch 'chore/ReflectPrompt-phase2' into chore/ReflectPrompt-ph…
mattkrick Sep 10, 2024
726f632
chore: migrate PasswordResetRequest
mattkrick Sep 10, 2024
9c7839d
use 2 queries for resets
mattkrick Sep 10, 2024
89040df
clean up clientside sortOrder
mattkrick Sep 10, 2024
5843139
Merge branch 'master' into chore/ReflectPrompt-phase2
mattkrick Sep 11, 2024
cc6bcbc
Merge branch 'chore/ReflectPrompt-phase2' into chore/ReflectPrompt-ph…
mattkrick Sep 11, 2024
69fa463
Merge branch 'chore/ReflectPrompt-phase3' into chore/PasswordResetReq…
mattkrick Sep 11, 2024
8abce47
chore: migrate PushInvitation
mattkrick Sep 11, 2024
c30e68f
fix test
mattkrick Sep 11, 2024
845366f
Merge branch 'master' into chore/NewMeeting-phase1
mattkrick Sep 11, 2024
feb72b8
add types
mattkrick Sep 12, 2024
ad4b876
Merge branch 'master' into chore/NewMeeting-phase1
mattkrick Sep 12, 2024
7d84391
fix name conflict
mattkrick Sep 12, 2024
a33d00f
remove as much coercion as possible
mattkrick Sep 12, 2024
a25d978
Merge branch 'master' into chore/NewMeeting-phase1
mattkrick Sep 12, 2024
cdc0a02
fix migration name
mattkrick Sep 12, 2024
835dd65
Merge branch 'master' into chore/NewMeeting-phase1
mattkrick Sep 13, 2024
5a155ca
revert processRecurrence test
mattkrick Sep 13, 2024
3a0d530
progress
mattkrick Sep 15, 2024
30c1ab3
finish adding writes to PG
mattkrick Sep 17, 2024
e2f8b30
fix downmigration
mattkrick Sep 17, 2024
2eb4482
self review
mattkrick Sep 17, 2024
7f256a2
first pass
mattkrick Sep 23, 2024
36fe2f8
chore: add default value for meetinCount
mattkrick Sep 24, 2024
9e3c1bc
equality checker first pass
mattkrick Sep 24, 2024
7eebaba
on delete cascade
mattkrick Sep 24, 2024
7c374ed
Merge branch 'master' into chore/NewMeeting-phase1
mattkrick Sep 24, 2024
24624f1
merge master
mattkrick Sep 24, 2024
a2200ce
Merge branch 'chore/NewMeeting-phase1b' into chore/NewMeeting-phase2
mattkrick Sep 24, 2024
c2acd22
fixup equality checker
mattkrick Sep 24, 2024
57790ac
fix stopMeetingSeries
mattkrick Sep 24, 2024
6a23205
fix trigger
mattkrick Sep 24, 2024
feb3e4b
fix trigger
mattkrick Sep 24, 2024
b06ab38
Merge branch 'chore/NewMeeting-phase1b' into chore/NewMeeting-phase2
mattkrick Sep 24, 2024
dd6c1bf
init
mattkrick Sep 24, 2024
2a28f19
remove comma after execute()
mattkrick Sep 25, 2024
11eeec0
progress
mattkrick Sep 25, 2024
f2b7b79
fix equality check
mattkrick Sep 25, 2024
d208f73
refactor to PG
mattkrick Sep 26, 2024
703b109
fix endTime index
mattkrick Sep 27, 2024
046198b
Merge branch 'chore/NewMeeting-phase1' into chore/NewMeeting-phase1b
mattkrick Sep 27, 2024
8c12687
fix tsc
mattkrick Sep 27, 2024
4e708b5
Merge branch 'chore/NewMeeting-phase1b' into chore/NewMeeting-phase2
mattkrick Sep 27, 2024
24739d8
merge 2
mattkrick Sep 27, 2024
a2c582e
fix nullability
mattkrick Sep 27, 2024
d7dca32
Merge branch 'master' into chore/NewMeeting-phase2
mattkrick Sep 27, 2024
f2d5f15
disable check_meeting_overlap trigger for tests
mattkrick Sep 27, 2024
882cb0b
handle empty arrays
mattkrick Sep 27, 2024
baec1ce
fix typo
mattkrick Sep 27, 2024
e803ce7
fix processRecurrence.test
mattkrick Sep 28, 2024
6c38ce0
Merge branch 'chore/NewMeeting-phase2' into chore/NewMeeting-phase3
mattkrick Oct 1, 2024
5290837
Merge branch 'master' into chore/NewMeeting-phase3
mattkrick Oct 1, 2024
c1668ae
fix: bugs in self review
mattkrick Oct 2, 2024
2b7f490
chore: write to PG
mattkrick Oct 2, 2024
bc524d5
remove MeetingMember db type
mattkrick Oct 2, 2024
8ec1185
Merge branch 'master' into chore/NewMeeting-phase3
mattkrick Oct 3, 2024
8ab1ba5
Merge branch 'chore/NewMeeting-phase3' into chore/MeetingMember-phase1
mattkrick Oct 3, 2024
ca19288
fix: updateRetroMaxVotes
mattkrick Oct 3, 2024
a588b0d
fix: re-add MeetingMember
mattkrick Oct 3, 2024
011e646
chore: migrate existing rows
mattkrick Oct 3, 2024
7c844ce
first pass removing R
mattkrick Oct 4, 2024
120cf15
fix: voting transaction logic
mattkrick Oct 7, 2024
e3980ba
Merge branch 'master' into chore/NewMeeting-phase3
mattkrick Oct 8, 2024
a3644d7
Merge branch 'chore/NewMeeting-phase3' into chore/MeetingMember-phase1
mattkrick Oct 8, 2024
cc01e7e
Merge branch 'master' into chore/NewMeeting-phase3
mattkrick Oct 8, 2024
551afb6
Merge branch 'chore/NewMeeting-phase3' into chore/MeetingMember-phase1
mattkrick Oct 8, 2024
c599981
Merge branch 'chore/MeetingMember-phase1' into chore/MeetingMember-ph…
mattkrick Oct 8, 2024
d0decfd
Merge branch 'chore/MeetingMember-phase2' into chore/MeetingMember-ph…
mattkrick Oct 8, 2024
3d43dfc
chore: migrate MassInvitation
mattkrick Oct 8, 2024
4c4e791
chore: move NewFeature to PG
mattkrick Oct 8, 2024
d0aea83
Merge branch 'master' into chore/MeetingMember-phase2
mattkrick Oct 8, 2024
af15e12
Merge branch 'chore/MeetingMember-phase2' into chore/MeetingMember-ph…
mattkrick Oct 8, 2024
1c14d5d
fixup lint
mattkrick Oct 8, 2024
74607a8
chore: add writes to PG
mattkrick Oct 9, 2024
4f3145f
Merge branch 'chore/MeetingMember-phase3' into chore/MassInvitation-1…
mattkrick Oct 9, 2024
abaa434
Merge branch 'master' into chore/MeetingMember-phase3
mattkrick Oct 9, 2024
339459d
Merge branch 'chore/MeetingMember-phase3' into chore/MassInvitation-1…
mattkrick Oct 9, 2024
21a3347
Merge branch 'chore/MassInvitation-1shot' into chore/NewFeature
mattkrick Oct 9, 2024
2658800
Merge branch 'chore/NewFeature' into chore/TeamInvitation-phase1
mattkrick Oct 9, 2024
7407c2c
chore: migrate rows to PG
mattkrick Oct 9, 2024
b53fbd8
chore: move reads to PG
mattkrick Oct 9, 2024
466c175
remove unused references
mattkrick Oct 9, 2024
b4f9d27
chore: first pass before taskId
mattkrick Oct 9, 2024
ea243a1
chore: add writes to PG
mattkrick Oct 10, 2024
204a8d5
fix: await create team
mattkrick Oct 10, 2024
badcd09
migrate first pass
mattkrick Oct 10, 2024
1f7a9f0
make content jsonb
mattkrick Oct 10, 2024
d759931
Merge branch 'chore/Task-phase1' into chore/Task-phase2
mattkrick Oct 10, 2024
31d444a
migrate old rows
mattkrick Oct 11, 2024
aaafa38
fix varchar lengths
mattkrick Oct 11, 2024
c31c618
refactor loaders
mattkrick Oct 11, 2024
4367111
fix: changeTaskTeam
mattkrick Oct 11, 2024
fb56d6b
Merge branch 'chore/Task-phase1' into chore/Task-phase2
mattkrick Oct 11, 2024
1efc089
Merge branch 'chore/Task-phase2' into chore/Task-phase3
mattkrick Oct 11, 2024
3246674
remove reads from r
mattkrick Oct 11, 2024
569ebaf
remove legacy Task db type
mattkrick Oct 11, 2024
b78f67d
self review
mattkrick Oct 15, 2024
18b6992
Merge branch 'chore/Task-phase1' into chore/Task-phase2
mattkrick Oct 15, 2024
3e1fb5d
Merge branch 'chore/Task-phase2' into chore/Task-phase3
mattkrick Oct 15, 2024
9544578
fix tags and archived filter
mattkrick Oct 15, 2024
a5dc4ef
fix task query for privates
mattkrick Oct 15, 2024
63dca7b
Merge branch 'master' into chore/Notification-phase1
mattkrick Oct 15, 2024
1fe7f45
Merge branch 'chore/Task-phase3' into chore/Notification-phase1
mattkrick Oct 15, 2024
176bbe5
Merge branch 'master' into chore/Task-phase2
mattkrick Oct 15, 2024
9300461
Merge branch 'chore/Task-phase2' into chore/Task-phase3
mattkrick Oct 15, 2024
d28d945
Merge branch 'chore/Task-phase3' into chore/Notification-phase1
mattkrick Oct 15, 2024
9db13f2
chore: add writes to PG
mattkrick Oct 16, 2024
d6828a8
migrate r to pg
mattkrick Oct 16, 2024
3a1a80e
update mig
mattkrick Oct 16, 2024
91a8d7d
add createdAt index
mattkrick Oct 16, 2024
c185d66
Merge branch 'chore/Notification-phase1' into chore/Notification-phase2
mattkrick Oct 16, 2024
03e950e
Merge branch 'master' into chore/Notification-phase1
mattkrick Oct 16, 2024
619ae19
Merge branch 'chore/Notification-phase1' into chore/Notification-phase2
mattkrick Oct 16, 2024
b9ed21a
fix migration name
mattkrick Oct 16, 2024
6ea1e85
Merge branch 'chore/Notification-phase1' into chore/Notification-phase2
mattkrick Oct 16, 2024
28fb031
Merge branch 'master' into chore/Notification-phase1
mattkrick Oct 17, 2024
3ffb9a1
Merge branch 'chore/Notification-phase1' into chore/Notification-phase2
mattkrick Oct 17, 2024
68132b6
Merge branch 'master' into chore/Notification-phase2
mattkrick Oct 17, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,193 @@
import {Kysely, PostgresDialect, sql} from 'kysely'
import {r} from 'rethinkdb-ts'
import connectRethinkDB from '../../database/connectRethinkDB'
import getPg from '../getPg'

export async function up() {
await connectRethinkDB()
const pg = new Kysely<any>({
dialect: new PostgresDialect({
pool: getPg()
})
})

try {
console.log('Adding index')
await r
.table('Notification')
.indexCreate('updatedAtId', (row: any) => [row('createdAt'), row('id')])
.run()
await r.table('Notification').indexWait().run()
} catch {
// index already exists
}

console.log('Adding index complete')

const MAX_PG_PARAMS = 65545
const PG_COLS = [
'id',
'status',
'createdAt',
'type',
'userId',
'meetingId',
'authorId',
'commentId',
'discussionId',
'teamId',
'evictorUserId',
'senderName',
'senderPicture',
'senderUserId',
'meetingName',
'retroReflectionId',
'retroDiscussStageIdx',
'orgId',
'last4',
'brand',
'activeDomain',
'domainJoinRequestId',
'email',
'name',
'picture',
'requestCreatedBy',
'responseId',
'changeAuthorId',
'involvement',
'taskId',
'archivorUserId',
'invitationId',
'orgName',
'orgPicture',
'scheduledLockAt'
] as const
type Notification = {
[K in (typeof PG_COLS)[number]]: any
}
const BATCH_SIZE = Math.trunc(MAX_PG_PARAMS / PG_COLS.length)

let curUpdatedAt = r.minval
let curId = r.minval

const insertRow = async (row) => {
if (!row.type) {
console.log('Notification has no type, skipping insert', row.id)
return
}
try {
await pg
.insertInto('Notification')
.values(row)
.onConflict((oc) => oc.doNothing())
.execute()
} catch (e) {
if (e.constraint === 'fk_meetingId') {
console.log('Notification has no meeting, skipping insert', row.id)
return
}
if (e.constraint === 'fk_userId') {
console.log('Notification has no user, skipping insert', row.id)
return
}
if (e.constraint === 'fk_changeAuthorId') {
console.log('Notification has no fk_changeAuthorId, skipping insert', row.id)
return
}
if (e.constraint === 'fk_taskId') {
console.log('Notification has no fk_taskId, skipping insert', row.id)
return
}
if (e.constraint === 'fk_archivorUserId') {
console.log('Notification has no fk_archivorUserId, skipping insert', row.id)
return
}
if (e.constraint === 'fk_orgId') {
console.log('Notification has no fk_orgId, skipping insert', row.id)
return
}
if (e.constraint === 'fk_evictorUserId') {
console.log('Notification has no fk_evictorUserId, skipping insert', row.id)
return
}
if (e.constraint === 'fk_invitationId') {
console.log('Notification has no fk_invitationId, skipping insert', row.id)
return
}
if (e.constraint === 'fk_responseId') {
console.log('Notification has no fk_responseId, skipping insert', row.id)
return
}
if (e.constraint === 'fk_authorId') {
console.log('Notification has no fk_authorId, skipping insert', row.id)
return
}
if (e.constraint === 'fk_commentId') {
console.log('Notification has no fk_commentId, skipping insert', row.id)
return
}
if (e.constraint === 'fk_teamId') {
console.log('Notification has no fk_teamId, skipping insert', row.id)
return
}
if (e.constraint === 'fk_discussionId') {
console.log('Notification has no fk_discussionId, skipping insert', row.id)
return
}
if (e.constraint === 'fk_senderUserId') {
console.log('Notification has no fk_senderUserId, skipping insert', row.id)
return
}
if (e.constraint === 'fk_retroReflectionId') {
console.log('Notification has no fk_retroReflectionId, skipping insert', row.id)
return
}
if (e.constraint === 'fk_domainJoinRequestId') {
console.log('Notification has no fk_domainJoinRequestId, skipping insert', row.id)
return
}
if (e.constraint === 'fk_requestCreatedBy') {
console.log('Notification has no fk_requestCreatedBy, skipping insert', row.id)
return
}
throw e
}
}
for (let i = 0; i < 1e6; i++) {
console.log('inserting row', i * BATCH_SIZE, String(curUpdatedAt), String(curId))
const rawRowsToInsert = (await r
.table('Notification')
.between([curUpdatedAt, curId], [r.maxval, r.maxval], {
index: 'updatedAtId',
leftBound: 'open',
rightBound: 'closed'
})
.orderBy({index: 'updatedAtId'})
.limit(BATCH_SIZE)
.pluck(...PG_COLS)
.run()) as Notification[]

const rowsToInsert = rawRowsToInsert.map((row) => {
const {responseId, ...rest} = row as any
return {
...rest,
responseId: responseId ? Number(responseId.split(':')[1]) : null
}
})

if (rowsToInsert.length === 0) break
const lastRow = rowsToInsert[rowsToInsert.length - 1]
curUpdatedAt = lastRow.createdAt
curId = lastRow.id
await Promise.all(rowsToInsert.map(async (row) => insertRow(row)))
}
}

export async function down() {
const pg = new Kysely<any>({
dialect: new PostgresDialect({
pool: getPg()
})
})
await sql`TRUNCATE TABLE "Notification" CASCADE`.execute(pg)
}
Loading