diff --git a/cmd/boulder/main.go b/cmd/boulder/main.go index bea4f470dec..aa080f7929e 100644 --- a/cmd/boulder/main.go +++ b/cmd/boulder/main.go @@ -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) diff --git a/sa/storage-authority.go b/sa/storage-authority.go index ef8ece40f71..5c039d8fc61 100644 --- a/sa/storage-authority.go +++ b/sa/storage-authority.go @@ -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