diff options
| -rwxr-xr-x | apply-updates.sh | 2 | ||||
| -rw-r--r-- | backend/database/dev/update_003_make_zone_code_required_unique.sql | 8 |
2 files changed, 9 insertions, 1 deletions
diff --git a/apply-updates.sh b/apply-updates.sh index ae13767..76c3519 100755 --- a/apply-updates.sh +++ b/apply-updates.sh @@ -70,7 +70,7 @@ if [[ ! -d "$UPDATES_DIR" ]]; then fi # Find update scripts -update_scripts=($(find "$UPDATES_DIR" -name "update_*.sql" | sort)) +update_scripts=($(find "$UPDATES_DIR" -name "update_003*.sql" | sort)) if [[ ${#update_scripts[@]} -eq 0 ]]; then echo "No update scripts found in $UPDATES_DIR." diff --git a/backend/database/dev/update_003_make_zone_code_required_unique.sql b/backend/database/dev/update_003_make_zone_code_required_unique.sql new file mode 100644 index 0000000..08e8896 --- /dev/null +++ b/backend/database/dev/update_003_make_zone_code_required_unique.sql @@ -0,0 +1,8 @@ +-- Make zone_code required and unique +-- This ensures data integrity for audits and lookups + +-- First, modify the column to be NOT NULL +ALTER TABLE `zones` MODIFY `zone_code` VARCHAR(50) NOT NULL; + +-- Then add the unique constraint +ALTER TABLE `zones` ADD UNIQUE KEY `unique_zone_code` (`zone_code`); |
