Skip to content

Commit 83fad8b

Browse files
committed
Removed usage of FROM_UNIXTIME mysql-specific function.
This provide better interoperability with different databases (e.g. sqlite). Fixes NginxProxyManager#557
1 parent 5d65166 commit 83fad8b

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

backend/internal/certificate.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ const internalCertificate = {
7777
.where('id', certificate.id)
7878
.andWhere('provider', 'letsencrypt')
7979
.patch({
80-
expires_on: certificateModel.raw('FROM_UNIXTIME(' + cert_info.dates.to + ')')
80+
expires_on: moment(cert_info.dates.to, 'X').format('YYYY-MM-DD HH:mm:ss')
8181
});
8282
})
8383
.catch((err) => {
@@ -180,7 +180,7 @@ const internalCertificate = {
180180
return certificateModel
181181
.query()
182182
.patchAndFetchById(certificate.id, {
183-
expires_on: certificateModel.raw('FROM_UNIXTIME(' + cert_info.dates.to + ')')
183+
expires_on: moment(cert_info.dates.to, 'X').format('YYYY-MM-DD HH:mm:ss')
184184
})
185185
.then((saved_row) => {
186186
// Add cert data for audit log
@@ -558,7 +558,7 @@ const internalCertificate = {
558558
// TODO: This uses a mysql only raw function that won't translate to postgres
559559
return internalCertificate.update(access, {
560560
id: data.id,
561-
expires_on: certificateModel.raw('FROM_UNIXTIME(' + validations.certificate.dates.to + ')'),
561+
expires_on: moment(validations.certificate.dates.to, 'X').format('YYYY-MM-DD HH:mm:ss'),
562562
domain_names: [validations.certificate.cn],
563563
meta: _.clone(row.meta) // Prevent the update method from changing this value that we'll use later
564564
})
@@ -769,7 +769,7 @@ const internalCertificate = {
769769
return certificateModel
770770
.query()
771771
.patchAndFetchById(certificate.id, {
772-
expires_on: certificateModel.raw('FROM_UNIXTIME(' + cert_info.dates.to + ')')
772+
expires_on: moment(cert_info.dates.to, 'X').format('YYYY-MM-DD HH:mm:ss')
773773
});
774774
})
775775
.then((updated_certificate) => {

0 commit comments

Comments
 (0)