Skip to content

Commit

Permalink
Merge branch '7.3'
Browse files Browse the repository at this point in the history
  • Loading branch information
at055612 committed Apr 25, 2024
2 parents ebc11f0 + f38e2e3 commit eba3301
Showing 1 changed file with 178 additions and 58 deletions.
236 changes: 178 additions & 58 deletions content/en/releases/v07.03/upgrade-notes.md
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ See [`migrage` command]({{< relref "/docs/user-guide/tools/command-line#migrate"

<!-- This section is auto-generated by TestListDbMigrations.listDbMigrationsForLatestVersion -->

For information purposes only, the following are the database migrations that will be run when upgrading to v7.3.0 from the previous minor version.
For information purposes only, the following are the database migrations that will be run when upgrading to 7.3.0 from the previous minor version.

Note, the `legacy` module will run first (if present) then the other module will run in no particular order.

Expand Down Expand Up @@ -181,6 +181,183 @@ SET SQL_NOTES=@OLD_SQL_NOTES;
```


#### Module `stroom-index`

##### Script `V07_03_00_001__index_field.sql`

**Path**: `stroom-index/stroom-index-impl-db/src/main/resources/stroom/index/impl/db/migration/V07_03_00_001__index_field.sql`

```sql
-- ------------------------------------------------------------------------
-- Copyright 2020 Crown Copyright
--
-- Licensed under the Apache License, Version 2.0 (the "License");
-- you may not use this file except in compliance with the License.
-- You may obtain a copy of the License at
--
-- http://www.apache.org/licenses/LICENSE-2.0
--
-- Unless required by applicable law or agreed to in writing, software
-- distributed under the License is distributed on an "AS IS" BASIS,
-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-- See the License for the specific language governing permissions and
-- limitations under the License.
-- ------------------------------------------------------------------------

-- Stop NOTE level warnings about objects (not)? existing
SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0;

DROP PROCEDURE IF EXISTS drop_field_source;
DELIMITER //
CREATE PROCEDURE drop_field_source ()
BEGIN
IF EXISTS (
SELECT NULL
FROM INFORMATION_SCHEMA.TABLES
WHERE TABLE_SCHEMA = database()
AND TABLE_NAME = 'field_info') THEN
DROP TABLE field_info;
END IF;
IF EXISTS (
SELECT NULL
FROM INFORMATION_SCHEMA.TABLES
WHERE TABLE_SCHEMA = database()
AND TABLE_NAME = 'field_source') THEN
DROP TABLE field_source;
END IF;
IF EXISTS (
SELECT NULL
FROM INFORMATION_SCHEMA.TABLES
WHERE TABLE_SCHEMA = database()
AND TABLE_NAME = 'field_schema_history') THEN
DROP TABLE field_schema_history;
END IF;
END//
DELIMITER ;
CALL drop_field_source();
DROP PROCEDURE drop_field_source;

--
-- Create the field_source table
--
CREATE TABLE IF NOT EXISTS `index_field_source` (
`id` int NOT NULL AUTO_INCREMENT,
`type` varchar(255) NOT NULL,
`uuid` varchar(255) NOT NULL,
`name` varchar(255) NOT NULL,
PRIMARY KEY (`id`),
UNIQUE KEY `index_field_source_type_uuid` (`type`, `uuid`)
) ENGINE=InnoDB DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci;

--
-- Create the index_field table
--
CREATE TABLE IF NOT EXISTS `index_field` (
`id` bigint NOT NULL AUTO_INCREMENT,
`fk_index_field_source_id` int NOT NULL,
`type` tinyint NOT NULL,
`name` varchar(255) NOT NULL,
`analyzer` varchar(255) NOT NULL,
`indexed` tinyint NOT NULL DEFAULT '0',
`stored` tinyint NOT NULL DEFAULT '0',
`term_positions` tinyint NOT NULL DEFAULT '0',
`case_sensitive` tinyint NOT NULL DEFAULT '0',
PRIMARY KEY (`id`),
UNIQUE KEY `index_field_source_id_name` (`fk_index_field_source_id`, `name`),
CONSTRAINT `index_field_fk_index_field_source_id` FOREIGN KEY (`fk_index_field_source_id`) REFERENCES `index_field_source` (`id`)
) ENGINE=InnoDB DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci;

SET SQL_NOTES=@OLD_SQL_NOTES;

-- vim: set tabstop=4 shiftwidth=4 expandtab:

```


##### Script `V07_03_00_005__index_field_change_pk.sql`

**Path**: `stroom-index/stroom-index-impl-db/src/main/resources/stroom/index/impl/db/migration/V07_03_00_005__index_field_change_pk.sql`

```sql
-- ------------------------------------------------------------------------
-- Copyright 2020 Crown Copyright
--
-- Licensed under the Apache License, Version 2.0 (the "License");
-- you may not use this file except in compliance with the License.
-- You may obtain a copy of the License at
--
-- http://www.apache.org/licenses/LICENSE-2.0
--
-- Unless required by applicable law or agreed to in writing, software
-- distributed under the License is distributed on an "AS IS" BASIS,
-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-- See the License for the specific language governing permissions and
-- limitations under the License.
-- ------------------------------------------------------------------------

-- Stop NOTE level warnings about objects (not)? existing
SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0;

DELIMITER $$

DROP PROCEDURE IF EXISTS modify_field_source$$

-- The surrogate PK results in fields from different indexes all being mixed together
-- in the PK index, which causes deadlocks in batch upserts due to gap locks.
-- Change the PK to be (fk_index_field_source_id, name) which should keep the fields
-- together.

CREATE PROCEDURE modify_field_source ()
BEGIN

-- Remove existing PK
IF EXISTS (
SELECT NULL
FROM INFORMATION_SCHEMA.columns
WHERE TABLE_SCHEMA = database()
AND TABLE_NAME = 'index_field'
AND COLUMN_NAME = 'id') THEN

ALTER TABLE index_field DROP COLUMN id;
END IF;

-- Add the new PK
IF NOT EXISTS (
SELECT NULL
FROM INFORMATION_SCHEMA.table_constraints
WHERE TABLE_SCHEMA = database()
AND TABLE_NAME = 'index_field'
AND CONSTRAINT_NAME = 'PRIMARY') THEN

ALTER TABLE index_field ADD PRIMARY KEY (fk_index_field_source_id, name);
END IF;

-- Remove existing index that is now served by PK
IF EXISTS (
SELECT NULL
FROM INFORMATION_SCHEMA.table_constraints
WHERE TABLE_SCHEMA = database()
AND TABLE_NAME = 'index_field'
AND CONSTRAINT_NAME = 'index_field_source_id_name') THEN

ALTER TABLE index_field DROP INDEX index_field_source_id_name;
END IF;

END $$

DELIMITER ;

CALL modify_field_source();

DROP PROCEDURE IF EXISTS modify_field_source;

SET SQL_NOTES=@OLD_SQL_NOTES;

-- vim: set tabstop=4 shiftwidth=4 expandtab:

```


#### Module `stroom-processor`

##### Script `V07_03_00_001__processor.sql`
Expand Down Expand Up @@ -338,60 +515,3 @@ CALL processor_add_column_v1(

```


#### Module `stroom-query`

##### Script `V07_03_00_001__query_datasource.sql`

**Path**: `stroom-query/stroom-query-field-impl-db/src/main/resources/stroom/query/field/impl/db/migration/V07_03_00_001__query_datasource.sql`

```sql
-- ------------------------------------------------------------------------
-- Copyright 2020 Crown Copyright
--
-- Licensed under the Apache License, Version 2.0 (the "License");
-- you may not use this file except in compliance with the License.
-- You may obtain a copy of the License at
--
-- http://www.apache.org/licenses/LICENSE-2.0
--
-- Unless required by applicable law or agreed to in writing, software
-- distributed under the License is distributed on an "AS IS" BASIS,
-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-- See the License for the specific language governing permissions and
-- limitations under the License.
-- ------------------------------------------------------------------------

-- Stop NOTE level warnings about objects (not)? existing
SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0;

--
-- Create the field_source table
--
CREATE TABLE IF NOT EXISTS `field_source` (
`id` int NOT NULL AUTO_INCREMENT,
`type` varchar(255) NOT NULL,
`uuid` varchar(255) NOT NULL,
`name` varchar(255) NOT NULL,
PRIMARY KEY (`id`),
UNIQUE KEY `field_source_type_uuid` (`type`, `uuid`)
) ENGINE=InnoDB DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci;

--
-- Create the field_info table
--
CREATE TABLE IF NOT EXISTS `field_info` (
`id` bigint NOT NULL AUTO_INCREMENT,
`fk_field_source_id` int NOT NULL,
`field_type` tinyint NOT NULL,
`field_name` varchar(255) NOT NULL,
PRIMARY KEY (`id`),
UNIQUE KEY `field_source_id_field_type_field_name` (`fk_field_source_id`, `field_type`, `field_name`),
CONSTRAINT `field_fk_field_source_id` FOREIGN KEY (`fk_field_source_id`) REFERENCES `field_source` (`id`)
) ENGINE=InnoDB DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci;

SET SQL_NOTES=@OLD_SQL_NOTES;

-- vim: set tabstop=4 shiftwidth=4 expandtab:

```

0 comments on commit eba3301

Please sign in to comment.