-
-
Notifications
You must be signed in to change notification settings - Fork 6.9k
Closed
Labels
CodeceptionPostgreSQLfeature:dbstatus:ready for adoptionFeel free to implement this issue.Feel free to implement this issue.type:bugBugBug
Milestone
Description
When I load fixtures, sequence number of tables are not updated or updated to wrong values,
I'm using this fix:
<?php
namespace tests\codeception\fixtures;
use yii\test\ActiveFixture;
class DocumentTypeFixture extends ActiveFixture {
public $modelClass = 'app\models\DocumentType';
public function load() {
parent::load();
if($this->db->drivername === 'pgsql') {
$this->db->createCommand("SELECT pg_catalog.setval(".
"pg_get_serial_sequence('document_type', 'id'),".
"(SELECT MAX(id)+1 FROM document_type)".
")")->execute();
}
}
}Error message:
1) tests\codeception\unit\crawlers\SuperMusicDocumentCrawlerTest::testCrawling
yii\db\IntegrityException: SQLSTATE[23505]:
Unique violation: 7 ERROR: duplicate key value violates unique constraint "document_type_pkey"
DETAIL: Key (id)=(3) already exists.
The SQL being executed was: INSERT INTO "document_type" ("name") VALUES ('taby')
Fixture data:
<?php
return [
'type' => [
'id' => 1,
'name' => 'type',
],
'type' => [
'id' => 2,
'name' => 'type2',
],
'type' => [
'id' => 3,
'name' => 'type333',
],
];Metadata
Metadata
Assignees
Labels
CodeceptionPostgreSQLfeature:dbstatus:ready for adoptionFeel free to implement this issue.Feel free to implement this issue.type:bugBugBug