Skip to content

Commit

Permalink
feat: add SlotUsageCheque (#403)
Browse files Browse the repository at this point in the history
* feat: add SlotUsageCheque

* feat: signature -> signedMessage

* feat: remove unused columns
  • Loading branch information
nicosantangelo committed Feb 14, 2022
1 parent d02aea6 commit 98ab624
Show file tree
Hide file tree
Showing 4 changed files with 43 additions and 0 deletions.
26 changes: 26 additions & 0 deletions migrations/1644469112765_create-slot-usage-cheques.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import { MigrationBuilder } from 'node-pg-migrate'
import { SlotUsageCheque } from '../src/SlotUsageCheque'

const tableName = SlotUsageCheque.tableName

export const up = (pgm: MigrationBuilder) => {
pgm.createTable(
tableName,
{
id: { type: 'UUID', primaryKey: true, unique: true, notNull: true },
signedMessage: { type: 'TEXT', notNull: true },
collection_id: { type: 'TEXT', notNull: true },
third_party_id: { type: 'TEXT', notNull: true },
created_at: { type: 'TIMESTAMP', notNull: true },
updated_at: { type: 'TIMESTAMP', notNull: true },
},
{ ifNotExists: true }
)

pgm.createIndex(tableName, 'collection_id')
pgm.createIndex(tableName, 'third_party_id')
}

export const down = (pgm: MigrationBuilder) => {
pgm.dropTable(tableName, {})
}
7 changes: 7 additions & 0 deletions src/SlotUsageCheque/SlotUsageCheque.model.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import { Model } from 'decentraland-server'

import { SlotUsageChequeAttributes } from './SlotUsageCheque.types'

export class SlotUsageCheque extends Model<SlotUsageChequeAttributes> {
static tableName = 'slot_usage_cheques'
}
8 changes: 8 additions & 0 deletions src/SlotUsageCheque/SlotUsageCheque.types.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
export type SlotUsageChequeAttributes = {
id: string
signedMessage: string
collection_id: string
third_party_id: string
updated_at: Date
created_at: Date
}
2 changes: 2 additions & 0 deletions src/SlotUsageCheque/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
export * from './SlotUsageCheque.types'
export * from './SlotUsageCheque.model'

0 comments on commit 98ab624

Please sign in to comment.