Skip to content

Commit

Permalink
feat: add SlotUsageCheque
Browse files Browse the repository at this point in the history
  • Loading branch information
nicosantangelo committed Feb 10, 2022
1 parent 933aa0e commit 0fb61b4
Show file tree
Hide file tree
Showing 4 changed files with 47 additions and 0 deletions.
28 changes: 28 additions & 0 deletions migrations/1644469112765_create-slot-usage-cheques.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
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 },
signature: { type: 'TEXT', notNull: true },
quantity: { type: 'TEXT', notNull: true },
salt: { 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'
}
10 changes: 10 additions & 0 deletions src/SlotUsageCheque/SlotUsageCheque.types.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
export type SlotUsageChequeAttributes = {
id: string
signature: string
quantity: string
salt: 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 0fb61b4

Please sign in to comment.