Skip to content

Commit

Permalink
Add a unique key to the devshop environment table (#437)
Browse files Browse the repository at this point in the history
* Add a unique key to the devshop environment table so that the same name/project_nid combo cannot be added twice.

* Add ./devmaster volume mount to testing docker-compose file as well.

* Revert "Add ./devmaster volume mount to testing docker-compose file as well."

This reverts commit 5f2e8d6.

* Use a key name that differs from the index name.

* Change unique key to project_nid_name.

* Drop the old index in the project_environment table before adding a new
unique key.

* Add "Run DevShop Server Upgrade Tests".

* merge fix

* Put php_version and php_default_version_debian variables to 7.1.

* Add "php_version" variable to devshop.users role so it is loaded in time for geerlingguy.php to read it.
  • Loading branch information
jonpugh authored Aug 14, 2020
1 parent 23c51d3 commit ad35194
Showing 1 changed file with 16 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ function devshop_projects_update_dependencies() {
*/
function devshop_projects_install() {

// Push devshop_projects's system weight to 1.
// Push devshop_projects system weight to 1.
db_update('system')
->fields(array(
'weight' => 1
Expand Down Expand Up @@ -131,8 +131,11 @@ function devshop_projects_schema() {
'description' => 'The NID of the last task that should be displayed on an environment.',
),
),
'indexes' => array(
'project_environment' => array('project_nid', 'name'),
'unique keys' => array(
'project_nid_name' => array(
'project_nid',
'name',
),
),
);
return $schema;
Expand Down Expand Up @@ -475,4 +478,13 @@ function devshop_projects_update_7009 () {
if (!db_query($query)) {
drupal_set_message(t('Something went wrong when running a query to update hosting_context table to ensure all projects are prefixed with "project_":') . $query);
}
}
}

/**
* Add the "project_environment" unique index to the hosting_devshop_project_environment table.
*/
function devshop_projects_update_7010() {
db_query("ALTER TABLE {hosting_devshop_project_environment} DROP INDEX project_environment");
db_query("CREATE UNIQUE INDEX project_nid_name ON {hosting_devshop_project_environment}(project_nid, name)")
->execute();
}

0 comments on commit ad35194

Please sign in to comment.