chore: add kind 3 to replaceable events migration

This commit is contained in:
Ricardo Arturo Cabral Mejia 2022-08-18 23:32:40 +00:00
parent 1222e49a24
commit b02c76c6d0
No known key found for this signature in database
GPG Key ID: 5931EBF43A650245
2 changed files with 2 additions and 2 deletions

View File

@ -1,7 +1,7 @@
exports.up = function (knex) {
// NIP-16: Replaceable Events
return knex.raw(
'CREATE UNIQUE INDEX replaceable_events_idx ON events ( event_pubkey, event_kind ) WHERE event_kind = 0 OR event_kind >= 10000 AND event_kind < 20000;',
'CREATE UNIQUE INDEX replaceable_events_idx ON events ( event_pubkey, event_kind ) WHERE event_kind = 0 OR event_kind = 3 OR event_kind >= 10000 AND event_kind < 20000;',
)
}

View File

@ -153,7 +153,7 @@ export class EventRepository implements IEventRepository {
return this.dbClient('events')
.insert(row)
// NIP-16: Replaceable Events
.onConflict(this.dbClient.raw('(event_pubkey, event_kind) WHERE event_kind = 0 OR event_kind >= 10000 AND event_kind < 2000'))
.onConflict(this.dbClient.raw('(event_pubkey, event_kind) WHERE event_kind = 0 OR event_kind = 3 OR event_kind >= 10000 AND event_kind < 2000'))
.merge(omit(['event_pubkey', 'event_kind'])(row))
.where('events.event_created_at', '<', row.event_created_at)
.then(prop('rowCount') as () => number)