Skip to content

Commit

Permalink
#0008444: Test suite Keywords - Add unique key to avoid duplicate ent…
Browse files Browse the repository at this point in the history
…ries

#0008445: Keywords - add unique index to avoid duplicates inside test project
  • Loading branch information
fmancardi committed Nov 1, 2018
1 parent a41f3a4 commit 4d41041
Show file tree
Hide file tree
Showing 7 changed files with 29 additions and 11 deletions.
18 changes: 15 additions & 3 deletions README.md
@@ -1,4 +1,4 @@
# TestLink 1.9.18 Gaura - Read me
# TestLink 1.9.19 Metonic cycle - Read me

## Contents
1. [Introduction](#1-introduction)
Expand Down Expand Up @@ -65,7 +65,7 @@ has been done and what still needs to be done.

## 2. Release notes / CRITICAL Configuration Notes

This release contains bugfixes and enhancement for 1.9.17
This release contains bugfixes and enhancement for 1.9.18
See CHANGELOG file for detailed list of issues fixed.

Give a look also to:
Expand Down Expand Up @@ -297,6 +297,8 @@ then look at sections: 'Upgrade from 1.9.4/5 to 1.9.7',
'Upgrade from 1.9.14 to 1.9.15',
'Upgrade from 1.9.15 to 1.9.16',
'Upgrade from 1.9.16 to 1.9.17'
'Upgrade from 1.9.17 to 1.9.18'
'Upgrade from 1.9.18 to 1.9.19'

3. Upgrade from 1.9.7 to 1.9.8

Expand Down Expand Up @@ -374,6 +376,13 @@ WARNING: if you are using a table prefix replace `prefix` with your prefix
a. Execute `install/sql/alter_tables/1.9.18/<your_db>/DB.1.9.17/step1/db_schema_update.sql`
b. Execute (IF EXISTS) `install/sql/alter_tables/1.9.18/<your_db>/DB.1.9.17/stepZ/z_final_step.sql`

14. Upgrade from 1.9.18 to 1.9.19

WARNING: if you are using a table prefix replace `prefix` with your prefix

a. Execute `install/sql/alter_tables/1.9.19/<your_db>/DB.1.9.18/step1/db_schema_update.sql`
b. Execute (IF EXISTS) `install/sql/alter_tables/1.9.19/<your_db>/DB.1.9.18/stepZ/z_final_step.sql`

**Hint**: When using MySQL Query Browser make sure you are not using single
command execution. (open script or use special script tab to
execute the whole script at once)
Expand All @@ -389,7 +398,7 @@ than yours. Extreme example: migration from 1.7.4
1.7.4 => 1.7.5 => 1.8.1 => 1.8.2 => 1.8.3 => 1.8.4 => 1.8.5 => 1.9.0
1.9.0 => 1.9.1 => 1.9.2 => 1.9.3 => 1.9.4 => 1.9.5 => 1.9.6 => 1.9.7 =>
1.9.8 => 1.9.9 => 1.9.10 => 1.9.11 => 1.9.12 => 1.9.13 => 1.9.14 =>
1.9.15 => 1.9.16 => 1.9.17 => 1.9.18
1.9.15 => 1.9.16 => 1.9.17 => 1.9.18 => 1.9.19

You have to read carefully README and instructions (if any) provided by
installer. Sometimes version changes do not require actions on DB structure
Expand Down Expand Up @@ -518,6 +527,9 @@ PLEASE: read these short hints before you write a topic:

## 10. Changes

### 1.9.19
- DB Schema changes new unique indexes.


### 1.9.18
- DB Schema changes to allow fine grain management of different entities.
Expand Down
2 changes: 1 addition & 1 deletion cfg/const.inc.php
Expand Up @@ -27,7 +27,7 @@
* about necesssary upgrades
* if you set this parameter also upgrade
* lib/functions/configCheck.php - checkSchemaVersion() */
define('TL_LATEST_DB_VERSION', 'DB ' . '1.9.18');
define('TL_LATEST_DB_VERSION', 'DB ' . '1.9.19');

// needed to avoid problems in install scripts that do not include config.inc.php
// want to point to root install dir, need to remove fixed part
Expand Down
2 changes: 1 addition & 1 deletion install/sql/mysql/testlink_create_default_data.sql
Expand Up @@ -6,7 +6,7 @@
# ---------------------------------------------------------------------------------

# Database version
INSERT INTO /*prefix*/db_version (version,notes,upgrade_ts) VALUES('DB 1.9.18', 'TestLink 1.9.18 Gaura',CURRENT_TIMESTAMP());
INSERT INTO /*prefix*/db_version (version,notes,upgrade_ts) VALUES('DB 1.9.19', 'TestLink 1.9.19 Metonic cycle',CURRENT_TIMESTAMP());

# Node types -
INSERT INTO /*prefix*/node_types (id,description) VALUES (1,'testproject');
Expand Down
6 changes: 4 additions & 2 deletions install/sql/mysql/testlink_create_tables.sql
Expand Up @@ -268,7 +268,8 @@ CREATE TABLE /*prefix*/keywords (
`notes` text,
PRIMARY KEY (`id`),
KEY /*prefix*/testproject_id (`testproject_id`),
KEY /*prefix*/keyword (`keyword`)
KEY /*prefix*/keyword (`keyword`),
UNIQUE KEY /*prefix*/keyword_testproject_id (`keyword`,`testproject_id`)
) DEFAULT CHARSET=utf8;


Expand Down Expand Up @@ -590,7 +591,8 @@ CREATE TABLE /*prefix*/object_keywords (
`fk_id` int(10) unsigned NOT NULL default '0',
`fk_table` varchar(30) default '',
`keyword_id` int(10) unsigned NOT NULL default '0',
PRIMARY KEY (`id`)
PRIMARY KEY (`id`),
UNIQUE KEY /*prefix*/udx01_object_keywords (`fk_id`,`fk_table`,`keyword_id`)
) DEFAULT CHARSET=utf8;


Expand Down
2 changes: 1 addition & 1 deletion install/sql/postgres/testlink_create_default_data.sql
Expand Up @@ -8,7 +8,7 @@
-- -----------------------------------------------------------------

-- Database version -
INSERT INTO /*prefix*/db_version ("version","upgrade_ts","notes") VALUES ('DB 1.9.18',now(),'TestLink 1.9.18 Gaura');
INSERT INTO /*prefix*/db_version ("version","upgrade_ts","notes") VALUES ('DB 1.9.19',now(),'TestLink 1.9.18 Metonic cycle');


-- Node types -
Expand Down
5 changes: 4 additions & 1 deletion install/sql/postgres/testlink_create_tables.sql
Expand Up @@ -436,10 +436,12 @@ CREATE TABLE /*prefix*/keywords(
"keyword" VARCHAR(100) NOT NULL DEFAULT '',
"testproject_id" BIGINT NOT NULL DEFAULT '0' REFERENCES /*prefix*/testprojects (id) ON DELETE CASCADE,
"notes" TEXT NULL DEFAULT NULL,
PRIMARY KEY ("id")
PRIMARY KEY ("id"),
);
CREATE INDEX /*prefix*/keywords_testproject_id ON /*prefix*/keywords ("testproject_id");
CREATE INDEX /*prefix*/keywords_keyword ON /*prefix*/keywords ("keyword");
CREATE UNIQUE INDEX /*prefix*/keywords_keyword_testproject_id ON /*prefix*/keywords (testproject_id,keyword);



--
Expand Down Expand Up @@ -470,6 +472,7 @@ CREATE TABLE /*prefix*/object_keywords(
"keyword_id" BIGINT NOT NULL DEFAULT '0' REFERENCES /*prefix*/keywords (id) ON DELETE CASCADE,
PRIMARY KEY ("id")
);
CREATE UNIQUE INDEX /*prefix*/object_keywords_udx01 ON /*prefix*/object_keywords (fk_id,fk_table,keyword_id);


--
Expand Down
5 changes: 3 additions & 2 deletions lib/functions/configCheck.php
Expand Up @@ -425,8 +425,8 @@ function checkSchemaVersion(&$db)

$manualop_msg = "You need to proceed with Manual upgrade of your DB scheme to {$latest_version} - Read README file!";

switch (trim($myrow['version']))
{
switch (trim($myrow['version'])) {
case '1.7.0 Alpha':
case '1.7.0 Beta 1':
case '1.7.0 Beta 2':
Expand All @@ -453,6 +453,7 @@ function checkSchemaVersion(&$db)
case 'DB 1.9.15':
case 'DB 1.9.16':
case 'DB 1.9.17':
case 'DB 1.9.18':
$result['msg'] = $manualop_msg;
break;

Expand Down

0 comments on commit 4d41041

Please sign in to comment.