Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
69 changes: 69 additions & 0 deletions db/migrations/20260701113522_add_box_monetary_value_weight.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
<?php

use Phinx\Migration\AbstractMigration;

class AddBoxMonetaryValueWeight extends AbstractMigration
{
public function up(): void
{
$this->table('stock')
->addColumn('weight_display_unit_id', 'integer', [
'null' => true,
'default' => 1, // kilogram
'signed' => false,
'after' => 'size_id',
])
Comment thread
pylipp marked this conversation as resolved.
->addColumn('weight', 'decimal', [
'null' => true,
'default' => null,
'signed' => false,
// Values for DECIMAL columns are stored using a binary format
// that packs nine decimal digits into 4 bytes
'precision' => 36,
'scale' => 18,
'after' => 'weight_display_unit_id',
])
->addColumn('monetary_value', 'decimal', [
'null' => true,
'default' => null,
'signed' => false,
'precision' => 36,
'scale' => 18,
'after' => 'weight',
])
->save()
;
$this->table('stock')
->addForeignKey('weight_display_unit_id', 'units', 'id', [
'delete' => 'RESTRICT', 'update' => 'CASCADE',
])
->save()
;
$this->table('camps')
->addColumn('currency', 'string', [
Comment thread
pylipp marked this conversation as resolved.
'null' => false,
'default' => 'EUR',
'limit' => 15,
'collation' => 'utf8_general_ci',
'encoding' => 'utf8',
'after' => 'currencyname',
])
->save()
;
}

public function down(): void
{
$this->table('stock')
->dropForeignKey('weight_display_unit_id')
->removeColumn('weight_display_unit_id')
->removeColumn('weight')
->removeColumn('monetary_value')
->save()
;
$this->table('camps')
->removeColumn('currency')
->save()
;
}
}
Loading