Skip to content

Commit

Permalink
fix: change retro group schema to allow for rethinkdb table migration (
Browse files Browse the repository at this point in the history
…#9653)

Signed-off-by: Matt Krick <matt.krick@gmail.com>
  • Loading branch information
mattkrick committed Apr 17, 2024
1 parent 1d18ec7 commit 0092d0b
Showing 1 changed file with 20 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {Kysely, PostgresDialect} from 'kysely'
import {Kysely, PostgresDialect, sql} from 'kysely'
import {r} from 'rethinkdb-ts'
import connectRethinkDB from '../../database/connectRethinkDB'
import getPg from '../getPg'
Expand All @@ -20,6 +20,12 @@ export async function up() {
// index already exists
}

await pg.schema
.alterTable('RetroReflectionGroup')
.alterColumn('voterIds', (ac) => ac.setDataType(sql`text[]`))
.alterColumn('promptId', (ac) => ac.setDataType('varchar(111)'))
.execute()

const MAX_PG_PARAMS = 65545
const PG_COLS = [
'id',
Expand Down Expand Up @@ -73,6 +79,19 @@ export async function up() {
.execute()
} catch (e) {
console.log({lastRow}, rowsToInsert.length)
await Promise.all(
rowsToInsert.map(async (row) => {
try {
const res = await pg
.insertInto('RetroReflectionGroup')
.values(row)
.onConflict((oc) => oc.doNothing())
.execute()
} catch (e) {
console.log(e, row)
}
})
)
throw e
}
}
Expand Down

0 comments on commit 0092d0b

Please sign in to comment.