This commit is contained in:
@@ -25,7 +25,8 @@ const createRoles string = `
|
||||
RoleId INTEGER PRIMARY KEY ASC,
|
||||
RoleName VARCHAR,
|
||||
ReadOnly BOOLEAN,
|
||||
Admin BOOLEAN
|
||||
Admin BOOLEAN,
|
||||
LdapGroup VARCHAR
|
||||
);
|
||||
`
|
||||
|
||||
@@ -96,15 +97,15 @@ func CreateTables() {
|
||||
}
|
||||
rowCount, _ = CheckCount("roles")
|
||||
if rowCount == 0 {
|
||||
if _, err = db.Exec("INSERT INTO roles VALUES(1, 'Admin', false, true);"); err != nil {
|
||||
if _, err = db.Exec("INSERT INTO roles VALUES(1, 'Admin', false, true, '');"); err != nil {
|
||||
log.Printf("Error adding initial admin role : '%s'", err)
|
||||
os.Exit(1)
|
||||
}
|
||||
if _, err = db.Exec("INSERT INTO roles VALUES(2, 'UserRole', false, false);"); err != nil {
|
||||
if _, err = db.Exec("INSERT INTO roles VALUES(2, 'UserRole', false, false, '');"); err != nil {
|
||||
log.Printf("Error adding initial user role : '%s'", err)
|
||||
os.Exit(1)
|
||||
}
|
||||
if _, err = db.Exec("INSERT INTO roles VALUES(3, 'GuestRole', true, false);"); err != nil {
|
||||
if _, err = db.Exec("INSERT INTO roles VALUES(3, 'GuestRole', true, false, '');"); err != nil {
|
||||
log.Printf("Error adding initial guest role : '%s'", err)
|
||||
os.Exit(1)
|
||||
}
|
||||
@@ -145,10 +146,23 @@ func CreateTables() {
|
||||
schemaCheck, _ := CheckColumnExists("schema", "Version")
|
||||
if !schemaCheck {
|
||||
if _, err = db.Exec("INSERT INTO schema VALUES(1);"); err != nil {
|
||||
log.Printf("Error adding initial scehama version : '%s'", err)
|
||||
log.Printf("Error adding initial schema version : '%s'", err)
|
||||
os.Exit(1)
|
||||
}
|
||||
}
|
||||
|
||||
// Database updates added after initial version released
|
||||
ldapCheck, _ := CheckColumnExists("roles", "LdapGroup")
|
||||
|
||||
if !ldapCheck {
|
||||
// Add the column for LdapGroup in the roles table
|
||||
_, err := db.Exec("ALTER TABLE roles ADD COLUMN LdapGroup VARCHAR;")
|
||||
if err != nil {
|
||||
log.Printf("Error altering roles table to add LdapGroup column : '%s'\n", err)
|
||||
os.Exit(1)
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// Count the number of records in the sqlite database
|
||||
|
Reference in New Issue
Block a user