teamhanko / passkeys

FIDO2-certified passkey server and SDKs for adding passkey support to any auth system
https://hanko.io/passkey-api
GNU Affero General Public License v3.0
115 stars 8 forks source link

Migrations fail on MySQL #43

Closed J-tt closed 6 months ago

J-tt commented 7 months ago

Migrations seem to be failing when running against MySQL due to restrictions around what can be part of a unique index (see: https://stackoverflow.com/a/1827099)

passkey-server.exe migrate up
2024/02/15 09:23:33 migrating database up
2024/02/15 09:23:33 Using config file: ./config/config.yaml
[POP] 2024/02/15 09:23:34 info - > create_tenants
[POP] 2024/02/15 09:23:34 info - > create_configs
[POP] 2024/02/15 09:23:34 info - > create_webauthn_configs
[POP] 2024/02/15 09:23:34 info - > create_relying_parties
[POP] 2024/02/15 09:23:34 info - > create_webauthn_origins
[POP] 2024/02/15 09:23:34 info - > create_cors
[POP] 2024/02/15 09:23:34 info - > create_cors_origins
[POP] 2024/02/15 09:23:34 info - > create_audit_log_configs
[POP] 2024/02/15 09:23:34 info - 0.7717 seconds
2024/02/15 09:23:34 error executing migrations/20231107191413_create_secrets.up.fizz, sql: CREATE TABLE `secrets` (
`id` char(36) NOT NULL,
PRIMARY KEY(`id`),
`name` VARCHAR (255) NOT NULL,
`key` text,
`is_api_secret` boolean NOT NULL DEFAULT true,
`config_id` char(36),
`created_at` DATETIME NOT NULL,
`updated_at` DATETIME NOT NULL,
FOREIGN KEY (`config_id`) REFERENCES `configs` (`id`) ON UPDATE cascade ON DELETE cascade
) ENGINE=InnoDB;
CREATE UNIQUE INDEX `secrets_key_config_id_idx` ON `secrets` (`key`, `config_id`);
CREATE UNIQUE INDEX `secrets_name_config_id_idx` ON `secrets` (`name`, `config_id`);: Error 1170 (42000): BLOB/TEXT column 'key' used in key specification without a key length
shentschel commented 7 months ago

There is now a PR which should fix this. The problem was that mysql cannot take a text column without a specified length for a unique key constraint. The PR will change the key column from text to varchar(200)