| Total Complexity | 2 |
| Total Lines | 46 |
| Duplicated Lines | 0 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 9 | class AddProductsTable20231207060117 extends AbstractMigration |
||
| 10 | { |
||
| 11 | |||
| 12 | public function up(): void |
||
| 13 | { |
||
| 14 | //Action when migrate up |
||
| 15 | $this->create('products', function (CreateTable $table) { |
||
| 16 | $table->integer('id') |
||
| 17 | ->autoincrement() |
||
| 18 | ->primary(); |
||
| 19 | |||
| 20 | $table->string('name') |
||
| 21 | ->description('The product name') |
||
| 22 | ->notNull(); |
||
| 23 | |||
| 24 | $table->string('description') |
||
| 25 | ->description('The product description'); |
||
| 26 | |||
| 27 | $table->float('price') |
||
| 28 | ->defaultValue(0) |
||
| 29 | ->description('The product price') |
||
| 30 | ->notNull(); |
||
| 31 | |||
| 32 | $table->float('quantity') |
||
| 33 | ->defaultValue(0) |
||
| 34 | ->description('The product quantity') |
||
| 35 | ->notNull(); |
||
| 36 | |||
| 37 | $table->integer('product_category_id') |
||
| 38 | ->description('Product category') |
||
| 39 | ->notNull(); |
||
| 40 | |||
| 41 | $table->timestamps(); |
||
| 42 | |||
| 43 | $table->foreign('product_category_id') |
||
| 44 | ->references('product_categories', 'id') |
||
| 45 | ->onDelete('NO ACTION'); |
||
| 46 | |||
| 47 | $table->engine('INNODB'); |
||
| 48 | }); |
||
| 49 | } |
||
| 50 | |||
| 51 | public function down(): void |
||
| 55 | } |
||
| 56 | } |