mirror of
https://github.com/fleetdm/fleet
synced 2026-04-21 13:37:30 +00:00
> closes #26403 # Checklist for submitter If some of the following don't apply, delete the relevant line. <!-- Note that API documentation changes are now addressed by the product design team. --> - [x] If database migrations are included, checked table schema to confirm autoupdate - For database migrations: - [x] Ensured the correct collation is explicitly set for character columns (`COLLATE utf8mb4_unicode_ci`). - [x] Added/updated automated tests - [x] Manual QA for all new/changed functionality
36 lines
964 B
Go
36 lines
964 B
Go
package tables
|
|
|
|
import (
|
|
"database/sql"
|
|
|
|
"github.com/pkg/errors"
|
|
)
|
|
|
|
func init() {
|
|
MigrationClient.AddMigration(Up_20211221110132, Down_20211221110132)
|
|
}
|
|
|
|
func Up_20211221110132(tx *sql.Tx) error {
|
|
hostEmailsTable := `
|
|
CREATE TABLE IF NOT EXISTS host_emails (
|
|
id int(10) unsigned NOT NULL AUTO_INCREMENT,
|
|
host_id int(10) UNSIGNED NOT NULL,
|
|
email varchar(255) NOT NULL,
|
|
source varchar(255) NOT NULL,
|
|
created_at timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
|
updated_at timestamp NOT NULL NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
|
|
|
|
PRIMARY KEY (id),
|
|
INDEX idx_host_emails_host_id_email (host_id, email),
|
|
INDEX idx_host_emails_email (email)
|
|
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
|
|
`
|
|
if _, err := tx.Exec(hostEmailsTable); err != nil {
|
|
return errors.Wrap(err, "create host_emails table")
|
|
}
|
|
return nil
|
|
}
|
|
|
|
func Down_20211221110132(tx *sql.Tx) error {
|
|
return nil
|
|
}
|