[go: up one dir, main page]

Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

hosts.name field not resized in database in MySQL #236

Open
jrrdev opened this issue Feb 3, 2021 · 0 comments
Open

hosts.name field not resized in database in MySQL #236

jrrdev opened this issue Feb 3, 2021 · 0 comments

Comments

@jrrdev
Copy link
Contributor
jrrdev commented Feb 3, 2021

What happened:

In #204, the hosts.name field was resized to 255 characters.
Nevertheless, with an existing MySQL installation the column is not resized in the database.

mysql> show create table hosts \G
*************************** 1. row ***************************
       Table: hosts
Create Table: CREATE TABLE `hosts` (
  `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
  `created_at` datetime DEFAULT NULL,
  `updated_at` datetime DEFAULT NULL,
  `deleted_at` datetime DEFAULT NULL,
  `name` varchar(32) DEFAULT NULL,
  `addr` varchar(255) DEFAULT NULL,
  `user` varchar(255) DEFAULT NULL,
  `password` varchar(255) DEFAULT NULL,
  `ssh_key_id` int(10) unsigned DEFAULT NULL,
  `fingerprint` varchar(255) DEFAULT NULL,
  `comment` varchar(255) DEFAULT NULL,
  `host_key` varbinary(10000) DEFAULT NULL,
  `url` varchar(255) DEFAULT NULL,
  `hop_id` int(10) unsigned DEFAULT NULL,
  `logging` varchar(255) DEFAULT NULL,
  PRIMARY KEY (`id`),
  UNIQUE KEY `uix_hosts_name` (`name`),
  KEY `idx_hosts_deleted_at` (`deleted_at`),
  KEY `idx_hosts_ssh_key_id` (`ssh_key_id`)
) ENGINE=InnoDB AUTO_INCREMENT=318 DEFAULT CHARSET=utf8
1 row in set (0,00 sec)

What you expected to happen:

hosts.name should be VARCHAR(255)

How to reproduce it (as minimally and precisely as possible):

  • Install SSHPortal < 1.14.1 with MySQL Backend
  • Upgrade to SSHPortal 1.14.1

Anything else we need to know?:

I tried to add the following migration in pkg/bastion/dbinit.go but it didn't work (see jrrdev@9799d5c) :-/

{
  ID: "33",
  Migrate: func(tx *gorm.DB) error {
    type Host struct {
      gorm.Model
      Name string `gorm:"size:255" valid:"required,length(1|255)"`
    }
    return tx.AutoMigrate(&Host{}).Error
  },
  Rollback: func(tx *gorm.DB) error { return fmt.Errorf("not implemented") },
},
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant