/** * {@inheritDoc} */ public function truncateTableSql(Table $table) { $name = $this->_driver->quoteIdentifier($table->name()); $queries = [sprintf('DELETE FROM %s', $name)]; // Restart identity sequences $pk = $table->primaryKey(); if (count($pk) === 1) { $column = $table->column($pk[0]); if (in_array($column['type'], ['integer', 'biginteger'])) { $queries[] = sprintf('DBCC CHECKIDENT(%s, RESEED, 0)', $name); } } return $queries; }
/** * Tests primaryKey method * * @return void */ public function testPrimaryKey() { $table = new Table(['table' => 'users', 'schema' => ['id' => ['type' => 'integer'], '_constraints' => ['primary' => ['type' => 'primary', 'columns' => ['id']]]]]); $this->assertEquals('id', $table->primaryKey()); $table->primaryKey('thingID'); $this->assertEquals('thingID', $table->primaryKey()); $table->primaryKey(['thingID', 'user_id']); $this->assertEquals(['thingID', 'user_id'], $table->primaryKey()); }