Add stock to product.

This commit was merged in pull request #49.
This commit is contained in:
2026-01-19 15:08:53 +01:00
parent 295a968581
commit 46065dae1a
3 changed files with 17 additions and 6 deletions

View File

@@ -170,13 +170,25 @@ class Migrate extends Command
$table->date('lastSeen')->nullable();
});
}
if (!Capsule::schema()->hasColumn('products', 'stock')) {
Capsule::schema()->table('products', function (Blueprint $table) {
$table->integer('stock')->nullable();
});
}
}
public function index(): void
{
if (!count(Capsule::select('SELECT name FROM sqlite_master WHERE type = "index" and name = "products_skuid_country_id_unique"'))) {
Capsule::schema()->table('products', function (Blueprint $table) {
$table->integer('skuID')->unique(false)->change();
$table->unique(['skuID', 'country_id']);
});
}
Capsule::schema()->table('products', function (Blueprint $table) {
$table->integer('skuID')->unique(false)->change();
$table->unique(['skuID', 'country_id']);
$table->foreign('id')->references('product_id')->on('stocks');
});
}
}