| Total Complexity | 2 |
| Complexity/F | 1 |
| Lines of Code | 26 |
| Function Count | 2 |
| Duplicated Lines | 0 |
| Ratio | 0 % |
| Changes | 0 | ||
| 1 | import BaseSchema from '@ioc:Adonis/Lucid/Schema' |
||
| 2 | |||
| 3 | export default class extends BaseSchema { |
||
| 4 | protected tableName = 'orders' |
||
| 5 | |||
| 6 | public async up () { |
||
| 7 | this.schema.createTable(this.tableName, (table) => { |
||
| 8 | table.increments('id') |
||
| 9 | table.integer('user_id').unsigned().references('users.id').onDelete('CASCADE') |
||
| 10 | table.integer('product_id').unsigned().references('products.id') |
||
| 11 | table.string('quantity') |
||
| 12 | table.tinyint('is_successful', 3).defaultTo(0) |
||
| 13 | |||
| 14 | /** |
||
| 15 | * Uses timestamptz for PostgreSQL and DATETIME2 for MSSQL |
||
| 16 | */ |
||
| 17 | table.timestamp('created_at', { useTz: true }) |
||
| 18 | table.timestamp('updated_at', { useTz: true }) |
||
| 19 | }) |
||
| 20 | } |
||
| 21 | |||
| 22 | public async down () { |
||
| 23 | this.schema.dropTable(this.tableName) |
||
| 24 | } |
||
| 25 | } |
||
| 26 |