Closed edzillion closed 5 years ago
return knex.schema.createTable('offer', (t) => {
t.increments('id').primary()
t.string('itemCode', 50)
t.enu('type', ['item', 'percentageItem', 'percentageCategory'], { useNative: true, enumName: 'offer_type' })
t.string('title', 50).notNullable()
t.string('description', 250).notNullable()
t.dateTime('createdAt').notNullable().defaultTo(knex.fn.now())
t.dateTime('publishedAt')
t.dateTime('updatedAt')
t.integer('amount')
t.boolean('public').notNullable().defaultTo(false)
t.float('price')
t.float('percentage')
t.string('category', 50)
})
}
@ana0 what exactly does it mean to use postgres native types, as described here? https://knexjs.org/
For Postgres, an additional options argument can be provided to specify whether or not to use Postgres's native TYPE:
table.enu('column', ['value1', 'value2'], { useNative: true, enumName: 'foo_type' })
@ana0 also how do I declare the enum values in my jsonSchema
? I looked around but couldn't find anything that looks like the syntax we are using:
type: { type: 'enum' },
PR merged
I am going off the current wireframes.
Offer Model
There are 4 types of offer:
item
- A Coffee for ©3.50percentageItem
- Pay 20% in © for every CoffeepercentageCategory
- Pay 20% on all items in © / pay 20% of all main courses in ©general
- A general call to action - We accept © here!So our
offer
model should look like this:id: { type: 'integer' },
- incremented id gives us sequential order numbersitemCode: { type: 'string' },
- used by organisations that have their own product/item codestype: { type: 'string' },
- type as listed abovetitle: { type: 'string' },
- this will be the headline, so perhaps it should be called 'strapline' or something?description: { type: 'string' },
- this will be inside the foldcreatedAt: { type: 'object' },
- for admin reasonspublishedAt: { type: 'object' },
- this is the time the offer was startedupdatedAt: { type: 'object' },
- for admin reasonslimit: { type: 'object },
- the amount of a good/service you will sell - see belowpublic: { type: 'boolean' },
- should this offer be shown publicly in the 'local offers' section?price: { type: 'float'}
- optional, could be a % offerpercentage: { type: 'float'}
- optional, percentage is the % of the offer to be paid in Circles.category: { type: 'string'}
- we could always have a tag system instead but that seems more complicated. @saraswathi can you have a think about this and come up with a list of categories?Limit Object
There are 3 types of limit:
maxCircles
- I will accept 500 circles / weekmaxItems
- I will sell 1 item / user / weekmaxUserCircles
- I will sell items worth 50 circles to each user / weekSo our
limit
object should look like this:type: { type: 'string' },
- type as listed aboveamount: { type: 'integer' },
- the amount of the type to limitperiod: { type: 'string' },
- the time period over which the limit is enforced (sincepublishedAt
above)current: { type: 'integer' }
- the current amount of item sold