waveterm/wavesrv/db/migrations/000029_canonicalport.up.sql

3 lines
167 B
MySQL
Raw Normal View History

Allow dots in alias and add port to canonical name (#209) * allow numerical start and allow dots in ssh alias We previously restricted the ssh alias to start with an alphabetic character and did not allow dots within it. This caused problems with users wanting to use an ip address as an alias. This lifts that restriction so both can freely be used. Note that while it is common to use the hostname as the alias, hostnames are not allowed to use the underscore character. However, we do allow the alias to contain an underscore. I do not think we can remove this from aliases now but it is something to watch out for in the future. * allow backslash in username This involved converting the regexp string into a raw string to able to use the backslash character. this is important. * Revert "allow backslash in username" This reverts commit cafe2812411cfba15b7ece1250a6def29d092366. Upon reflection, more time is needed to evaluate that this actually corrects the issue. It will be performed with proper diligence at a later time. * add port to end of canoncial names when not 22 The canonical name is the identifying key in the database, so it causes problems if another remote entry has the same canonical name. By adding the port number to the end of this, it is possible to differentiate the two. * add db migrations for adding port to canonicalname The up migration adds the port to the existing canonical id if it exists and is not 22. The down migration strips the port off the canonical name and deletes extra remotes with the same canonical name. If all remotes with that canonical name have been archived, it keeps the first one added to the database. If any have not been archived, it keeps the first added to the database from the non-archived group. * remove ability to edit port number via ssh import Previously, ssh imports could edit the port number since it was possible to change them in the config file without changin the canonical name. Now that the canonical name contains the port, a change in the port will simply create a new database entry. For this reason, the ability to modify the ssh port is dead code and has been removed. * allow backslash in username This involved converting the regexp string into a raw string to able to use the backslash character. this is important. * simplify up migration logic The previous up migration was suboptimal because it was accounting for a corner case not found in production. That case no longer needs to be considered, so the procedure was simplified.
2024-01-04 19:16:26 +01:00
UPDATE remote
SET remotecanonicalname = remotecanonicalname || COALESCE( ":" || json_extract(sshopts, '$.sshport'), "")
WHERE json_extract(sshopts, '$.sshport') != 22;