first commit
This commit is contained in:
@@ -0,0 +1,26 @@
|
||||
<?php
|
||||
|
||||
namespace App\Database\Seeds;
|
||||
|
||||
use CodeIgniter\Database\Seeder;
|
||||
|
||||
class DefaultInstrumentsSeeder extends Seeder
|
||||
{
|
||||
public function run(): void
|
||||
{
|
||||
$now = date('Y-m-d H:i:s');
|
||||
$names = ['Obligacje', 'ETF'];
|
||||
|
||||
foreach ($names as $name) {
|
||||
// Idempotentnie: pomin instrument, ktory juz istnieje
|
||||
$exists = (int) $this->db->table('inv_instruments')->where('name', $name)->countAllResults();
|
||||
if ($exists === 0) {
|
||||
$this->db->table('inv_instruments')->insert([
|
||||
'name' => $name,
|
||||
'created_at' => $now,
|
||||
'updated_at' => $now,
|
||||
]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user