Merge pull request #107 from rolandshoemaker/aware-initables
Move InitTables and have it check for table existence before creation
This commit is contained in:
commit
6c8f6a26a7
|
|
@ -72,8 +72,7 @@ func main() {
|
|||
wfe := wfe.NewWebFrontEndImpl(auditlogger)
|
||||
sa, err := sa.NewSQLStorageAuthority(auditlogger, c.SA.DBDriver, c.SA.DBName)
|
||||
cmd.FailOnError(err, "Unable to create SA")
|
||||
err = sa.InitTables()
|
||||
cmd.FailOnError(err, "Unable to initialize SA")
|
||||
|
||||
ra := ra.NewRegistrationAuthorityImpl(auditlogger)
|
||||
va := va.NewValidationAuthorityImpl(auditlogger, c.CA.TestMode)
|
||||
|
||||
|
|
|
|||
|
|
@ -46,6 +46,12 @@ func NewSQLStorageAuthority(logger *blog.AuditLogger, driver string, name string
|
|||
log: logger,
|
||||
bucket: make(map[string]interface{}),
|
||||
}
|
||||
|
||||
err = ssa.InitTables()
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
|
|
@ -56,28 +62,28 @@ func (ssa *SQLStorageAuthority) InitTables() (err error) {
|
|||
}
|
||||
|
||||
// Create registrations table
|
||||
_, err = tx.Exec("CREATE TABLE registrations (id TEXT, thumbprint TEXT, value TEXT);")
|
||||
_, err = tx.Exec("CREATE TABLE IF NOT EXISTS registrations (id TEXT, thumbprint TEXT, value TEXT);")
|
||||
if err != nil {
|
||||
tx.Rollback()
|
||||
return
|
||||
}
|
||||
|
||||
// Create pending authorizations table
|
||||
_, err = tx.Exec("CREATE TABLE pending_authz (id TEXT, value BLOB);")
|
||||
_, err = tx.Exec("CREATE TABLE IF NOT EXISTS pending_authz (id TEXT, value BLOB);")
|
||||
if err != nil {
|
||||
tx.Rollback()
|
||||
return
|
||||
}
|
||||
|
||||
// Create finalized authorizations table
|
||||
_, err = tx.Exec("CREATE TABLE authz (sequence INTEGER, id TEXT, digest TEXT, value BLOB);")
|
||||
_, err = tx.Exec("CREATE TABLE IF NOT EXISTS authz (sequence INTEGER, id TEXT, digest TEXT, value BLOB);")
|
||||
if err != nil {
|
||||
tx.Rollback()
|
||||
return
|
||||
}
|
||||
|
||||
// Create certificates table
|
||||
_, err = tx.Exec("CREATE TABLE certificates (serial string, digest TEXT, value BLOB);")
|
||||
_, err = tx.Exec("CREATE TABLE IF NOT EXISTS certificates (serial STRING, digest TEXT, value BLOB);")
|
||||
if err != nil {
|
||||
tx.Rollback()
|
||||
return
|
||||
|
|
|
|||
Loading…
Reference in New Issue