Skip to content

Commit 4644a05

Browse files
authored
Create unique index on BLSample(containerId, location, subLocation) (#244)
1 parent d3393da commit 4644a05

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
-- This update might require some clean-up of the BLSample table in advance to
2+
-- remove rows that would violate the unique index being created here. Some
3+
-- example statements that might help:
4+
--
5+
-- UPDATE BLSample SET location = NULL WHERE location = '';
6+
-- UPDATE BLSample SET location = NULL WHERE location = 'null';
7+
-- UPDATE BLSample SET location = CAST(location AS INT) WHERE location LIKE '0%';
8+
--
9+
-- Note that in SQL, NULL != NULL, so therefore you will not violate a unique
10+
-- index if you have multiple rows where a field used in the index is NULL.
11+
12+
INSERT IGNORE INTO SchemaStatus (scriptName, schemaStatus) VALUES ('2024_10_15_BLSample_unique_index.sql', 'ONGOING');
13+
14+
CREATE UNIQUE INDEX IF NOT EXISTS BLSample_uidx_containerId_location_subLocation ON BLSample(containerId, location, subLocation);
15+
16+
UPDATE SchemaStatus SET schemaStatus = 'DONE' WHERE scriptName = '2024_10_15_BLSample_unique_index.sql';

0 commit comments

Comments
 (0)