diff --git a/models/setup.go b/models/setup.go index 153f55b..d43bbaf 100644 --- a/models/setup.go +++ b/models/setup.go @@ -36,6 +36,8 @@ const createUsers string = ` RoleId INTEGER, UserName VARCHAR, Password VARCHAR, + LdapUser BOOLEAN, + LdapDN VARCHAR, FOREIGN KEY (RoleId) REFERENCES roles(RoleId) ); ` @@ -177,6 +179,22 @@ func CreateTables() { } } + // Add the two LDAP columns to the users table if they weren't there + ldapUserCheck, _ := CheckColumnExists("users", "LdapUser") + if !ldapUserCheck { + log.Printf("CreateTables creating ldap columns in user table") + _, err := db.Exec("ALTER TABLE users ADD COLUMN LdapUser BOOLEAN;") + if err != nil { + log.Printf("Error altering users table to add LdapUser column : '%s'\n", err) + os.Exit(1) + } + + _, err = db.Exec("ALTER TABLE users ADD COLUMN LdapDN VARCHAR;") + if err != nil { + log.Printf("Error altering users table to add LdapDN column : '%s'\n", err) + os.Exit(1) + } + } } // Count the number of records in the sqlite database