Skip to content

Commit 63f1f5d

Browse files
committed
Fix MySQL key length limit in metadata table migration
Annotations table used key VARCHAR(1000) with a unique index on (resource_guid, key), totaling 5020 bytes in utf8mb4 — exceeding MySQL's 3072-byte max key length. Align with codebase convention established in migration 20240102150000: use key_name VARCHAR(63) with a three-column unique index on (resource_guid, key_prefix, key_name). Also add NOT NULL default '' to key_prefix on both labels and annotations tables.
1 parent a5ab35b commit 63f1f5d

1 file changed

Lines changed: 4 additions & 4 deletions

File tree

db/migrations/20260407100001_create_route_access_rules.rb

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
primary_key :id, name: :id
2121
String :guid, null: false, size: 255
2222
String :resource_guid, null: false, size: 255
23-
String :key_prefix, size: 253
23+
String :key_prefix, null: false, default: '', size: 253
2424
String :key_name, null: false, size: 63
2525
String :value, null: false, size: 63
2626
DateTime :created_at, null: false
@@ -38,15 +38,15 @@
3838
primary_key :id, name: :id
3939
String :guid, null: false, size: 255
4040
String :resource_guid, null: false, size: 255
41-
String :key_prefix, size: 253
42-
String :key, null: false, size: 1000
41+
String :key_prefix, null: false, default: '', size: 253
42+
String :key_name, null: false, size: 63
4343
String :value, size: 5000
4444
DateTime :created_at, null: false
4545
DateTime :updated_at
4646

4747
index :guid, unique: true, name: :route_access_rule_annotations_guid_index
4848
index :resource_guid, name: :route_access_rule_annotations_resource_guid_index
49-
index %i[resource_guid key], unique: true, name: :route_access_rule_annotations_key_index
49+
index %i[resource_guid key_prefix key_name], unique: true, name: :route_access_rule_annotations_key_index
5050
foreign_key [:resource_guid], :route_access_rules, key: :guid, on_delete: :cascade, name: :fk_route_access_rule_annotations_resource_guid
5151
end
5252
end

0 commit comments

Comments
 (0)