Merge pull request #35 from dhensby/pulls/db-index-update
Update module to work with new stricter index definitions
This commit is contained in:
commit
acaaf95d22
32
.travis.yml
32
.travis.yml
|
@ -1,30 +1,34 @@
|
||||||
# See https://github.com/silverstripe-labs/silverstripe-travis-support for setup details
|
language: php
|
||||||
|
|
||||||
|
dist: precise
|
||||||
|
|
||||||
sudo: false
|
sudo: false
|
||||||
|
|
||||||
language: php
|
|
||||||
|
|
||||||
php:
|
php:
|
||||||
- 5.5
|
|
||||||
- 5.6
|
- 5.6
|
||||||
- 7.0
|
- 7.0
|
||||||
|
- 7.1
|
||||||
|
|
||||||
env:
|
env:
|
||||||
- DB=SQLITE CORE_RELEASE=master PDO=1
|
- DB=SQLITE CORE_RELEASE=4 PDO=1
|
||||||
|
|
||||||
matrix:
|
matrix:
|
||||||
|
fast_finish: true
|
||||||
include:
|
include:
|
||||||
- php: 5.6
|
- php: 5.6
|
||||||
env: DB=SQLITE CORE_RELEASE=master PDO=0
|
env: DB=SQLITE CORE_RELEASE=4 PDO=0
|
||||||
allow_failures:
|
|
||||||
- php: 7.0
|
|
||||||
|
|
||||||
before_script:
|
before_script:
|
||||||
- composer self-update || true
|
# Init PHP
|
||||||
- git clone git://github.com/silverstripe-labs/silverstripe-travis-support.git ~/travis-support
|
- printf "\n" | pecl install imagick
|
||||||
- php ~/travis-support/travis_setup.php --source `pwd` --target ~/builds/ss
|
- phpenv rehash
|
||||||
- cd ~/builds/ss
|
- phpenv config-rm xdebug.ini
|
||||||
- composer install
|
- echo 'memory_limit = 2048M' >> ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/travis.ini
|
||||||
|
|
||||||
|
# Install composer dependencies
|
||||||
|
- composer validate
|
||||||
|
- composer require symfony/config:^3.2 silverstripe/framework:4.0.x-dev silverstripe/cms:4.0.x-dev silverstripe/siteconfig:4.0.x-dev silverstripe/config:1.0.x-dev silverstripe/admin:1.0.x-dev silverstripe/assets:1.0.x-dev silverstripe/versioned:1.0.x-dev --no-update
|
||||||
|
- composer install --prefer-dist --no-interaction --no-progress --no-suggest --optimize-autoloader --verbose --profile
|
||||||
|
|
||||||
script:
|
script:
|
||||||
- vendor/bin/phpunit framework/tests
|
- vendor/bin/phpunit vendor/silverstripe/framework/tests
|
||||||
|
|
|
@ -4,7 +4,6 @@ namespace SilverStripe\SQLite;
|
||||||
|
|
||||||
use SilverStripe\Control\Director;
|
use SilverStripe\Control\Director;
|
||||||
use SilverStripe\Dev\Debug;
|
use SilverStripe\Dev\Debug;
|
||||||
use SilverStripe\Dev\SapphireTest;
|
|
||||||
use SilverStripe\ORM\Connect\DBSchemaManager;
|
use SilverStripe\ORM\Connect\DBSchemaManager;
|
||||||
use Exception;
|
use Exception;
|
||||||
|
|
||||||
|
@ -210,7 +209,7 @@ class SQLite3SchemaManager extends DBSchemaManager
|
||||||
{
|
{
|
||||||
$ok = true;
|
$ok = true;
|
||||||
|
|
||||||
if (!SapphireTest::using_temp_db() && !self::$checked_and_repaired) {
|
if (!self::$checked_and_repaired) {
|
||||||
$this->alterationMessage("Checking database integrity", "repaired");
|
$this->alterationMessage("Checking database integrity", "repaired");
|
||||||
|
|
||||||
// Check for any tables with failed integrity
|
// Check for any tables with failed integrity
|
||||||
|
@ -370,10 +369,9 @@ class SQLite3SchemaManager extends DBSchemaManager
|
||||||
*/
|
*/
|
||||||
public function createIndex($tableName, $indexName, $indexSpec)
|
public function createIndex($tableName, $indexName, $indexSpec)
|
||||||
{
|
{
|
||||||
$parsedSpec = $this->parseIndexSpec($indexName, $indexSpec);
|
|
||||||
$sqliteName = $this->buildSQLiteIndexName($tableName, $indexName);
|
$sqliteName = $this->buildSQLiteIndexName($tableName, $indexName);
|
||||||
$columns = $parsedSpec['value'];
|
$columns = $this->implodeColumnList($indexSpec['columns']);
|
||||||
$unique = ($parsedSpec['type'] == 'unique') ? 'UNIQUE' : '';
|
$unique = ($indexSpec['type'] == 'unique') ? 'UNIQUE' : '';
|
||||||
$this->query("CREATE $unique INDEX IF NOT EXISTS \"$sqliteName\" ON \"$tableName\" ($columns)");
|
$this->query("CREATE $unique INDEX IF NOT EXISTS \"$sqliteName\" ON \"$tableName\" ($columns)");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -402,18 +400,6 @@ class SQLite3SchemaManager extends DBSchemaManager
|
||||||
return "{$tableName}_{$indexName}";
|
return "{$tableName}_{$indexName}";
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function parseIndexSpec($name, $spec)
|
|
||||||
{
|
|
||||||
$spec = parent::parseIndexSpec($name, $spec);
|
|
||||||
|
|
||||||
// Only allow index / unique index types
|
|
||||||
if (!in_array($spec['type'], array('index', 'unique'))) {
|
|
||||||
$spec['type'] = 'index';
|
|
||||||
}
|
|
||||||
|
|
||||||
return $spec;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function indexKey($table, $index, $spec)
|
public function indexKey($table, $index, $spec)
|
||||||
{
|
{
|
||||||
return $this->buildSQLiteIndexName($table, $index);
|
return $this->buildSQLiteIndexName($table, $index);
|
||||||
|
@ -437,11 +423,11 @@ class SQLite3SchemaManager extends DBSchemaManager
|
||||||
}
|
}
|
||||||
|
|
||||||
// Safely encode this spec
|
// Safely encode this spec
|
||||||
$indexList[$indexName] = $this->parseIndexSpec($indexName, array(
|
$indexList[$indexName] = array(
|
||||||
'name' => $indexName,
|
'name' => $indexName,
|
||||||
'value' => $this->implodeColumnList($list),
|
'columns' => $list,
|
||||||
'type' => $indexType
|
'type' => $indexType,
|
||||||
));
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
return $indexList;
|
return $indexList;
|
||||||
|
|
|
@ -18,7 +18,7 @@
|
||||||
"silverstripe/vendor-plugin": "^1.0"
|
"silverstripe/vendor-plugin": "^1.0"
|
||||||
},
|
},
|
||||||
"require-dev": {
|
"require-dev": {
|
||||||
"phpunit/phpunit": "~4.8"
|
"phpunit/phpunit": "^5.7"
|
||||||
},
|
},
|
||||||
"extra": {
|
"extra": {
|
||||||
"branch-alias": {
|
"branch-alias": {
|
||||||
|
|
|
@ -0,0 +1,16 @@
|
||||||
|
<phpunit bootstrap="vendor/silverstripe/cms/tests/bootstrap.php" colors="true">
|
||||||
|
|
||||||
|
<testsuite name="Default">
|
||||||
|
<directory>tests</directory>
|
||||||
|
</testsuite>
|
||||||
|
|
||||||
|
<filter>
|
||||||
|
<whitelist addUncoveredFilesFromWhitelist="true">
|
||||||
|
<directory suffix=".php">.</directory>
|
||||||
|
<exclude>
|
||||||
|
<directory suffix=".php">tests/</directory>
|
||||||
|
</exclude>
|
||||||
|
</whitelist>
|
||||||
|
</filter>
|
||||||
|
|
||||||
|
</phpunit>
|
Loading…
Reference in New Issue