Skip to content
Snippets Groups Projects
Commit debbf2f0 authored by Ghislain Loas's avatar Ghislain Loas
Browse files

hotline 46627 remove old index in notices_paniers

parent 36122a9e
Branches
Tags
4 merge requests!1797Master,!1746Master,!1745Hotline master,!1742Hotline#46627 fix selection edition
<?php
$adapter = Zend_Db_Table_Abstract::getDefaultAdapter();
try {
$adapter->query('ALTER TABLE notices_paniers DROP INDEX user_panier, DROP COLUMN id_panier');
} catch(Exception $e) {}
......@@ -129,7 +129,7 @@ abstract class UpgradeDBTestCase extends PHPUnit_Framework_TestCase {
protected function assertIndex($table, $name, $type, $message='') {
try {
foreach($this->query(sprintf('show keys in `%s`', $table))->fetchAll() as $row) {
if ($name == $row['Key_name'] && $type == $row['Index_type'])
if ($name == $row['Key_name'] && $type == $row['Index_type'])
return true;
}
} catch (Exception $e) {}
......@@ -143,6 +143,25 @@ abstract class UpgradeDBTestCase extends PHPUnit_Framework_TestCase {
}
protected function assertNotIndex($table, $name, $message = '') {
$message = $message
? $message
: sprintf('Failed asserting that "%s" table NOT CONTAINS index "%s" .',
$table, $name);
try {
foreach($this->query(sprintf('show keys in `%s`', $table))->fetchAll() as $row) {
if ($name == $row['Key_name'])
throw new Exception();
}
} catch (Exception $e) {
$this->fail($message);
}
return true;
}
protected function assertFieldType($table, $name, $type, $message='') {
return $this->assertField($table, $name, $type, 'Type', $message);
}
......@@ -683,7 +702,7 @@ class UpgradeDB_295_Test extends UpgradeDBTestCase {
class UpgradeDB_296_Test extends UpgradeDBTestCase {
public function prepare() {
try {
$this->query("ALTER TABLE `ouvertures` MODIFY `jour` date NOT NULL, DROP INDEX `id_site`");
$this->query("ALTER TABLE `ouvertures` MODIFY `jour` date NOT NULL, DROP INDEX `id_site`");
} catch(Exception $e) {}
}
......@@ -837,4 +856,29 @@ class UpgradeDB_303_Test extends UpgradeDBTestCase {
public function locationIdShouldBeIndexed() {
$this->assertIndex('bib_c_site', 'id_lieu', 'BTREE');
}
}
class UpgradeDB_304_Test extends UpgradeDBTestCase {
public function prepare() {
try {
$this->query('ALTER TABLE notices_paniers ADD COLUMN id_panier int(11) NOT NULL');
$this->query('UPDATE notices_paniers SET id_panier = id');
$this->query('ALTER TABLE notices_paniers ADD CONSTRAINT user_panier UNIQUE (id_user, id_panier)');
} catch(Exception $e) {
}
}
/** @test */
public function columnIdPanierShouldNotExist() {
$this->assertNotColumn('notices_paniers', 'id_panier');
}
/** @test */
public function uniqueIndexUserPanierShouldNotExist() {
$this->assertNotIndex('notices_paniers', 'user_panier');
}
}
\ No newline at end of file
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment